net: L3 master device
Subsystems (7)
cover net: L3 master device
The VRF device is essentially a Layer 3 master device used to associate netdevices with a specific routing table and to influence FIB lookups via 'ip rules' and controlling the oif/iif used for the lookup.
This series generalizes the VRF into L3 master device, l3mdev. Similar to switchdev it has a Kconfig option and separate set of operations in net_device allowing it to be completely compiled out if not wanted. The l3mdev methods rely on the 'master' aspect and use of netdev_master_upper_dev_get_rcu to retrieve the master device from a given netdevice if it is enslaved to an L3_MASTER.
The VRF device is converted to use the l3mdev operations. At the end the vrf_ptr is no longer and removed, as are all direct references to VRF. The end result is a much simpler implementation for VRF.
Thanks to Nikolay for suggestions (eg., use of the master linkage which is the key to making this work) and to Roopa, Andy and Shrijeet for early reviews.
David Ahern (11):
net: Introduce L3 Master device abstraction
net: Rename IFF_VRF_MASTER to IFF_L3MDEV
net: Add support for l3mdev ops to VRF driver
net: Replace vrf_master_ifindex{,_rcu} with l3mdev equivalents
net: Replace vrf_dev_table and friends
net: Replace calls to vrf_dev_get_rth
net: Remove the now unused vrf_ptr
net: Remove vrf header file
net: Move netif_index_is_l3_master to l3mdev.h
net: Rename FLOWI_FLAG_VRFSRC to FLOWI_FLAG_L3MDEV_SRC
net: Add netif_is_l3_slave
MAINTAINERS | 8 ++- drivers/net/Kconfig | 1 + drivers/net/vrf.c | 87 ++++++++++++---------- include/linux/netdevice.h | 41 ++++------- include/net/flow.h | 2 +- include/net/l3mdev.h | 152 +++++++++++++++++++++++++++++++++++++++ include/net/route.h | 5 +- include/net/vrf.h | 178 ---------------------------------------------- net/Kconfig | 1 + net/Makefile | 3 + net/ipv4/af_inet.c | 4 +- net/ipv4/fib_frontend.c | 12 ++-- net/ipv4/fib_trie.c | 2 +- net/ipv4/icmp.c | 8 +-- net/ipv4/ip_fragment.c | 6 +- net/ipv4/ip_output.c | 2 +- net/ipv4/route.c | 16 ++--- net/ipv4/udp.c | 4 +- net/ipv4/xfrm4_policy.c | 8 +-- net/ipv6/xfrm6_policy.c | 8 +-- net/l3mdev/Kconfig | 10 +++ net/l3mdev/Makefile | 5 ++ net/l3mdev/l3mdev.c | 74 +++++++++++++++++++ 23 files changed, 354 insertions(+), 283 deletions(-) create mode 100644 include/net/l3mdev.h delete mode 100644 include/net/vrf.h create mode 100644 net/l3mdev/Kconfig create mode 100644 net/l3mdev/Makefile create mode 100644 net/l3mdev/l3mdev.c
Signature · 1 line
1.9.1
RFC 1/11 net: Introduce L3 Master device abstraction
L3 master devices allow users of the abstraction to influence FIB lookups for enslaved devices. Current API provides a means for the master device to return a specific FIB table for an enslaved device, to return an rtable/custom dst and influence the OIF used for fib lookups.
--- MAINTAINERS | 7 +++ include/linux/netdevice.h | 3 ++ include/net/l3mdev.h | 128 ++++++++++++++++++++++++++++++++++++++++++++++ net/Kconfig | 1 + net/Makefile | 3 ++ net/l3mdev/Kconfig | 10 ++++ net/l3mdev/Makefile | 5 ++ net/l3mdev/l3mdev.c | 84 ++++++++++++++++++++++++++++++ 8 files changed, 241 insertions(+) create mode 100644 include/net/l3mdev.h create mode 100644 net/l3mdev/Kconfig create mode 100644 net/l3mdev/Makefile create mode 100644 net/l3mdev/l3mdev.c
MAINTAINERS +7 -0
@@ -6088,6 +6088,13 @@ F: Documentation/auxdisplay/ks0108 F: drivers/auxdisplay/ks0108.c F: include/linux/ks0108.h +L3MDEV +M: David Ahern <[email protected]> +L: [email protected] +S: Maintained +F: net/l3mdev +F: include/net/l3mdev.h + LAPB module L: [email protected] S: Orphan
include/linux/netdevice.h +3 -0
@@ -1586,6 +1586,9 @@ struct net_device {#ifdef CONFIG_NET_SWITCHDEV const struct switchdev_ops *switchdev_ops;#endif +#ifdef CONFIG_NET_L3_MASTER_DEV +const struct l3mdev_ops *l3mdev_ops; +#endif const struct header_ops *header_ops;
include/net/l3mdev.h new file +128 -0
128 lines not on this page · raw message
net/Kconfig +1 -0
@@ -232,6 +232,7 @@ source "net/netlink/Kconfig" source "net/mpls/Kconfig" source "net/hsr/Kconfig" source "net/switchdev/Kconfig" +source "net/l3mdev/Kconfig" config RPS bool
net/Makefile +3 -0
@@ -74,3 +74,6 @@ obj-$(CONFIG_HSR) += hsr/ ifneq ($(CONFIG_NET_SWITCHDEV),) obj-y += switchdev/ endif +ifneq ($(CONFIG_NET_L3_MASTER_DEV),) +obj-y += l3mdev/ +endif
net/l3mdev/Kconfig new file +10 -0
@@ -0,0 +1,10 @@ +# +# Configuration for L3 master device support +# + +config NET_L3_MASTER_DEV + bool "L3 Master device support" + depends on INET || IPV6 + ---help--- + This module provides glue between core networking code and device + drivers to support L3 master devices like VRF.
net/l3mdev/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# +# Makefile for the L3 device API +# + +obj-$(CONFIG_NET_L3_MASTER_DEV) += l3mdev.o
net/l3mdev/l3mdev.c new file +84 -0
84 lines not on this page · raw message
Signature · 1 line
1.9.1
RFC 2/11 net: Rename IFF_VRF_MASTER to IFF_L3MDEV
In reply to David AhernRename IFF_VRF_MASTER to IFF_L3MDEV and update the name of the netif_is_vrf and netif_index_is_vrf macros.
--- drivers/net/vrf.c | 6 +++--- include/linux/netdevice.h | 14 +++++++------- include/net/route.h | 2 +- include/net/vrf.h | 4 ++-- net/ipv4/ip_output.c | 2 +- net/ipv4/route.c | 2 +- net/ipv4/udp.c | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-)
drivers/net/vrf.c +3 -3
@@ -437,7 +437,7 @@ static int do_vrf_add_slave(struct net_device *dev, struct net_device *port_dev)static int vrf_add_slave (struct net_device *dev,struct net_device *port_dev) { -if (netif_is_vrf (port_dev) ||vrf_is_slave (port_dev)) +if (netif_is_l3_master (port_dev) ||vrf_is_slave (port_dev))return -EINVAL ;return do_vrf_add_slave (dev, port_dev);
@@ -590,7 +590,7 @@ static int vrf_newlink(struct net *src_net, struct net_device *dev, vrf->tb_id =nla_get_u32 (data[IFLA_VRF_TABLE ]); - dev->priv_flags |=IFF_VRF_MASTER ; + dev->priv_flags |=IFF_L3MDEV ; err = -ENOMEM ; vrf_ptr =kmalloc (sizeof (*dev->vrf_ptr),GFP_KERNEL );
@@ -656,7 +656,7 @@ static int vrf_device_event(struct notifier_block *unused,struct net_vrf_dev *vrf_ptr =rtnl_dereference (dev->vrf_ptr);struct net_device *vrf_dev; -if (!vrf_ptr ||netif_is_vrf (dev)) +if (!vrf_ptr ||netif_is_l3_master (dev)) goto out; vrf_dev =netdev_master_upper_dev_get (dev);
include/linux/netdevice.h +7 -7
@@ -1257,7 +1257,7 @@ struct net_device_ops {* @IFF_LIVE_ADDR_CHANGE: device supports hardware address * change when it's running * @IFF_MACVLAN: Macvlan device -* @IFF_VRF_MASTER: device is a VRF master +* @IFF_L3MDEV: device is associated with L3 master device * @IFF_NO_QUEUE: device can run without qdisc attached * @IFF_OPENVSWITCH: device is a Open vSwitch master */
@@ -1282,7 +1282,7 @@ enum netdev_priv_flags {IFF_XMIT_DST_RELEASE_PERM =1 <<17 ,IFF_IPVLAN_MASTER =1 <<18 ,IFF_IPVLAN_SLAVE =1 <<19 , -IFF_VRF_MASTER =1 <<20 , +IFF_L3MDEV =1 <<20 ,IFF_NO_QUEUE =1 <<21 , IFF_OPENVSWITCH = 1<<22, };
@@ -1307,7 +1307,7 @@ enum netdev_priv_flags {#define IFF_XMIT_DST_RELEASE_PERM IFF_XMIT_DST_RELEASE_PERM#define IFF_IPVLAN_MASTER IFF_IPVLAN_MASTER#define IFF_IPVLAN_SLAVE IFF_IPVLAN_SLAVE -#define IFF_VRF_MASTER IFF_VRF_MASTER +#define IFF_L3MDEV IFF_L3MDEV#define IFF_NO_QUEUE IFF_NO_QUEUE#define IFF_OPENVSWITCH IFF_OPENVSWITCH
@@ -3826,9 +3826,9 @@ static inline bool netif_supports_nofcs(struct net_device *dev)return dev->priv_flags &IFF_SUPP_NOFCS ; } -static inline bool netif_is_vrf (const struct net_device *dev) +static inline bool netif_is_l3_master (const struct net_device *dev) { -return dev->priv_flags &IFF_VRF_MASTER ; +return dev->flags &IFF_MASTER && dev->priv_flags &IFF_L3MDEV ; }static inline bool netif_is_bridge_master (const struct net_device *dev)
@@ -3841,7 +3841,7 @@ static inline bool netif_is_ovs_master(const struct net_device *dev)return dev->priv_flags &IFF_OPENVSWITCH ; } -static inline bool netif_index_is_vrf (struct net *net,int ifindex) +static inline bool netif_index_is_l3_master (struct net *net,int ifindex) {bool rc = false;
@@ -3855,7 +3855,7 @@ static inline bool netif_index_is_vrf(struct net *net, int ifindex) dev =dev_get_by_index_rcu (net, ifindex);if (dev) - rc =netif_is_vrf (dev); + rc =netif_is_l3_master (dev);rcu_read_unlock ();#endif
include/net/route.h +1 -1
@@ -256,7 +256,7 @@ static inline void ip_route_connect_init(struct flowi4 *fl4, __be32 dst, __be32if (inet_sk (sk)->transparent) flow_flags |=FLOWI_FLAG_ANYSRC ; -if (netif_index_is_vrf (sock_net (sk), oif)) +if (netif_index_is_l3_master (sock_net (sk), oif)) flow_flags |=FLOWI_FLAG_VRFSRC ; flowi4_init_output(fl4, oif, sk->sk_mark, tos, RT_SCOPE_UNIVERSE,
include/net/vrf.h +2 -2
@@ -43,7 +43,7 @@ static inline int vrf_master_ifindex_rcu(const struct net_device *dev)if (!dev)return 0 ; -if (netif_is_vrf (dev)) { +if (netif_is_l3_master (dev)) { ifindex = dev->ifindex; }else { vrf_ptr =rcu_dereference (dev->vrf_ptr);
@@ -125,7 +125,7 @@ static inline u32 vrf_dev_table_rtnl(const struct net_device *dev)return tb_id; } -/* caller has already checked netif_is_vrf(dev) */ +/* caller has already checked netif_is_l3_master(dev) */ static inline struct rtable *vrf_dev_get_rth (const struct net_device *dev) {struct rtable *rth =ERR_PTR (-ENETUNREACH );
net/ipv4/ip_output.c +1 -1
@@ -1569,7 +1569,7 @@ void ip_send_unicast_reply(struct sock *sk, struct sk_buff *skb, } oif = arg->bound_dev_if; -if (!oif &&netif_index_is_vrf (net, skb->skb_iif)) +if (!oif &&netif_index_is_l3_master (net, skb->skb_iif)) oif = skb->skb_iif; flowi4_init_output(&fl4, oif,
net/ipv4/route.c +1 -1
@@ -2126,7 +2126,7 @@ struct rtable *__ip_route_output_key(struct net *net, struct flowi4 *fl4) fl4->saddr =inet_select_addr (dev_out,0 ,RT_SCOPE_HOST ); } -if (netif_is_vrf (dev_out) && +if (netif_is_l3_master (dev_out) && !(fl4->flowi4_flags &FLOWI_FLAG_VRFSRC )) { rth =vrf_dev_get_rth (dev_out); goto out;
net/ipv4/udp.c +1 -1
@@ -1021,7 +1021,7 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)* device lookup source address from VRF table. This mimics * behavior of ip_route_connect{_init}. */ -if (netif_index_is_vrf (net, ipc.oif)) { +if (netif_index_is_l3_master (net, ipc.oif)) { flowi4_init_output(fl4, ipc.oif, sk->sk_mark, tos, RT_SCOPE_UNIVERSE, sk->sk_protocol, (flow_flags | FLOWI_FLAG_VRFSRC),
Signature · 1 line
1.9.1
RFC 3/11 net: Add support for l3mdev ops to VRF driver
In reply to David Ahern--- drivers/net/Kconfig | 1 + drivers/net/vrf.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+)
drivers/net/Kconfig +1 -0
@@ -299,6 +299,7 @@ config NLMON config NET_VRF tristate "Virtual Routing and Forwarding (Lite)" depends on IP_MULTIPLE_TABLES && IPV6_MULTIPLE_TABLES + depends on NET_L3_MASTER_DEV ---help--- This option enables the support for mapping interfaces into VRF's. The support enables VRF devices.
drivers/net/vrf.c +29 -0
@@ -35,6 +35,7 @@#include <net/route.h> #include <net/addrconf.h> #include <net/vrf.h> +#include <net/l3mdev.h> #define DRV_NAME "vrf"#define DRV_VERSION "1.0"
@@ -528,6 +529,33 @@ static const struct net_device_ops vrf_netdev_ops = { .ndo_del_slave = vrf_del_slave, }; +static u32 vrf_fib_table (const struct net_device *dev) +{ +struct net_vrf *vrf =netdev_priv (dev); + +return vrf->tb_id; +} + +static struct rtable *vrf_get_rtable (const struct net_device *dev, +const struct flowi4 *fl4) +{ +struct rtable *rth =NULL ; + +if (!(fl4->flowi4_flags &FLOWI_FLAG_VRFSRC )) { +struct net_vrf *vrf =netdev_priv (dev); + + rth = vrf->rth; +atomic_inc (&rth->dst.__refcnt); + } + +return rth; +} + +static const struct l3mdev_ops vrf_l3mdev_ops = { + .l3mdev_fib_table = vrf_fib_table, + .l3mdev_get_rtable = vrf_get_rtable, +}; +static void vrf_get_drvinfo (struct net_device *dev,struct ethtool_drvinfo *info) {
@@ -545,6 +573,7 @@ static void vrf_setup(struct net_device *dev)/* Initialize the device structure. */ dev->netdev_ops = &vrf_netdev_ops; + dev->l3mdev_ops = &vrf_l3mdev_ops; dev->ethtool_ops = &vrf_ethtool_ops; dev->destructor = free_netdev;
Signature · 1 line
1.9.1
RFC 4/11 net: Replace vrf_master_ifindex{,_rcu} with l3mdev equivalents
In reply to David AhernReplace calls to vrf_master_ifindex_rcu and vrf_master_ifindex with either l3mdev_master_ifindex_rcu or l3mdev_master_ifindex.
The pattern:
oif = vrf_master_ifindex(dev) ? : dev->ifindex;
is replaced with
oif = l3mdev_fib_oif(dev);And remove the now unused vrf macros.
--- include/net/vrf.h | 41 ----------------------------------------- net/ipv4/fib_frontend.c | 5 +++-- net/ipv4/icmp.c | 8 ++++---- net/ipv4/ip_fragment.c | 6 +++--- net/ipv4/route.c | 7 ++++--- net/ipv4/xfrm4_policy.c | 8 +++----- net/ipv6/xfrm6_policy.c | 8 +++----- 7 files changed, 20 insertions(+), 63 deletions(-)
include/net/vrf.h +0 -41
@@ -34,37 +34,6 @@ struct net_vrf {#if IS_ENABLED (CONFIG_NET_VRF ) -/* called with rcu_read_lock() */ -static inline int vrf_master_ifindex_rcu (const struct net_device *dev) -{ -struct net_vrf_dev *vrf_ptr; -int ifindex =0 ; - -if (!dev) -return 0 ; - -if (netif_is_l3_master (dev)) { - ifindex = dev->ifindex; - }else { - vrf_ptr =rcu_dereference (dev->vrf_ptr); -if (vrf_ptr) - ifindex = vrf_ptr->ifindex; - } - -return ifindex; -} - -static inline int vrf_master_ifindex (const struct net_device *dev) -{ -int ifindex; - -rcu_read_lock (); - ifindex =vrf_master_ifindex_rcu (dev); -rcu_read_unlock (); - -return ifindex; -} -/* called with rcu_read_lock */ static inline u32 vrf_dev_table_rcu (const struct net_device *dev) {
@@ -139,16 +108,6 @@ static inline struct rtable *vrf_dev_get_rth(const struct net_device *dev) }#else -static inline int vrf_master_ifindex_rcu (const struct net_device *dev) -{ -return 0 ; -} - -static inline int vrf_master_ifindex (const struct net_device *dev) -{ -return 0 ; -} -static inline u32 vrf_dev_table_rcu (const struct net_device *dev) {return 0 ;
net/ipv4/fib_frontend.c +3 -2
@@ -46,6 +46,7 @@#include <net/rtnetlink.h> #include <net/xfrm.h> #include <net/vrf.h> +#include <net/l3mdev.h> #include <trace/events/fib.h> #ifndef CONFIG_IP_MULTIPLE_TABLES
@@ -332,7 +333,7 @@ static int __fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,bool dev_match; fl4.flowi4_oif =0 ; - fl4.flowi4_iif =vrf_master_ifindex_rcu (dev); + fl4.flowi4_iif =l3mdev_master_ifindex_rcu (dev);if (!fl4.flowi4_iif) fl4.flowi4_iif = oif ? :LOOPBACK_IFINDEX ; fl4.daddr = src;
@@ -366,7 +367,7 @@ static int __fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,if (nh->nh_dev == dev) { dev_match = true;break ; - }else if (vrf_master_ifindex_rcu (nh->nh_dev) == dev->ifindex) { + }else if (l3mdev_master_ifindex_rcu (nh->nh_dev) == dev->ifindex) { dev_match = true;break ; }
net/ipv4/icmp.c +4 -4
@@ -96,7 +96,7 @@#include <net/xfrm.h> #include <net/inet_common.h> #include <net/ip_fib.h> -#include <net/vrf.h> +#include <net/l3mdev.h> /* * Build xmit assembly blocks
@@ -309,7 +309,7 @@ static bool icmpv4_xrlim_allow(struct net *net, struct rtable *rt, rc = false;if (icmp_global_allow ()) { -int vif =vrf_master_ifindex (dst->dev); +int vif =l3mdev_master_ifindex (dst->dev);struct inet_peer *peer; peer =inet_getpeer_v4 (net->ipv4.peers, fl4->daddr, vif,1 );
@@ -427,7 +427,7 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb) fl4.flowi4_mark = mark; fl4.flowi4_tos =RT_TOS (ip_hdr (skb)->tos); fl4.flowi4_proto =IPPROTO_ICMP ; - fl4.flowi4_oif =vrf_master_ifindex (skb->dev) ? : skb->dev->ifindex; + fl4.flowi4_oif =l3mdev_fib_oif (skb->dev);security_skb_classify_flow (skb,flowi4_to_flowi (&fl4)); rt =ip_route_output_key (net, &fl4);if (IS_ERR (rt))
@@ -461,7 +461,7 @@ static struct rtable *icmp_route_lookup(struct net *net, fl4->flowi4_proto =IPPROTO_ICMP ; fl4->fl4_icmp_type = type; fl4->fl4_icmp_code = code; - fl4->flowi4_oif =vrf_master_ifindex (skb_in->dev) ? : skb_in->dev->ifindex; + fl4->flowi4_oif =l3mdev_fib_oif (skb_in->dev);security_skb_classify_flow (skb_in,flowi4_to_flowi (fl4)); rt =__ip_route_output_key (net, fl4);
net/ipv4/ip_fragment.c +3 -3
@@ -48,7 +48,7 @@#include <linux/inet.h> #include <linux/netfilter_ipv4.h> #include <net/inet_ecn.h> -#include <net/vrf.h> +#include <net/l3mdev.h> /* NOTE. Logic of IP defragmentation is parallel to corresponding IPv6 * code now. If you change something here, _PLEASE_ update ipv6/reassembly.c
@@ -78,7 +78,7 @@ struct ipq {u8 ecn;/* RFC3168 support */ u16 max_df_size;/* largest frag with DF set seen */ int iif; -int vif;/* VRF device index */ +int vif;/* L3 master device index */ unsigned int rid;struct inet_peer *peer; };
@@ -657,7 +657,7 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *prev,int ip_defrag (struct sk_buff *skb,u32 user) {struct net_device *dev = skb->dev ? :skb_dst (skb)->dev; -int vif =vrf_master_ifindex_rcu (dev); +int vif =l3mdev_master_ifindex_rcu (dev);struct net *net =dev_net (dev);struct ipq *qp;
net/ipv4/route.c +4 -3
@@ -113,6 +113,7 @@#include <net/secure_seq.h> #include <net/ip_tunnels.h> #include <net/vrf.h> +#include <net/l3mdev.h> #define RT_FL_TOS (oldflp4) \ ((oldflp4)->flowi4_tos & (IPTOS_RT_MASK | RTO_ONLINK))
@@ -847,7 +848,7 @@ void ip_rt_send_redirect(struct sk_buff *skb)return ; } log_martians =IN_DEV_LOG_MARTIANS (in_dev); - vif =vrf_master_ifindex_rcu (rt->dst.dev); + vif =l3mdev_master_ifindex_rcu (rt->dst.dev);rcu_read_unlock (); net =dev_net (rt->dst.dev);
@@ -941,7 +942,7 @@ static int ip_error(struct sk_buff *skb) } peer =inet_getpeer_v4 (net->ipv4.peers,ip_hdr (skb)->saddr, -vrf_master_ifindex (skb->dev),1 ); +l3mdev_master_ifindex (skb->dev),1 ); send = true;if (peer) {
@@ -1740,7 +1741,7 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,* Now we are ready to route packet. */ fl4.flowi4_oif =0 ; - fl4.flowi4_iif =vrf_master_ifindex_rcu (dev) ? : dev->ifindex; + fl4.flowi4_iif =l3mdev_fib_oif_rcu (dev); fl4.flowi4_mark = skb->mark; fl4.flowi4_tos = tos; fl4.flowi4_scope =RT_SCOPE_UNIVERSE ;
net/ipv4/xfrm4_policy.c +3 -5
@@ -15,7 +15,7 @@#include <net/dst.h> #include <net/xfrm.h> #include <net/ip.h> -#include <net/vrf.h> +#include <net/l3mdev.h> static struct xfrm_policy_afinfo xfrm4_policy_afinfo;
@@ -109,10 +109,8 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)struct flowi4 *fl4 = &fl->u.ip4;int oif =0 ; -if (skb_dst (skb)) { - oif =vrf_master_ifindex (skb_dst (skb)->dev) ? - :skb_dst (skb)->dev->ifindex; - } +if (skb_dst (skb)) + oif =l3mdev_fib_oif (skb_dst (skb)->dev);memset (fl4,0 ,sizeof (struct flowi4 )); fl4->flowi4_mark = skb->mark;
net/ipv6/xfrm6_policy.c +3 -5
@@ -20,7 +20,7 @@#include <net/ip.h> #include <net/ipv6.h> #include <net/ip6_route.h> -#include <net/vrf.h> +#include <net/l3mdev.h> #if IS_ENABLED (CONFIG_IPV6_MIP6 )#include <net/mip6.h> #endif
@@ -132,10 +132,8 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse) nexthdr = nh[nhoff]; -if (skb_dst (skb)) { - oif =vrf_master_ifindex (skb_dst (skb)->dev) ? - :skb_dst (skb)->dev->ifindex; - } +if (skb_dst (skb)) + oif =l3mdev_fib_oif (skb_dst (skb)->dev);memset (fl6,0 ,sizeof (struct flowi6 )); fl6->flowi6_mark = skb->mark;
Signature · 1 line
1.9.1
RFC 5/11 net: Replace vrf_dev_table and friends
In reply to David AhernReplace calls to vrf_dev_table and friends with l3mdev_fib_table and kin.
--- include/net/vrf.h | 80 ------------------------------------------------- net/ipv4/af_inet.c | 4 +-- net/ipv4/fib_frontend.c | 7 ++--- 3 files changed, 5 insertions(+), 86 deletions(-)
include/net/vrf.h +0 -80
@@ -34,66 +34,6 @@ struct net_vrf {#if IS_ENABLED (CONFIG_NET_VRF ) -/* called with rcu_read_lock */ -static inline u32 vrf_dev_table_rcu (const struct net_device *dev) -{ -u32 tb_id =0 ; - -if (dev) { -struct net_vrf_dev *vrf_ptr; - - vrf_ptr =rcu_dereference (dev->vrf_ptr); -if (vrf_ptr) - tb_id = vrf_ptr->tb_id; - } -return tb_id; -} - -static inline u32 vrf_dev_table (const struct net_device *dev) -{ -u32 tb_id; - -rcu_read_lock (); - tb_id =vrf_dev_table_rcu (dev); -rcu_read_unlock (); - -return tb_id; -} - -static inline u32 vrf_dev_table_ifindex (struct net *net,int ifindex) -{ -struct net_device *dev; -u32 tb_id =0 ; - -if (!ifindex) -return 0 ; - -rcu_read_lock (); - - dev =dev_get_by_index_rcu (net, ifindex); -if (dev) - tb_id =vrf_dev_table_rcu (dev); - -rcu_read_unlock (); - -return tb_id; -} - -/* called with rtnl */ -static inline u32 vrf_dev_table_rtnl (const struct net_device *dev) -{ -u32 tb_id =0 ; - -if (dev) { -struct net_vrf_dev *vrf_ptr; - - vrf_ptr =rtnl_dereference (dev->vrf_ptr); -if (vrf_ptr) - tb_id = vrf_ptr->tb_id; - } -return tb_id; -} -/* caller has already checked netif_is_l3_master(dev) */ static inline struct rtable *vrf_dev_get_rth (const struct net_device *dev) {
@@ -108,26 +48,6 @@ static inline struct rtable *vrf_dev_get_rth(const struct net_device *dev) }#else -static inline u32 vrf_dev_table_rcu (const struct net_device *dev) -{ -return 0 ; -} - -static inline u32 vrf_dev_table (const struct net_device *dev) -{ -return 0 ; -} - -static inline u32 vrf_dev_table_ifindex (struct net *net,int ifindex) -{ -return 0 ; -} - -static inline u32 vrf_dev_table_rtnl (const struct net_device *dev) -{ -return 0 ; -} -static inline struct rtable *vrf_dev_get_rth (const struct net_device *dev) {return ERR_PTR (-ENETUNREACH );
net/ipv4/af_inet.c +2 -2
@@ -119,7 +119,7 @@#ifdef CONFIG_IP_MROUTE #include <linux/mroute.h> #endif -#include <net/vrf.h> +#include <net/l3mdev.h> /* The inetsw table contains everything that inet_create needs to
@@ -450,7 +450,7 @@ int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) goto out; } - tb_id =vrf_dev_table_ifindex (net, sk->sk_bound_dev_if) ? : tb_id; + tb_id =l3mdev_fib_table_by_index (net, sk->sk_bound_dev_if) ? : tb_id; chk_addr_ret =inet_addr_type_table (net, addr->sin_addr.s_addr, tb_id);/* Not specified by any standard per-se, however it breaks too
net/ipv4/fib_frontend.c +3 -4
@@ -45,7 +45,6 @@#include <net/ip_fib.h> #include <net/rtnetlink.h> #include <net/xfrm.h> -#include <net/vrf.h> #include <net/l3mdev.h> #include <trace/events/fib.h>
@@ -256,7 +255,7 @@ EXPORT_SYMBOL(inet_addr_type);unsigned int inet_dev_addr_type (struct net *net,const struct net_device *dev,__be32 addr) { -u32 rt_table =vrf_dev_table (dev) ? :RT_TABLE_LOCAL ; +u32 rt_table =l3mdev_fib_table (dev) ? :RT_TABLE_LOCAL ;return __inet_dev_addr_type (net, dev, addr, rt_table); }
@@ -269,7 +268,7 @@ unsigned int inet_addr_type_dev_table(struct net *net,const struct net_device *dev, __be32 addr) { - u32 rt_table = vrf_dev_table(dev) ? : RT_TABLE_LOCAL; + u32 rt_table = l3mdev_fib_table(dev) ? : RT_TABLE_LOCAL;return __inet_dev_addr_type (net,NULL , addr, rt_table); }
@@ -804,7 +803,7 @@ static int inet_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)static void fib_magic (int cmd,int type,__be32 dst,int dst_len,struct in_ifaddr *ifa) {struct net *net =dev_net (ifa->ifa_dev->dev); -u32 tb_id =vrf_dev_table_rtnl (ifa->ifa_dev->dev); +u32 tb_id =l3mdev_fib_table (ifa->ifa_dev->dev);struct fib_table *tb;struct fib_config cfg = { .fc_protocol =RTPROT_KERNEL ,
Signature · 1 line
1.9.1
RFC 6/11 net: Replace calls to vrf_dev_get_rth
In reply to David AhernReplace calls to vrf_dev_get_rth with l3mdev_get_rtable. The check on the flow flags is handled in the l3mdev operation.
--- include/net/vrf.h | 22 ---------------------- net/ipv4/route.c | 9 ++++----- 2 files changed, 4 insertions(+), 27 deletions(-)
include/net/vrf.h +0 -22
@@ -32,26 +32,4 @@ struct net_vrf { u32 tb_id; }; - -#if IS_ENABLED (CONFIG_NET_VRF ) -/* caller has already checked netif_is_l3_master(dev) */ -static inline struct rtable *vrf_dev_get_rth (const struct net_device *dev) -{ -struct rtable *rth =ERR_PTR (-ENETUNREACH ); -struct net_vrf *vrf =netdev_priv (dev); - -if (vrf) { - rth = vrf->rth; -atomic_inc (&rth->dst.__refcnt); - } -return rth; -} - -#else -static inline struct rtable *vrf_dev_get_rth (const struct net_device *dev) -{ -return ERR_PTR (-ENETUNREACH ); -} -#endif -#endif /* __LINUX_NET_VRF_H */
net/ipv4/route.c +4 -5
@@ -112,7 +112,6 @@#endif #include <net/secure_seq.h> #include <net/ip_tunnels.h> -#include <net/vrf.h> #include <net/l3mdev.h> #define RT_FL_TOS (oldflp4) \
@@ -2127,10 +2126,10 @@ struct rtable *__ip_route_output_key(struct net *net, struct flowi4 *fl4) fl4->saddr =inet_select_addr (dev_out,0 ,RT_SCOPE_HOST ); } -if (netif_is_l3_master (dev_out) && - !(fl4->flowi4_flags &FLOWI_FLAG_VRFSRC )) { - rth =vrf_dev_get_rth (dev_out); - goto out; +if (netif_is_l3_master (dev_out)) { + rth =l3mdev_get_rtable (dev_out, fl4); +if (rth) + goto out; } }
Signature · 1 line
1.9.1
RFC 7/11 net: Remove the now unused vrf_ptr
In reply to David Ahern--- drivers/net/vrf.c | 32 ++------------------------------ include/linux/netdevice.h | 2 -- include/net/vrf.h | 6 ------ 3 files changed, 2 insertions(+), 38 deletions(-)
drivers/net/vrf.c +2 -30
@@ -395,18 +395,15 @@ static void __vrf_insert_slave(struct slave_queue *queue, struct slave *slave)static int do_vrf_add_slave (struct net_device *dev,struct net_device *port_dev) { -struct net_vrf_dev *vrf_ptr =kmalloc (sizeof (*vrf_ptr),GFP_KERNEL );struct slave *slave =kzalloc (sizeof (*slave),GFP_KERNEL );struct net_vrf *vrf =netdev_priv (dev);struct slave_queue *queue = &vrf->queue;int ret = -ENOMEM ; -if (!slave || !vrf_ptr) +if (!slave) goto out_fail; slave->dev = port_dev; - vrf_ptr->ifindex = dev->ifindex; - vrf_ptr->tb_id = vrf->tb_id;/* register the packet handler for slave ports */ ret =netdev_rx_handler_register (port_dev, vrf_handle_frame, dev);
@@ -423,7 +420,6 @@ static int do_vrf_add_slave(struct net_device *dev, struct net_device *port_dev) port_dev->flags |=IFF_SLAVE ;__vrf_insert_slave (queue, slave); -rcu_assign_pointer (port_dev->vrf_ptr, vrf_ptr);cycle_netdev (port_dev);return 0 ;
@@ -431,7 +427,6 @@ static int do_vrf_add_slave(struct net_device *dev, struct net_device *port_dev) out_unregister:netdev_rx_handler_unregister (port_dev); out_fail: -kfree (vrf_ptr);kfree (slave);return ret; }
@@ -447,21 +442,15 @@ static int vrf_add_slave(struct net_device *dev, struct net_device *port_dev)/* inverse of do_vrf_add_slave */ static int do_vrf_del_slave (struct net_device *dev,struct net_device *port_dev) { -struct net_vrf_dev *vrf_ptr =rtnl_dereference (port_dev->vrf_ptr);struct net_vrf *vrf =netdev_priv (dev);struct slave_queue *queue = &vrf->queue;struct slave *slave; -RCU_INIT_POINTER (port_dev->vrf_ptr,NULL ); -netdev_upper_dev_unlink (port_dev, dev); port_dev->flags &= ~IFF_SLAVE ;netdev_rx_handler_unregister (port_dev); -/* after netdev_rx_handler_unregister for synchronize_rcu */ -kfree (vrf_ptr); -cycle_netdev (port_dev); slave =__vrf_find_slave_dev (queue, port_dev);
@@ -600,10 +589,6 @@ static int vrf_validate(struct nlattr *tb[], struct nlattr *data[])static void vrf_dellink (struct net_device *dev,struct list_head *head) { -struct net_vrf_dev *vrf_ptr =rtnl_dereference (dev->vrf_ptr); - -RCU_INIT_POINTER (dev->vrf_ptr,NULL ); -kfree_rcu (vrf_ptr, rcu);unregister_netdevice_queue (dev, head); }
@@ -611,7 +596,6 @@ static int vrf_newlink(struct net *src_net, struct net_device *dev, struct nlattr *tb[], struct nlattr *data[]) { struct net_vrf *vrf = netdev_priv(dev); -struct net_vrf_dev *vrf_ptr;int err;if (!data || !data[IFLA_VRF_TABLE ])
@@ -621,24 +605,13 @@ static int vrf_newlink(struct net *src_net, struct net_device *dev, dev->priv_flags |=IFF_L3MDEV ; - err = -ENOMEM ; - vrf_ptr =kmalloc (sizeof (*dev->vrf_ptr),GFP_KERNEL ); -if (!vrf_ptr) - goto out_fail; - - vrf_ptr->ifindex = dev->ifindex; - vrf_ptr->tb_id = vrf->tb_id; - err =register_netdevice (dev);if (err <0 ) goto out_fail; -rcu_assign_pointer (dev->vrf_ptr, vrf_ptr); -return 0 ; out_fail: -kfree (vrf_ptr);free_netdev (dev);return err; }
@@ -682,10 +655,9 @@ static int vrf_device_event(struct notifier_block *unused,/* only care about unregister events to drop slave references */ if (event ==NETDEV_UNREGISTER ) { -struct net_vrf_dev *vrf_ptr =rtnl_dereference (dev->vrf_ptr);struct net_device *vrf_dev; -if (!vrf_ptr ||netif_is_l3_master (dev)) +if (netif_is_l3_master (dev)) goto out; vrf_dev =netdev_master_upper_dev_get (dev);
include/linux/netdevice.h +0 -2
@@ -1426,7 +1426,6 @@ enum netdev_priv_flags {* @dn_ptr: DECnet specific data * @ip6_ptr: IPv6 specific data * @ax25_ptr: AX.25 specific data -* @vrf_ptr: VRF specific data * @ieee80211_ptr: IEEE 802.11 specific data, assign before registering * * @last_rx: Time of last Rx
@@ -1648,7 +1647,6 @@ struct net_device {struct dn_dev __rcu *dn_ptr;struct inet6_dev __rcu *ip6_ptr;void *ax25_ptr; -struct net_vrf_dev __rcu *vrf_ptr;struct wireless_dev *ieee80211_ptr;struct wpan_dev *ieee802154_ptr;#if IS_ENABLED (CONFIG_MPLS_ROUTING )
include/net/vrf.h +0 -6
@@ -11,12 +11,6 @@ #ifndef __LINUX_NET_VRF_H #define __LINUX_NET_VRF_H -struct net_vrf_dev { - struct rcu_head rcu; - int ifindex; /* ifindex of master dev */ - u32 tb_id; /* table id for VRF */ -}; - struct slave { struct list_head list; struct net_device *dev;
Signature · 1 line
1.9.1
RFC 8/11 net: Remove vrf header file
In reply to David AhernMove remaining structs to VRF driver and delete the vrf header file.
--- MAINTAINERS | 1 - drivers/net/vrf.c | 16 +++++++++++++++- include/net/vrf.h | 29 ----------------------------- 3 files changed, 15 insertions(+), 31 deletions(-) delete mode 100644 include/net/vrf.h
MAINTAINERS +0 -1
@@ -11249,7 +11249,6 @@ M: Shrijeet Mukherjee <[email protected]> L: [email protected] S: Maintained F: drivers/net/vrf.c -F: include/net/vrf.h VT1211 HARDWARE MONITOR DRIVER M: Juerg Haefliger <[email protected]>
drivers/net/vrf.c +15 -1
@@ -34,7 +34,6 @@#include <net/rtnetlink.h> #include <net/route.h> #include <net/addrconf.h> -#include <net/vrf.h> #include <net/l3mdev.h> #define DRV_NAME "vrf"
@@ -45,6 +44,21 @@#define vrf_master_get_rcu (dev) \ ((struct net_device *)rcu_dereference(dev->rx_handler_data)) +struct slave { +struct list_head list; +struct net_device *dev; +}; + +struct slave_queue { +struct list_head all_slaves; +}; + +struct net_vrf { +struct slave_queue queue; +struct rtable *rth; +u32 tb_id; +}; +struct pcpu_dstats {u64 tx_pkts;u64 tx_bytes;
include/net/vrf.h deleted +0 -29
@@ -1,29 +0,0 @@ -/* -* include/net/net_vrf.h - adds vrf dev structure definitions -* Copyright (c) 2015 Cumulus Networks -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -*/ - -#ifndef __LINUX_NET_VRF_H -#define __LINUX_NET_VRF_H - -struct slave { -struct list_head list; -struct net_device *dev; -}; - -struct slave_queue { -struct list_head all_slaves; -}; - -struct net_vrf { -struct slave_queue queue; -struct rtable *rth; -u32 tb_id; -}; - -#endif /* __LINUX_NET_VRF_H */
Signature · 1 line
1.9.1
RFC 9/11 net: Move netif_index_is_l3_master to l3mdev.h
In reply to David AhernChange CONFIG dependency to CONFIG_NET_L3_MASTER_DEV as well.
--- include/linux/netdevice.h | 21 --------------------- include/net/l3mdev.h | 24 ++++++++++++++++++++++++ include/net/route.h | 1 + 3 files changed, 25 insertions(+), 21 deletions(-)
include/linux/netdevice.h +0 -21
@@ -3839,27 +3839,6 @@ static inline bool netif_is_ovs_master(const struct net_device *dev)return dev->priv_flags &IFF_OPENVSWITCH ; } -static inline bool netif_index_is_l3_master (struct net *net,int ifindex) -{ -bool rc = false; - -#if IS_ENABLED (CONFIG_NET_VRF ) -struct net_device *dev; - -if (ifindex ==0 ) -return false; - -rcu_read_lock (); - - dev =dev_get_by_index_rcu (net, ifindex); -if (dev) - rc =netif_is_l3_master (dev); - -rcu_read_unlock (); -#endif -return rc; -} -/* This device needs to keep skb dst for qdisc enqueue or ndo_start_xmit() */ static inline void netif_keep_dst (struct net_device *dev) {
include/net/l3mdev.h +24 -0
@@ -84,6 +84,25 @@ static inline struct rtable *l3mdev_get_rtable(const struct net_device *dev, return NULL; } +static inline bool netif_index_is_l3_master (struct net *net,int ifindex) +{ +struct net_device *dev; +bool rc = false; + +if (ifindex ==0 ) +return false; + +rcu_read_lock (); + + dev =dev_get_by_index_rcu (net, ifindex); +if (dev) + rc =netif_is_l3_master (dev); + +rcu_read_unlock (); + +return rc; +} +#else static inline int l3mdev_master_ifindex_rcu (struct net_device *dev)
@@ -123,6 +142,11 @@ static inline struct rtable *l3mdev_get_rtable(const struct net_device *dev,return NULL ; } +static inline bool netif_index_is_l3_master (struct net *net,int ifindex) +{ +return false; +} +#endif #endif /* _NET_L3MDEV_H_ */
include/net/route.h +1 -0
@@ -28,6 +28,7 @@#include <net/inetpeer.h> #include <net/flow.h> #include <net/inet_sock.h> +#include <net/l3mdev.h> #include <linux/in_route.h> #include <linux/rtnetlink.h> #include <linux/rcupdate.h>
Signature · 1 line
1.9.1
RFC 10/11 net: Rename FLOWI_FLAG_VRFSRC to FLOWI_FLAG_L3MDEV_SRC
In reply to David Ahern--- drivers/net/vrf.c | 4 ++-- include/net/flow.h | 2 +- include/net/route.h | 2 +- net/ipv4/fib_trie.c | 2 +- net/ipv4/udp.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/vrf.c +2 -2
@@ -208,7 +208,7 @@ static netdev_tx_t vrf_process_v4_outbound(struct sk_buff *skb, .flowi4_oif = vrf_dev->ifindex, .flowi4_iif = LOOPBACK_IFINDEX, .flowi4_tos = RT_TOS(ip4h->tos), - .flowi4_flags = FLOWI_FLAG_ANYSRC | FLOWI_FLAG_VRFSRC, + .flowi4_flags = FLOWI_FLAG_ANYSRC | FLOWI_FLAG_L3MDEV_SRC, .daddr = ip4h->daddr, };
@@ -544,7 +544,7 @@ static struct rtable *vrf_get_rtable(const struct net_device *dev, {struct rtable *rth =NULL ; -if (!(fl4->flowi4_flags &FLOWI_FLAG_VRFSRC )) { +if (!(fl4->flowi4_flags &FLOWI_FLAG_L3MDEV_SRC )) {struct net_vrf *vrf =netdev_priv (dev); rth = vrf->rth;
include/net/flow.h +1 -1
@@ -34,7 +34,7 @@ struct flowi_common {__u8 flowic_flags;#define FLOWI_FLAG_ANYSRC 0x01#define FLOWI_FLAG_KNOWN_NH 0x02 -#define FLOWI_FLAG_VRFSRC 0x04 +#define FLOWI_FLAG_L3MDEV_SRC 0x04__u32 flowic_secid;struct flowi_tunnel flowic_tun_key; };
include/net/route.h +1 -1
@@ -258,7 +258,7 @@ static inline void ip_route_connect_init(struct flowi4 *fl4, __be32 dst, __be32 flow_flags |=FLOWI_FLAG_ANYSRC ;if (netif_index_is_l3_master (sock_net (sk), oif)) - flow_flags |=FLOWI_FLAG_VRFSRC ; + flow_flags |=FLOWI_FLAG_L3MDEV_SRC ;flowi4_init_output (fl4, oif, sk->sk_mark, tos,RT_SCOPE_UNIVERSE , protocol, flow_flags, dst, src, dport, sport);
net/ipv4/fib_trie.c +1 -1
@@ -1426,7 +1426,7 @@ int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp, nh->nh_flags &RTNH_F_LINKDOWN && !(fib_flags & FIB_LOOKUP_IGNORE_LINKSTATE)) continue; -if (!(flp->flowi4_flags &FLOWI_FLAG_VRFSRC )) { +if (!(flp->flowi4_flags &FLOWI_FLAG_L3MDEV_SRC )) {if (flp->flowi4_oif && flp->flowi4_oif != nh->nh_oif)continue ;
net/ipv4/udp.c +1 -1
@@ -1024,7 +1024,7 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)if (netif_index_is_l3_master (net, ipc.oif)) {flowi4_init_output (fl4, ipc.oif, sk->sk_mark, tos,RT_SCOPE_UNIVERSE , sk->sk_protocol, - (flow_flags |FLOWI_FLAG_VRFSRC ), + (flow_flags |FLOWI_FLAG_L3MDEV_SRC ), faddr, saddr, dport, inet->inet_sport);
Signature · 1 line
1.9.1
RFC 11/11 net: Add netif_is_l3_slave
In reply to David AhernSimplifies ops checking. An L3 master is expected to define l3mdev_ops at a minimum.
--- drivers/net/vrf.c | 6 +++--- include/linux/netdevice.h | 5 +++++ net/l3mdev/l3mdev.c | 13 ++++--------- 3 files changed, 12 insertions(+), 12 deletions(-)
drivers/net/vrf.c +3 -3
@@ -39,8 +39,6 @@#define DRV_NAME "vrf"#define DRV_VERSION "1.0" -#define vrf_is_slave (dev) ((dev)->flags & IFF_SLAVE) -#define vrf_master_get_rcu (dev) \ ((struct net_device *)rcu_dereference(dev->rx_handler_data))
@@ -433,6 +431,7 @@ static int do_vrf_add_slave(struct net_device *dev, struct net_device *port_dev) goto out_unregister; port_dev->flags |=IFF_SLAVE ; + port_dev->priv_flags |=IFF_L3MDEV ;__vrf_insert_slave (queue, slave);cycle_netdev (port_dev);
@@ -447,7 +446,7 @@ static int do_vrf_add_slave(struct net_device *dev, struct net_device *port_dev)static int vrf_add_slave (struct net_device *dev,struct net_device *port_dev) { -if (netif_is_l3_master (port_dev) ||vrf_is_slave (port_dev)) +if (netif_is_l3_master (port_dev) ||netif_is_l3_slave (port_dev))return -EINVAL ;return do_vrf_add_slave (dev, port_dev);
@@ -462,6 +461,7 @@ static int do_vrf_del_slave(struct net_device *dev, struct net_device *port_dev)netdev_upper_dev_unlink (port_dev, dev); port_dev->flags &= ~IFF_SLAVE ; + port_dev->priv_flags &= ~IFF_L3MDEV ;netdev_rx_handler_unregister (port_dev);
include/linux/netdevice.h +5 -0
@@ -3829,6 +3829,11 @@ static inline bool netif_is_l3_master(const struct net_device *dev)return dev->flags &IFF_MASTER && dev->priv_flags &IFF_L3MDEV ; } +static inline bool netif_is_l3_slave (const struct net_device *dev) +{ +return dev->flags &IFF_SLAVE && dev->priv_flags &IFF_L3MDEV ; +} +static inline bool netif_is_bridge_master (const struct net_device *dev) {return dev->priv_flags &IFF_EBRIDGE ;
net/l3mdev/l3mdev.c +4 -9
@@ -16,12 +16,11 @@ int l3mdev_master_ifindex_rcu(struct net_device *dev)if (netif_is_l3_master (dev)) { ifindex = dev->ifindex; - }else if (dev->flags &IFF_SLAVE ) { + }else if (netif_is_l3_slave (dev)) {struct net_device *master; master =netdev_master_upper_dev_get_rcu (dev); -if (netif_is_l3_master (master)) - ifindex = master->ifindex; + ifindex = master->ifindex; }return ifindex;
@@ -44,7 +43,7 @@ u32 l3mdev_fib_table_rcu(const struct net_device *dev)if (dev->l3mdev_ops->l3mdev_fib_table) tb_id = dev->l3mdev_ops->l3mdev_fib_table (dev); - }else if (dev->flags &IFF_SLAVE ) { + }else if (netif_is_l3_slave (dev)) {/* TO-DO: remove the need for typecast. * Users of netdev_master_upper_dev_get_rcu need non-const, * but current inet_*type functions take a const
@@ -53,11 +52,7 @@ u32 l3mdev_fib_table_rcu(const struct net_device *dev)const struct net_device *master; master =netdev_master_upper_dev_get_rcu (_dev); -if (!master) -return 0 ; - -if (netif_is_l3_master (master) && - master->l3mdev_ops->l3mdev_fib_table) +if (master->l3mdev_ops->l3mdev_fib_table) tb_id = master->l3mdev_ops->l3mdev_fib_table (master); }
Signature · 1 line
1.9.1