Skip to content

Commit c6c6707

Browse files
image-dragonPaolo Abeni
authored andcommitted
net: ip: make ip_route_input_mc() return drop reason
Make ip_route_input_mc() return drop reason, and adjust the call of it in ip_route_input_rcu(). Signed-off-by: Menglong Dong <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 37653a0 commit c6c6707

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

net/ipv4/route.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,8 +1709,9 @@ int ip_mc_validate_source(struct sk_buff *skb, __be32 daddr, __be32 saddr,
17091709
}
17101710

17111711
/* called in rcu_read_lock() section */
1712-
static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
1713-
dscp_t dscp, struct net_device *dev, int our)
1712+
static enum skb_drop_reason
1713+
ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
1714+
dscp_t dscp, struct net_device *dev, int our)
17141715
{
17151716
struct in_device *in_dev = __in_dev_get_rcu(dev);
17161717
unsigned int flags = RTCF_MULTICAST;
@@ -1721,7 +1722,7 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
17211722
err = ip_mc_validate_source(skb, daddr, saddr, dscp, dev, in_dev,
17221723
&itag);
17231724
if (err)
1724-
return err;
1725+
return SKB_DROP_REASON_NOT_SPECIFIED;
17251726

17261727
if (our)
17271728
flags |= RTCF_LOCAL;
@@ -1732,7 +1733,7 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
17321733
rth = rt_dst_alloc(dev_net(dev)->loopback_dev, flags, RTN_MULTICAST,
17331734
false);
17341735
if (!rth)
1735-
return -ENOBUFS;
1736+
return SKB_DROP_REASON_NOMEM;
17361737

17371738
#ifdef CONFIG_IP_ROUTE_CLASSID
17381739
rth->dst.tclassid = itag;
@@ -1748,7 +1749,7 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
17481749

17491750
skb_dst_drop(skb);
17501751
skb_dst_set(skb, &rth->dst);
1751-
return 0;
1752+
return SKB_NOT_DROPPED_YET;
17521753
}
17531754

17541755

@@ -2446,12 +2447,12 @@ static int ip_route_input_rcu(struct sk_buff *skb, __be32 daddr, __be32 saddr,
24462447
* route cache entry is created eventually.
24472448
*/
24482449
if (ipv4_is_multicast(daddr)) {
2450+
enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
24492451
struct in_device *in_dev = __in_dev_get_rcu(dev);
24502452
int our = 0;
2451-
int err = -EINVAL;
24522453

24532454
if (!in_dev)
2454-
return err;
2455+
return -EINVAL;
24552456
our = ip_check_mc_rcu(in_dev, daddr, saddr,
24562457
ip_hdr(skb)->protocol);
24572458

@@ -2472,10 +2473,10 @@ static int ip_route_input_rcu(struct sk_buff *skb, __be32 daddr, __be32 saddr,
24722473
IN_DEV_MFORWARD(in_dev))
24732474
#endif
24742475
) {
2475-
err = ip_route_input_mc(skb, daddr, saddr, dscp, dev,
2476-
our);
2476+
reason = ip_route_input_mc(skb, daddr, saddr, dscp,
2477+
dev, our);
24772478
}
2478-
return err;
2479+
return reason ? -EINVAL : 0;
24792480
}
24802481

24812482
return ip_route_input_slow(skb, daddr, saddr, dscp, dev, res);

0 commit comments

Comments
 (0)