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.

udp: Remove udp_table in struct udp_seq_afinfo.

Since UDP and UDP-Lite had dedicated socket hash tables for
each, we have had to fetch them from different pointers for
procfs or bpf iterator.

UDP always has its global or per-netns table in
net->ipv4.udp_table and struct udp_seq_afinfo.udp_table
is NULL.

OTOH, UDP-Lite had only one global table in the pointer.

We no longer use the field.

Let's remove it and udp_get_table_seq().

Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20260311052020.1213705-12-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Kuniyuki Iwashima and committed by
Jakub Kicinski
c570bd25 5c273858

+4 -20
-1
include/net/udp.h
··· 552 552 #ifdef CONFIG_PROC_FS 553 553 struct udp_seq_afinfo { 554 554 sa_family_t family; 555 - struct udp_table *udp_table; 556 555 }; 557 556 558 557 struct udp_iter_state {
+4 -18
net/ipv4/udp.c
··· 3194 3194 #ifdef CONFIG_BPF_SYSCALL 3195 3195 static const struct seq_operations bpf_iter_udp_seq_ops; 3196 3196 #endif 3197 - static struct udp_table *udp_get_table_seq(struct seq_file *seq, 3198 - struct net *net) 3199 - { 3200 - const struct udp_seq_afinfo *afinfo; 3201 - 3202 - #ifdef CONFIG_BPF_SYSCALL 3203 - if (seq->op == &bpf_iter_udp_seq_ops) 3204 - return net->ipv4.udp_table; 3205 - #endif 3206 - 3207 - afinfo = pde_data(file_inode(seq->file)); 3208 - return afinfo->udp_table ? : net->ipv4.udp_table; 3209 - } 3210 3197 3211 3198 static struct sock *udp_get_first(struct seq_file *seq, int start) 3212 3199 { ··· 3202 3215 struct udp_table *udptable; 3203 3216 struct sock *sk; 3204 3217 3205 - udptable = udp_get_table_seq(seq, net); 3218 + udptable = net->ipv4.udp_table; 3206 3219 3207 3220 for (state->bucket = start; state->bucket <= udptable->mask; 3208 3221 ++state->bucket) { ··· 3234 3247 } while (sk && !seq_sk_match(seq, sk)); 3235 3248 3236 3249 if (!sk) { 3237 - udptable = udp_get_table_seq(seq, net); 3250 + udptable = net->ipv4.udp_table; 3238 3251 3239 3252 if (state->bucket <= udptable->mask) 3240 3253 spin_unlock_bh(&udptable->hash[state->bucket].lock); ··· 3282 3295 struct udp_iter_state *state = seq->private; 3283 3296 struct udp_table *udptable; 3284 3297 3285 - udptable = udp_get_table_seq(seq, seq_file_net(seq)); 3298 + udptable = seq_file_net(seq)->ipv4.udp_table; 3286 3299 3287 3300 if (state->bucket <= udptable->mask) 3288 3301 spin_unlock_bh(&udptable->hash[state->bucket].lock); ··· 3386 3399 if (iter->cur_sk == iter->end_sk) 3387 3400 state->bucket++; 3388 3401 3389 - udptable = udp_get_table_seq(seq, net); 3402 + udptable = net->ipv4.udp_table; 3390 3403 3391 3404 again: 3392 3405 /* New batch for the next bucket. ··· 3624 3637 3625 3638 static struct udp_seq_afinfo udp4_seq_afinfo = { 3626 3639 .family = AF_INET, 3627 - .udp_table = NULL, 3628 3640 }; 3629 3641 3630 3642 static int __net_init udp4_proc_init_net(struct net *net)
-1
net/ipv6/udp.c
··· 1872 1872 1873 1873 static struct udp_seq_afinfo udp6_seq_afinfo = { 1874 1874 .family = AF_INET6, 1875 - .udp_table = NULL, 1876 1875 }; 1877 1876 1878 1877 int __net_init udp6_proc_init(struct net *net)