Skip to content

Commit 61b95c7

Browse files
image-dragonPaolo Abeni
authored and
Paolo Abeni
committed
net: ip: make ip_route_input_rcu() return drop reasons
In this commit, we make ip_route_input_rcu() return drop reasons, which come from ip_route_input_mc() and ip_route_input_slow(). The only caller of ip_route_input_rcu() is ip_route_input_noref(). We adjust it by making it return -EINVAL on error and ignore the reasons that ip_route_input_rcu() returns. In the following patch, we will make ip_route_input_noref() returns the drop reasons. Signed-off-by: Menglong Dong <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 5b92112 commit 61b95c7

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

net/ipv4/route.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2448,9 +2448,10 @@ ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
24482448
}
24492449

24502450
/* called with rcu_read_lock held */
2451-
static int ip_route_input_rcu(struct sk_buff *skb, __be32 daddr, __be32 saddr,
2452-
dscp_t dscp, struct net_device *dev,
2453-
struct fib_result *res)
2451+
static enum skb_drop_reason
2452+
ip_route_input_rcu(struct sk_buff *skb, __be32 daddr, __be32 saddr,
2453+
dscp_t dscp, struct net_device *dev,
2454+
struct fib_result *res)
24542455
{
24552456
/* Multicast recognition logic is moved from route cache to here.
24562457
* The problem was that too many Ethernet cards have broken/missing
@@ -2493,23 +2494,23 @@ static int ip_route_input_rcu(struct sk_buff *skb, __be32 daddr, __be32 saddr,
24932494
reason = ip_route_input_mc(skb, daddr, saddr, dscp,
24942495
dev, our);
24952496
}
2496-
return reason ? -EINVAL : 0;
2497+
return reason;
24972498
}
24982499

2499-
return ip_route_input_slow(skb, daddr, saddr, dscp, dev, res) ? -EINVAL : 0;
2500+
return ip_route_input_slow(skb, daddr, saddr, dscp, dev, res);
25002501
}
25012502

25022503
int ip_route_input_noref(struct sk_buff *skb, __be32 daddr, __be32 saddr,
25032504
dscp_t dscp, struct net_device *dev)
25042505
{
2506+
enum skb_drop_reason reason;
25052507
struct fib_result res;
2506-
int err;
25072508

25082509
rcu_read_lock();
2509-
err = ip_route_input_rcu(skb, daddr, saddr, dscp, dev, &res);
2510+
reason = ip_route_input_rcu(skb, daddr, saddr, dscp, dev, &res);
25102511
rcu_read_unlock();
25112512

2512-
return err;
2513+
return reason ? -EINVAL : 0;
25132514
}
25142515
EXPORT_SYMBOL(ip_route_input_noref);
25152516

@@ -3321,7 +3322,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
33213322
skb->mark = mark;
33223323
err = ip_route_input_rcu(skb, dst, src,
33233324
inet_dsfield_to_dscp(rtm->rtm_tos),
3324-
dev, &res);
3325+
dev, &res) ? -EINVAL : 0;
33253326

33263327
rt = skb_rtable(skb);
33273328
if (err == 0 && rt->dst.error)

0 commit comments

Comments
 (0)