]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ipv4: Retire UDP-Lite.
authorKuniyuki Iwashima <kuniyu@google.com>
Wed, 11 Mar 2026 05:19:51 +0000 (05:19 +0000)
committerJakub Kicinski <kuba@kernel.org>
Sat, 14 Mar 2026 01:57:44 +0000 (18:57 -0700)
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>
include/net/sock.h
include/net/udp.h
include/net/udplite.h
net/ipv4/Makefile
net/ipv4/af_inet.c
net/ipv4/proc.c
net/ipv4/udp.c
net/ipv4/udp_bpf.c
net/ipv4/udp_diag.c
net/ipv4/udp_impl.h [deleted file]
net/ipv4/udplite.c [deleted file]

index 6c3f1340e8ef267ece842fb9559f3314e241b515..16a1b8895206a9038d8bc952f9732645f487e15d 100644 (file)
@@ -126,14 +126,14 @@ typedef __u64 __bitwise __addrpair;
  *     @skc_bypass_prot_mem: bypass the per-protocol memory accounting for skb
  *     @skc_bound_dev_if: bound device index if != 0
  *     @skc_bind_node: bind hash linkage for various protocol lookup tables
- *     @skc_portaddr_node: second hash linkage for UDP/UDP-Lite protocol
+ *     @skc_portaddr_node: second hash linkage for UDP
  *     @skc_prot: protocol handlers inside a network family
  *     @skc_net: reference to the network namespace of this socket
  *     @skc_v6_daddr: IPV6 destination address
  *     @skc_v6_rcv_saddr: IPV6 source address
  *     @skc_cookie: socket's cookie value
  *     @skc_node: main hash linkage for various protocol lookup tables
- *     @skc_nulls_node: main hash linkage for TCP/UDP/UDP-Lite protocol
+ *     @skc_nulls_node: main hash linkage for TCP
  *     @skc_tx_queue_mapping: tx queue number for this connection
  *     @skc_rx_queue_mapping: rx queue number for this connection
  *     @skc_flags: place holder for sk_flags
index 05f63e9e00a76844eec87b3db5c4b0065470fa8e..39223e2692e9416b0f7d8bee0eba4f6d44b59681 100644 (file)
@@ -105,7 +105,7 @@ struct udp_table {
        unsigned int            log;
 };
 extern struct udp_table udp_table;
-void udp_table_init(struct udp_table *, const char *);
+
 static inline struct udp_hslot *udp_hashslot(struct udp_table *table,
                                             const struct net *net,
                                             unsigned int num)
@@ -312,7 +312,7 @@ static inline void udp_drops_inc(struct sock *sk)
        numa_drop_add(&udp_sk(sk)->drop_counters, 1);
 }
 
-/* hash routines shared between UDPv4/6 and UDP-Litev4/6 */
+/* hash routines shared between UDPv4/6 */
 static inline int udp_lib_hash(struct sock *sk)
 {
        BUG();
@@ -420,6 +420,8 @@ bool udp_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst);
 int udp_err(struct sk_buff *, u32);
 int udp_abort(struct sock *sk, int err);
 int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len);
+INDIRECT_CALLABLE_DECLARE(int udp_recvmsg(struct sock *sk, struct msghdr *msg,
+                                         size_t len, int flags));
 void udp_splice_eof(struct socket *sock);
 int udp_push_pending_frames(struct sock *sk);
 void udp_flush_pending_frames(struct sock *sk);
@@ -427,7 +429,6 @@ int udp_cmsg_send(struct sock *sk, struct msghdr *msg, u16 *gso_size);
 void udp4_hwcsum(struct sk_buff *skb, __be32 src, __be32 dst);
 int udp_rcv(struct sk_buff *skb);
 int udp_ioctl(struct sock *sk, int cmd, int *karg);
