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 struct proto.h.udp_table.

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

UDP always has its global or per-netns table in
net->ipv4.udp_table and struct proto.h.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_prot().

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

authored by

Kuniyuki Iwashima and committed by
Jakub Kicinski
5c273858 74f0cca1

+12 -16
-1
include/net/sock.h
··· 1392 1392 1393 1393 union { 1394 1394 struct inet_hashinfo *hashinfo; 1395 - struct udp_table *udp_table; 1396 1395 struct raw_hashinfo *raw_hash; 1397 1396 struct smc_hashinfo *smc_hash; 1398 1397 } h;
+12 -14
net/ipv4/udp.c
··· 134 134 #define MAX_UDP_PORTS 65536 135 135 #define PORTS_PER_CHAIN (MAX_UDP_PORTS / UDP_HTABLE_SIZE_MIN_PERNET) 136 136 137 - static struct udp_table *udp_get_table_prot(struct sock *sk) 138 - { 139 - return sk->sk_prot->h.udp_table ? : sock_net(sk)->ipv4.udp_table; 140 - } 141 - 142 137 static int udp_lib_lport_inuse(struct net *net, __u16 num, 143 138 const struct udp_hslot *hslot, 144 139 unsigned long *bitmap, ··· 235 240 int udp_lib_get_port(struct sock *sk, unsigned short snum, 236 241 unsigned int hash2_nulladdr) 237 242 { 238 - struct udp_table *udptable = udp_get_table_prot(sk); 239 243 struct udp_hslot *hslot, *hslot2; 240 244 struct net *net = sock_net(sk); 245 + struct udp_table *udptable; 241 246 int error = -EADDRINUSE; 247 + 248 + udptable = net->ipv4.udp_table; 242 249 243 250 if (!snum) { 244 251 DECLARE_BITMAP(bitmap, PORTS_PER_CHAIN); ··· 2221 2224 void udp_lib_unhash(struct sock *sk) 2222 2225 { 2223 2226 if (sk_hashed(sk)) { 2224 - struct udp_table *udptable = udp_get_table_prot(sk); 2225 2227 struct udp_hslot *hslot, *hslot2; 2228 + struct net *net = sock_net(sk); 2229 + struct udp_table *udptable; 2226 2230 2227 2231 sock_rps_delete_flow(sk); 2228 - hslot = udp_hashslot(udptable, sock_net(sk), 2229 - udp_sk(sk)->udp_port_hash); 2232 + udptable = net->ipv4.udp_table; 2233 + hslot = udp_hashslot(udptable, net, udp_sk(sk)->udp_port_hash); 2230 2234 hslot2 = udp_hashslot2(udptable, udp_sk(sk)->udp_portaddr_hash); 2231 2235 2232 2236 spin_lock_bh(&hslot->lock); ··· 2236 2238 if (sk_del_node_init_rcu(sk)) { 2237 2239 hslot->count--; 2238 2240 inet_sk(sk)->inet_num = 0; 2239 - sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1); 2241 + sock_prot_inuse_add(net, sk->sk_prot, -1); 2240 2242 2241 2243 spin_lock(&hslot2->lock); 2242 2244 hlist_del_init_rcu(&udp_sk(sk)->udp_portaddr_node); ··· 2256 2258 void udp_lib_rehash(struct sock *sk, u16 newhash, u16 newhash4) 2257 2259 { 2258 2260 if (sk_hashed(sk)) { 2259 - struct udp_table *udptable = udp_get_table_prot(sk); 2260 2261 struct udp_hslot *hslot, *hslot2, *nhslot2; 2262 + struct net *net = sock_net(sk); 2263 + struct udp_table *udptable; 2261 2264 2262 - hslot = udp_hashslot(udptable, sock_net(sk), 2263 - udp_sk(sk)->udp_port_hash); 2265 + udptable = net->ipv4.udp_table; 2266 + hslot = udp_hashslot(udptable, net, udp_sk(sk)->udp_port_hash); 2264 2267 hslot2 = udp_hashslot2(udptable, udp_sk(sk)->udp_portaddr_hash); 2265 2268 nhslot2 = udp_hashslot2(udptable, newhash); 2266 2269 ··· 3174 3175 .sysctl_wmem_offset = offsetof(struct net, ipv4.sysctl_udp_wmem_min), 3175 3176 .sysctl_rmem_offset = offsetof(struct net, ipv4.sysctl_udp_rmem_min), 3176 3177 .obj_size = sizeof(struct udp_sock), 3177 - .h.udp_table = NULL, 3178 3178 .diag_destroy = udp_abort, 3179 3179 }; 3180 3180 EXPORT_SYMBOL(udp_prot);
-1
net/ipv6/udp.c
··· 1924 1924 .sysctl_rmem_offset = offsetof(struct net, ipv4.sysctl_udp_rmem_min), 1925 1925 .obj_size = sizeof(struct udp6_sock), 1926 1926 .ipv6_pinfo_offset = offsetof(struct udp6_sock, inet6), 1927 - .h.udp_table = NULL, 1928 1927 .diag_destroy = udp_abort, 1929 1928 }; 1930 1929