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.

ipv4: Retire UDP-Lite.

We have deprecated IPv6 UDP-Lite sockets.

Let's drop support for IPv4 UDP-Lite sockets as well.

Most of the changes are similar to the IPv6 patch: removing
udplite.c and udp_impl.h, marking most functions in udp_impl.h
as static, moving the prototype for udp_recvmsg() to udp.h, and
adding INDIRECT_CALLABLE_SCOPE for it.

In addition, the INET_DIAG support for UDP-Lite is dropped.

We will remove the remaining dead code in the following patches.

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

authored by

Kuniyuki Iwashima and committed by
Jakub Kicinski
56520b39 92586f02

+26 -244
+2 -2
include/net/sock.h
··· 126 126 * @skc_bypass_prot_mem: bypass the per-protocol memory accounting for skb 127 127 * @skc_bound_dev_if: bound device index if != 0 128 128 * @skc_bind_node: bind hash linkage for various protocol lookup tables 129 - * @skc_portaddr_node: second hash linkage for UDP/UDP-Lite protocol 129 + * @skc_portaddr_node: second hash linkage for UDP 130 130 * @skc_prot: protocol handlers inside a network family 131 131 * @skc_net: reference to the network namespace of this socket 132 132 * @skc_v6_daddr: IPV6 destination address 133 133 * @skc_v6_rcv_saddr: IPV6 source address 134 134 * @skc_cookie: socket's cookie value 135 135 * @skc_node: main hash linkage for various protocol lookup tables 136 - * @skc_nulls_node: main hash linkage for TCP/UDP/UDP-Lite protocol 136 + * @skc_nulls_node: main hash linkage for TCP 137 137 * @skc_tx_queue_mapping: tx queue number for this connection 138 138 * @skc_rx_queue_mapping: rx queue number for this connection 139 139 * @skc_flags: place holder for sk_flags
+4 -3
include/net/udp.h
··· 105 105 unsigned int log; 106 106 }; 107 107 extern struct udp_table udp_table; 108 - void udp_table_init(struct udp_table *, const char *); 108 + 109 109 static inline struct udp_hslot *udp_hashslot(struct udp_table *table, 110 110 const struct net *net, 111 111 unsigned int num) ··· 312 312 numa_drop_add(&udp_sk(sk)->drop_counters, 1); 313 313 } 314 314 315 - /* hash routines shared between UDPv4/6 and UDP-Litev4/6 */ 315 + /* hash routines shared between UDPv4/6 */ 316 316 static inline int udp_lib_hash(struct sock *sk) 317 317 { 318 318 BUG(); ··· 420 420 int udp_err(struct sk_buff *, u32); 421 421 int udp_abort(struct sock *sk, int err); 422 422 int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len); 423 + INDIRECT_CALLABLE_DECLARE(int udp_recvmsg(struct sock *sk, struct msghdr *msg, 424 + size_t len, int flags)); 423 425 void udp_splice_eof(struct socket *sock); 424 426 int udp_push_pending_frames(struct sock *sk); 425 427 void udp_flush_pending_frames(struct sock *sk); ··· 429 427 void udp4_hwcsum(struct sk_buff *skb, __be32 src, __be32 dst); 430 428 int udp_rcv(struct sk_buff *skb); 431 429 int udp_ioctl(struct sock *sk, int cmd, int *karg); 432 - int udp_init_sock(struct sock *sk); 433 430 int udp_pre_connect(struct sock *sk, struct sockaddr_unsized *uaddr, int addr_len); 434 431 int __udp_disconnect(struct sock *sk, int flags); 435 432 int udp_disconnect(struct sock *sk, int flags);
-4
include/net/udplite.h
··· 12 12 #define UDPLITE_SEND_CSCOV 10 /* sender partial coverage (as sent) */ 13 13 #define UDPLITE_RECV_CSCOV 11 /* receiver partial coverage (threshold ) */ 14 14 15 - extern struct proto udplite_prot; 16 - extern struct udp_table udplite_table; 17 - 18 15 /* 19 16 * Checksum computation is all in software, hence simpler getfrag. 20 17 */ ··· 81 84 return skb_checksum(skb, off, len, 0); 82 85 } 83 86 84 - void udplite4_register(void); 85 87 #endif /* _UDPLITE_H */
+1 -1
net/ipv4/Makefile
··· 10 10 tcp.o tcp_input.o tcp_output.o tcp_timer.o tcp_ipv4.o \ 11 11 tcp_minisocks.o tcp_cong.o tcp_metrics.o tcp_fastopen.o \ 12 12 tcp_recovery.o tcp_ulp.o \ 13 - tcp_offload.o tcp_plb.o datagram.o raw.o udp.o udplite.o \ 13 + tcp_offload.o tcp_plb.o datagram.o raw.o udp.o \ 14 14 udp_offload.o arp.o icmp.o devinet.o af_inet.o igmp.o \ 15 15 fib_frontend.o fib_semantics.o fib_trie.o fib_notifier.o \ 16 16 inet_fragment.o ping.o ip_tunnel_core.o gre_offload.o \
-6
net/ipv4/af_inet.c
··· 104 104 #include <net/tcp.h> 105 105 #include <net/psp.h> 106 106 #include <net/udp.h> 107 - #include <net/udplite.h> 108 107 #include <net/ping.h> 109 108 #include <linux/skbuff.h> 110 109 #include <net/sock.h> ··· 883 884 } 884 885 EXPORT_SYMBOL_GPL(inet_splice_eof); 885 886 886 - INDIRECT_CALLABLE_DECLARE(int udp_recvmsg(struct sock *, struct msghdr *, 887 - size_t, int)); 888 887 int inet_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, 889 888 int flags) 890 889 { ··· 1981 1984 1982 1985 /* Setup UDP memory threshold */ 1983 1986 udp_init(); 1984 - 1985 - /* Add UDP-Lite (RFC 3828) */ 1986 - udplite4_register(); 1987 1987 1988 1988 raw_init(); 1989 1989
-3
net/ipv4/proc.c
··· 35 35 #include <net/mptcp.h> 36 36 #include <net/proto_memory.h> 37 37 #include <net/udp.h> 38 - #include <net/udplite.h> 39 38 #include <linux/bottom_half.h> 40 39 #include <linux/inetdevice.h> 41 40 #include <linux/proc_fs.h> ··· 64 65 seq_printf(seq, "UDP: inuse %d mem %ld\n", 65 66 sock_prot_inuse_get(net, &udp_prot), 66 67 proto_memory_allocated(&udp_prot)); 67 - seq_printf(seq, "UDPLITE: inuse %d\n", 68 - sock_prot_inuse_get(net, &udplite_prot)); 69 68 seq_printf(seq, "RAW: inuse %d\n", 70 69 sock_prot_inuse_get(net, &raw_prot)); 71 70 seq_printf(seq, "FRAG: inuse %u memory %lu\n",
+18 -15
net/ipv4/udp.c
··· 98 98 #include <linux/skbuff.h> 99 99 #include <linux/proc_fs.h> 100 100 #include <linux/seq_file.h> 101 + #include <net/aligned_data.h> 101 102 #include <net/net_namespace.h> 102 103 #include <net/icmp.h> 104 + #include <net/inet_common.h> 103 105 #include <net/inet_hashtables.h> 104 106 #include <net/ip.h> 105 107 #include <net/ip_tunnels.h> ··· 114 112 #include <linux/btf_ids.h> 115 113 #include <trace/events/skb.h> 116 114 #include <net/busy_poll.h> 117 - #include "udp_impl.h" 118 115 #include <net/sock_reuseport.h> 119 116 #include <net/addrconf.h> 120 117 #include <net/udp_tunnel.h> 118 + #include <net/udplite.h> 121 119 #include <net/gro.h> 122 120 #if IS_ENABLED(CONFIG_IPV6) 123 121 #include <net/ipv6_stubs.h> ··· 231 229 } 232 230 233 231 /** 234 - * udp_lib_get_port - UDP/-Lite port lookup for IPv4 and IPv6 232 + * udp_lib_get_port - UDP port lookup for IPv4 and IPv6 235 233 * 236 234 * @sk: socket struct in question 237 235 * @snum: port number to look up ··· 355 353 } 356 354 EXPORT_IPV6_MOD(udp_lib_get_port); 357 355 358 - int udp_v4_get_port(struct sock *sk, unsigned short snum) 356 + static int udp_v4_get_port(struct sock *sk, unsigned short snum) 359 357 { 360 358 unsigned int hash2_nulladdr = 361 359 ipv4_portaddr_hash(sock_net(sk), htonl(INADDR_ANY), snum); ··· 930 928 * to find the appropriate port. 931 929 */ 932 930 933 - int __udp4_lib_err(struct sk_buff *skb, u32 info, struct udp_table *udptable) 931 + static int __udp4_lib_err(struct sk_buff *skb, u32 info, struct udp_table *udptable) 934 932 { 935 933 struct inet_sock *inet; 936 934 const struct iphdr *iph = (const struct iphdr *)skb->data; ··· 1857 1855 inet_sock_destruct(sk); 1858 1856 } 1859 1857 1860 - int udp_init_sock(struct sock *sk) 1858 + static int udp_init_sock(struct sock *sk) 1861 1859 { 1862 1860 int res = udp_lib_init_sock(sk); 1863 1861 ··· 2072 2070 * return it, otherwise we block. 2073 2071 */ 2074 2072 2073 + INDIRECT_CALLABLE_SCOPE 2075 2074 int udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int flags) 2076 2075 { 2077 2076 struct inet_sock *inet = inet_sk(sk); ··· 2345 2342 } 2346 2343 EXPORT_IPV6_MOD(udp_lib_rehash); 2347 2344 2348 - void udp_v4_rehash(struct sock *sk) 2345 + static void udp_v4_rehash(struct sock *sk) 2349 2346 { 2350 2347 u16 new_hash = ipv4_portaddr_hash(sock_net(sk), 2351 2348 inet_sk(sk)->inet_rcv_saddr, ··· 2691 2688 * All we need to do is get the socket, and then do a checksum. 2692 2689 */ 2693 2690 2694 - int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable, 2695 - int proto) 2691 + static int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable, 2692 + int proto) 2696 2693 { 2697 2694 struct sock *sk = NULL; 2698 2695 struct udphdr *uh; ··· 2938 2935 return __udp4_lib_rcv(skb, dev_net(skb->dev)->ipv4.udp_table, IPPROTO_UDP); 2939 2936 } 2940 2937 2941 - void udp_destroy_sock(struct sock *sk) 2938 + static void udp_destroy_sock(struct sock *sk) 2942 2939 { 2943 2940 struct udp_sock *up = udp_sk(sk); 2944 2941 bool slow = lock_sock_fast(sk); ··· 3128 3125 } 3129 3126 EXPORT_IPV6_MOD(udp_lib_setsockopt); 3130 3127 3131 - int udp_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, 3132 - unsigned int optlen) 3128 + static int udp_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, 3129 + unsigned int optlen) 3133 3130 { 3134 3131 if (level == SOL_UDP || level == SOL_UDPLITE || level == SOL_SOCKET) 3135 3132 return udp_lib_setsockopt(sk, level, optname, ··· 3199 3196 } 3200 3197 EXPORT_IPV6_MOD(udp_lib_getsockopt); 3201 3198 3202 - int udp_getsockopt(struct sock *sk, int level, int optname, 3203 - char __user *optval, int __user *optlen) 3199 + static int udp_getsockopt(struct sock *sk, int level, int optname, 3200 + char __user *optval, int __user *optlen) 3204 3201 { 3205 3202 if (level == SOL_UDP || level == SOL_UDPLITE) 3206 3203 return udp_lib_getsockopt(sk, level, optname, optval, optlen); ··· 3750 3747 return afinfo->family; 3751 3748 } 3752 3749 3753 - const struct seq_operations udp_seq_ops = { 3750 + static const struct seq_operations udp_seq_ops = { 3754 3751 .start = udp_seq_start, 3755 3752 .next = udp_seq_next, 3756 3753 .stop = udp_seq_stop, ··· 3809 3806 } 3810 3807 __setup("uhash_entries=", set_uhash_entries); 3811 3808 3812 - void __init udp_table_init(struct udp_table *table, const char *name) 3809 + static void __init udp_table_init(struct udp_table *table, const char *name) 3813 3810 { 3814 3811 unsigned int i, slot_size; 3815 3812
-2
net/ipv4/udp_bpf.c
··· 7 7 #include <net/inet_common.h> 8 8 #include <asm/ioctls.h> 9 9 10 - #include "udp_impl.h" 11 - 12 10 static struct proto *udpv6_prot_saved __read_mostly; 13 11 14 12 static int sk_udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
+1 -46
net/ipv4/udp_diag.c
··· 10 10 #include <linux/inet_diag.h> 11 11 #include <linux/udp.h> 12 12 #include <net/udp.h> 13 - #include <net/udplite.h> 14 13 #include <linux/sock_diag.h> 15 14 16 15 static int sk_diag_dump(struct sock *sk, struct sk_buff *skb, ··· 223 224 return __udp_diag_destroy(in_skb, req, sock_net(in_skb->sk)->ipv4.udp_table); 224 225 } 225 226 226 - static int udplite_diag_destroy(struct sk_buff *in_skb, 227 - const struct inet_diag_req_v2 *req) 228 - { 229 - return __udp_diag_destroy(in_skb, req, &udplite_table); 230 - } 231 - 232 227 #endif 233 228 234 229 static const struct inet_diag_handler udp_diag_handler = { ··· 237 244 #endif 238 245 }; 239 246 240 - static void udplite_diag_dump(struct sk_buff *skb, struct netlink_callback *cb, 241 - const struct inet_diag_req_v2 *r) 242 - { 243 - udp_dump(&udplite_table, skb, cb, r); 244 - } 245 - 246 - static int udplite_diag_dump_one(struct netlink_callback *cb, 247 - const struct inet_diag_req_v2 *req) 248 - { 249 - return udp_dump_one(&udplite_table, cb, req); 250 - } 251 - 252 - static const struct inet_diag_handler udplite_diag_handler = { 253 - .owner = THIS_MODULE, 254 - .dump = udplite_diag_dump, 255 - .dump_one = udplite_diag_dump_one, 256 - .idiag_get_info = udp_diag_get_info, 257 - .idiag_type = IPPROTO_UDPLITE, 258 - .idiag_info_size = 0, 259 - #ifdef CONFIG_INET_DIAG_DESTROY 260 - .destroy = udplite_diag_destroy, 261 - #endif 262 - }; 263 - 264 247 static int __init udp_diag_init(void) 265 248 { 266 - int err; 267 - 268 - err = inet_diag_register(&udp_diag_handler); 269 - if (err) 270 - goto out; 271 - err = inet_diag_register(&udplite_diag_handler); 272 - if (err) 273 - goto out_lite; 274 - out: 275 - return err; 276 - out_lite: 277 - inet_diag_unregister(&udp_diag_handler); 278 - goto out; 249 + return inet_diag_register(&udp_diag_handler); 279 250 } 280 251 281 252 static void __exit udp_diag_exit(void) 282 253 { 283 - inet_diag_unregister(&udplite_diag_handler); 284 254 inet_diag_unregister(&udp_diag_handler); 285 255 } 286 256 ··· 252 296 MODULE_LICENSE("GPL"); 253 297 MODULE_DESCRIPTION("UDP socket monitoring via SOCK_DIAG"); 254 298 MODULE_ALIAS_NET_PF_PROTO_TYPE(PF_NETLINK, NETLINK_SOCK_DIAG, 2-17 /* AF_INET - IPPROTO_UDP */); 255 - MODULE_ALIAS_NET_PF_PROTO_TYPE(PF_NETLINK, NETLINK_SOCK_DIAG, 2-136 /* AF_INET - IPPROTO_UDPLITE */);
-27
net/ipv4/udp_impl.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef _UDP4_IMPL_H 3 - #define _UDP4_IMPL_H 4 - #include <net/aligned_data.h> 5 - #include <net/udp.h> 6 - #include <net/udplite.h> 7 - #include <net/protocol.h> 8 - #include <net/inet_common.h> 9 - 10 - int __udp4_lib_rcv(struct sk_buff *, struct udp_table *, int); 11 - int __udp4_lib_err(struct sk_buff *, u32, struct udp_table *); 12 - 13 - int udp_v4_get_port(struct sock *sk, unsigned short snum); 14 - void udp_v4_rehash(struct sock *sk); 15 - 16 - int udp_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, 17 - unsigned int optlen); 18 - int udp_getsockopt(struct sock *sk, int level, int optname, 19 - char __user *optval, int __user *optlen); 20 - 21 - int udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int flags); 22 - void udp_destroy_sock(struct sock *sk); 23 - 24 - #ifdef CONFIG_PROC_FS 25 - extern const struct seq_operations udp_seq_ops; 26 - #endif 27 - #endif /* _UDP4_IMPL_H */
-135
net/ipv4/udplite.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-or-later 2 - /* 3 - * UDPLITE An implementation of the UDP-Lite protocol (RFC 3828). 4 - * 5 - * Authors: Gerrit Renker <gerrit@erg.abdn.ac.uk> 6 - * 7 - * Changes: 8 - * Fixes: 9 - */ 10 - 11 - #define pr_fmt(fmt) "UDPLite: " fmt 12 - 13 - #include <linux/export.h> 14 - #include <linux/proc_fs.h> 15 - #include "udp_impl.h" 16 - 17 - struct udp_table udplite_table __read_mostly; 18 - EXPORT_SYMBOL(udplite_table); 19 - 20 - /* Designate sk as UDP-Lite socket */ 21 - static int udplite_sk_init(struct sock *sk) 22 - { 23 - pr_warn_once("UDP-Lite is deprecated and scheduled to be removed in 2025, " 24 - "please contact the netdev mailing list\n"); 25 - return udp_init_sock(sk); 26 - } 27 - 28 - static int udplite_rcv(struct sk_buff *skb) 29 - { 30 - return __udp4_lib_rcv(skb, &udplite_table, IPPROTO_UDPLITE); 31 - } 32 - 33 - static int udplite_err(struct sk_buff *skb, u32 info) 34 - { 35 - return __udp4_lib_err(skb, info, &udplite_table); 36 - } 37 - 38 - static const struct net_protocol udplite_protocol = { 39 - .handler = udplite_rcv, 40 - .err_handler = udplite_err, 41 - .no_policy = 1, 42 - }; 43 - 44 - struct proto udplite_prot = { 45 - .name = "UDP-Lite", 46 - .owner = THIS_MODULE, 47 - .close = udp_lib_close, 48 - .connect = ip4_datagram_connect, 49 - .disconnect = udp_disconnect, 50 - .ioctl = udp_ioctl, 51 - .init = udplite_sk_init, 52 - .destroy = udp_destroy_sock, 53 - .setsockopt = udp_setsockopt, 54 - .getsockopt = udp_getsockopt, 55 - .sendmsg = udp_sendmsg, 56 - .recvmsg = udp_recvmsg, 57 - .hash = udp_lib_hash, 58 - .unhash = udp_lib_unhash, 59 - .rehash = udp_v4_rehash, 60 - .get_port = udp_v4_get_port, 61 - 62 - .memory_allocated = &net_aligned_data.udp_memory_allocated, 63 - .per_cpu_fw_alloc = &udp_memory_per_cpu_fw_alloc, 64 - 65 - .sysctl_mem = sysctl_udp_mem, 66 - .sysctl_wmem_offset = offsetof(struct net, ipv4.sysctl_udp_wmem_min), 67 - .sysctl_rmem_offset = offsetof(struct net, ipv4.sysctl_udp_rmem_min), 68 - .obj_size = sizeof(struct udp_sock), 69 - .h.udp_table = &udplite_table, 70 - }; 71 - EXPORT_SYMBOL(udplite_prot); 72 - 73 - static struct inet_protosw udplite4_protosw = { 74 - .type = SOCK_DGRAM, 75 - .protocol = IPPROTO_UDPLITE, 76 - .prot = &udplite_prot, 77 - .ops = &inet_dgram_ops, 78 - .flags = INET_PROTOSW_PERMANENT, 79 - }; 80 - 81 - #ifdef CONFIG_PROC_FS 82 - static struct udp_seq_afinfo udplite4_seq_afinfo = { 83 - .family = AF_INET, 84 - .udp_table = &udplite_table, 85 - }; 86 - 87 - static int __net_init udplite4_proc_init_net(struct net *net) 88 - { 89 - if (!proc_create_net_data("udplite", 0444, net->proc_net, &udp_seq_ops, 90 - sizeof(struct udp_iter_state), &udplite4_seq_afinfo)) 91 - return -ENOMEM; 92 - return 0; 93 - } 94 - 95 - static void __net_exit udplite4_proc_exit_net(struct net *net) 96 - { 97 - remove_proc_entry("udplite", net->proc_net); 98 - } 99 - 100 - static struct pernet_operations udplite4_net_ops = { 101 - .init = udplite4_proc_init_net, 102 - .exit = udplite4_proc_exit_net, 103 - }; 104 - 105 - static __init int udplite4_proc_init(void) 106 - { 107 - return register_pernet_subsys(&udplite4_net_ops); 108 - } 109 - #else 110 - static inline int udplite4_proc_init(void) 111 - { 112 - return 0; 113 - } 114 - #endif 115 - 116 - void __init udplite4_register(void) 117 - { 118 - udp_table_init(&udplite_table, "UDP-Lite"); 119 - if (proto_register(&udplite_prot, 1)) 120 - goto out_register_err; 121 - 122 - if (inet_add_protocol(&udplite_protocol, IPPROTO_UDPLITE) < 0) 123 - goto out_unregister_proto; 124 - 125 - inet_register_protosw(&udplite4_protosw); 126 - 127 - if (udplite4_proc_init()) 128 - pr_err("%s: Cannot register /proc!\n", __func__); 129 - return; 130 - 131 - out_unregister_proto: 132 - proto_unregister(&udplite_prot); 133 - out_register_err: 134 - pr_crit("%s: Cannot add UDP-Lite protocol\n", __func__); 135 - }