-int udp_init_sock(struct sock *sk);
 int udp_pre_connect(struct sock *sk, struct sockaddr_unsized *uaddr, int addr_len);
 int __udp_disconnect(struct sock *sk, int flags);
 int udp_disconnect(struct sock *sk, int flags);
index 786919d29f8de7664b5e8cabab00692ecf4b9089..fdd769745ac4d925414fb605b73aa272ba7f4d3e 100644 (file)
@@ -12,9 +12,6 @@
 #define UDPLITE_SEND_CSCOV   10 /* sender partial coverage (as sent)      */
 #define UDPLITE_RECV_CSCOV   11 /* receiver partial coverage (threshold ) */
 
-extern struct proto            udplite_prot;
-extern struct udp_table                udplite_table;
-
 /*
  *     Checksum computation is all in software, hence simpler getfrag.
  */
@@ -84,5 +81,4 @@ static inline __wsum udplite_csum(struct sk_buff *skb)
        return skb_checksum(skb, off, len, 0);
 }
 
-void udplite4_register(void);
 #endif /* _UDPLITE_H */
index 18108a6f0499907a675aead180f90a7b8ca2ea6c..7f9f988139867f77d701ebbb576830faf5b9040d 100644 (file)
@@ -10,7 +10,7 @@ obj-y     := route.o inetpeer.o protocol.o \
             tcp.o tcp_input.o tcp_output.o tcp_timer.o tcp_ipv4.o \
             tcp_minisocks.o tcp_cong.o tcp_metrics.o tcp_fastopen.o \
             tcp_recovery.o tcp_ulp.o \
-            tcp_offload.o tcp_plb.o datagram.o raw.o udp.o udplite.o \
+            tcp_offload.o tcp_plb.o datagram.o raw.o udp.o \
             udp_offload.o arp.o icmp.o devinet.o af_inet.o igmp.o \
             fib_frontend.o fib_semantics.o fib_trie.o fib_notifier.o \
             inet_fragment.o ping.o ip_tunnel_core.o gre_offload.o \
index 4a112f0ee269465da9505dfb23b46e992d99094b..5d4bc4c1a731dcc4b50e8a6e674ecaebb6ff1952 100644 (file)
 #include <net/tcp.h>
 #include <net/psp.h>
 #include <net/udp.h>
-#include <net/udplite.h>
 #include <net/ping.h>
 #include <linux/skbuff.h>
 #include <net/sock.h>
@@ -884,8 +883,6 @@ void inet_splice_eof(struct socket *sock)
 }
 EXPORT_SYMBOL_GPL(inet_splice_eof);
 
