rtnetlink.c (9e87e48f8e5de2146842fd0ff436e0256b52c4a9) | rtnetlink.c (a54acb3a6f853e8394c4cb7b6a4d93c88f13eefd) |
---|---|
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) --- 39 unchanged lines hidden (view full) --- 1032 nla_put_u8(skb, IFLA_LINKMODE, dev->link_mode) || 1033 nla_put_u32(skb, IFLA_MTU, dev->mtu) || 1034 nla_put_u32(skb, IFLA_GROUP, dev->group) || 1035 nla_put_u32(skb, IFLA_PROMISCUITY, dev->promiscuity) || 1036 nla_put_u32(skb, IFLA_NUM_TX_QUEUES, dev->num_tx_queues) || 1037#ifdef CONFIG_RPS 1038 nla_put_u32(skb, IFLA_NUM_RX_QUEUES, dev->num_rx_queues) || 1039#endif | 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) --- 39 unchanged lines hidden (view full) --- 1050 nla_put_u8(skb, IFLA_LINKMODE, dev->link_mode) || 1051 nla_put_u32(skb, IFLA_MTU, dev->mtu) || 1052 nla_put_u32(skb, IFLA_GROUP, dev->group) || 1053 nla_put_u32(skb, IFLA_PROMISCUITY, dev->promiscuity) || 1054 nla_put_u32(skb, IFLA_NUM_TX_QUEUES, dev->num_tx_queues) || 1055#ifdef CONFIG_RPS 1056 nla_put_u32(skb, IFLA_NUM_RX_QUEUES, dev->num_rx_queues) || 1057#endif |
1040 (dev->ifindex != dev->iflink && 1041 nla_put_u32(skb, IFLA_LINK, dev->iflink)) || | 1058 (dev->ifindex != dev_get_iflink(dev) && 1059 nla_put_u32(skb, IFLA_LINK, dev_get_iflink(dev))) || |
1042 (upper_dev && 1043 nla_put_u32(skb, IFLA_MASTER, upper_dev->ifindex)) || 1044 nla_put_u8(skb, IFLA_CARRIER, netif_carrier_ok(dev)) || 1045 (dev->qdisc && 1046 nla_put_string(skb, IFLA_QDISC, dev->qdisc->ops->id)) || 1047 (dev->ifalias && 1048 nla_put_string(skb, IFLA_IFALIAS, dev->ifalias)) || 1049 nla_put_u32(skb, IFLA_CARRIER_CHANGES, --- 17 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 | 1060 (upper_dev && 1061 nla_put_u32(skb, IFLA_MASTER, upper_dev->ifindex)) || 1062 nla_put_u8(skb, IFLA_CARRIER, netif_carrier_ok(dev)) || 1063 (dev->qdisc && 1064 nla_put_string(skb, IFLA_QDISC, dev->qdisc->ops->id)) || 1065 (dev->ifalias && 1066 nla_put_string(skb, IFLA_IFALIAS, dev->ifalias)) || 1067 nla_put_u32(skb, IFLA_CARRIER_CHANGES, --- 17 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) --- 950 unchanged lines hidden (view full) --- 2799 2800 if (nla_put_string(skb, IFLA_IFNAME, dev->name) || 2801 nla_put_u32(skb, IFLA_MTU, dev->mtu) || 2802 nla_put_u8(skb, IFLA_OPERSTATE, operstate) || 2803 (br_dev && 2804 nla_put_u32(skb, IFLA_MASTER, br_dev->ifindex)) || 2805 (dev->addr_len && 2806 nla_put(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr)) || | 1900 else 1901 return -EINVAL; 1902 1903 if (!dev) 1904 return -ENODEV; 1905 1906 ops = dev->rtnl_link_ops; 1907 if (!ops || !ops->dellink) --- 950 unchanged lines hidden (view full) --- 2858 2859 if (nla_put_string(skb, IFLA_IFNAME, dev->name) || 2860 nla_put_u32(skb, IFLA_MTU, dev->mtu) || 2861 nla_put_u8(skb, IFLA_OPERSTATE, operstate) || 2862 (br_dev && 2863 nla_put_u32(skb, IFLA_MASTER, br_dev->ifindex)) || 2864 (dev->addr_len && 2865 nla_put(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr)) || |
2807 (dev->ifindex != dev->iflink && 2808 nla_put_u32(skb, IFLA_LINK, dev->iflink))) | 2866 (dev->ifindex != dev_get_iflink(dev) && 2867 nla_put_u32(skb, IFLA_LINK, dev_get_iflink(dev)))) |
2809 goto nla_put_failure; 2810 2811 br_afspec = nla_nest_start(skb, IFLA_AF_SPEC); 2812 if (!br_afspec) 2813 goto nla_put_failure; 2814 2815 if (nla_put_u16(skb, IFLA_BRIDGE_FLAGS, BRIDGE_FLAGS_SELF)) { 2816 nla_nest_cancel(skb, br_afspec); --- 443 unchanged lines hidden --- | 2868 goto nla_put_failure; 2869 2870 br_afspec = nla_nest_start(skb, IFLA_AF_SPEC); 2871 if (!br_afspec) 2872 goto nla_put_failure; 2873 2874 if (nla_put_u16(skb, IFLA_BRIDGE_FLAGS, BRIDGE_FLAGS_SELF)) { 2875 nla_nest_cancel(skb, br_afspec); --- 443 unchanged lines hidden --- |