rtnetlink.c (d079535d5e1bf5e2e7c856bae2483414ea21e137) | rtnetlink.c (66400d543072d6ff6f8df036e3f12f5c154c19cc) |
---|---|
1/* 2 * INET An implementation of the TCP/IP protocol suite for the LINUX 3 * operating system. INET is implemented using the BSD Socket 4 * interface as the means of communication with the user level. 5 * 6 * Routing netlink socket interface: protocol independent part. 7 * 8 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> --- 968 unchanged lines hidden (view full) --- 977 } 978 979 if (nla_put(skb, IFLA_PHYS_PORT_ID, ppid.id_len, ppid.id)) 980 return -EMSGSIZE; 981 982 return 0; 983} 984 | 1/* 2 * INET An implementation of the TCP/IP protocol suite for the LINUX 3 * operating system. INET is implemented using the BSD Socket 4 * interface as the means of communication with the user level. 5 * 6 * Routing netlink socket interface: protocol independent part. 7 * 8 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> --- 968 unchanged lines hidden (view full) --- 977 } 978 979 if (nla_put(skb, IFLA_PHYS_PORT_ID, ppid.id_len, ppid.id)) 980 return -EMSGSIZE; 981 982 return 0; 983} 984 |
985static int rtnl_phys_port_name_fill(struct sk_buff *skb, struct net_device *dev) 986{ 987 char name[IFNAMSIZ]; 988 int err; 989 990 err = dev_get_phys_port_name(dev, name, sizeof(name)); 991 if (err) { 992 if (err == -EOPNOTSUPP) 993 return 0; 994 return err; 995 } 996 997 if (nla_put(skb, IFLA_PHYS_PORT_NAME, strlen(name), name)) 998 return -EMSGSIZE; 999 1000 return 0; 1001} 1002 |
|
985static int rtnl_phys_switch_id_fill(struct sk_buff *skb, struct net_device *dev) 986{ 987 int err; 988 struct netdev_phys_item_id psid; 989 990 err = netdev_switch_parent_id_get(dev, &psid); 991 if (err) { 992 if (err == -EOPNOTSUPP) --- 74 unchanged lines hidden (view full) --- 1067 if (nla_put(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr) || 1068 nla_put(skb, IFLA_BROADCAST, dev->addr_len, dev->broadcast)) 1069 goto nla_put_failure; 1070 } 1071 1072 if (rtnl_phys_port_id_fill(skb, dev)) 1073 goto nla_put_failure; 1074 | 1003static int rtnl_phys_switch_id_fill(struct sk_buff *skb, struct net_device *dev) 1004{ 1005 int err; 1006 struct netdev_phys_item_id psid; 1007 1008 err = netdev_switch_parent_id_get(dev, &psid); 1009 if (err) { 1010 if (err == -EOPNOTSUPP) --- 74 unchanged lines hidden (view full) --- 1085 if (nla_put(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr) || 1086 nla_put(skb, IFLA_BROADCAST, dev->addr_len, dev->broadcast)) 1087 goto nla_put_failure; 1088 } 1089 1090 if (rtnl_phys_port_id_fill(skb, dev)) 1091 goto nla_put_failure; 1092 |
1093 if (rtnl_phys_port_name_fill(skb, dev)) 1094 goto nla_put_failure; 1095 |
|
1075 if (rtnl_phys_switch_id_fill(skb, dev)) 1076 goto nla_put_failure; 1077 1078 attr = nla_reserve(skb, IFLA_STATS, 1079 sizeof(struct rtnl_link_stats)); 1080 if (attr == NULL) 1081 goto nla_put_failure; 1082 --- 727 unchanged lines hidden (view full) --- 1810 if (err < 0) 1811 goto errout; 1812 1813 err = do_setlink(skb, dev, ifm, tb, ifname, 0); 1814errout: 1815 return err; 1816} 1817 | 1096 if (rtnl_phys_switch_id_fill(skb, dev)) 1097 goto nla_put_failure; 1098 1099 attr = nla_reserve(skb, IFLA_STATS, 1100 sizeof(struct rtnl_link_stats)); 1101 if (attr == NULL) 1102 goto nla_put_failure; 1103 --- 727 unchanged lines hidden (view full) --- 1831 if (err < 0) 1832 goto errout; 1833 1834 err = do_setlink(skb, dev, ifm, tb, ifname, 0); 1835errout: 1836 return err; 1837} 1838 |
1839static int rtnl_group_dellink(const struct net *net, int group) 1840{ 1841 struct net_device *dev, *aux; 1842 LIST_HEAD(list_kill); 1843 bool found = false; 1844 1845 if (!group) 1846 return -EPERM; 1847 1848 for_each_netdev(net, dev) { 1849 if (dev->group == group) { 1850 const struct rtnl_link_ops *ops; 1851 1852 found = true; 1853 ops = dev->rtnl_link_ops; 1854 if (!ops || !ops->dellink) 1855 return -EOPNOTSUPP; 1856 } 1857 } 1858 1859 if (!found) 1860 return -ENODEV; 1861 1862 for_each_netdev_safe(net, dev, aux) { 1863 if (dev->group == group) { 1864 const struct rtnl_link_ops *ops; 1865 1866 ops = dev->rtnl_link_ops; 1867 ops->dellink(dev, &list_kill); 1868 } 1869 } 1870 unregister_netdevice_many(&list_kill); 1871 1872 return 0; 1873} 1874 |
|
1818static int rtnl_dellink(struct sk_buff *skb, struct nlmsghdr *nlh) 1819{ 1820 struct net *net = sock_net(skb->sk); 1821 const struct rtnl_link_ops *ops; 1822 struct net_device *dev; 1823 struct ifinfomsg *ifm; 1824 char ifname[IFNAMSIZ]; 1825 struct nlattr *tb[IFLA_MAX+1]; --- 7 unchanged lines hidden (view full) --- 1833 if (tb[IFLA_IFNAME]) 1834 nla_strlcpy(ifname, tb[IFLA_IFNAME], IFNAMSIZ); 1835 1836 ifm = nlmsg_data(nlh); 1837 if (ifm->ifi_index > 0) 1838 dev = __dev_get_by_index(net, ifm->ifi_index); 1839 else if (tb[IFLA_IFNAME]) 1840 dev = __dev_get_by_name(net, ifname); | 1875static int rtnl_dellink(struct sk_buff *skb, struct nlmsghdr *nlh) 1876{ 1877 struct net *net = sock_net(skb->sk); 1878 const struct rtnl_link_ops *ops; 1879 struct net_device *dev; 1880 struct ifinfomsg *ifm; 1881 char ifname[IFNAMSIZ]; 1882 struct nlattr *tb[IFLA_MAX+1]; --- 7 unchanged lines hidden (view full) --- 1890 if (tb[IFLA_IFNAME]) 1891 nla_strlcpy(ifname, tb[IFLA_IFNAME], IFNAMSIZ); 1892 1893 ifm = nlmsg_data(nlh); 1894 if (ifm->ifi_index > 0) 1895 dev = __dev_get_by_index(net, ifm->ifi_index); 1896 else if (tb[IFLA_IFNAME]) 1897 dev = __dev_get_by_name(net, ifname); |
1898 else if (tb[IFLA_GROUP]) 1899 return rtnl_group_dellink(net, nla_get_u32(tb[IFLA_GROUP])); |
|
1841 else 1842 return -EINVAL; 1843 1844 if (!dev) 1845 return -ENODEV; 1846 1847 ops = dev->rtnl_link_ops; 1848 if (!ops || !ops->dellink) --- 78 unchanged lines hidden (view full) --- 1927} 1928EXPORT_SYMBOL(rtnl_create_link); 1929 1930static int rtnl_group_changelink(const struct sk_buff *skb, 1931 struct net *net, int group, 1932 struct ifinfomsg *ifm, 1933 struct nlattr **tb) 1934{ | 1900 else 1901 return -EINVAL; 1902 1903 if (!dev) 1904 return -ENODEV; 1905 1906 ops = dev->rtnl_link_ops; 1907 if (!ops || !ops->dellink) --- 78 unchanged lines hidden (view full) --- 1986} 1987EXPORT_SYMBOL(rtnl_create_link); 1988 1989static int rtnl_group_changelink(const struct sk_buff *skb, 1990 struct net *net, int group, 1991 struct ifinfomsg *ifm, 1992 struct nlattr **tb) 1993{ |
1935 struct net_device *dev, *aux; | 1994 struct net_device *dev; |
1936 int err; 1937 | 1995 int err; 1996 |
1938 for_each_netdev_safe(net, dev, aux) { | 1997 for_each_netdev(net, dev) { |
1939 if (dev->group == group) { 1940 err = do_setlink(skb, dev, ifm, tb, NULL, 0); 1941 if (err < 0) 1942 return err; 1943 } 1944 } 1945 1946 return 0; --- 1313 unchanged lines hidden --- | 1998 if (dev->group == group) { 1999 err = do_setlink(skb, dev, ifm, tb, NULL, 0); 2000 if (err < 0) 2001 return err; 2002 } 2003 } 2004 2005 return 0; --- 1313 unchanged lines hidden --- |