Data transfer on the link layer of the linux protocol stack (add interface to the bridge (4))

  
 

As mentioned earlier, when adding interfaces to the bridge, user space calls ioctl (br_socket_fd, SIOCBRADDIF, & ifr) to note that dev->do_ioctl has been done in void br_dev_setup(struct net_device *dev) assignment, namely: dev- & gt; performed when do_ioctl = br_dev_ioctl ioctl access, the process proceeds to br_dev_ioctl: (net /brige /br_ioctl.c) int br_dev_ioctl (struct net_device * dev, struct ifreq * rq, int cmd) {struct net_bridge * br = netdev_priv (dev); switch (cmd) {case SIOCDEVPRIVATE: return old_dev_ioctl (dev, rq, cmd); //add an interface case SIOCBRADDIF: //remove an interface case SIOCBRDELIF: return add_del_if (br, rq- & gt ; ifr_ifindex, cmd == SIOCBRADDIF);} pr_debug (" Bridge does not support ioctl 0x% x \\ n ", cmd); return -EOPNOTSUPP;} signs we use in user space is SIOCBRADDIF. So the process goes to add_del_if() static int add_del_if(struct net_bridge *br, int ifindex, int isadd)

{struct net_device *dev;int ret;if (!capable(CAP_NET_ADMIN))return -EPERM;dev = Dev_get_by_index(ifindex);if (dev == NULL)return -EINVAL;if (isadd)ret = br_add_if(br, dev);elseret = br_del_if(br, dev);dev_put(dev);return ret;}because cmd = = SIOCBRADDIF is true, so call br_add_if():int br_add_if(struct net_bridge *br, struct net_device *dev) (net/brige/br_if.c)){struct net_bridge_port *p;int err = 0;//loopback. Or non-network interface if (dev->flags & IFF_LOOPBACK

Copyright © Windows knowledge All Rights Reserved