Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'net-ipv4-some-drop-reason-cleanup-and-improvements'

Antoine Tenart says:

====================
net: ipv4: some drop reason cleanup and improvements

A few patches that were laying around cleaning up and improving drop
reasons in net/ipv4.
====================

Link: https://patch.msgid.link/20250915091958.15382-1-atenart@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+21 -22
+1 -1
include/net/udp.h
··· 404 404 return __skb_recv_udp(sk, flags, &off, err); 405 405 } 406 406 407 - int udp_v4_early_demux(struct sk_buff *skb); 407 + enum skb_drop_reason udp_v4_early_demux(struct sk_buff *skb); 408 408 bool udp_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst); 409 409 int udp_err(struct sk_buff *, u32); 410 410 int udp_abort(struct sock *sk, int err);
+14 -15
net/ipv4/ip_input.c
··· 263 263 } 264 264 EXPORT_SYMBOL(ip_local_deliver); 265 265 266 - static inline bool ip_rcv_options(struct sk_buff *skb, struct net_device *dev) 266 + static inline enum skb_drop_reason 267 + ip_rcv_options(struct sk_buff *skb, struct net_device *dev) 267 268 { 268 - struct ip_options *opt; 269 269 const struct iphdr *iph; 270 + struct ip_options *opt; 270 271 271 272 /* It looks as overkill, because not all 272 273 IP options require packet mangling. ··· 278 277 */ 279 278 if (skb_cow(skb, skb_headroom(skb))) { 280 279 __IP_INC_STATS(dev_net(dev), IPSTATS_MIB_INDISCARDS); 281 - goto drop; 280 + return SKB_DROP_REASON_NOMEM; 282 281 } 283 282 284 283 iph = ip_hdr(skb); ··· 287 286 288 287 if (ip_options_compile(dev_net(dev), opt, skb)) { 289 288 __IP_INC_STATS(dev_net(dev), IPSTATS_MIB_INHDRERRORS); 290 - goto drop; 289 + return SKB_DROP_REASON_IP_INHDR; 291 290 } 292 291 293 292 if (unlikely(opt->srr)) { ··· 299 298 net_info_ratelimited("source route option %pI4 -> %pI4\n", 300 299 &iph->saddr, 301 300 &iph->daddr); 302 - goto drop; 301 + return SKB_DROP_REASON_NOT_SPECIFIED; 303 302 } 304 303 } 305 304 306 305 if (ip_options_rcv_srr(skb, dev)) 307 - goto drop; 306 + return SKB_DROP_REASON_NOT_SPECIFIED; 308 307 } 309 308 310 - return false; 311 - drop: 312 - return true; 309 + return SKB_NOT_DROPPED_YET; 313 310 } 314 311 315 312 static bool ip_can_use_hint(const struct sk_buff *skb, const struct iphdr *iph, ··· 318 319 } 319 320 320 321 int tcp_v4_early_demux(struct sk_buff *skb); 321 - int udp_v4_early_demux(struct sk_buff *skb); 322 + enum skb_drop_reason udp_v4_early_demux(struct sk_buff *skb); 322 323 static int ip_rcv_finish_core(struct net *net, 323 324 struct sk_buff *skb, struct net_device *dev, 324 325 const struct sk_buff *hint) ··· 334 335 goto drop_error; 335 336 } 336 337 337 - drop_reason = SKB_DROP_REASON_NOT_SPECIFIED; 338 338 if (READ_ONCE(net->ipv4.sysctl_ip_early_demux) && 339 339 !skb_dst(skb) && 340 340 !skb->sk && ··· 352 354 drop_reason = udp_v4_early_demux(skb); 353 355 if (unlikely(drop_reason)) 354 356 goto drop_error; 355 - drop_reason = SKB_DROP_REASON_NOT_SPECIFIED; 356 357 357 358 /* must reload iph, skb->head might have changed */ 358 359 iph = ip_hdr(skb); ··· 369 372 ip4h_dscp(iph), dev); 370 373 if (unlikely(drop_reason)) 371 374 goto drop_error; 372 - drop_reason = SKB_DROP_REASON_NOT_SPECIFIED; 373 375 } else { 374 376 struct in_device *in_dev = __in_dev_get_rcu(dev); 375 377 ··· 387 391 } 388 392 #endif 389 393 390 - if (iph->ihl > 5 && ip_rcv_options(skb, dev)) 391 - goto drop; 394 + if (iph->ihl > 5) { 395 + drop_reason = ip_rcv_options(skb, dev); 396 + if (drop_reason) 397 + goto drop; 398 + } 392 399 393 400 rt = skb_rtable(skb); 394 401 if (rt->rt_type == RTN_MULTICAST) {
+6 -6
net/ipv4/udp.c
··· 2811 2811 return NULL; 2812 2812 } 2813 2813 2814 - int udp_v4_early_demux(struct sk_buff *skb) 2814 + enum skb_drop_reason udp_v4_early_demux(struct sk_buff *skb) 2815 2815 { 2816 2816 struct net *net = dev_net(skb->dev); 2817 2817 struct in_device *in_dev = NULL; ··· 2825 2825 2826 2826 /* validate the packet */ 2827 2827 if (!pskb_may_pull(skb, skb_transport_offset(skb) + sizeof(struct udphdr))) 2828 - return 0; 2828 + return SKB_NOT_DROPPED_YET; 2829 2829 2830 2830 iph = ip_hdr(skb); 2831 2831 uh = udp_hdr(skb); ··· 2834 2834 in_dev = __in_dev_get_rcu(skb->dev); 2835 2835 2836 2836 if (!in_dev) 2837 - return 0; 2837 + return SKB_NOT_DROPPED_YET; 2838 2838 2839 2839 ours = ip_check_mc_rcu(in_dev, iph->daddr, iph->saddr, 2840 2840 iph->protocol); 2841 2841 if (!ours) 2842 - return 0; 2842 + return SKB_NOT_DROPPED_YET; 2843 2843 2844 2844 sk = __udp4_lib_mcast_demux_lookup(net, uh->dest, iph->daddr, 2845 2845 uh->source, iph->saddr, ··· 2850 2850 } 2851 2851 2852 2852 if (!sk) 2853 - return 0; 2853 + return SKB_NOT_DROPPED_YET; 2854 2854 2855 2855 skb->sk = sk; 2856 2856 DEBUG_NET_WARN_ON_ONCE(sk_is_refcounted(sk)); ··· 2877 2877 ip4h_dscp(iph), 2878 2878 skb->dev, in_dev, &itag); 2879 2879 } 2880 - return 0; 2880 + return SKB_NOT_DROPPED_YET; 2881 2881 } 2882 2882 2883 2883 int udp_rcv(struct sk_buff *skb)