Hello all,
I am trying to write a module, as part of whichiI would like to set up a bridge device and add the network interface to the same.
I found that if_bridge.c contains the crux of the code relating to bridge and its related operations. Since all the functions are static, it cant be accessed directly.
I ran truss & ktrace to understand the request flow.
Running truss on the
fFrom which iI understood that ioctl's are used to find the index and create a clone of the interface before creating the bridge. I think the socket & ioctal can be replaced with sys_socket () and sys_ioctl () in our module level.
I have used added the MODULE_DEPEND(if_bridge, bridgestp, 1, 1, 1); to load the bridgestp when my module is loaded and this is successful as kldstat shows the bridgestp.ko is loaded
But not sure what other operations are needed to be done in order to create the bridge.
I am trying to write a module, as part of which
I found that if_bridge.c contains the crux of the code relating to bridge and its related operations. Since all the functions are static, it cant be accessed directly.
I ran truss & ktrace to understand the request flow.
Running truss on the
ifconfig bridge create
command shows the following output:
Code:
socket(PF_INET,SOCK_DGRAM|SOCK_CLOEXEC,0) = 3 (0x3)
ioctl(3,SIOCGIFINDEX,0xffffe330) ERR#6 'Device not configured'
close(3) = 0 (0x0)
__sysctl(0x7fffffffe2c0,0x6,0x0,0x7fffffffe2b8,0x0,0x0) = 0 (0x0)
__sysctl(0x7fffffffe2c0,0x6,0x801817000,0x7fffffffe2b8,0x0,0x0) = 0 (0x0)
__sysctl(0x7fffffffe1f0,0x2,0x7fffffffe240,0x7fffffffe238,0x801816000,0x12) = 0 (0x0)
__sysctl(0x7fffffffe240,0x3,0x7fffffffe2fc,0x7fffffffe300,0x0,0x0) = 0 (0x0)
socket(PF_INET,SOCK_DGRAM,0) = 3 (0x3)
ioctl(3,SIOCIFCREATE2,0xffffe2f0) = 0 (0x0)
fstat(1,{ mode=crw------- ,inode=59,size=0,blksize=4096 }) = 0 (0x0)
ioctl(1,TIOCGETA,0xffffe0f0) = 0 (0x0)
write(1,"bridge0\n",8) = 8 (0x8)
I have used added the MODULE_DEPEND(if_bridge, bridgestp, 1, 1, 1); to load the bridgestp when my module is loaded and this is successful as kldstat shows the bridgestp.ko is loaded
But not sure what other operations are needed to be done in order to create the bridge.