-INDIRECT_CALLABLE_DECLARE(int udp_recvmsg(struct sock *, struct msghdr *,
-                                         size_t, int));
 int inet_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
                 int flags)
 {
@@ -1985,9 +1982,6 @@ static int __init inet_init(void)
        /* Setup UDP memory threshold */
        udp_init();
 
-       /* Add UDP-Lite (RFC 3828) */
-       udplite4_register();
-
        raw_init();
 
        ping_init();
index 974afc4ecbe2edaae08d98c7b5988ec49bc099f9..cf51f8fcf34b83a6e025c1da7b4ef60e3eb80e9c 100644 (file)
@@ -35,7 +35,6 @@
 #include <net/mptcp.h>
 #include <net/proto_memory.h>
 #include <net/udp.h>
-#include <net/udplite.h>
 #include <linux/bottom_half.h>
 #include <linux/inetdevice.h>
 #include <linux/proc_fs.h>
@@ -65,8 +64,6 @@ static int sockstat_seq_show(struct seq_file *seq, void *v)
        seq_printf(seq, "UDP: inuse %d mem %ld\n",
                   sock_prot_inuse_get(net, &udp_prot),
                   proto_memory_allocated(&udp_prot));
-       seq_printf(seq, "UDPLITE: inuse %d\n",
-                  sock_prot_inuse_get(net, &udplite_prot));
        seq_printf(seq, "RAW: inuse %d\n",
                   sock_prot_inuse_get(net, &raw_prot));
        seq_printf(seq,  "FRAG: inuse %u memory %lu\n",
index 1fcdc5482594020818f0e9c2233ab9e88167d6b3..b3f63a5ea2a900e09c3c0243a9d3696a5edfb3a5 100644 (file)
 #include <linux/skbuff.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <net/aligned_data.h>
 #include <net/net_namespace.h>
 #include <net/icmp.h>
+#include <net/inet_common.h>
 #include <net/inet_hashtables.h>
 #include <net/ip.h>
 #include <net/ip_tunnels.h>
 #include <linux/btf_ids.h>
 #include <trace/events/skb.h>
 #include <net/busy_poll.h>
-#include "udp_impl.h"
 #include <net/sock_reuseport.h>
 #include <net/addrconf.h>
 #include <net/udp_tunnel.h>
+#include <net/udplite.h>
 #include <net/gro.h>
 #if IS_ENABLED(CONFIG_IPV6)
 #include <net/ipv6_stubs.h>
@@ -229,7 +231,7 @@ static int udp_reuseport_add_sock(struct sock *sk, struct udp_hslot *hslot)
 }
 
 /**
- *  udp_lib_get_port  -  UDP/-Lite port lookup for IPv4 and IPv6
+ *  udp_lib_get_port  -  UDP port lookup for IPv4 and IPv6
  *
  *  @sk:          socket struct in question
  *  @snum:        port number to look up
@@ -353,7 +355,7 @@ fail:
 }
 EXPORT_IPV6_MOD(udp_lib_get_port);
 
-int udp_v4_get_port(struct sock *sk, unsigned short snum)
+static int udp_v4_get_port(struct sock *sk, unsigned short snum)
 {
        unsigned int hash2_nulladdr =
                ipv4_portaddr_hash(sock_net(sk), htonl(INADDR_ANY), snum);
@@ -928,7 +930,7 @@ out:
  * to find the appropriate port.
  */
 
-int __udp4_lib_err(struct sk_buff *skb, u32 info, struct udp_table *udptable)
+static int __udp4_lib_err(struct sk_buff *skb, u32 info, struct udp_table *udptable)
 {
        struct inet_sock *inet;
        const struct iphdr *iph = (const struct iphdr *)skb->data;
@@ -1855,7 +1857,7 @@ static void udp_destruct_sock(struct sock *sk)
        inet_sock_destruct(sk);
 }
 
-int udp_init_sock(struct sock *sk)
+static int udp_init_sock(struct sock *sk)
 {
        int res = udp_lib_init_sock(sk);
 
@@ -2070,6 +2072,7 @@ EXPORT_IPV6_MOD(udp_read_skb);
  *     return it, otherwise we block.
  */
 
+INDIRECT_CALLABLE_SCOPE
 int udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int flags)
 {
        struct inet_sock *inet = inet_sk(sk);
@@ -2342,7 +2345,7 @@ void udp_lib_rehash(struct sock *sk, u16 newhash, u16 newhash4)
 }
 EXPORT_IPV6_MOD(udp_lib_rehash);
 
-void udp_v4_rehash(struct sock *sk)
+static void udp_v4_rehash(struct sock *sk)
 {
        u16 new_hash = ipv4_portaddr_hash(sock_net(sk),
                                          inet_sk(sk)->inet_rcv_saddr,
@@ -2688,8 +2691,8 @@ static int udp_unicast_rcv_skb(struct sock *sk, struct sk_buff *skb,
  *     All we need to do is get the socket, and then do a checksum.
  */
 
-int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
-                  int proto)
+static int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
+                         int proto)
 {
        struct sock *sk = NULL;
        struct udphdr *uh;
@@ -2935,7 +2938,7 @@ int udp_rcv(struct sk_buff *skb)
        return __udp4_lib_rcv(skb, dev_net(skb->dev)->ipv4.udp_table, IPPROTO_UDP);
 }
 
-void udp_destroy_sock(struct sock *sk)
+static void udp_destroy_sock(struct sock *sk)
 {
        struct udp_sock *up = udp_sk(sk);
        bool slow = lock_sock_fast(sk);
@@ -3125,8 +3128,8 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname,
 }
 EXPORT_IPV6_MOD(udp_lib_setsockopt);
 
-int udp_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval,
-                  unsigned int optlen)
+static int udp_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval,
+                         unsigned int optlen)
 {
        if (level == SOL_UDP  ||  level == SOL_UDPLITE || level == SOL_SOCKET)
                return udp_lib_setsockopt(sk, level, optname,
@@ -3196,8 +3199,8 @@ int udp_lib_getsockopt(struct sock *sk, int level, int optname,
 }
 EXPORT_IPV6_MOD(udp_lib_getsockopt);
 
-int udp_getsockopt(struct sock *sk, int level, int optname,
-                  char __user *optval, int __user *optlen)
+static int udp_getsockopt(struct sock *sk, int level, int optname,
+                         char __user *optval, int __user *optlen)
 {
        if (level == SOL_UDP  ||  level == SOL_UDPLITE)
                return udp_lib_getsockopt(sk, level, optname, optval, optlen);
@@ -3747,7 +3750,7 @@ static unsigned short seq_file_family(const struct seq_file *seq)
        return afinfo->family;
 }
 
-const struct seq_operations udp_seq_ops = {
+static const struct seq_operations udp_seq_ops = {
        .start          = udp_seq_start,
        .next           = udp_seq_next,
        .stop           = udp_seq_stop,
@@ -3806,7 +3809,7 @@ static int __init set_uhash_entries(char *str)
 }
 __setup("uhash_entries=", set_uhash_entries);
 
-void __init udp_table_init(struct udp_table *table, const char *name)
+static void __init udp_table_init(struct udp_table *table, const char *name)
 {
        unsigned int i, slot_size;
 
index d328a3078ae04f4c3fca1510fae8bc8ad8c701ce..9f33b07b148131929757f25daed85cbb15b84bad 100644 (file)
@@ -7,8 +7,6 @@
 #include <net/inet_common.h>
 #include <asm/ioctls.h>
 
-#include "udp_impl.h"
-
 static struct proto *udpv6_prot_saved __read_mostly;
 
 static int sk_udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
index 6e491c720c9075bcef9d5daf9bc852fab3412231..a010d05062a08972d2f24b2ee19520e6654d5360 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/inet_diag.h>
 #include <linux/udp.h>
 #include <net/udp.h>
-#include <net/udplite.h>
 #include <linux/sock_diag.h>
 
 static int sk_diag_dump(struct sock *sk, struct sk_buff *skb,
@@ -224,12 +223,6 @@ static int udp_diag_destroy(struct sk_buff *in_skb,
        return __udp_diag_destroy(in_skb, req, sock_net(in_skb->sk)->ipv4.udp_table);
 }
 
-static int udplite_diag_destroy(struct sk_buff *in_skb,
-                               const struct inet_diag_req_v2 *req)
-{
-       return __udp_diag_destroy(in_skb, req, &udplite_table);
-}
-
 #endif
 
 static const struct inet_diag_handler udp_diag_handler = {
@@ -244,50 +237,13 @@ static const struct inet_diag_handler udp_diag_handler = {
 #endif
 };
 
-static void udplite_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
-                             const struct inet_diag_req_v2 *r)
-{
-       udp_dump(&udplite_table, skb, cb, r);
-}
-
-static int udplite_diag_dump_one(struct netlink_callback *cb,
-                                const struct inet_diag_req_v2 *req)
-{
-       return udp_dump_one(&udplite_table, cb, req);
-}
-
-static const struct inet_diag_handler udplite_diag_handler = {
-       .owner           = THIS_MODULE,
-       .dump            = udplite_diag_dump,
-       .dump_one        = udplite_diag_dump_one,
-       .idiag_get_info  = udp_diag_get_info,
-       .idiag_type      = IPPROTO_UDPLITE,
-       .idiag_info_size = 0,
-#ifdef CONFIG_INET_DIAG_DESTROY
-       .destroy         = udplite_diag_destroy,
-#endif
-};
-
 static int __init udp_diag_init(void)
 {
-       int err;
-
-       err = inet_diag_register(&udp_diag_handler);
-       if (err)
-               goto out;
-       err = inet_diag_register(&udplite_diag_handler);
-       if (err)
-               goto out_lite;
-out:
-       return err;
-out_lite:
-       inet_diag_unregister(&udp_diag_handler);
-       goto out;
+       return inet_diag_register(&udp_diag_handler);
 }
 
 static void __exit udp_diag_exit(void)
 {
-       inet_diag_unregister(&udplite_diag_handler);
        inet_diag_unregister(&udp_diag_handler);
 }
 
@@ -296,4 +252,3 @@ module_exit(udp_diag_exit);
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("UDP socket monitoring via SOCK_DIAG");
 MODULE_ALIAS_NET_PF_PROTO_TYPE(PF_NETLINK, NETLINK_SOCK_DIAG, 2-17 /* AF_INET - IPPROTO_UDP */);
-MODULE_ALIAS_NET_PF_PROTO_TYPE(PF_NETLINK, NETLINK_SOCK_DIAG, 2-136 /* AF_INET - IPPROTO_UDPLITE */);
diff --git a/net/ipv4/udp_impl.h b/net/ipv4/udp_impl.h
deleted file mode 100644 (file)
index 0ca4384..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _UDP4_IMPL_H
-#define _UDP4_IMPL_H
-#include <net/aligned_data.h>
-#include <net/udp.h>
-#include <net/udplite.h>
-#include <net/protocol.h>
-#include <net/inet_common.h>
-
-int __udp4_lib_rcv(struct sk_buff *, struct udp_table *, int);
-int __udp4_lib_err(struct sk_buff *, u32, struct udp_table *);
-
-int udp_v4_get_port(struct sock *sk, unsigned short snum);
-void udp_v4_rehash(struct sock *sk);
-
-int udp_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval,
-                  unsigned int optlen);
-int udp_getsockopt(struct sock *sk, int level, int optname,
-                  char __user *optval, int __user *optlen);
-
-int udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int flags);
-void udp_destroy_sock(struct sock *sk);
-
-#ifdef CONFIG_PROC_FS
-extern const struct seq_operations udp_seq_ops;
-#endif
-#endif /* _UDP4_IMPL_H */
diff --git a/net/ipv4/udplite.c b/net/ipv4/udplite.c
deleted file mode 100644 (file)
index 826e9e7..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- *  UDPLITE     An implementation of the UDP-Lite protocol (RFC 3828).
- *
- *  Authors:    Gerrit Renker       <gerrit@erg.abdn.ac.uk>
- *
- *  Changes:
- *  Fixes:
- */
-
-#define pr_fmt(fmt) "UDPLite: " fmt
-
-#include <linux/export.h>
-#include <linux/proc_fs.h>
-#include "udp_impl.h"
-
-struct udp_table       udplite_table __read_mostly;
-EXPORT_SYMBOL(udplite_table);
-
-/* Designate sk as UDP-Lite socket */
-static int udplite_sk_init(struct sock *sk)
-{
-       pr_warn_once("UDP-Lite is deprecated and scheduled to be removed in 2025, "
-                    "please contact the netdev mailing list\n");
-       return udp_init_sock(sk);
-}
-
-static int udplite_rcv(struct sk_buff *skb)
-{
-       return __udp4_lib_rcv(skb, &udplite_table, IPPROTO_UDPLITE);
-}
-
-static int udplite_err(struct sk_buff *skb, u32 info)
-{
-       return __udp4_lib_err(skb, info, &udplite_table);
-}
-
-static const struct net_protocol udplite_protocol = {
-       .handler        = udplite_rcv,
-       .err_handler    = udplite_err,
-       .no_policy      = 1,
-};
-
-struct proto   udplite_prot = {
-       .name              = "UDP-Lite",
-       .owner             = THIS_MODULE,
-       .close             = udp_lib_close,
-       .connect           = ip4_datagram_connect,
-       .disconnect        = udp_disconnect,
-       .ioctl             = udp_ioctl,
-       .init              = udplite_sk_init,
-       .destroy           = udp_destroy_sock,
-       .setsockopt        = udp_setsockopt,
-       .getsockopt        = udp_getsockopt,
-       .sendmsg           = udp_sendmsg,
-       .recvmsg           = udp_recvmsg,
-       .hash              = udp_lib_hash,
-       .unhash            = udp_lib_unhash,
-       .rehash            = udp_v4_rehash,
-       .get_port          = udp_v4_get_port,
-
-       .memory_allocated  = &net_aligned_data.udp_memory_allocated,
-       .per_cpu_fw_alloc  = &udp_memory_per_cpu_fw_alloc,
-
-       .sysctl_mem        = sysctl_udp_mem,
-       .sysctl_wmem_offset = offsetof(struct net, ipv4.sysctl_udp_wmem_min),
-       .sysctl_rmem_offset = offsetof(struct net, ipv4.sysctl_udp_rmem_min),
-       .obj_size          = sizeof(struct udp_sock),
-       .h.udp_table       = &udplite_table,
-};
-EXPORT_SYMBOL(udplite_prot);
-
-static struct inet_protosw udplite4_protosw = {
-       .type           =  SOCK_DGRAM,
-       .protocol       =  IPPROTO_UDPLITE,
-       .prot           =  &udplite_prot,
-       .ops            =  &inet_dgram_ops,
-       .flags          =  INET_PROTOSW_PERMANENT,
-};
-
-#ifdef CONFIG_PROC_FS
-static struct udp_seq_afinfo udplite4_seq_afinfo = {
-       .family         = AF_INET,
-       .udp_table      = &udplite_table,
-};
-
-static int __net_init udplite4_proc_init_net(struct net *net)
-{
-       if (!proc_create_net_data("udplite", 0444, net->proc_net, &udp_seq_ops,
-                       sizeof(struct udp_iter_state), &udplite4_seq_afinfo))
-               return -ENOMEM;
-       return 0;
-}
-
-static void __net_exit udplite4_proc_exit_net(struct net *net)
-{
-       remove_proc_entry("udplite", net->proc_net);
-}
-
-static struct pernet_operations udplite4_net_ops = {
-       .init = udplite4_proc_init_net,
-       .exit = udplite4_proc_exit_net,
-};
-
-static __init int udplite4_proc_init(void)
-{
-       return register_pernet_subsys(&udplite4_net_ops);
-}
-#else
-static inline int udplite4_proc_init(void)
-{
-       return 0;
-}
-#endif
-
-void __init udplite4_register(void)
-{
-       udp_table_init(&udplite_table, "UDP-Lite");
-       if (proto_register(&udplite_prot, 1))
-               goto out_register_err;
-
-       if (inet_add_protocol(&udplite_protocol, IPPROTO_UDPLITE) < 0)
-               goto out_unregister_proto;
-
-       inet_register_protosw(&udplite4_protosw);
-
-       if (udplite4_proc_init())
-               pr_err("%s: Cannot register /proc!\n", __func__);
-       return;
-
-out_unregister_proto:
-       proto_unregister(&udplite_prot);
-out_register_err:
-       pr_crit("%s: Cannot add UDP-Lite protocol\n", __func__);
-}