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

inet: udp{4|6}_lib_lookup_skb() skb argument is const

The skb is needed only to fetch the keys for the lookup.

Both functions are used from GRO stack, we do not want
accidental modification of the skb.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Alexander Lobakin <alobakin@pm.me>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
7b58e63e d6bb2d1e

+5 -5
+3 -3
include/net/udp.h
··· 164 164 UDP_SKB_CB(skb)->cscov -= sizeof(struct udphdr); 165 165 } 166 166 167 - typedef struct sock *(*udp_lookup_t)(struct sk_buff *skb, __be16 sport, 167 + typedef struct sock *(*udp_lookup_t)(const struct sk_buff *skb, __be16 sport, 168 168 __be16 dport); 169 169 170 170 INDIRECT_CALLABLE_DECLARE(struct sk_buff *udp4_gro_receive(struct list_head *, ··· 313 313 struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport, 314 314 __be32 daddr, __be16 dport, int dif, int sdif, 315 315 struct udp_table *tbl, struct sk_buff *skb); 316 - struct sock *udp4_lib_lookup_skb(struct sk_buff *skb, 316 + struct sock *udp4_lib_lookup_skb(const struct sk_buff *skb, 317 317 __be16 sport, __be16 dport); 318 318 struct sock *udp6_lib_lookup(struct net *net, 319 319 const struct in6_addr *saddr, __be16 sport, ··· 324 324 const struct in6_addr *daddr, __be16 dport, 325 325 int dif, int sdif, struct udp_table *tbl, 326 326 struct sk_buff *skb); 327 - struct sock *udp6_lib_lookup_skb(struct sk_buff *skb, 327 + struct sock *udp6_lib_lookup_skb(const struct sk_buff *skb, 328 328 __be16 sport, __be16 dport); 329 329 330 330 /* UDP uses skb->dev_scratch to cache as much information as possible and avoid
+1 -1
net/ipv4/udp.c
··· 541 541 inet_sdif(skb), udptable, skb); 542 542 } 543 543 544 - struct sock *udp4_lib_lookup_skb(struct sk_buff *skb, 544 + struct sock *udp4_lib_lookup_skb(const struct sk_buff *skb, 545 545 __be16 sport, __be16 dport) 546 546 { 547 547 const struct iphdr *iph = ip_hdr(skb);
+1 -1
net/ipv6/udp.c
··· 276 276 inet6_sdif(skb), udptable, skb); 277 277 } 278 278 279 - struct sock *udp6_lib_lookup_skb(struct sk_buff *skb, 279 + struct sock *udp6_lib_lookup_skb(const struct sk_buff *skb, 280 280 __be16 sport, __be16 dport) 281 281 { 282 282 const struct ipv6hdr *iph = ipv6_hdr(skb);