net: Replace vrf_master_ifindex{, _rcu} with l3mdev equivalents
Replace 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. Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
ee15ee5d94
commit
385add906b
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
fl4.flowi4_oif = l3mdev_master_ifindex(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);
|
||||
fl4->flowi4_oif = l3mdev_master_ifindex(skb_in->dev);
|
||||
|
||||
security_skb_classify_flow(skb_in, flowi4_to_flowi(fl4));
|
||||
rt = __ip_route_output_key(net, fl4);
|
||||
|
|
|
@ -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 @@ out_fail:
|
|||
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;
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
@ -1739,7 +1740,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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -111,10 +111,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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue