diff options
author | David S. Miller <davem@davemloft.net> | 2015-04-02 14:05:02 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-04-02 14:05:02 -0400 |
commit | e4a924f5768c55002c02ceba9b9f86824c35f956 (patch) | |
tree | ae8db8c41d5950644db9d4f5e609f228df958e57 /net/ipv4 | |
parent | 033f46b3c13d4072d8ee6b26dd1e90fdd06895d0 (diff) | |
parent | a45253bf32bf49cdb2807bad212b84f5ab51ac26 (diff) |
Merge branch 'netdev_iflink_remove'
Nicolas Dichtel says:
====================
Remove iflink field from the net_device structure
The first goal of this series was to advertise the veth peer via the IFLA_LINK
attribute, but iflink was not ready for network namespaces.
The iflink of an interface should be set to its ifindex for a physical interface
and to another value (0 if not relevant) for a virtual interface.
This was not the case for some interfaces, like vxlan, bond, or bridge for
example.
There is also a risk, if the targeted interface moves to another netns, that the
ifindex changes without updating corresponding iflink fields (eg. vlan).
Moving the management of this property into virtual interface drivers allows to
better handle this last case because most of virtual interface drivers have a
pointer to the link netdevice.
Anyway, dev->iflink value was always a copy of some internal data of the virtual
interface driver, thus let's use these internal data directly.
So, this series removes the iflink field and let the drivers manage it.
Only the last patch was present in the v1, but I fully rework it.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/ip_gre.c | 2 | ||||
-rw-r--r-- | net/ipv4/ip_tunnel.c | 9 | ||||
-rw-r--r-- | net/ipv4/ip_vti.c | 2 | ||||
-rw-r--r-- | net/ipv4/ipip.c | 2 | ||||
-rw-r--r-- | net/ipv4/ipmr.c | 9 |
5 files changed, 19 insertions, 5 deletions
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index 0eb2a040a830..1060ca0bc23a 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c | |||
@@ -456,6 +456,7 @@ static const struct net_device_ops ipgre_netdev_ops = { | |||
456 | .ndo_do_ioctl = ipgre_tunnel_ioctl, | 456 | .ndo_do_ioctl = ipgre_tunnel_ioctl, |
457 | .ndo_change_mtu = ip_tunnel_change_mtu, | 457 | .ndo_change_mtu = ip_tunnel_change_mtu, |
458 | .ndo_get_stats64 = ip_tunnel_get_stats64, | 458 | .ndo_get_stats64 = ip_tunnel_get_stats64, |
459 | .ndo_get_iflink = ip_tunnel_get_iflink, | ||
459 | }; | 460 | }; |
460 | 461 | ||
461 | #define GRE_FEATURES (NETIF_F_SG | \ | 462 | #define GRE_FEATURES (NETIF_F_SG | \ |
@@ -686,6 +687,7 @@ static const struct net_device_ops gre_tap_netdev_ops = { | |||
686 | .ndo_validate_addr = eth_validate_addr, | 687 | .ndo_validate_addr = eth_validate_addr, |
687 | .ndo_change_mtu = ip_tunnel_change_mtu, | 688 | .ndo_change_mtu = ip_tunnel_change_mtu, |
688 | .ndo_get_stats64 = ip_tunnel_get_stats64, | 689 | .ndo_get_stats64 = ip_tunnel_get_stats64, |
690 | .ndo_get_iflink = ip_tunnel_get_iflink, | ||
689 | }; | 691 | }; |
690 | 692 | ||
691 | static void ipgre_tap_setup(struct net_device *dev) | 693 | static void ipgre_tap_setup(struct net_device *dev) |
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c index 2cd08280c77b..4bb7252110a6 100644 --- a/net/ipv4/ip_tunnel.c +++ b/net/ipv4/ip_tunnel.c | |||
@@ -389,7 +389,6 @@ static int ip_tunnel_bind_dev(struct net_device *dev) | |||
389 | hlen = tdev->hard_header_len + tdev->needed_headroom; | 389 | hlen = tdev->hard_header_len + tdev->needed_headroom; |
390 | mtu = tdev->mtu; | 390 | mtu = tdev->mtu; |
391 | } | 391 | } |
392 | dev->iflink = tunnel->parms.link; | ||
393 | 392 | ||
394 | dev->needed_headroom = t_hlen + hlen; | 393 | dev->needed_headroom = t_hlen + hlen; |
395 | mtu -= (dev->hard_header_len + t_hlen); | 394 | mtu -= (dev->hard_header_len + t_hlen); |
@@ -980,6 +979,14 @@ struct net *ip_tunnel_get_link_net(const struct net_device *dev) | |||
980 | } | 979 | } |
981 | EXPORT_SYMBOL(ip_tunnel_get_link_net); | 980 | EXPORT_SYMBOL(ip_tunnel_get_link_net); |
982 | 981 | ||
982 | int ip_tunnel_get_iflink(const struct net_device *dev) | ||
983 | { | ||
984 | struct ip_tunnel *tunnel = netdev_priv(dev); | ||
985 | |||
986 | return tunnel->parms.link; | ||
987 | } | ||
988 | EXPORT_SYMBOL(ip_tunnel_get_iflink); | ||
989 | |||
983 | int ip_tunnel_init_net(struct net *net, int ip_tnl_net_id, | 990 | int ip_tunnel_init_net(struct net *net, int ip_tnl_net_id, |
984 | struct rtnl_link_ops *ops, char *devname) | 991 | struct rtnl_link_ops *ops, char *devname) |
985 | { | 992 | { |
diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c index 5a6e27054f0a..c4f93c0d1104 100644 --- a/net/ipv4/ip_vti.c +++ b/net/ipv4/ip_vti.c | |||
@@ -341,6 +341,7 @@ static const struct net_device_ops vti_netdev_ops = { | |||
341 | .ndo_do_ioctl = vti_tunnel_ioctl, | 341 | .ndo_do_ioctl = vti_tunnel_ioctl, |
342 | .ndo_change_mtu = ip_tunnel_change_mtu, | 342 | .ndo_change_mtu = ip_tunnel_change_mtu, |
343 | .ndo_get_stats64 = ip_tunnel_get_stats64, | 343 | .ndo_get_stats64 = ip_tunnel_get_stats64, |
344 | .ndo_get_iflink = ip_tunnel_get_iflink, | ||
344 | }; | 345 | }; |
345 | 346 | ||
346 | static void vti_tunnel_setup(struct net_device *dev) | 347 | static void vti_tunnel_setup(struct net_device *dev) |
@@ -361,7 +362,6 @@ static int vti_tunnel_init(struct net_device *dev) | |||
361 | dev->hard_header_len = LL_MAX_HEADER + sizeof(struct iphdr); | 362 | dev->hard_header_len = LL_MAX_HEADER + sizeof(struct iphdr); |
362 | dev->mtu = ETH_DATA_LEN; | 363 | dev->mtu = ETH_DATA_LEN; |
363 | dev->flags = IFF_NOARP; | 364 | dev->flags = IFF_NOARP; |
364 | dev->iflink = 0; | ||
365 | dev->addr_len = 4; | 365 | dev->addr_len = 4; |
366 | dev->features |= NETIF_F_LLTX; | 366 | dev->features |= NETIF_F_LLTX; |
367 | netif_keep_dst(dev); | 367 | netif_keep_dst(dev); |
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c index bfbcc85c02ee..5c81f6e40842 100644 --- a/net/ipv4/ipip.c +++ b/net/ipv4/ipip.c | |||
@@ -272,6 +272,7 @@ static const struct net_device_ops ipip_netdev_ops = { | |||
272 | .ndo_do_ioctl = ipip_tunnel_ioctl, | 272 | .ndo_do_ioctl = ipip_tunnel_ioctl, |
273 | .ndo_change_mtu = ip_tunnel_change_mtu, | 273 | .ndo_change_mtu = ip_tunnel_change_mtu, |
274 | .ndo_get_stats64 = ip_tunnel_get_stats64, | 274 | .ndo_get_stats64 = ip_tunnel_get_stats64, |
275 | .ndo_get_iflink = ip_tunnel_get_iflink, | ||
275 | }; | 276 | }; |
276 | 277 | ||
277 | #define IPIP_FEATURES (NETIF_F_SG | \ | 278 | #define IPIP_FEATURES (NETIF_F_SG | \ |
@@ -286,7 +287,6 @@ static void ipip_tunnel_setup(struct net_device *dev) | |||
286 | 287 | ||
287 | dev->type = ARPHRD_TUNNEL; | 288 | dev->type = ARPHRD_TUNNEL; |
288 | dev->flags = IFF_NOARP; | 289 | dev->flags = IFF_NOARP; |
289 | dev->iflink = 0; | ||
290 | dev->addr_len = 4; | 290 | dev->addr_len = 4; |
291 | dev->features |= NETIF_F_LLTX; | 291 | dev->features |= NETIF_F_LLTX; |
292 | netif_keep_dst(dev); | 292 | netif_keep_dst(dev); |
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index b4a545d24adb..d2e3b3ef039e 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c | |||
@@ -473,8 +473,14 @@ static netdev_tx_t reg_vif_xmit(struct sk_buff *skb, struct net_device *dev) | |||
473 | return NETDEV_TX_OK; | 473 | return NETDEV_TX_OK; |
474 | } | 474 | } |
475 | 475 | ||
476 | static int reg_vif_get_iflink(const struct net_device *dev) | ||
477 | { | ||
478 | return 0; | ||
479 | } | ||
480 | |||
476 | static const struct net_device_ops reg_vif_netdev_ops = { | 481 | static const struct net_device_ops reg_vif_netdev_ops = { |
477 | .ndo_start_xmit = reg_vif_xmit, | 482 | .ndo_start_xmit = reg_vif_xmit, |
483 | .ndo_get_iflink = reg_vif_get_iflink, | ||
478 | }; | 484 | }; |
479 | 485 | ||
480 | static void reg_vif_setup(struct net_device *dev) | 486 | static void reg_vif_setup(struct net_device *dev) |
@@ -509,7 +515,6 @@ static struct net_device *ipmr_reg_vif(struct net *net, struct mr_table *mrt) | |||
509 | free_netdev(dev); | 515 | free_netdev(dev); |
510 | return NULL; | 516 | return NULL; |
511 | } | 517 | } |
512 | dev->iflink = 0; | ||
513 | 518 | ||
514 | rcu_read_lock(); | 519 | rcu_read_lock(); |
515 | in_dev = __in_dev_get_rcu(dev); | 520 | in_dev = __in_dev_get_rcu(dev); |
@@ -801,7 +806,7 @@ static int vif_add(struct net *net, struct mr_table *mrt, | |||
801 | v->pkt_out = 0; | 806 | v->pkt_out = 0; |
802 | v->link = dev->ifindex; | 807 | v->link = dev->ifindex; |
803 | if (v->flags & (VIFF_TUNNEL | VIFF_REGISTER)) | 808 | if (v->flags & (VIFF_TUNNEL | VIFF_REGISTER)) |
804 | v->link = dev->iflink; | 809 | v->link = dev_get_iflink(dev); |
805 | 810 | ||
806 | /* And finish update writing critical data */ | 811 | /* And finish update writing critical data */ |
807 | write_lock_bh(&mrt_lock); | 812 | write_lock_bh(&mrt_lock); |