Skip to content

Commit c2a2ff6

Browse files
atenartkuba-moo
authored andcommitted
net: ipv4: fix stat increase when udp early demux drops the packet
udp_v4_early_demux now returns drop reasons as it either returns 0 or ip_mc_validate_source, which returns itself a drop reason. However its use was not converted in ip_rcv_finish_core and the drop reason is ignored, leading to potentially skipping increasing LINUX_MIB_IPRPFILTER if the drop reason is SKB_DROP_REASON_IP_RPFILTER. This is a fix and we're not converting udp_v4_early_demux to explicitly return a drop reason to ease backports; this can be done as a follow-up. Fixes: d46f827 ("net: ip: make ip_mc_validate_source() return drop reason") Cc: Menglong Dong <[email protected]> Reported-by: Sabrina Dubroca <[email protected]> Signed-off-by: Antoine Tenart <[email protected]> Reviewed-by: Sabrina Dubroca <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 5186ff7 commit c2a2ff6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

net/ipv4/ip_input.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,8 @@ static int ip_rcv_finish_core(struct net *net,
319319
const struct sk_buff *hint)
320320
{
321321
const struct iphdr *iph = ip_hdr(skb);
322-
int err, drop_reason;
323322
struct rtable *rt;
323+
int drop_reason;
324324

325325
if (ip_can_use_hint(skb, iph, hint)) {
326326
drop_reason = ip_route_use_hint(skb, iph->daddr, iph->saddr,
@@ -345,9 +345,10 @@ static int ip_rcv_finish_core(struct net *net,
345345
break;
346346
case IPPROTO_UDP:
347347
if (READ_ONCE(net->ipv4.sysctl_udp_early_demux)) {
348-
err = udp_v4_early_demux(skb);
349-
if (unlikely(err))
348+
drop_reason = udp_v4_early_demux(skb);
349+
if (unlikely(drop_reason))
350350
goto drop_error;
351+
drop_reason = SKB_DROP_REASON_NOT_SPECIFIED;
351352

352353
/* must reload iph, skb->head might have changed */
353354
iph = ip_hdr(skb);

0 commit comments

Comments
 (0)