aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Dichtel <nicolas.dichtel@6wind.com>2015-04-02 11:07:00 -0400
committerDavid S. Miller <davem@davemloft.net>2015-04-02 14:04:59 -0400
commita54acb3a6f853e8394c4cb7b6a4d93c88f13eefd (patch)
treeb1e887d2bc8c205d4fe3b331e40fddba5de6ee01
parent033f46b3c13d4072d8ee6b26dd1e90fdd06895d0 (diff)
dev: introduce dev_get_iflink()
The goal of this patch is to prepare the removal of the iflink field. It introduces a new ndo function, which will be implemented by virtual interfaces. There is no functional change into this patch. All readers of iflink field now call dev_get_iflink(). Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ipvlan/ipvlan_core.c2
-rw-r--r--include/linux/netdevice.h4
-rw-r--r--net/batman-adv/hard-interface.c5
-rw-r--r--net/bridge/br_netlink.c4
-rw-r--r--net/core/dev.c21
-rw-r--r--net/core/link_watch.c4
-rw-r--r--net/core/net-sysfs.c10
-rw-r--r--net/core/rtnetlink.c8
-rw-r--r--net/ipv4/ipmr.c2
-rw-r--r--net/ipv6/addrconf.c4
-rw-r--r--net/ipv6/ip6mr.c2
11 files changed, 48 insertions, 18 deletions
diff --git a/drivers/net/ipvlan/ipvlan_core.c b/drivers/net/ipvlan/ipvlan_core.c
index 2a175006028b..131bde98188d 100644
--- a/drivers/net/ipvlan/ipvlan_core.c
+++ b/drivers/net/ipvlan/ipvlan_core.c
@@ -330,7 +330,7 @@ static int ipvlan_process_v4_outbound(struct sk_buff *skb)
330 struct rtable *rt; 330 struct rtable *rt;
331 int err, ret = NET_XMIT_DROP; 331 int err, ret = NET_XMIT_DROP;
332 struct flowi4 fl4 = { 332 struct flowi4 fl4 = {
333 .flowi4_oif = dev->iflink, 333 .flowi4_oif = dev_get_iflink(dev),
334 .flowi4_tos = RT_TOS(ip4h->tos), 334 .flowi4_tos = RT_TOS(ip4h->tos),
335 .flowi4_flags = FLOWI_FLAG_ANYSRC, 335 .flowi4_flags = FLOWI_FLAG_ANYSRC,
336 .daddr = ip4h->daddr, 336 .daddr = ip4h->daddr,
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 967bb4c8caf1..788eb7a622ad 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1030,6 +1030,8 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
1030 * int queue_index, u32 maxrate); 1030 * int queue_index, u32 maxrate);
1031 * Called when a user wants to set a max-rate limitation of specific 1031 * Called when a user wants to set a max-rate limitation of specific
1032 * TX queue. 1032 * TX queue.
1033 * int (*ndo_get_iflink)(const struct net_device *dev);
1034 * Called to get the iflink value of this device.
1033 */ 1035 */
1034struct net_device_ops { 1036struct net_device_ops {
1035 int (*ndo_init)(struct net_device *dev); 1037 int (*ndo_init)(struct net_device *dev);
@@ -1191,6 +1193,7 @@ struct net_device_ops {
1191 int (*ndo_set_tx_maxrate)(struct net_device *dev, 1193 int (*ndo_set_tx_maxrate)(struct net_device *dev,
1192 int queue_index, 1194 int queue_index,
1193 u32 maxrate); 1195 u32 maxrate);
1196 int (*ndo_get_iflink)(const struct net_device *dev);
1194}; 1197};
1195 1198
1196/** 1199/**
@@ -2149,6 +2152,7 @@ void __dev_remove_pack(struct packet_type *pt);
2149void dev_add_offload(struct packet_offload *po); 2152void dev_add_offload(struct packet_offload *po);
2150void dev_remove_offload(struct packet_offload *po); 2153void dev_remove_offload(struct packet_offload *po);
2151 2154
2155int dev_get_iflink(const struct net_device *dev);
2152struct net_device *__dev_get_by_flags(struct net *net, unsigned short flags, 2156struct net_device *__dev_get_by_flags(struct net *net, unsigned short flags,
2153 unsigned short mask); 2157 unsigned short mask);
2154struct net_device *dev_get_by_name(struct net *net, const char *name); 2158struct net_device *dev_get_by_name(struct net *net, const char *name);
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index fbda6b54baff..baf1f9843f2c 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -83,11 +83,12 @@ static bool batadv_is_on_batman_iface(const struct net_device *net_dev)
83 return true; 83 return true;
84 84
85 /* no more parents..stop recursion */ 85 /* no more parents..stop recursion */
86 if (net_dev->iflink == 0 || net_dev->iflink == net_dev->ifindex) 86 if (dev_get_iflink(net_dev) == 0 ||
87 dev_get_iflink(net_dev) == net_dev->ifindex)
87 return false; 88 return false;
88 89
89 /* recurse over the parent device */ 90 /* recurse over the parent device */
90 parent_dev = __dev_get_by_index(&init_net, net_dev->iflink); 91 parent_dev = __dev_get_by_index(&init_net, dev_get_iflink(net_dev));
91 /* if we got a NULL parent_dev there is something broken.. */ 92 /* if we got a NULL parent_dev there is something broken.. */
92 if (WARN(!parent_dev, "Cannot find parent device")) 93 if (WARN(!parent_dev, "Cannot find parent device"))
93 return false; 94 return false;
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index e1115a224a95..0e4ddb81610d 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -305,8 +305,8 @@ static int br_fill_ifinfo(struct sk_buff *skb,
305 nla_put_u8(skb, IFLA_OPERSTATE, operstate) || 305 nla_put_u8(skb, IFLA_OPERSTATE, operstate) ||
306 (dev->addr_len && 306 (dev->addr_len &&
307 nla_put(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr)) || 307 nla_put(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr)) ||
308 (dev->ifindex != dev->iflink && 308 (dev->ifindex != dev_get_iflink(dev) &&
309 nla_put_u32(skb, IFLA_LINK, dev->iflink))) 309 nla_put_u32(skb, IFLA_LINK, dev_get_iflink(dev))))
310 goto nla_put_failure; 310 goto nla_put_failure;
311 311
312 if (event == RTM_NEWLINK && port) { 312 if (event == RTM_NEWLINK && port) {
diff --git a/net/core/dev.c b/net/core/dev.c
index 65492b0354c0..77172d085760 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -660,6 +660,23 @@ __setup("netdev=", netdev_boot_setup);
660*******************************************************************************/ 660*******************************************************************************/
661 661
662/** 662/**
663 * dev_get_iflink - get 'iflink' value of a interface
664 * @dev: targeted interface
665 *
666 * Indicates the ifindex the interface is linked to.
667 * Physical interfaces have the same 'ifindex' and 'iflink' values.
668 */
669
670int dev_get_iflink(const struct net_device *dev)
671{
672 if (dev->netdev_ops && dev->netdev_ops->ndo_get_iflink)
673 return dev->netdev_ops->ndo_get_iflink(dev);
674
675 return dev->iflink;
676}
677EXPORT_SYMBOL(dev_get_iflink);
678
679/**
663 * __dev_get_by_name - find a device by its name 680 * __dev_get_by_name - find a device by its name
664 * @net: the applicable net namespace 681 * @net: the applicable net namespace
665 * @name: name to find 682 * @name: name to find
@@ -6345,7 +6362,7 @@ int register_netdevice(struct net_device *dev)
6345 else if (__dev_get_by_index(net, dev->ifindex)) 6362 else if (__dev_get_by_index(net, dev->ifindex))
6346 goto err_uninit; 6363 goto err_uninit;
6347 6364
6348 if (dev->iflink == -1) 6365 if (dev_get_iflink(dev) == -1)
6349 dev->iflink = dev->ifindex; 6366 dev->iflink = dev->ifindex;
6350 6367
6351 /* Transfer changeable features to wanted_features and enable 6368 /* Transfer changeable features to wanted_features and enable
@@ -7061,7 +7078,7 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
7061 7078
7062 /* If there is an ifindex conflict assign a new one */ 7079 /* If there is an ifindex conflict assign a new one */
7063 if (__dev_get_by_index(net, dev->ifindex)) { 7080 if (__dev_get_by_index(net, dev->ifindex)) {
7064 int iflink = (dev->iflink == dev->ifindex); 7081 int iflink = (dev_get_iflink(dev) == dev->ifindex);
7065 dev->ifindex = dev_new_index(net); 7082 dev->ifindex = dev_new_index(net);
7066 if (iflink) 7083 if (iflink)
7067 dev->iflink = dev->ifindex; 7084 dev->iflink = dev->ifindex;
diff --git a/net/core/link_watch.c b/net/core/link_watch.c
index 49a9e3e06c08..982861607f88 100644
--- a/net/core/link_watch.c
+++ b/net/core/link_watch.c
@@ -40,7 +40,7 @@ static DEFINE_SPINLOCK(lweventlist_lock);
40static unsigned char default_operstate(const struct net_device *dev) 40static unsigned char default_operstate(const struct net_device *dev)
41{ 41{
42 if (!netif_carrier_ok(dev)) 42 if (!netif_carrier_ok(dev))
43 return (dev->ifindex != dev->iflink ? 43 return (dev->ifindex != dev_get_iflink(dev) ?
44 IF_OPER_LOWERLAYERDOWN : IF_OPER_DOWN); 44 IF_OPER_LOWERLAYERDOWN : IF_OPER_DOWN);
45 45
46 if (netif_dormant(dev)) 46 if (netif_dormant(dev))
@@ -89,7 +89,7 @@ static bool linkwatch_urgent_event(struct net_device *dev)
89 if (!netif_running(dev)) 89 if (!netif_running(dev))
90 return false; 90 return false;
91 91
92 if (dev->ifindex != dev->iflink) 92 if (dev->ifindex != dev_get_iflink(dev))
93 return true; 93 return true;
94 94
95 if (dev->priv_flags & IFF_TEAM_PORT) 95 if (dev->priv_flags & IFF_TEAM_PORT)
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index cc5cf689809c..4238d6da5c60 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -109,11 +109,19 @@ NETDEVICE_SHOW_RO(dev_id, fmt_hex);
109NETDEVICE_SHOW_RO(dev_port, fmt_dec); 109NETDEVICE_SHOW_RO(dev_port, fmt_dec);
110NETDEVICE_SHOW_RO(addr_assign_type, fmt_dec); 110NETDEVICE_SHOW_RO(addr_assign_type, fmt_dec);
111NETDEVICE_SHOW_RO(addr_len, fmt_dec); 111NETDEVICE_SHOW_RO(addr_len, fmt_dec);
112NETDEVICE_SHOW_RO(iflink, fmt_dec);
113NETDEVICE_SHOW_RO(ifindex, fmt_dec); 112NETDEVICE_SHOW_RO(ifindex, fmt_dec);
114NETDEVICE_SHOW_RO(type, fmt_dec); 113NETDEVICE_SHOW_RO(type, fmt_dec);
115NETDEVICE_SHOW_RO(link_mode, fmt_dec); 114NETDEVICE_SHOW_RO(link_mode, fmt_dec);
116 115
116static ssize_t iflink_show(struct device *dev, struct device_attribute *attr,
117 char *buf)
118{
119 struct net_device *ndev = to_net_dev(dev);
120
121 return sprintf(buf, fmt_dec, dev_get_iflink(ndev));
122}
123static DEVICE_ATTR_RO(iflink);
124
117static ssize_t format_name_assign_type(const struct net_device *dev, char *buf) 125static ssize_t format_name_assign_type(const struct net_device *dev, char *buf)
118{ 126{
119 return sprintf(buf, fmt_dec, dev->name_assign_type); 127 return sprintf(buf, fmt_dec, dev->name_assign_type);
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index b96ac2109c82..ee0186cdd5cf 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1055,8 +1055,8 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
1055#ifdef CONFIG_RPS 1055#ifdef CONFIG_RPS
1056 nla_put_u32(skb, IFLA_NUM_RX_QUEUES, dev->num_rx_queues) || 1056 nla_put_u32(skb, IFLA_NUM_RX_QUEUES, dev->num_rx_queues) ||
1057#endif 1057#endif
1058 (dev->ifindex != dev->iflink && 1058 (dev->ifindex != dev_get_iflink(dev) &&
1059 nla_put_u32(skb, IFLA_LINK, dev->iflink)) || 1059 nla_put_u32(skb, IFLA_LINK, dev_get_iflink(dev))) ||
1060 (upper_dev && 1060 (upper_dev &&
1061 nla_put_u32(skb, IFLA_MASTER, upper_dev->ifindex)) || 1061 nla_put_u32(skb, IFLA_MASTER, upper_dev->ifindex)) ||
1062 nla_put_u8(skb, IFLA_CARRIER, netif_carrier_ok(dev)) || 1062 nla_put_u8(skb, IFLA_CARRIER, netif_carrier_ok(dev)) ||
@@ -2863,8 +2863,8 @@ int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
2863 nla_put_u32(skb, IFLA_MASTER, br_dev->ifindex)) || 2863 nla_put_u32(skb, IFLA_MASTER, br_dev->ifindex)) ||
2864 (dev->addr_len && 2864 (dev->addr_len &&
2865 nla_put(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr)) || 2865 nla_put(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr)) ||
2866 (dev->ifindex != dev->iflink && 2866 (dev->ifindex != dev_get_iflink(dev) &&
2867 nla_put_u32(skb, IFLA_LINK, dev->iflink))) 2867 nla_put_u32(skb, IFLA_LINK, dev_get_iflink(dev))))
2868 goto nla_put_failure; 2868 goto nla_put_failure;
2869 2869
2870 br_afspec = nla_nest_start(skb, IFLA_AF_SPEC); 2870 br_afspec = nla_nest_start(skb, IFLA_AF_SPEC);
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index b4a545d24adb..eec68b0c3bc8 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -801,7 +801,7 @@ static int vif_add(struct net *net, struct mr_table *mrt,
801 v->pkt_out = 0; 801 v->pkt_out = 0;
802 v->link = dev->ifindex; 802 v->link = dev->ifindex;
803 if (v->flags & (VIFF_TUNNEL | VIFF_REGISTER)) 803 if (v->flags & (VIFF_TUNNEL | VIFF_REGISTER))
804 v->link = dev->iflink; 804 v->link = dev_get_iflink(dev);
805 805
806 /* And finish update writing critical data */ 806 /* And finish update writing critical data */
807 write_lock_bh(&mrt_lock); 807 write_lock_bh(&mrt_lock);
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 5c9e94cb1b2c..37b70e82bff8 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -4858,8 +4858,8 @@ static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev,
4858 (dev->addr_len && 4858 (dev->addr_len &&
4859 nla_put(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr)) || 4859 nla_put(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr)) ||
4860 nla_put_u32(skb, IFLA_MTU, dev->mtu) || 4860 nla_put_u32(skb, IFLA_MTU, dev->mtu) ||
4861 (dev->ifindex != dev->iflink && 4861 (dev->ifindex != dev_get_iflink(dev) &&
4862 nla_put_u32(skb, IFLA_LINK, dev->iflink))) 4862 nla_put_u32(skb, IFLA_LINK, dev_get_iflink(dev))))
4863 goto nla_put_failure; 4863 goto nla_put_failure;
4864 protoinfo = nla_nest_start(skb, IFLA_PROTINFO); 4864 protoinfo = nla_nest_start(skb, IFLA_PROTINFO);
4865 if (!protoinfo) 4865 if (!protoinfo)
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index caf6b99374e6..18a5ab286420 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -992,7 +992,7 @@ static int mif6_add(struct net *net, struct mr6_table *mrt,
992 v->pkt_out = 0; 992 v->pkt_out = 0;
993 v->link = dev->ifindex; 993 v->link = dev->ifindex;
994 if (v->flags & MIFF_REGISTER) 994 if (v->flags & MIFF_REGISTER)
995 v->link = dev->iflink; 995 v->link = dev_get_iflink(dev);
996 996
997 /* And finish update writing critical data */ 997 /* And finish update writing critical data */
998 write_lock_bh(&mrt_lock); 998 write_lock_bh(&mrt_lock);