]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
udp: Remove udp_table in struct udp_seq_afinfo.
authorKuniyuki Iwashima <kuniyu@google.com>
Wed, 11 Mar 2026 05:19:58 +0000 (05:19 +0000)
committerJakub Kicinski <kuba@kernel.org>
Sat, 14 Mar 2026 01:57:45 +0000 (18:57 -0700)
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>
include/net/udp.h
net/ipv4/udp.c
net/ipv6/udp.c

index bc275cda9f8ce21177011b3aed40802badbc807c..76f401988353e0948904bf63e81e7c4d194e5f03 100644 (file)
@@ -552,7 +552,6 @@ static inline int copy_linear_skb(struct sk_buff *skb, int len, int off,
 #ifdef CONFIG_PROC_FS
 struct udp_seq_afinfo {
        sa_family_t                     family;
-       struct udp_table                *udp_table;
 };
 
 struct udp_iter_state {
index a7ca727347cec795c77b9a852f474b7cee917908..14b372b211be663751cc427a86663a4910241292 100644 (file)
@@ -3193,21 +3193,8 @@ static bool seq_sk_match(struct seq_file *seq, const struct sock *sk)
 
 #ifdef CONFIG_BPF_SYSCALL
 static const struct seq_operations bpf_iter_udp_seq_ops;
-#endif
-static struct udp_table *udp_get_table_seq(struct seq_file *seq,
-                                          struct net *net)
-{
-       const struct udp_seq_afinfo *afinfo;
-
-#ifdef CONFIG_BPF_SYSCALL
-       if (seq->op == &bpf_iter_udp_seq_ops)
-               return net->ipv4.udp_table;
 #endif
 
-       afinfo = pde_data(file_inode(seq->file));
-       return afinfo->udp_table ? : net->ipv4.udp_table;
-}
-
 static struct sock *udp_get_first(struct seq_file *seq, int start)
 {
        struct udp_iter_state *state = seq->private;
@@ -3215,7 +3202,7 @@ static struct sock *udp_get_first(struct seq_file *seq, int start)
        struct udp_table *udptable;
        struct sock *sk;
 
-       udptable = udp_get_table_seq(seq, net);
+       udptable = net->ipv4.udp_table;
 
        for (state->bucket = start; state->bucket <= udptable->mask;
             ++state->bucket) {
@@ -3247,7 +3234,7 @@ static struct sock *udp_get_next(struct seq_file *seq, struct sock *sk)
        } while (sk && !seq_sk_match(seq, sk));
 
        if (!sk) {
-               udptable = udp_get_table_seq(seq, net);
+               udptable = net->ipv4.udp_table;
 
                if (state->bucket <= udptable->mask)
                        spin_unlock_bh(&udptable->hash[state->bucket].lock);
@@ -3295,7 +3282,7 @@ void udp_seq_stop(struct seq_file *seq, void *v)
        struct udp_iter_state *state = seq->private;
        struct udp_table *udptable;
 
-       udptable = udp_get_table_seq(seq, seq_file_net(seq));
+       udptable = seq_file_net(seq)->ipv4.udp_table;
 
        if (state->bucket <= udptable->mask)
                spin_unlock_bh(&udptable->hash[state->bucket].lock);
@@ -3399,7 +3386,7 @@ static struct sock *bpf_iter_udp_batch(struct seq_file *seq)
        if (iter->cur_sk == iter->end_sk)
                state->bucket++;
 
-       udptable = udp_get_table_seq(seq, net);
+       udptable = net->ipv4.udp_table;
 
 again:
        /* New batch for the next bucket.
@@ -3637,7 +3624,6 @@ static const struct seq_operations udp_seq_ops = {
 
 static struct udp_seq_afinfo udp4_seq_afinfo = {
        .family         = AF_INET,
-       .udp_table      = NULL,
 };
 
 static int __net_init udp4_proc_init_net(struct net *net)
index 5bddbf457b61f218169ff18382964ee0487c0ccf..eeb77363a55666e365cfd3e6f913be9d92abbfe2 100644 (file)
@@ -1872,7 +1872,6 @@ static const struct seq_operations udp6_seq_ops = {
 
 static struct udp_seq_afinfo udp6_seq_afinfo = {
        .family         = AF_INET6,
-       .udp_table      = NULL,
 };
 
 int __net_init udp6_proc_init(struct net *net)