Skip to contentSkip to conversation

udp: Farewell to UDP-Lite.

PATCH In review Kuniyuki Iwashima 6 participants 29 messages May 30, 2023 – May 31, 2023

Subsystems (8)
lore
Share & tools
lore
#0 lore raw

cover udp: Farewell to UDP-Lite.

Recently syzkaller reported a 7-year-old null-ptr-deref [0] that occurs when a UDP-Lite socket tries to allocate a buffer under memory pressure.

Someone should have stumbled on the bug much earlier if UDP-Lite had been used in a real app. Additionally, we do not always need a large UDP-Lite workload to hit the bug since UDP and UDP-Lite share the same memory accounting limit.

Given no one uses UDP-Lite, we can drop it and simplify UDP code by removing a bunch of conditionals.

This series removes UDP-Lite support from the core networking stack first and incrementally removes the dead code.

[0]: https://lore.kernel.org/netdev/[email protected]/

Kuniyuki Iwashima (14):
udp: Random clenaup.
udplite: Retire UDP-Lite for IPv6.
ipv6: Remove IPV6_ADDRFORM support for IPPROTO_UDPLITE.
udplite: Retire UDP-Lite for IPv4.
udp: Remove UDP-Lite SNMP stats.
udp: Remove UDPLITE_SEND_CSCOV and UDPLITE_RECV_CSCOV.
udp: Remove pcslen, pcrlen, and pcflag in struct udp_sock.
udp: Remove csum branch for UDP-Lite.
udp: Don't pass proto to udp[46]_csum_init().
udp: Don't pass proto to __udp[46]_lib_rcv().
udp: Optimise ulen tests in __udp[46]_lib_rcv().
udp: Remove udp_table in struct proto.
udp: Remove udp_table in struct udp_seq_afinfo.
udp: Don't pass udp_table to __udp[46]_lib_lookup().

 include/linux/udp.h        |  14 +-
 include/net/ip6_checksum.h |   1 -
 include/net/ipv6.h         |   2 -
 include/net/ipv6_stubs.h   |   3 +-
 include/net/netns/mib.h    |   5 -
 include/net/sock.h         |   5 +-
 include/net/transp_v6.h    |   3 -
 include/net/udp.h          |  71 +++----
 include/net/udplite.h      |  86 --------
 net/core/filter.c          |   5 +-
 net/ipv4/Makefile          |   2 +-
 net/ipv4/af_inet.c         |  10 -
 net/ipv4/proc.c            |  15 --
 net/ipv4/udp.c             | 421 ++++++++++++-------------------------
 net/ipv4/udp_bpf.c         |   2 -
 net/ipv4/udp_diag.c        |  84 ++------
 net/ipv4/udp_impl.h        |  29 ---
 net/ipv4/udp_offload.c     |   5 +-
 net/ipv4/udplite.c         | 136 ------------
 net/ipv6/Makefile          |   2 +-
 net/ipv6/af_inet6.c        |  25 +--
 net/ipv6/ip6_checksum.c    |  49 +----
 net/ipv6/ipv6_sockglue.c   |  17 +-
 net/ipv6/proc.c            |  16 --
 net/ipv6/udp.c             | 294 ++++++++++++--------------
 net/ipv6/udp_impl.h        |  31 ---
 net/ipv6/udp_offload.c     |   5 +-
 net/ipv6/udplite.c         | 136 ------------
 28 files changed, 330 insertions(+), 1144 deletions(-)
 delete mode 100644 include/net/udplite.h
 delete mode 100644 net/ipv4/udp_impl.h
 delete mode 100644 net/ipv4/udplite.c
 delete mode 100644 net/ipv6/udp_impl.h
 delete mode 100644 net/ipv6/udplite.c
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/14 udp: Random clenaup.

This is preparation patch to make the following diff smaller.

No functional changes are intended:

- Keep Reverse Xmas Tree Order
- Define struct net instead of using sock_net() repeatedly

---
 net/ipv4/udp.c | 68 +++++++++++++++++++++++++++-----------------------
 net/ipv6/udp.c | 58 +++++++++++++++++++++++-------------------
 2 files changed, 69 insertions(+), 57 deletions(-)
net/ipv4/udp.c +37 -31
index fd3dae081f3a..7a874c497cbd 100644
@@ -901,16 +901,17 @@ EXPORT_SYMBOL(udp_set_csum);
 static int udp_send_skb(struct sk_buff *skb, struct flowi4 *fl4,
 			struct inet_cork *cork)
 {
+	int err, len, datalen, is_udplite;
 	struct sock *sk = skb->sk;
-	struct inet_sock *inet = inet_sk(sk);
+	struct inet_sock *inet;
 	struct udphdr *uh;
-	int err;
-	int is_udplite = IS_UDPLITE(sk);
-	int offset = skb_transport_offset(skb);
-	int len = skb->len - offset;
-	int datalen = len - sizeof(*uh);
 	__wsum csum = 0;
 
+	inet = inet_sk(sk);
+	is_udplite = IS_UDPLITE(sk);
+	len = skb->len - skb_transport_offset(skb);
+	datalen = len - sizeof(*uh);
+
 	/*
 	 * Create a UDP header
 	 */
@@ -1051,24 +1052,25 @@ EXPORT_SYMBOL_GPL(udp_cmsg_send);
 
 int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
 {
+	int (*getfrag)(void *, char *, int, int, int, struct sk_buff *);
+	DECLARE_SOCKADDR(struct sockaddr_in *, usin, msg->msg_name);
 	struct inet_sock *inet = inet_sk(sk);
 	struct udp_sock *up = udp_sk(sk);
-	DECLARE_SOCKADDR(struct sockaddr_in *, usin, msg->msg_name);
+	struct ip_options_data opt_copy;
+	int is_udplite = IS_UDPLITE(sk);
+	__be32 daddr, faddr, saddr;
+	struct rtable *rt = NULL;
 	struct flowi4 fl4_stack;
-	struct flowi4 *fl4;
-	int ulen = len;
 	struct ipcm_cookie ipc;
-	struct rtable *rt = NULL;
-	int free = 0;
+	struct sk_buff *skb;
+	struct flowi4 *fl4;
 	int connected = 0;
-	__be32 daddr, faddr, saddr;
+	int ulen = len;
 	u8 tos, scope;
 	__be16 dport;
-	int err, is_udplite = IS_UDPLITE(sk);
-	int corkreq = READ_ONCE(up->corkflag) || msg->msg_flags&MSG_MORE;
-	int (*getfrag)(void *, char *, int, int, int, struct sk_buff *);
-	struct sk_buff *skb;
-	struct ip_options_data opt_copy;
+	int free = 0;
+	int corkreq;
+	int err;
 
 	if (len > 0xFFFF)
 		return -EMSGSIZE;
@@ -1080,6 +1082,7 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
 	if (msg->msg_flags & MSG_OOB) /* Mirror BSD error message compatibility */
 		return -EOPNOTSUPP;
 
+	corkreq = READ_ONCE(up->corkflag) || msg->msg_flags & MSG_MORE;
 	getfrag = is_udplite ? udplite_getfrag : ip_generic_getfrag;
 
 	fl4 = &inet->cork.fl.u.ip4;
@@ -1805,13 +1808,13 @@ EXPORT_SYMBOL(udp_read_skb);
 int udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int flags,
 		int *addr_len)
 {
-	struct inet_sock *inet = inet_sk(sk);
 	DECLARE_SOCKADDR(struct sockaddr_in *, sin, msg->msg_name);
-	struct sk_buff *skb;
-	unsigned int ulen, copied;
 	int off, err, peeking = flags & MSG_PEEK;
+	struct inet_sock *inet = inet_sk(sk);
 	int is_udplite = IS_UDPLITE(sk);
 	bool checksum_valid = false;
+	unsigned int ulen, copied;
+	struct sk_buff *skb;
 
 	if (flags & MSG_ERRQUEUE)
 		return ip_recv_error(sk, msg, len, addr_len);
@@ -1965,9 +1968,9 @@ void udp_lib_unhash(struct sock *sk)
 	if (sk_hashed(sk)) {
 		struct udp_table *udptable = udp_get_table_prot(sk);
 		struct udp_hslot *hslot, *hslot2;
+		struct net *net = sock_net(sk);
 
-		hslot  = udp_hashslot(udptable, sock_net(sk),
-				      udp_sk(sk)->udp_port_hash);
+		hslot  = udp_hashslot(udptable, net, udp_sk(sk)->udp_port_hash);
 		hslot2 = udp_hashslot2(udptable, udp_sk(sk)->udp_portaddr_hash);
 
 		spin_lock_bh(&hslot->lock);
@@ -1976,7 +1979,7 @@ void udp_lib_unhash(struct sock *sk)
 		if (sk_del_node_init_rcu(sk)) {
 			hslot->count--;
 			inet_sk(sk)->inet_num = 0;
-			sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
+			sock_prot_inuse_add(net, sk->sk_prot, -1);
 
 			spin_lock(&hslot2->lock);
 			hlist_del_init_rcu(&udp_sk(sk)->udp_portaddr_node);
@@ -1996,6 +1999,7 @@ void udp_lib_rehash(struct sock *sk, u16 newhash)
 	if (sk_hashed(sk)) {
 		struct udp_table *udptable = udp_get_table_prot(sk);
 		struct udp_hslot *hslot, *hslot2, *nhslot2;
+		struct net *net = sock_net(sk);
 
 		hslot2 = udp_hashslot2(udptable, udp_sk(sk)->udp_portaddr_hash);
 		nhslot2 = udp_hashslot2(udptable, newhash);
@@ -2003,8 +2007,7 @@ void udp_lib_rehash(struct sock *sk, u16 newhash)
 
 		if (hslot2 != nhslot2 ||
 		    rcu_access_pointer(sk->sk_reuseport_cb)) {
-			hslot = udp_hashslot(udptable, sock_net(sk),
-					     udp_sk(sk)->udp_port_hash);
+			hslot = udp_hashslot(udptable, net, udp_sk(sk)->udp_port_hash);
 			/* we must lock primary chain too */
 			spin_lock_bh(&hslot->lock);
 			if (rcu_access_pointer(sk->sk_reuseport_cb))
@@ -2239,15 +2242,18 @@ static int __udp4_lib_mcast_deliver(struct net *net, struct sk_buff *skb,
 				    struct udp_table *udptable,
 				    int proto)
 {
-	struct sock *sk, *first = NULL;
+	int dif = skb->dev->ifindex, sdif = inet_sdif(skb);
+	unsigned int offset, hash2 = 0, hash2_any = 0;
 	unsigned short hnum = ntohs(uh->dest);
-	struct udp_hslot *hslot = udp_hashslot(udptable, net, hnum);
-	unsigned int hash2 = 0, hash2_any = 0, use_hash2 = (hslot->count > 10);
-	unsigned int offset = offsetof(typeof(*sk), sk_node);
-	int dif = skb->dev->ifindex;
-	int sdif = inet_sdif(skb);
+	struct sock *sk, *first = NULL;
 	struct hlist_node *node;
+	struct udp_hslot *hslot;
 	struct sk_buff *nskb;
+	bool use_hash2;
+
+	hslot = udp_hashslot(udptable, net, hnum);
+	offset = offsetof(typeof(*sk), sk_node);
+	use_hash2 = hslot->count > 10;
 
 	if (use_hash2) {
 		hash2_any = ipv4_portaddr_hash(net, htonl(INADDR_ANY), hnum) &
net/ipv6/udp.c +32 -26

108 lines not on this page · raw message

Signature · 1 line
2.30.2
#3 lore raw

PATCH 2/14 udplite: Retire UDP-Lite for IPv6.

In reply to Kuniyuki Iwashima

We no longer support IPPROTO_UDPLITE for AF_INET6.

This commit removes udplite.c and udp_impl.h under net/ipv6 and makes some functions static that UDP shared.

Note that udplite.h is included in udp.c temporarily not to introduce breakage, but we will remove it later with dead code.

---
 include/net/ipv6.h      |   2 -
 include/net/transp_v6.h |   3 -
 net/ipv6/Makefile       |   2 +-
 net/ipv6/af_inet6.c     |  19 +-----
 net/ipv6/proc.c         |   2 -
 net/ipv6/udp.c          |  31 ++++-----
 net/ipv6/udp_impl.h     |  31 ---------
 net/ipv6/udplite.c      | 136 ----------------------------------------
 8 files changed, 18 insertions(+), 208 deletions(-)
 delete mode 100644 net/ipv6/udp_impl.h
 delete mode 100644 net/ipv6/udplite.c
include/net/ipv6.h +0 -2
index 7332296eca44..c180c03e4e69 100644
@@ -1258,8 +1258,6 @@ int tcp6_proc_init(struct net *net);
 void tcp6_proc_exit(struct net *net);
 int udp6_proc_init(struct net *net);
 void udp6_proc_exit(struct net *net);
-int udplite6_proc_init(void);
-void udplite6_proc_exit(void);
 int ipv6_misc_proc_init(void);
 void ipv6_misc_proc_exit(void);
 int snmp6_register_dev(struct inet6_dev *idev);
include/net/transp_v6.h +0 -3
index d27b1caf3753..76211668055b 100644
@@ -8,7 +8,6 @@
 /* IPv6 transport protocols */
 extern struct proto rawv6_prot;
 extern struct proto udpv6_prot;
-extern struct proto udplitev6_prot;
 extern struct proto tcpv6_prot;
 extern struct proto pingv6_prot;
 
@@ -28,8 +27,6 @@ int rawv6_init(void);
 void rawv6_exit(void);
 int udpv6_init(void);
 void udpv6_exit(void);
-int udplitev6_init(void);
-void udplitev6_exit(void);
 int tcpv6_init(void);
 void tcpv6_exit(void);
 
net/ipv6/Makefile +1 -1
index 3036a45e8a1e..63b7830d8146 100644
@@ -7,7 +7,7 @@ obj-$(CONFIG_IPV6) += ipv6.o
 
 ipv6-y :=	af_inet6.o anycast.o ip6_output.o ip6_input.o addrconf.o \
 		addrlabel.o \
-		route.o ip6_fib.o ipv6_sockglue.o ndisc.o udp.o udplite.o \
+		route.o ip6_fib.o ipv6_sockglue.o ndisc.o udp.o \
 		raw.o icmp.o mcast.o reassembly.o tcp_ipv6.o ping.o \
 		exthdrs.o datagram.o ip6_flowlabel.o inet6_connection_sock.o \
 		udp_offload.o seg6.o fib6_notifier.o rpl.o ioam6.o
net/ipv6/af_inet6.c +1 -18
index 2bbf13216a3d..ca360680fae0 100644
@@ -43,7 +43,6 @@
 #include <net/ip.h>
 #include <net/ipv6.h>
 #include <net/udp.h>
-#include <net/udplite.h>
 #include <net/tcp.h>
 #include <net/ping.h>
 #include <net/protocol.h>
@@ -1086,13 +1085,9 @@ static int __init inet6_init(void)
 	if (err)
 		goto out_unregister_tcp_proto;
 
-	err = proto_register(&udplitev6_prot, 1);
-	if (err)
-		goto out_unregister_udp_proto;
-
 	err = proto_register(&rawv6_prot, 1);
 	if (err)
-		goto out_unregister_udplite_proto;
+		goto out_unregister_udp_proto;
 
 	err = proto_register(&pingv6_prot, 1);
 	if (err)
@@ -1143,8 +1138,6 @@ static int __init inet6_init(void)
 	err = -ENOMEM;
 	if (raw6_proc_init())
 		goto proc_raw6_fail;
-	if (udplite6_proc_init())
-		goto proc_udplite6_fail;
 	if (ipv6_misc_proc_init())
 		goto proc_misc6_fail;
 	if (if6_proc_init())
@@ -1180,10 +1173,6 @@ static int __init inet6_init(void)
 	if (err)
 		goto udpv6_fail;
 
-	err = udplitev6_init();
-	if (err)
-		goto udplitev6_fail;
-
 	err = udpv6_offload_init();
 	if (err)
 		goto udpv6_offload_fail;
@@ -1254,8 +1243,6 @@ static int __init inet6_init(void)
 tcpv6_fail:
 	udpv6_offload_exit();
 udpv6_offload_fail:
-	udplitev6_exit();
-udplitev6_fail:
 	udpv6_exit();
 udpv6_fail:
 	ipv6_frag_exit();
@@ -1277,8 +1264,6 @@ static int __init inet6_init(void)
 proc_if6_fail:
 	ipv6_misc_proc_exit();
 proc_misc6_fail:
-	udplite6_proc_exit();
-proc_udplite6_fail:
 	raw6_proc_exit();
 proc_raw6_fail:
 #endif
@@ -1302,8 +1287,6 @@ static int __init inet6_init(void)
 	proto_unregister(&pingv6_prot);
 out_unregister_raw_proto:
 	proto_unregister(&rawv6_prot);
-out_unregister_udplite_proto:
-	proto_unregister(&udplitev6_prot);
 out_unregister_udp_proto:
 	proto_unregister(&udpv6_prot);
 out_unregister_tcp_proto:
net/ipv6/proc.c +0 -2
index e20b3705c2d2..91bcd4525494 100644
@@ -39,8 +39,6 @@ static int sockstat6_seq_show(struct seq_file *seq, void *v)
 		       sock_prot_inuse_get(net, &tcpv6_prot));
 	seq_printf(seq, "UDP6: inuse %d\n",
 		       sock_prot_inuse_get(net, &udpv6_prot));
-	seq_printf(seq, "UDPLITE6: inuse %d\n",
-			sock_prot_inuse_get(net, &udplitev6_prot));
 	seq_printf(seq, "RAW6: inuse %d\n",
 		       sock_prot_inuse_get(net, &rawv6_prot));
 	seq_printf(seq, "FRAG6: inuse %u memory %lu\n",
net/ipv6/udp.c +16 -15
index 2ec611c2f964..bc3f7ac8c28a 100644
@@ -50,11 +50,12 @@
 #include <net/inet6_hashtables.h>
 #include <net/busy_poll.h>
 #include <net/sock_reuseport.h>
+#include <net/udp.h>
+#include <net/udplite.h>
 
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <trace/events/skb.h>
-#include "udp_impl.h"
 
 static void udpv6_destruct_sock(struct sock *sk)
 {
@@ -62,7 +63,7 @@ static void udpv6_destruct_sock(struct sock *sk)
 	inet6_sock_destruct(sk);
 }
 
-int udpv6_init_sock(struct sock *sk)
+static int udpv6_init_sock(struct sock *sk)
 {
 	udp_lib_init_sock(sk);
 	sk->sk_destruct = udpv6_destruct_sock;
@@ -93,7 +94,7 @@ static u32 udp6_ehashfn(const struct net *net,
 			       udp_ipv6_hash_secret + net_hash_mix(net));
 }
 
-int udp_v6_get_port(struct sock *sk, unsigned short snum)
+static int udp_v6_get_port(struct sock *sk, unsigned short snum)
 {
 	unsigned int hash2_nulladdr =
 		ipv6_portaddr_hash(sock_net(sk), &in6addr_any, snum);
@@ -105,7 +106,7 @@ int udp_v6_get_port(struct sock *sk, unsigned short snum)
 	return udp_lib_get_port(sk, snum, hash2_nulladdr);
 }
 
-void udp_v6_rehash(struct sock *sk)
+static void udp_v6_rehash(struct sock *sk)
 {
 	u16 new_hash = ipv6_portaddr_hash(sock_net(sk),
 					  &sk->sk_v6_rcv_saddr,
@@ -572,9 +573,9 @@ static struct sock *__udp6_lib_err_encap(struct net *net,
 	return sk;
 }
 
-int __udp6_lib_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
-		   u8 type, u8 code, int offset, __be32 info,
-		   struct udp_table *udptable)
+static int __udp6_lib_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
+			  u8 type, u8 code, int offset, __be32 info,
+			  struct udp_table *udptable)
 {
 	struct ipv6_pinfo *np;
 	const struct ipv6hdr *hdr = (const struct ipv6hdr *)skb->data;
@@ -944,8 +945,8 @@ static int udp6_unicast_rcv_skb(struct sock *sk, struct sk_buff *skb,
 	return 0;
 }
 
-int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
-		   int proto)
+static int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
+			  int proto)
 {
 	enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
 	const struct in6_addr *saddr, *daddr;
@@ -1659,7 +1660,7 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
 }
 EXPORT_SYMBOL(udpv6_sendmsg);
 
-void udpv6_destroy_sock(struct sock *sk)
+static void udpv6_destroy_sock(struct sock *sk)
 {
 	struct udp_sock *up = udp_sk(sk);
 	lock_sock(sk);
@@ -1686,8 +1687,8 @@ void udpv6_destroy_sock(struct sock *sk)
 /*
  *	Socket option code for UDP
  */
-int udpv6_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval,
-		     unsigned int optlen)
+static int udpv6_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,
@@ -1696,8 +1697,8 @@ int udpv6_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval,
 	return ipv6_setsockopt(sk, level, optname, optval, optlen);
 }
 
-int udpv6_getsockopt(struct sock *sk, int level, int optname,
-		     char __user *optval, int __user *optlen)
+static int udpv6_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);
@@ -1712,7 +1713,7 @@ static const struct inet6_protocol udpv6_protocol = {
 
 /* ------------------------------------------------------------------------ */
 #ifdef CONFIG_PROC_FS
-int udp6_seq_show(struct seq_file *seq, void *v)
+static int udp6_seq_show(struct seq_file *seq, void *v)
 {
 	if (v == SEQ_START_TOKEN) {
 		seq_puts(seq, IPV6_SEQ_DGRAM_HEADER);
net/ipv6/udp_impl.h deleted +0 -31
deleted file mode 100644
index 0590f566379d..000000000000
@@ -1,31 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _UDP6_IMPL_H
-#define _UDP6_IMPL_H
-#include <net/udp.h>
-#include <net/udplite.h>
-#include <net/protocol.h>
-#include <net/addrconf.h>
-#include <net/inet_common.h>
-#include <net/transp_v6.h>
-
-int __udp6_lib_rcv(struct sk_buff *, struct udp_table *, int);
-int __udp6_lib_err(struct sk_buff *, struct inet6_skb_parm *, u8, u8, int,
-		   __be32, struct udp_table *);
-
-int udpv6_init_sock(struct sock *sk);
-int udp_v6_get_port(struct sock *sk, unsigned short snum);
-void udp_v6_rehash(struct sock *sk);
-
-int udpv6_getsockopt(struct sock *sk, int level, int optname,
-		     char __user *optval, int __user *optlen);
-int udpv6_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval,
-		     unsigned int optlen);
-int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len);
-int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int flags,
-		  int *addr_len);
-void udpv6_destroy_sock(struct sock *sk);
-
-#ifdef CONFIG_PROC_FS
-int udp6_seq_show(struct seq_file *seq, void *v);
-#endif
-#endif	/* _UDP6_IMPL_H */
net/ipv6/udplite.c deleted +0 -136

136 lines not on this page · raw message

Signature · 1 line
2.30.2
#6 lore raw

PATCH 3/14 ipv6: Remove IPV6_ADDRFORM support for IPPROTO_UDPLITE.

In reply to Kuniyuki Iwashima

The previous commit removes UDP-Lite v6 support, so conversion from UDP-Lite v6 to v4 never occurs.

---
 net/ipv6/ipv6_sockglue.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)
net/ipv6/ipv6_sockglue.c +4 -13
index ae818ff46224..150cd6620315 100644
@@ -45,7 +45,6 @@
 #include <net/inet_common.h>
 #include <net/tcp.h>
 #include <net/udp.h>
-#include <net/udplite.h>
 #include <net/xfrm.h>
 #include <net/compat.h>
 #include <net/seg6.h>
@@ -434,10 +433,8 @@ int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
 			if (sk->sk_type == SOCK_RAW)
 				break;
 
-			if (sk->sk_protocol == IPPROTO_UDP ||
-			    sk->sk_protocol == IPPROTO_UDPLITE) {
-				struct udp_sock *up = udp_sk(sk);
-				if (up->pending == AF_INET6) {
+			if (sk->sk_protocol == IPPROTO_UDP) {
+				if (udp_sk(sk)->pending == AF_INET6) {
 					retv = -EBUSY;
 					break;
 				}
@@ -478,16 +475,11 @@ int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
 				sk->sk_family = PF_INET;
 				tcp_sync_mss(sk, icsk->icsk_pmtu_cookie);
 			} else {
-				struct proto *prot = &udp_prot;
-
-				if (sk->sk_protocol == IPPROTO_UDPLITE)
-					prot = &udplite_prot;
-
 				sock_prot_inuse_add(net, sk->sk_prot, -1);
-				sock_prot_inuse_add(net, prot, 1);
+				sock_prot_inuse_add(net, &udp_prot, 1);
 
 				/* Paired with READ_ONCE(sk->sk_prot) in inet6_dgram_ops */
-				WRITE_ONCE(sk->sk_prot, prot);
+				WRITE_ONCE(sk->sk_prot, &udp_prot);
 				sk->sk_socket->ops = &inet_dgram_ops;
 				sk->sk_family = PF_INET;
 			}
@@ -1137,7 +1129,6 @@ int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
 	switch (optname) {
 	case IPV6_ADDRFORM:
 		if (sk->sk_protocol != IPPROTO_UDP &&
-		    sk->sk_protocol != IPPROTO_UDPLITE &&
 		    sk->sk_protocol != IPPROTO_TCP)
 			return -ENOPROTOOPT;
 		if (sk->sk_state != TCP_ESTABLISHED)
Signature · 1 line
2.30.2
#9 lore raw

PATCH 5/14 udp: Remove UDP-Lite SNMP stats.

In reply to Kuniyuki Iwashima

We stored UDP-Lite stats in udplite_statistics and udplite_stats_in6 of struct netns_mib.

Since UDP and UDP-Lite share code, UDP_INC_STATS() always has to check if the socket is UDP-Lite. However, we no longer increment UDP-Lite stats.

Let's remove the stats and save one protocol test.

---
 include/net/netns/mib.h |  5 ---
 include/net/udp.h       | 43 +++++++++--------------
 net/ipv4/af_inet.c      |  6 ----
 net/ipv4/proc.c         | 13 -------
 net/ipv4/udp.c          | 76 ++++++++++++++++++-----------------------
 net/ipv6/af_inet6.c     |  6 ----
 net/ipv6/proc.c         | 14 --------
 net/ipv6/udp.c          | 48 +++++++++++---------------
 8 files changed, 69 insertions(+), 142 deletions(-)
include/net/netns/mib.h +0 -5
index 7e373664b1e7..dce05f8e6a33 100644
@@ -28,11 +28,6 @@ struct netns_mib {
 	DEFINE_SNMP_STAT(struct mptcp_mib, mptcp_statistics);
 #endif
 
-	DEFINE_SNMP_STAT(struct udp_mib, udplite_statistics);
-#if IS_ENABLED(CONFIG_IPV6)
-	DEFINE_SNMP_STAT(struct udp_mib, udplite_stats_in6);
-#endif
-
 	DEFINE_SNMP_STAT(struct icmp_mib, icmp_statistics);
 	DEFINE_SNMP_STAT_ATOMIC(struct icmpmsg_mib, icmpmsg_statistics);
 #if IS_ENABLED(CONFIG_IPV6)
include/net/udp.h +17 -26

54 lines not on this page · raw message

net/ipv4/af_inet.c +0 -6
index bf9fdce5bd05..332a01ffd550 100644
@@ -1769,9 +1769,6 @@ static __net_init int ipv4_mib_init_net(struct net *net)
 	net->mib.udp_statistics = alloc_percpu(struct udp_mib);
 	if (!net->mib.udp_statistics)
 		goto err_udp_mib;
-	net->mib.udplite_statistics = alloc_percpu(struct udp_mib);
-	if (!net->mib.udplite_statistics)
-		goto err_udplite_mib;
 	net->mib.icmp_statistics = alloc_percpu(struct icmp_mib);
 	if (!net->mib.icmp_statistics)
 		goto err_icmp_mib;
@@ -1786,8 +1783,6 @@ static __net_init int ipv4_mib_init_net(struct net *net)
 err_icmpmsg_mib:
 	free_percpu(net->mib.icmp_statistics);
 err_icmp_mib:
-	free_percpu(net->mib.udplite_statistics);
-err_udplite_mib:
 	free_percpu(net->mib.udp_statistics);
 err_udp_mib:
 	free_percpu(net->mib.net_statistics);
@@ -1803,7 +1798,6 @@ static __net_exit void ipv4_mib_exit_net(struct net *net)
 {
 	kfree(net->mib.icmpmsg_statistics);
 	free_percpu(net->mib.icmp_statistics);
-	free_percpu(net->mib.udplite_statistics);
 	free_percpu(net->mib.udp_statistics);
 	free_percpu(net->mib.net_statistics);
 	free_percpu(net->mib.ip_statistics);
net/ipv4/proc.c +0 -13
index 7cf33b1763ed..d27e92fc45c1 100644
@@ -34,7 +34,6 @@
 #include <net/tcp.h>
 #include <net/mptcp.h>
 #include <net/udp.h>
-#include <net/udplite.h>
 #include <linux/bottom_half.h>
 #include <linux/inetdevice.h>
 #include <linux/proc_fs.h>
@@ -434,18 +433,6 @@ static int snmp_seq_show_tcp_udp(struct seq_file *seq, void *v)
 	for (i = 0; snmp4_udp_list[i].name; i++)
 		seq_printf(seq, " %lu", buff[i]);
 
-	memset(buff, 0, TCPUDP_MIB_MAX * sizeof(unsigned long));
-
-	/* the UDP and UDP-Lite MIBs are the same */
-	seq_puts(seq, "\nUdpLite:");
-	snmp_get_cpu_field_batch(buff, snmp4_udp_list,
-				 net->mib.udplite_statistics);
-	for (i = 0; snmp4_udp_list[i].name; i++)
-		seq_printf(seq, " %s", snmp4_udp_list[i].name);
-	seq_puts(seq, "\nUdpLite:");
-	for (i = 0; snmp4_udp_list[i].name; i++)
-		seq_printf(seq, " %lu", buff[i]);
-
 	seq_putc(seq, '\n');
 	return 0;
 }
net/ipv4/udp.c +33 -43

186 lines not on this page · raw message

net/ipv6/af_inet6.c +0 -6
index ca360680fae0..16df217be69d 100644
@@ -899,9 +899,6 @@ static int __net_init ipv6_init_mibs(struct net *net)
 	net->mib.udp_stats_in6 = alloc_percpu(struct udp_mib);
 	if (!net->mib.udp_stats_in6)
 		return -ENOMEM;
-	net->mib.udplite_stats_in6 = alloc_percpu(struct udp_mib);
-	if (!net->mib.udplite_stats_in6)
-		goto err_udplite_mib;
 	net->mib.ipv6_statistics = alloc_percpu(struct ipstats_mib);
 	if (!net->mib.ipv6_statistics)
 		goto err_ip_mib;
@@ -927,8 +924,6 @@ static int __net_init ipv6_init_mibs(struct net *net)
 err_icmp_mib:
 	free_percpu(net->mib.ipv6_statistics);
 err_ip_mib:
-	free_percpu(net->mib.udplite_stats_in6);
-err_udplite_mib:
 	free_percpu(net->mib.udp_stats_in6);
 	return -ENOMEM;
 }
@@ -936,7 +931,6 @@ static int __net_init ipv6_init_mibs(struct net *net)
 static void ipv6_cleanup_mibs(struct net *net)
 {
 	free_percpu(net->mib.udp_stats_in6);
-	free_percpu(net->mib.udplite_stats_in6);
 	free_percpu(net->mib.ipv6_statistics);
 	free_percpu(net->mib.icmpv6_statistics);
 	kfree(net->mib.icmpv6msg_statistics);
net/ipv6/proc.c +0 -14
index 91bcd4525494..5b431057969c 100644
@@ -129,18 +129,6 @@ static const struct snmp_mib snmp6_udp6_list[] = {
 	SNMP_MIB_SENTINEL
 };
 
-static const struct snmp_mib snmp6_udplite6_list[] = {
-	SNMP_MIB_ITEM("UdpLite6InDatagrams", UDP_MIB_INDATAGRAMS),
-	SNMP_MIB_ITEM("UdpLite6NoPorts", UDP_MIB_NOPORTS),
-	SNMP_MIB_ITEM("UdpLite6InErrors", UDP_MIB_INERRORS),
-	SNMP_MIB_ITEM("UdpLite6OutDatagrams", UDP_MIB_OUTDATAGRAMS),
-	SNMP_MIB_ITEM("UdpLite6RcvbufErrors", UDP_MIB_RCVBUFERRORS),
-	SNMP_MIB_ITEM("UdpLite6SndbufErrors", UDP_MIB_SNDBUFERRORS),
-	SNMP_MIB_ITEM("UdpLite6InCsumErrors", UDP_MIB_CSUMERRORS),
-	SNMP_MIB_ITEM("UdpLite6MemErrors", UDP_MIB_MEMERRORS),
-	SNMP_MIB_SENTINEL
-};
-
 static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, atomic_long_t *smib)
 {
 	char name[32];
@@ -222,8 +210,6 @@ static int snmp6_seq_show(struct seq_file *seq, void *v)
 	snmp6_seq_show_icmpv6msg(seq, net->mib.icmpv6msg_statistics->mibs);
 	snmp6_seq_show_item(seq, net->mib.udp_stats_in6,
 			    NULL, snmp6_udp6_list);
-	snmp6_seq_show_item(seq, net->mib.udplite_stats_in6,
-			    NULL, snmp6_udplite6_list);
 	return 0;
 }
 
net/ipv6/udp.c +19 -29

121 lines not on this page · raw message

Signature · 1 line
2.30.2
#8 lore raw

PATCH 4/14 udplite: Retire UDP-Lite for IPv4.

In reply to Kuniyuki Iwashima

We no longer support IPPROTO_UDPLITE for AF_INET.

This commit removes udplite.c and udp_impl.h under net/ipv4 and makes some functions static that UDP shared.

Also, we remove the SOCK_DIAG code for UDP-Lite.

Note that udplite.h is included in udp.c temporarily not to introduce breakage, but we will remove it later with dead code.

---
 include/net/sock.h    |   4 +-
 include/net/udp.h     |   5 +-
 include/net/udplite.h |   6 --
 net/ipv4/Makefile     |   2 +-
 net/ipv4/af_inet.c    |   4 --
 net/ipv4/proc.c       |   2 -
 net/ipv4/udp.c        |  36 +++++------
 net/ipv4/udp_bpf.c    |   2 -
 net/ipv4/udp_diag.c   |  46 +-------------
 net/ipv4/udp_impl.h   |  29 ---------
 net/ipv4/udplite.c    | 136 ------------------------------------------
 11 files changed, 25 insertions(+), 247 deletions(-)
 delete mode 100644 net/ipv4/udp_impl.h
 delete mode 100644 net/ipv4/udplite.c
include/net/sock.h +2 -2
index 656ea89f60ff..0b6c74bdd688 100644
@@ -133,14 +133,14 @@ typedef __u64 __bitwise __addrpair;
  *	@skc_net_refcnt: socket is using net ref counting
  *	@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 protocol
  *	@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 protocol
  *	@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
include/net/udp.h +2 -3
index 5cad44318d71..bfe62e73552a 100644
@@ -76,7 +76,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,
 					     struct net *net, unsigned int num)
 {
@@ -183,7 +183,7 @@ static inline void udp_lib_init_sock(struct sock *sk)
 	set_bit(SOCK_CUSTOM_SOCKOPT, &sk->sk_socket->flags);
 }
 
-/* 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();
@@ -284,7 +284,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, unsigned long arg);
-int udp_init_sock(struct sock *sk);
 int udp_pre_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len);
 int __udp_disconnect(struct sock *sk, int flags);
 int udp_disconnect(struct sock *sk, int flags);
include/net/udplite.h +0 -6
index 299c14ce2bb9..e436917f9b14 100644
@@ -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.
  */
@@ -80,7 +77,4 @@ static inline __wsum udplite_csum(struct sk_buff *skb)
 	return skb_checksum(skb, off, len, 0);
 }
 
-void udplite4_register(void);
-int udplite_get_port(struct sock *sk, unsigned short snum,
-		     int (*scmp)(const struct sock *, const struct sock *));
 #endif	/* _UDPLITE_H */
net/ipv4/Makefile +1 -1
index b18ba8ef93ad..a49e09f3f32a 100644
@@ -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_rate.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 \
net/ipv4/af_inet.c +0 -4
index 946650036c7f..bf9fdce5bd05 100644
@@ -102,7 +102,6 @@
 #include <net/gro.h>
 #include <net/tcp.h>
 #include <net/udp.h>
-#include <net/udplite.h>
 #include <net/ping.h>
 #include <linux/skbuff.h>
 #include <net/sock.h>
@@ -2009,9 +2008,6 @@ static int __init inet_init(void)
 	/* Setup UDP memory threshold */
 	udp_init();
 
-	/* Add UDP-Lite (RFC 3828) */
-	udplite4_register();
-
 	raw_init();
 
 	ping_init();
net/ipv4/proc.c +0 -2
index eaf1d3113b62..7cf33b1763ed 100644
@@ -64,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",
net/ipv4/udp.c +19 -17
index 7a874c497cbd..2e966ce4a41b 100644
@@ -99,6 +99,7 @@
 #include <linux/seq_file.h>
 #include <net/net_namespace.h>
 #include <net/icmp.h>
+#include <net/inet_common.h>
 #include <net/inet_hashtables.h>
 #include <net/ip_tunnels.h>
 #include <net/route.h>
@@ -109,9 +110,10 @@
 #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.h>
+#include <net/udplite.h>
 #include <net/udp_tunnel.h>
 #if IS_ENABLED(CONFIG_IPV6)
 #include <net/ipv6_stubs.h>
@@ -227,7 +229,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
@@ -349,7 +351,7 @@ int udp_lib_get_port(struct sock *sk, unsigned short snum,
 }
 EXPORT_SYMBOL(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);
@@ -712,7 +714,7 @@ static struct sock *__udp4_lib_err_encap(struct net *net,
  * 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;
@@ -1327,8 +1329,8 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
 }
 EXPORT_SYMBOL(udp_sendmsg);
 
-int udp_sendpage(struct sock *sk, struct page *page, int offset,
-		 size_t size, int flags)
+static int udp_sendpage(struct sock *sk, struct page *page, int offset,
+			size_t size, int flags)
 {
 	struct bio_vec bvec;
 	struct msghdr msg = { .msg_flags = flags | MSG_SPLICE_PAGES };
@@ -1591,7 +1593,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)
 {
 	udp_lib_init_sock(sk);
 	sk->sk_destruct = udp_destruct_sock;
@@ -2032,7 +2034,7 @@ void udp_lib_rehash(struct sock *sk, u16 newhash)
 }
 EXPORT_SYMBOL(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,
@@ -2376,8 +2378,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;
 	struct udphdr *uh;
@@ -2619,7 +2621,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);
@@ -2774,8 +2776,8 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname,
 }
 EXPORT_SYMBOL(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,
@@ -2845,8 +2847,8 @@ int udp_lib_getsockopt(struct sock *sk, int level, int optname,
 }
 EXPORT_SYMBOL(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);
@@ -3092,7 +3094,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
 		atomic_read(&sp->sk_drops));
 }
 
-int udp4_seq_show(struct seq_file *seq, void *v)
+static int udp4_seq_show(struct seq_file *seq, void *v)
 {
 	seq_setwidth(seq, 127);
 	if (v == SEQ_START_TOKEN)
@@ -3403,7 +3405,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;
 
net/ipv4/udp_bpf.c +0 -2
index 0735d820e413..90336d215f79 100644
@@ -6,8 +6,6 @@
 #include <net/udp.h>
 #include <net/inet_common.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,
net/ipv4/udp_diag.c +1 -45

73 lines not on this page · raw message

net/ipv4/udp_impl.h deleted +0 -29
deleted file mode 100644
index 4ba7a88a1b1d..000000000000
@@ -1,29 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _UDP4_IMPL_H
-#define _UDP4_IMPL_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,
-		int *addr_len);
-int udp_sendpage(struct sock *sk, struct page *page, int offset, size_t size,
-		 int flags);
-void udp_destroy_sock(struct sock *sk);
-
-#ifdef CONFIG_PROC_FS
-int udp4_seq_show(struct seq_file *seq, void *v);
-#endif
-#endif	/* _UDP4_IMPL_H */
net/ipv4/udplite.c deleted +0 -136

136 lines not on this page · raw message

Signature · 1 line
2.30.2
#11 lore raw

PATCH 6/14 udp: Remove UDPLITE_SEND_CSCOV and UDPLITE_RECV_CSCOV.

In reply to Kuniyuki Iwashima

We could set partial checksum coverage for UDP-Lite via setsockopt, but it's no longer supported.

---
 include/net/udplite.h |  4 ----
 net/ipv4/udp.c        | 45 ++-----------------------------------------
 net/ipv6/udp.c        |  4 ++--
 3 files changed, 4 insertions(+), 49 deletions(-)
include/net/udplite.h +0 -4
index e436917f9b14..f4c513cff753 100644
@@ -8,10 +8,6 @@
 #include <net/ip6_checksum.h>
 #include <net/udp.h>
 
-/* UDP-Lite socket options */
-#define UDPLITE_SEND_CSCOV   10 /* sender partial coverage (as sent)      */
-#define UDPLITE_RECV_CSCOV   11 /* receiver partial coverage (threshold ) */
-
 /*
  *	Checksum computation is all in software, hence simpler getfrag.
  */
net/ipv4/udp.c +2 -43

75 lines not on this page · raw message

net/ipv6/udp.c +2 -2
index 161686aa0dbe..ecd304bbecb4 100644
@@ -1680,7 +1680,7 @@ static void udpv6_destroy_sock(struct sock *sk)
 static int udpv6_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval,
 			    unsigned int optlen)
 {
-	if (level == SOL_UDP  ||  level == SOL_UDPLITE || level == SOL_SOCKET)
+	if (level == SOL_UDP || level == SOL_SOCKET)
 		return udp_lib_setsockopt(sk, level, optname,
 					  optval, optlen,
 					  udp_v6_push_pending_frames);
@@ -1690,7 +1690,7 @@ static int udpv6_setsockopt(struct sock *sk, int level, int optname, sockptr_t o
 static int udpv6_getsockopt(struct sock *sk, int level, int optname,
 			    char __user *optval, int __user *optlen)
 {
-	if (level == SOL_UDP  ||  level == SOL_UDPLITE)
+	if (level == SOL_UDP)
 		return udp_lib_getsockopt(sk, level, optname, optval, optlen);
 	return ipv6_getsockopt(sk, level, optname, optval, optlen);
 }
Signature · 1 line
2.30.2
#12 lore raw

PATCH 7/14 udp: Remove pcslen, pcrlen, and pcflag in struct udp_sock.

In reply to Kuniyuki Iwashima

We removed partial checksum coverage support in the previous commit; thus, udp_sk(sk)->{pcslen,pcrlen,pcflag} are always zero. We can safely remove the related code guarded by pcflag.

---
After removing these members, the layout of udp_sock changes as follows. We may want to move encap/gro functions on the last cache line to save one cache line ?

Before:

struct udp_sock {
        struct inet_sock           inet __attribute__((__aligned__(8))); /*     0   976 */

        /* XXX last struct has 4 bytes of padding */

        /* --- cacheline 15 boundary (960 bytes) was 16 bytes ago --- */

...
unsigned char accept_udp_fraglist:1; /* 985: 5 1 */

/* XXX 2 bits hole, try to pack */

__u16 len; /* 986 2 */
__u16 gso_size; /* 988 2 */
__u16 pcslen; /* 990 2 */
__u16 pcrlen; /* 992 2 */
__u8 pcflag; /* 994 1 */
__u8 unused[3]; /* 995 3 */

/* XXX 2 bytes hole, try to pack */

int (*encap_rcv)(struct sock *, struct sk_buff *); /* 1000 8 */
void (*encap_err_rcv)(struct sock *, struct sk_buff *, int, __be16, u32, u8 *); /* 1008 8 */
int (*encap_err_lookup)(struct sock *, struct sk_buff *); /* 1016 8 */
/* --- cacheline 16 boundary (1024 bytes) --- */
void (*encap_destroy)(struct sock *); /* 1024 8 */
struct sk_buff * (*gro_receive)(struct sock *, struct list_head *, struct sk_buff *); /* 1032 8 */
int (*gro_complete)(struct sock *, struct sk_buff *, int); /* 1040 8 */

/* XXX 40 bytes hole, try to pack */

/* --- cacheline 17 boundary (1088 bytes) --- */
struct sk_buff_head reader_queue __attribute__((__aligned__(64))); /* 1088 24 */
int forward_deficit; /* 1112 4 */
int forward_threshold; /* 1116 4 */

/* size: 1152, cachelines: 18, members: 25 */
/* sum members: 1077, holes: 2, sum holes: 42 */
/* sum bitfield members: 6 bits, bit holes: 1, sum bit holes: 2 bits */ /* padding: 32 */
/* paddings: 1, sum paddings: 4 */
/* forced alignments: 2, forced holes: 1, sum forced holes: 40 */
} __attribute__((__aligned__(64)));

After:

struct udp_sock {
        struct inet_sock           inet __attribute__((__aligned__(8))); /*     0   976 */

        /* XXX last struct has 4 bytes of padding */

        /* --- cacheline 15 boundary (960 bytes) was 16 bytes ago --- */
...
        unsigned char              accept_udp_fraglist:1; /*   985: 5  1 */

        /* XXX 2 bits hole, try to pack */

        __u16                      len;                  /*   986     2 */
        __u16                      gso_size;             /*   988     2 */

        /* XXX 2 bytes hole, try to pack */

        int                        (*encap_rcv)(struct sock *, struct sk_buff *); /*   992     8 */
        void                       (*encap_err_rcv)(struct sock *, struct sk_buff *, int, __be16, u32, u8 *); /*  1000     8 */
        int                        (*encap_err_lookup)(struct sock *, struct sk_buff *); /*  1008     8 */
        void                       (*encap_destroy)(struct sock *); /*  1016     8 */
        /* --- cacheline 16 boundary (1024 bytes) --- */
        struct sk_buff *           (*gro_receive)(struct sock *, struct list_head *, struct sk_buff *); /*  1024     8 */
        int                        (*gro_complete)(struct sock *, struct sk_buff *, int); /*  1032     8 */

        /* XXX 48 bytes hole, try to pack */

        /* --- cacheline 17 boundary (1088 bytes) --- */
        struct sk_buff_head        reader_queue __attribute__((__aligned__(64))); /*  1088    24 */
        int                        forward_deficit;      /*  1112     4 */
        int                        forward_threshold;    /*  1116     4 */

        /* size: 1152, cachelines: 18, members: 21 */
        /* sum members: 1069, holes: 2, sum holes: 50 */
        /* sum bitfield members: 6 bits, bit holes: 1, sum bit holes: 2 bits */
        /* padding: 32 */
        /* paddings: 1, sum paddings: 4 */
        /* forced alignments: 2, forced holes: 1, sum forced holes: 48 */
} __attribute__((__aligned__(64)));
---
 include/linux/udp.h   | 12 +-----------
 include/net/udplite.h |  6 ------
 net/ipv4/udp.c        | 34 ----------------------------------
 net/ipv6/udp.c        | 17 -----------------
 4 files changed, 1 insertion(+), 68 deletions(-)
include/linux/udp.h +1 -11
index 43c1fb2d2c21..f2f44ad62ea0 100644
@@ -57,17 +57,7 @@ struct udp_sock {
 	 */
 	__u16		 len;		/* total length of pending frames */
 	__u16		 gso_size;
-	/*
-	 * Fields specific to UDP-Lite.
-	 */
-	__u16		 pcslen;
-	__u16		 pcrlen;
-/* indicator bits used by pcflag: */
-#define UDPLITE_BIT      0x1  		/* set by udplite proto init function */
-#define UDPLITE_SEND_CC  0x2  		/* set via udplite setsockopt         */
-#define UDPLITE_RECV_CC  0x4		/* set via udplite setsocktopt        */
-	__u8		 pcflag;        /* marks socket as UDP-Lite if > 0    */
-	__u8		 unused[3];
+
 	/*
 	 * For encapsulation sockets.
 	 */
include/net/udplite.h +0 -6
index f4c513cff753..1bc9393f2890 100644
@@ -59,15 +59,9 @@ static inline int udplite_checksum_init(struct sk_buff *skb, struct udphdr *uh)
 /* Fast-path computation of checksum. Socket may not be locked. */
 static inline __wsum udplite_csum(struct sk_buff *skb)
 {
-	const struct udp_sock *up = udp_sk(skb->sk);
 	const int off = skb_transport_offset(skb);
 	int len = skb->len - off;
 
-	if ((up->pcflag & UDPLITE_SEND_CC) && up->pcslen < len) {
-		if (0 < up->pcslen)
-			len = up->pcslen;
-		udp_hdr(skb)->len = htons(up->pcslen);
-	}
 	skb->ip_summed = CHECKSUM_NONE;     /* no HW support for checksumming */
 
 	return skb_checksum(skb, off, len, 0);
net/ipv4/udp.c +0 -34
index dc416db001c8..345a6364a969 100644
@@ -2129,40 +2129,6 @@ static int udp_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb)
 		/* FALLTHROUGH -- it's a UDP Packet */
 	}
 
-	/*
-	 * 	UDP-Lite specific tests, ignored on UDP sockets
-	 */
-	if ((up->pcflag & UDPLITE_RECV_CC)  &&  UDP_SKB_CB(skb)->partial_cov) {
-
-		/*
-		 * MIB statistics other than incrementing the error count are
-		 * disabled for the following two types of errors: these depend
-		 * on the application settings, not on the functioning of the
-		 * protocol stack as such.
-		 *
-		 * RFC 3828 here recommends (sec 3.3): "There should also be a
-		 * way ... to ... at least let the receiving application block
-		 * delivery of packets with coverage values less than a value
-		 * provided by the application."
-		 */
-		if (up->pcrlen == 0) {          /* full coverage was set  */
-			net_dbg_ratelimited("UDPLite: partial coverage %d while full coverage %d requested\n",
-					    UDP_SKB_CB(skb)->cscov, skb->len);
-			goto drop;
-		}
-		/* The next case involves violating the min. coverage requested
-		 * by the receiver. This is subtle: if receiver wants x and x is
-		 * greater than the buffersize/MTU then receiver will complain
-		 * that it wants x while sender emits packets of smaller size y.
-		 * Therefore the above ...()->partial_cov statement is essential.
-		 */
-		if (UDP_SKB_CB(skb)->cscov  <  up->pcrlen) {
-			net_dbg_ratelimited("UDPLite: coverage %d too small, need min %d\n",
-					    UDP_SKB_CB(skb)->cscov, up->pcrlen);
-			goto drop;
-		}
-	}
-
 	prefetch(&sk->sk_rmem_alloc);
 	if (rcu_access_pointer(sk->sk_filter) &&
 	    udp_lib_checksum_complete(skb))
net/ipv6/udp.c +0 -17
index ecd304bbecb4..5c4b0e662ff5 100644
@@ -738,23 +738,6 @@ static int udpv6_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb)
 		/* FALLTHROUGH -- it's a UDP Packet */
 	}
 
-	/*
-	 * UDP-Lite specific tests, ignored on UDP sockets (see net/ipv4/udp.c).
-	 */
-	if ((up->pcflag & UDPLITE_RECV_CC)  &&  UDP_SKB_CB(skb)->partial_cov) {
-
-		if (up->pcrlen == 0) {          /* full coverage was set  */
-			net_dbg_ratelimited("UDPLITE6: partial coverage %d while full coverage %d requested\n",
-					    UDP_SKB_CB(skb)->cscov, skb->len);
-			goto drop;
-		}
-		if (UDP_SKB_CB(skb)->cscov  <  up->pcrlen) {
-			net_dbg_ratelimited("UDPLITE6: coverage %d too small, need min %d\n",
-					    UDP_SKB_CB(skb)->cscov, up->pcrlen);
-			goto drop;
-		}
-	}
-
 	prefetch(&sk->sk_rmem_alloc);
 	if (rcu_access_pointer(sk->sk_filter) &&
 	    udp_lib_checksum_complete(skb))
Signature · 1 line
2.30.2
#13 lore raw

PATCH 8/14 udp: Remove csum branch for UDP-Lite.

In reply to Kuniyuki Iwashima

Some functions still have conditional branches for UDP-Lite's checksum that we can altogether remove now.

We can remove udp_skb_cb and partial_cov in struct udp_skb_cb and finally remove udplite.h.

---
 include/linux/udp.h     |  2 --
 include/net/udp.h       | 17 ++--------
 include/net/udplite.h   | 70 -----------------------------------------
 net/ipv4/udp.c          | 58 +++++++---------------------------
 net/ipv6/ip6_checksum.c | 16 +---------
 net/ipv6/udp.c          | 37 +++++++---------------
 6 files changed, 27 insertions(+), 173 deletions(-)
 delete mode 100644 include/net/udplite.h
include/linux/udp.h +0 -2
index f2f44ad62ea0..ed6cad269fd1 100644
@@ -146,6 +146,4 @@ static inline void udp_allow_gso(struct sock *sk)
 #define udp_portaddr_for_each_entry_rcu(__sk, list) \
 	hlist_for_each_entry_rcu(__sk, list, __sk_common.skc_portaddr_node)
 
-#define IS_UDPLITE(__sk) (__sk->sk_protocol == IPPROTO_UDPLITE)
-
 #endif	/* _LINUX_UDP_H */
include/net/udp.h +3 -14
index d00509873f6f..902ee75bd25e 100644
@@ -30,11 +30,9 @@
 #include <linux/indirect_call_wrapper.h>
 
 /**
- *	struct udp_skb_cb  -  UDP(-Lite) private variables
+ *	struct udp_skb_cb  -  UDP private variables
  *
  *	@header:      private variables used by IPv4/IPv6
- *	@cscov:       checksum coverage length (UDP-Lite only)
- *	@partial_cov: if set indicates partial csum coverage
  */
 struct udp_skb_cb {
 	union {
@@ -43,8 +41,6 @@ struct udp_skb_cb {
 		struct inet6_skb_parm	h6;
 #endif
 	} header;
-	__u16		cscov;
-	__u8		partial_cov;
 };
 #define UDP_SKB_CB(__skb)	((struct udp_skb_cb *)((__skb)->cb))
 
@@ -105,13 +101,11 @@ extern int sysctl_udp_wmem_min;
 struct sk_buff;
 
 /*
- *	Generic checksumming routines for UDP(-Lite) v4 and v6
+ *	Generic checksumming routines for UDP v4 and v6
  */
 static inline __sum16 __udp_lib_checksum_complete(struct sk_buff *skb)
 {
-	return (UDP_SKB_CB(skb)->cscov == skb->len ?
-		__skb_checksum_complete(skb) :
-		__skb_checksum_complete_head(skb, UDP_SKB_CB(skb)->cscov));
+	return __skb_checksum_complete(skb);
 }
 
 static inline int udp_lib_checksum_complete(struct sk_buff *skb)
@@ -162,7 +156,6 @@ static inline void udp_csum_pull_header(struct sk_buff *skb)
 		skb->csum = csum_partial(skb->data, sizeof(struct udphdr),
 					 skb->csum);
 	skb_pull_rcsum(skb, sizeof(struct udphdr));
-	UDP_SKB_CB(skb)->cscov -= sizeof(struct udphdr);
 }
 
 typedef struct sock *(*udp_lookup_t)(const struct sk_buff *skb, __be16 sport,
@@ -494,9 +487,6 @@ static inline struct sk_buff *udp_rcv_segment(struct sock *sk,
 
 static inline void udp_post_segment_fix_csum(struct sk_buff *skb)
 {
-	/* UDP-lite can't land here - no GRO */
-	WARN_ON_ONCE(UDP_SKB_CB(skb)->partial_cov);
-
 	/* UDP packets generated with UDP_SEGMENT and traversing:
 	 *
 	 * UDP tunnel(xmit) -> veth (segmentation) -> veth (gro) -> UDP tunnel (rx)
@@ -510,7 +500,6 @@ static inline void udp_post_segment_fix_csum(struct sk_buff *skb)
 	 * a valid csum after the segmentation.
 	 * Additionally fixup the UDP CB.
 	 */
-	UDP_SKB_CB(skb)->cscov = skb->len;
 	if (skb->ip_summed == CHECKSUM_NONE && !skb->csum_valid)
 		skb->csum_valid = 1;
 }
include/net/udplite.h deleted +0 -70

70 lines not on this page · raw message

net/ipv4/udp.c +12 -46

150 lines not on this page · raw message

net/ipv6/ip6_checksum.c +1 -15
index 377717045f8f..1362db7a3660 100644
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <net/ip.h>
+#include <net/ip6_checksum.h>
 #include <net/udp.h>
-#include <net/udplite.h>
 #include <asm/checksum.h>
 
 #ifndef _HAVE_ARCH_IPV6_CSUM
@@ -66,20 +66,6 @@ int udp6_csum_init(struct sk_buff *skb, struct udphdr *uh, int proto)
 {
 	int err;
 
-	UDP_SKB_CB(skb)->partial_cov = 0;
-	UDP_SKB_CB(skb)->cscov = skb->len;
-
-	if (proto == IPPROTO_UDPLITE) {
-		err = udplite_checksum_init(skb, uh);
-		if (err)
-			return err;
-
-		if (UDP_SKB_CB(skb)->partial_cov) {
-			skb->csum = ip6_compute_pseudo(skb, proto);
-			return 0;
-		}
-	}
-
 	/* To support RFC 6936 (allow zero checksum in UDP/IPV6 for tunnels)
 	 * we accept a checksum of zero here. When we find the socket
 	 * for the UDP packet we'll check if that socket allows zero checksum
net/ipv6/udp.c +11 -26
index 5c4b0e662ff5..21d48f8803d0 100644
@@ -51,7 +51,6 @@
 #include <net/busy_poll.h>
 #include <net/sock_reuseport.h>
 #include <net/udp.h>
-#include <net/udplite.h>
 
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
@@ -344,7 +343,6 @@ int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
 	int off, err, peeking = flags & MSG_PEEK;
 	struct ipv6_pinfo *np = inet6_sk(sk);
 	struct inet_sock *inet = inet_sk(sk);
-	int is_udplite = IS_UDPLITE(sk);
 	struct udp_mib __percpu *mib;
 	bool checksum_valid = false;
 	unsigned int ulen, copied;
@@ -373,14 +371,10 @@ int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
 	is_udp4 = (skb->protocol == htons(ETH_P_IP));
 	mib = __UDPX_MIB(sk, is_udp4);
 
-	/*
-	 * If checksum is needed at all, try to do it while copying the
-	 * data.  If the data is truncated, or if we only want a partial
-	 * coverage checksum (UDP-Lite), do it before the copy.
+	/* If checksum is needed at all, try to do it while copying the
+	 * data.  If the data is truncated, do it before the copy.
 	 */
-
-	if (copied < ulen || peeking ||
-	    (is_udplite && UDP_SKB_CB(skb)->partial_cov)) {
+	if (copied < ulen || peeking) {
 		checksum_valid = udp_skb_csum_unnecessary(skb) ||
 				!__udp_lib_checksum_complete(skb);
 		if (!checksum_valid)
@@ -910,7 +904,7 @@ static int udp6_unicast_rcv_skb(struct sock *sk, struct sk_buff *skb,
 {
 	int ret;
 
-	if (inet_get_convert_csum(sk) && uh->check && !IS_UDPLITE(sk))
+	if (inet_get_convert_csum(sk) && uh->check)
 		skb_checksum_try_convert(skb, IPPROTO_UDP, ip6_compute_pseudo);
 
 	ret = udpv6_queue_rcv_skb(sk, skb);
@@ -1205,12 +1199,10 @@ static void udp6_hwcsum_outgoing(struct sock *sk, struct sk_buff *skb,
 static int udp_v6_send_skb(struct sk_buff *skb, struct flowi6 *fl6,
 			   struct inet_cork *cork)
 {
-	int err, len, datalen, is_udplite;
 	struct sock *sk = skb->sk;
+	int err, len, datalen;
 	struct udphdr *uh;
-	__wsum csum = 0;
 
-	is_udplite = IS_UDPLITE(sk);
 	len = skb->len - skb_transport_offset(skb);
 	datalen = len - sizeof(*uh);
 
@@ -1239,8 +1231,7 @@ static int udp_v6_send_skb(struct sk_buff *skb, struct flowi6 *fl6,
 			kfree_skb(skb);
 			return -EINVAL;
 		}
-		if (skb->ip_summed != CHECKSUM_PARTIAL || is_udplite ||
-		    dst_xfrm(skb_dst(skb))) {
+		if (skb->ip_summed != CHECKSUM_PARTIAL || dst_xfrm(skb_dst(skb))) {
 			kfree_skb(skb);
 			return -EIO;
 		}
@@ -1254,21 +1245,18 @@ static int udp_v6_send_skb(struct sk_buff *skb, struct flowi6 *fl6,
 		goto csum_partial;
 	}
 
-	if (is_udplite)
-		csum = udplite_csum(skb);
-	else if (udp_sk(sk)->no_check6_tx) {   /* UDP csum disabled */
+	if (udp_sk(sk)->no_check6_tx) {   /* UDP csum disabled */
 		skb->ip_summed = CHECKSUM_NONE;
 		goto send;
 	} else if (skb->ip_summed == CHECKSUM_PARTIAL) { /* UDP hardware csum */
 csum_partial:
 		udp6_hwcsum_outgoing(sk, skb, &fl6->saddr, &fl6->daddr, len);
 		goto send;
-	} else
-		csum = udp_csum(skb);
+	}
 
 	/* add protocol-dependent pseudo-header */
 	uh->check = csum_ipv6_magic(&fl6->saddr, &fl6->daddr,
-				    len, fl6->flowi6_proto, csum);
+				    len, fl6->flowi6_proto, udp_csum(skb));
 	if (uh->check == 0)
 		uh->check = CSUM_MANGLED_0;
 
@@ -1308,7 +1296,6 @@ static int udp_v6_push_pending_frames(struct sock *sk)
 
 int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
 {
-	int (*getfrag)(void *, char *, int, int, int, struct sk_buff *);
 	DECLARE_SOCKADDR(struct sockaddr_in6 *, sin6, msg->msg_name);
 	struct ipv6_txoptions *opt_to_free = NULL;
 	struct in6_addr *daddr, *final_p, final;
@@ -1319,7 +1306,6 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
 	struct udp_sock *up = udp_sk(sk);
 	struct ipv6_txoptions opt_space;
 	int addr_len = msg->msg_namelen;
-	int is_udplite = IS_UDPLITE(sk);
 	struct inet_cork_full cork;
 	struct ipcm6_cookie ipc6;
 	bool connected = false;
@@ -1392,7 +1378,6 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
 	corkreq = READ_ONCE(up->corkflag) || msg->msg_flags & MSG_MORE;
 	fl6 = &cork.fl.u.ip6;
 
-	getfrag  =  is_udplite ?  udplite_getfrag : ip_generic_getfrag;
 	if (up->pending) {
 		if (up->pending == AF_INET)
 			return udp_sendmsg(sk, msg, len);
@@ -1562,7 +1547,7 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
 	if (!corkreq) {
 		struct sk_buff *skb;
 
-		skb = ip6_make_skb(sk, getfrag, msg, ulen,
+		skb = ip6_make_skb(sk, ip_generic_getfrag, msg, ulen,
 				   sizeof(struct udphdr), &ipc6,
 				   (struct rt6_info *)dst,
 				   msg->msg_flags, &cork);
@@ -1590,7 +1575,7 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
 	if (ipc6.dontfrag < 0)
 		ipc6.dontfrag = np->dontfrag;
 	up->len += ulen;
-	err = ip6_append_data(sk, getfrag, msg, ulen, sizeof(struct udphdr),
+	err = ip6_append_data(sk, ip_generic_getfrag, msg, ulen, sizeof(struct udphdr),
 			      &ipc6, fl6, (struct rt6_info *)dst,
 			      corkreq ? msg->msg_flags|MSG_MORE : msg->msg_flags);
 	if (err)
Signature · 1 line
2.30.2
#14 lore raw

PATCH 9/14 udp: Don't pass proto to udp[46]_csum_init().

In reply to Kuniyuki Iwashima

We passed IPPROTO_UDPLITE as proto to __udp[46]_lib_rcv(), which passes it to udp[46]_csum_init().

However, we no longer call __udp[46]_lib_rcv() with IPPROTO_UDPLITE, so proto is always IPPROTO_UDP in udp[46]_csum_init(), and we can hard-code it.

Also, udp6_csum_init() is not called from other functions, so we move it to net/ipv6/udp.c as a static function.

---
 include/net/ip6_checksum.h |  1 -
 net/ipv4/udp.c             |  7 +++----
 net/ipv6/ip6_checksum.c    | 33 ---------------------------------
 net/ipv6/udp.c             | 34 +++++++++++++++++++++++++++++++++-
 4 files changed, 36 insertions(+), 39 deletions(-)
include/net/ip6_checksum.h +0 -1
index c8a96b888277..f9e03cc7a19c 100644
@@ -83,5 +83,4 @@ void udp6_set_csum(bool nocheck, struct sk_buff *skb,
 		   const struct in6_addr *saddr,
 		   const struct in6_addr *daddr, int len);
 
-int udp6_csum_init(struct sk_buff *skb, struct udphdr *uh, int proto);
 #endif
net/ipv4/udp.c +3 -4
index aee075fb5f4f..f8a545c6e3e7 100644
@@ -2247,15 +2247,14 @@ static int __udp4_lib_mcast_deliver(struct net *net, struct sk_buff *skb,
  * Otherwise, csum completion requires checksumming packet body,
  * including udp header and folding it to skb->csum.
  */
-static inline int udp4_csum_init(struct sk_buff *skb, struct udphdr *uh,
-				 int proto)
+static inline int udp4_csum_init(struct sk_buff *skb, struct udphdr *uh)
 {
 	int err;
 
 	/* Note, we are only interested in != 0 or == 0, thus the
 	 * force to int.
 	 */
-	err = (__force int)skb_checksum_init_zero_check(skb, proto, uh->check,
+	err = (__force int)skb_checksum_init_zero_check(skb, IPPROTO_UDP, uh->check,
 							inet_compute_pseudo);
 	if (err)
 		return err;
@@ -2335,7 +2334,7 @@ static int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
 		uh = udp_hdr(skb);
 	}
 
-	if (udp4_csum_init(skb, uh, proto))
+	if (udp4_csum_init(skb, uh))
 		goto csum_error;
 
 	sk = skb_steal_sock(skb, &refcounted);
net/ipv6/ip6_checksum.c +0 -33
index 1362db7a3660..e1a594873675 100644
@@ -62,39 +62,6 @@ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 EXPORT_SYMBOL(csum_ipv6_magic);
 #endif
 
-int udp6_csum_init(struct sk_buff *skb, struct udphdr *uh, int proto)
-{
-	int err;
-
-	/* To support RFC 6936 (allow zero checksum in UDP/IPV6 for tunnels)
-	 * we accept a checksum of zero here. When we find the socket
-	 * for the UDP packet we'll check if that socket allows zero checksum
-	 * for IPv6 (set by socket option).
-	 *
-	 * Note, we are only interested in != 0 or == 0, thus the
-	 * force to int.
-	 */
-	err = (__force int)skb_checksum_init_zero_check(skb, proto, uh->check,
-							ip6_compute_pseudo);
-	if (err)
-		return err;
-
-	if (skb->ip_summed == CHECKSUM_COMPLETE && !skb->csum_valid) {
-		/* If SW calculated the value, we know it's bad */
-		if (skb->csum_complete_sw)
-			return 1;
-
-		/* HW says the value is bad. Let's validate that.
-		 * skb->csum is no longer the full packet checksum,
-		 * so don't treat is as such.
-		 */
-		skb_checksum_complete_unset(skb);
-	}
-
-	return 0;
-}
-EXPORT_SYMBOL(udp6_csum_init);
-
 /* Function to set UDP checksum for an IPv6 UDP packet. This is intended
  * for the simple case like when setting the checksum for a UDP tunnel.
  */
net/ipv6/udp.c +33 -1
index 21d48f8803d0..170bbaa4a9d4 100644
@@ -896,6 +896,38 @@ static void udp6_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst)
 	}
 }
 
+static int udp6_csum_init(struct sk_buff *skb, struct udphdr *uh)
+{
+	int err;
+
+	/* To support RFC 6936 (allow zero checksum in UDP/IPV6 for tunnels)
+	 * we accept a checksum of zero here. When we find the socket
+	 * for the UDP packet we'll check if that socket allows zero checksum
+	 * for IPv6 (set by socket option).
+	 *
+	 * Note, we are only interested in != 0 or == 0, thus the
+	 * force to int.
+	 */
+	err = (__force int)skb_checksum_init_zero_check(skb, IPPROTO_UDP, uh->check,
+							ip6_compute_pseudo);
+	if (err)
+		return err;
+
+	if (skb->ip_summed == CHECKSUM_COMPLETE && !skb->csum_valid) {
+		/* If SW calculated the value, we know it's bad */
+		if (skb->csum_complete_sw)
+			return 1;
+
+		/* HW says the value is bad. Let's validate that.
+		 * skb->csum is no longer the full packet checksum,
+		 * so don't treat is as such.
+		 */
+		skb_checksum_complete_unset(skb);
+	}
+
+	return 0;
+}
+
 /* wrapper for udp_queue_rcv_skb tacking care of csum conversion and
  * return code conversion for ip layer consumption
  */
@@ -956,7 +988,7 @@ static int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
 		}
 	}
 
-	if (udp6_csum_init(skb, uh, proto))
+	if (udp6_csum_init(skb, uh))
 		goto csum_error;
 
 	/* Check if the socket is already available, e.g. due to early demux */
Signature · 1 line
2.30.2
#15 lore raw

PATCH 10/14 udp: Don't pass proto to __udp[46]_lib_rcv().

In reply to Kuniyuki Iwashima

We passed IPPROTO_UDPLITE as proto to __udp[46]_lib_rcv() to share the code with UDP-Lite, which we no longer support.

We need not check proto in __udp[46]_lib_rcv().

---
 net/ipv4/udp.c | 26 ++++++++++----------------
 net/ipv6/udp.c | 38 +++++++++++++++++---------------------
 2 files changed, 27 insertions(+), 37 deletions(-)
net/ipv4/udp.c +10 -16
index f8a545c6e3e7..23ebea2b84e4 100644
@@ -2180,8 +2180,7 @@ EXPORT_SYMBOL(udp_sk_rx_dst_set);
 static int __udp4_lib_mcast_deliver(struct net *net, struct sk_buff *skb,
 				    struct udphdr  *uh,
 				    __be32 saddr, __be32 daddr,
-				    struct udp_table *udptable,
-				    int proto)
+				    struct udp_table *udptable)
 {
 	int dif = skb->dev->ifindex, sdif = inet_sdif(skb);
 	unsigned int offset, hash2 = 0, hash2_any = 0;
@@ -2299,8 +2298,7 @@ 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.
  */
 
-static 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)
 {
 	struct sock *sk;
 	struct udphdr *uh;
@@ -2327,12 +2325,10 @@ static int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
 	if (ulen > skb->len)
 		goto short_packet;
 
-	if (proto == IPPROTO_UDP) {
-		/* UDP validates ulen. */
-		if (ulen < sizeof(*uh) || pskb_trim_rcsum(skb, ulen))
-			goto short_packet;
-		uh = udp_hdr(skb);
-	}
+	if (ulen < sizeof(*uh) || pskb_trim_rcsum(skb, ulen))
+		goto short_packet;
+
+	uh = udp_hdr(skb);
 
 	if (udp4_csum_init(skb, uh))
 		goto csum_error;
@@ -2353,7 +2349,7 @@ static int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
 
 	if (rt->rt_flags & (RTCF_BROADCAST|RTCF_MULTICAST))
 		return __udp4_lib_mcast_deliver(net, skb, uh,
-						saddr, daddr, udptable, proto);
+						saddr, daddr, udptable);
 
 	sk = __udp4_lib_lookup_skb(skb, uh->source, uh->dest, udptable);
 	if (sk)
@@ -2380,8 +2376,7 @@ static int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
 
 short_packet:
 	drop_reason = SKB_DROP_REASON_PKT_TOO_SMALL;
-	net_dbg_ratelimited("UDP%s: short packet: From %pI4:%u %d/%d to %pI4:%u\n",
-			    proto == IPPROTO_UDPLITE ? "Lite" : "",
+	net_dbg_ratelimited("UDP: short packet: From %pI4:%u %d/%d to %pI4:%u\n",
 			    &saddr, ntohs(uh->source),
 			    ulen, skb->len,
 			    &daddr, ntohs(uh->dest));
@@ -2393,8 +2388,7 @@ static int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
 	 * the network is concerned, anyway) as per 4.1.3.4 (MUST).
 	 */
 	drop_reason = SKB_DROP_REASON_UDP_CSUM;
-	net_dbg_ratelimited("UDP%s: bad checksum. From %pI4:%u to %pI4:%u ulen %d\n",
-			    proto == IPPROTO_UDPLITE ? "Lite" : "",
+	net_dbg_ratelimited("UDP: bad checksum. From %pI4:%u to %pI4:%u ulen %d\n",
 			    &saddr, ntohs(uh->source), &daddr, ntohs(uh->dest),
 			    ulen);
 	__UDP_INC_STATS(net, UDP_MIB_CSUMERRORS);
@@ -2539,7 +2533,7 @@ int udp_v4_early_demux(struct sk_buff *skb)
 
 int udp_rcv(struct sk_buff *skb)
 {
-	return __udp4_lib_rcv(skb, dev_net(skb->dev)->ipv4.udp_table, IPPROTO_UDP);
+	return __udp4_lib_rcv(skb, dev_net(skb->dev)->ipv4.udp_table);
 }
 
 static void udp_destroy_sock(struct sock *sk)
net/ipv6/udp.c +17 -21
index 170bbaa4a9d4..ee859679427a 100644
@@ -819,8 +819,9 @@ static void udp6_csum_zero_error(struct sk_buff *skb)
  * so we don't need to lock the hashes.
  */
 static int __udp6_lib_mcast_deliver(struct net *net, struct sk_buff *skb,
-		const struct in6_addr *saddr, const struct in6_addr *daddr,
-		struct udp_table *udptable, int proto)
+				    const struct in6_addr *saddr,
+				    const struct in6_addr *daddr,
+				    struct udp_table *udptable)
 {
 	int dif = inet6_iif(skb), sdif = inet6_sdif(skb);
 	unsigned int offset, hash2 = 0, hash2_any = 0;
@@ -947,8 +948,7 @@ static int udp6_unicast_rcv_skb(struct sock *sk, struct sk_buff *skb,
 	return 0;
 }
 
-static int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
-			  int proto)
+static int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable)
 {
 	enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
 	const struct in6_addr *saddr, *daddr;
@@ -969,23 +969,20 @@ static int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
 	if (ulen > skb->len)
 		goto short_packet;
 
-	if (proto == IPPROTO_UDP) {
-		/* UDP validates ulen. */
+	/* Check for jumbo payload */
+	if (ulen == 0)
+		ulen = skb->len;
 
-		/* Check for jumbo payload */
-		if (ulen == 0)
-			ulen = skb->len;
+	if (ulen < sizeof(*uh))
+		goto short_packet;
 
-		if (ulen < sizeof(*uh))
+	if (ulen < skb->len) {
+		if (pskb_trim_rcsum(skb, ulen))
 			goto short_packet;
 
-		if (ulen < skb->len) {
-			if (pskb_trim_rcsum(skb, ulen))
-				goto short_packet;
-			saddr = &ipv6_hdr(skb)->saddr;
-			daddr = &ipv6_hdr(skb)->daddr;
-			uh = udp_hdr(skb);
-		}
+		saddr = &ipv6_hdr(skb)->saddr;
+		daddr = &ipv6_hdr(skb)->daddr;
+		uh = udp_hdr(skb);
 	}
 
 	if (udp6_csum_init(skb, uh))
@@ -1017,7 +1014,7 @@ static int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
 	 */
 	if (ipv6_addr_is_multicast(daddr))
 		return __udp6_lib_mcast_deliver(net, skb,
-				saddr, daddr, udptable, proto);
+						saddr, daddr, udptable);
 
 	/* Unicast */
 	sk = __udp6_lib_lookup_skb(skb, uh->source, uh->dest, udptable);
@@ -1048,8 +1045,7 @@ static int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
 short_packet:
 	if (reason == SKB_DROP_REASON_NOT_SPECIFIED)
 		reason = SKB_DROP_REASON_PKT_TOO_SMALL;
-	net_dbg_ratelimited("UDP%sv6: short packet: From [%pI6c]:%u %d/%d to [%pI6c]:%u\n",
-			    proto == IPPROTO_UDPLITE ? "-Lite" : "",
+	net_dbg_ratelimited("UDPv6: short packet: From [%pI6c]:%u %d/%d to [%pI6c]:%u\n",
 			    saddr, ntohs(uh->source),
 			    ulen, skb->len,
 			    daddr, ntohs(uh->dest));
@@ -1138,7 +1134,7 @@ void udp_v6_early_demux(struct sk_buff *skb)
 
 INDIRECT_CALLABLE_SCOPE int udpv6_rcv(struct sk_buff *skb)
 {
-	return __udp6_lib_rcv(skb, dev_net(skb->dev)->ipv4.udp_table, IPPROTO_UDP);
+	return __udp6_lib_rcv(skb, dev_net(skb->dev)->ipv4.udp_table);
 }
 
 /*
Signature · 1 line
2.30.2
#16 lore raw

PATCH 11/14 udp: Optimise ulen tests in __udp[46]_lib_rcv().

In reply to Kuniyuki Iwashima

In __udp4_lib_rcv(), we need not call udp_hdr() unless we call pskb_trim_rcsum().

In __udp6_lib_rcv(), we can save two unneeded conditions for every jumbo payload that never be true.

	if (ulen > skb->len)
		goto short_packet;
	if (ulen == 0)
		ulen = skb->len;
	if (ulen < skb->len)

Note the number of tests for non-jumbo IPv6 payload is not changed.

---
 net/ipv4/udp.c |  8 +++++---
 net/ipv6/udp.c | 30 +++++++++++++++++-------------
 2 files changed, 22 insertions(+), 16 deletions(-)
net/ipv4/udp.c +5 -3
index 23ebea2b84e4..eb968d20d5a8 100644
@@ -2325,10 +2325,12 @@ static int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable)
 	if (ulen > skb->len)
 		goto short_packet;
 
-	if (ulen < sizeof(*uh) || pskb_trim_rcsum(skb, ulen))
-		goto short_packet;
+	if (ulen < sizeof(*uh)) {
+		if (pskb_trim_rcsum(skb, ulen))
+			goto short_packet;
 
-	uh = udp_hdr(skb);
+		uh = udp_hdr(skb);
+	}
 
 	if (udp4_csum_init(skb, uh))
 		goto csum_error;
net/ipv6/udp.c +17 -13
index ee859679427a..6f5c29af4157 100644
@@ -966,23 +966,27 @@ static int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable)
 	uh = udp_hdr(skb);
 
 	ulen = ntohs(uh->len);
-	if (ulen > skb->len)
-		goto short_packet;
+	if (ulen) {
+		if (ulen > skb->len)
+			goto short_packet;
 
-	/* Check for jumbo payload */
-	if (ulen == 0)
-		ulen = skb->len;
+		if (ulen < sizeof(*uh))
+			goto short_packet;
 
-	if (ulen < sizeof(*uh))
-		goto short_packet;
+		if (ulen < skb->len) {
+			if (pskb_trim_rcsum(skb, ulen))
+				goto short_packet;
 
-	if (ulen < skb->len) {
-		if (pskb_trim_rcsum(skb, ulen))
-			goto short_packet;
+			saddr = &ipv6_hdr(skb)->saddr;
+			daddr = &ipv6_hdr(skb)->daddr;
+			uh = udp_hdr(skb);
+		}
+	} else {
+		/* jumbo payload */
+		ulen = skb->len;
 
-		saddr = &ipv6_hdr(skb)->saddr;
-		daddr = &ipv6_hdr(skb)->daddr;
-		uh = udp_hdr(skb);
+		if (ulen < sizeof(*uh))
+			goto short_packet;
 	}
 
 	if (udp6_csum_init(skb, uh))
Signature · 1 line
2.30.2
#17 lore raw

PATCH 12/14 udp: Remove udp_table in struct proto.

In reply to Kuniyuki Iwashima

We managed UDP-Lite sockets in a global hash table (udplite_table) that we can get from the global per-protocol variable, sk_prot->h.udp_table.

OTOH, we use per-netns hash tables for UDP, so we set NULL to sk_prot->h.udp_table.

When we got a hash table, we needed to check if sk_prot->h.udp_table was NULL to get a proper one.

However, we no longer support UDP-Lite and always use the per-netns hash table without the test. Also, we can remove h.udp_table in struct proto.

---
 include/net/sock.h |  1 -
 net/ipv4/udp.c     | 16 +++++++---------
 net/ipv6/udp.c     |  1 -
 3 files changed, 7 insertions(+), 11 deletions(-)
include/net/sock.h +0 -1
index 0b6c74bdd688..52f56a01b590 100644
@@ -1339,7 +1339,6 @@ struct proto {
 
 	union {
 		struct inet_hashinfo	*hashinfo;
-		struct udp_table	*udp_table;
 		struct raw_hashinfo	*raw_hash;
 		struct smc_hashinfo	*smc_hash;
 	} h;
net/ipv4/udp.c +7 -9
index eb968d20d5a8..8b460e0e73bc 100644
@@ -132,11 +132,6 @@ EXPORT_PER_CPU_SYMBOL_GPL(udp_memory_per_cpu_fw_alloc);
 #define MAX_UDP_PORTS 65536
 #define PORTS_PER_CHAIN (MAX_UDP_PORTS / UDP_HTABLE_SIZE_MIN_PERNET)
 
-static struct udp_table *udp_get_table_prot(struct sock *sk)
-{
-	return sk->sk_prot->h.udp_table ? : sock_net(sk)->ipv4.udp_table;
-}
-
 static int udp_lib_lport_inuse(struct net *net, __u16 num,
 			       const struct udp_hslot *hslot,
 			       unsigned long *bitmap,
@@ -238,11 +233,13 @@ static int udp_reuseport_add_sock(struct sock *sk, struct udp_hslot *hslot)
 int udp_lib_get_port(struct sock *sk, unsigned short snum,
 		     unsigned int hash2_nulladdr)
 {
-	struct udp_table *udptable = udp_get_table_prot(sk);
 	struct udp_hslot *hslot, *hslot2;
 	struct net *net = sock_net(sk);
+	struct udp_table *udptable;
 	int error = -EADDRINUSE;
 
+	udptable = net->ipv4.udp_table;
+
 	if (!snum) {
 		DECLARE_BITMAP(bitmap, PORTS_PER_CHAIN);
 		unsigned short first, last;
@@ -1945,10 +1942,11 @@ EXPORT_SYMBOL(udp_disconnect);
 void udp_lib_unhash(struct sock *sk)
 {
 	if (sk_hashed(sk)) {
-		struct udp_table *udptable = udp_get_table_prot(sk);
 		struct udp_hslot *hslot, *hslot2;
 		struct net *net = sock_net(sk);
+		struct udp_table *udptable;
 
+		udptable = net->ipv4.udp_table;
 		hslot  = udp_hashslot(udptable, net, udp_sk(sk)->udp_port_hash);
 		hslot2 = udp_hashslot2(udptable, udp_sk(sk)->udp_portaddr_hash);
 
@@ -1976,10 +1974,11 @@ EXPORT_SYMBOL(udp_lib_unhash);
 void udp_lib_rehash(struct sock *sk, u16 newhash)
 {
 	if (sk_hashed(sk)) {
-		struct udp_table *udptable = udp_get_table_prot(sk);
 		struct udp_hslot *hslot, *hslot2, *nhslot2;
 		struct net *net = sock_net(sk);
+		struct udp_table *udptable;
 
+		udptable = net->ipv4.udp_table;
 		hslot2 = udp_hashslot2(udptable, udp_sk(sk)->udp_portaddr_hash);
 		nhslot2 = udp_hashslot2(udptable, newhash);
 		udp_sk(sk)->udp_portaddr_hash = newhash;
@@ -2819,7 +2818,6 @@ struct proto udp_prot = {
 	.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		= NULL,
 	.diag_destroy		= udp_abort,
 };
 EXPORT_SYMBOL(udp_prot);
net/ipv6/udp.c +0 -1
index 6f5c29af4157..23480b84ba08 100644
@@ -1778,7 +1778,6 @@ struct proto udpv6_prot = {
 	.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 udp6_sock),
-	.h.udp_table		= NULL,
 	.diag_destroy		= udp_abort,
 };
 
Signature · 1 line
2.30.2
#18 lore raw

PATCH 13/14 udp: Remove udp_table in struct udp_seq_afinfo.

In reply to Kuniyuki Iwashima

We managed UDP-Lite sockets in a global hash table (udplite_table) that we can get from a per-protocol variable, udp_seq_afinfo.udp_table.

OTOH, we use per-netns hash tables for UDP, so we set NULL to udp_seq_afinfo.udp_table.

When we got a hash table, we needed to check if udp_seq_afinfo.udp_table was NULL to get a proper one.

However, we no longer support UDP-Lite and always use the per-netns hash table without the test. Also, we can remove udp_table in struct udp_seq_afinfo.

---
 include/net/udp.h |  1 -
 net/ipv4/udp.c    | 22 ++++------------------
 net/ipv6/udp.c    |  1 -
 3 files changed, 4 insertions(+), 20 deletions(-)
include/net/udp.h +0 -1
index 902ee75bd25e..ea2308989dc7 100644
@@ -414,7 +414,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 {
net/ipv4/udp.c +4 -18
index 8b460e0e73bc..7eddf88dfce6 100644
@@ -2837,21 +2837,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;
@@ -2859,7 +2846,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) {
@@ -2891,7 +2878,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);
@@ -2939,7 +2926,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);
@@ -3020,7 +3007,7 @@ static struct sock *bpf_iter_udp_batch(struct seq_file *seq)
 		iter->offset = 0;
 	}
 
-	udptable = udp_get_table_seq(seq, net);
+	udptable = net->ipv4.udp_table;
 
 again:
 	/* New batch for the next bucket.
@@ -3229,7 +3216,6 @@ EXPORT_SYMBOL(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)
net/ipv6/udp.c +0 -1
index 23480b84ba08..066e9b9ae5f0 100644
@@ -1728,7 +1728,6 @@ EXPORT_SYMBOL(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)
Signature · 1 line
2.30.2
#19 lore raw

PATCH 14/14 udp: Don't pass udp_table to __udp[46]_lib_lookup().

In reply to Kuniyuki Iwashima

We use the same socket lookup function for UDP and UDP-Lite.

However, we managed UDP-Lite sockets in a global hash table and UDP sockets in per-netns hash tables.

To use a proper table in __udp6_lib_lookup(), we needed to add an argument for udp_table in many functions.

However, we no longer support UDP-Lite and need not pass udp_table again and again.

---
 include/net/ipv6_stubs.h |  3 +-
 include/net/udp.h        |  5 ++--
 net/core/filter.c        |  5 ++--
 net/ipv4/udp.c           | 61 +++++++++++++---------------------------
 net/ipv4/udp_diag.c      | 38 ++++++++++++-------------
 net/ipv4/udp_offload.c   |  5 ++--
 net/ipv6/udp.c           | 55 +++++++++++-------------------------
 net/ipv6/udp_offload.c   |  5 ++--
 8 files changed, 65 insertions(+), 112 deletions(-)
include/net/ipv6_stubs.h +1 -2
index c48186bf4737..ff6ac49b02f5 100644
@@ -79,8 +79,7 @@ struct ipv6_bpf_stub {
 	struct sock *(*udp6_lib_lookup)(struct net *net,
 				     const struct in6_addr *saddr, __be16 sport,
 				     const struct in6_addr *daddr, __be16 dport,
-				     int dif, int sdif, struct udp_table *tbl,
-				     struct sk_buff *skb);
+				     int dif, int sdif, struct sk_buff *skb);
 	int (*ipv6_setsockopt)(struct sock *sk, int level, int optname,
 			       sockptr_t optval, unsigned int optlen);
 	int (*ipv6_getsockopt)(struct sock *sk, int level, int optname,
include/net/udp.h +2 -3
index ea2308989dc7..31bcf12c8b20 100644
@@ -293,7 +293,7 @@ struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport,
 			     __be32 daddr, __be16 dport, int dif);
 struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport,
 			       __be32 daddr, __be16 dport, int dif, int sdif,
-			       struct udp_table *tbl, struct sk_buff *skb);
+			       struct sk_buff *skb);
 struct sock *udp4_lib_lookup_skb(const struct sk_buff *skb,
 				 __be16 sport, __be16 dport);
 struct sock *udp6_lib_lookup(struct net *net,
@@ -303,8 +303,7 @@ struct sock *udp6_lib_lookup(struct net *net,
 struct sock *__udp6_lib_lookup(struct net *net,
 			       const struct in6_addr *saddr, __be16 sport,
 			       const struct in6_addr *daddr, __be16 dport,
-			       int dif, int sdif, struct udp_table *tbl,
-			       struct sk_buff *skb);
+			       int dif, int sdif, struct sk_buff *skb);
 struct sock *udp6_lib_lookup_skb(const struct sk_buff *skb,
 				 __be16 sport, __be16 dport);
 int udp_read_skb(struct sock *sk, skb_read_actor_t recv_actor);
net/core/filter.c +2 -3
index 968139f4a1ac..32e3a0677f99 100644
@@ -6522,7 +6522,7 @@ static struct sock *sk_lookup(struct net *net, struct bpf_sock_tuple *tuple,
 		else
 			sk = __udp4_lib_lookup(net, src4, tuple->ipv4.sport,
 					       dst4, tuple->ipv4.dport,
-					       dif, sdif, net->ipv4.udp_table, NULL);
+					       dif, sdif, NULL);
 #if IS_ENABLED(CONFIG_IPV6)
 	} else {
 		struct in6_addr *src6 = (struct in6_addr *)&tuple->ipv6.saddr;
@@ -6537,8 +6537,7 @@ static struct sock *sk_lookup(struct net *net, struct bpf_sock_tuple *tuple,
 			sk = ipv6_bpf_stub->udp6_lib_lookup(net,
 							    src6, tuple->ipv6.sport,
 							    dst6, tuple->ipv6.dport,
-							    dif, sdif,
-							    net->ipv4.udp_table, NULL);
+							    dif, sdif, NULL);
 #endif
 	}
 
net/ipv4/udp.c +20 -41

172 lines not on this page · raw message

net/ipv4/udp_diag.c +19 -19
index b8de2babfb0c..0f4ffd516efb 100644
@@ -38,17 +38,17 @@ static int udp_dump_one(struct udp_table *tbl,
 	if (req->sdiag_family == AF_INET)
 		/* src and dst are swapped for historical reasons */
 		sk = __udp4_lib_lookup(net,
-				req->id.idiag_src[0], req->id.idiag_sport,
-				req->id.idiag_dst[0], req->id.idiag_dport,
-				req->id.idiag_if, 0, tbl, NULL);
+				       req->id.idiag_src[0], req->id.idiag_sport,
+				       req->id.idiag_dst[0], req->id.idiag_dport,
+				       req->id.idiag_if, 0, NULL);
 #if IS_ENABLED(CONFIG_IPV6)
 	else if (req->sdiag_family == AF_INET6)
 		sk = __udp6_lib_lookup(net,
-				(struct in6_addr *)req->id.idiag_src,
-				req->id.idiag_sport,
-				(struct in6_addr *)req->id.idiag_dst,
-				req->id.idiag_dport,
-				req->id.idiag_if, 0, tbl, NULL);
+				       (struct in6_addr *)req->id.idiag_src,
+				       req->id.idiag_sport,
+				       (struct in6_addr *)req->id.idiag_dst,
+				       req->id.idiag_dport,
+				       req->id.idiag_if, 0, NULL);
 #endif
 	if (sk && !refcount_inc_not_zero(&sk->sk_refcnt))
 		sk = NULL;
@@ -175,25 +175,25 @@ static int __udp_diag_destroy(struct sk_buff *in_skb,
 
 	if (req->sdiag_family == AF_INET)
 		sk = __udp4_lib_lookup(net,
-				req->id.idiag_dst[0], req->id.idiag_dport,
-				req->id.idiag_src[0], req->id.idiag_sport,
-				req->id.idiag_if, 0, tbl, NULL);
+				       req->id.idiag_dst[0], req->id.idiag_dport,
+				       req->id.idiag_src[0], req->id.idiag_sport,
+				       req->id.idiag_if, 0, NULL);
 #if IS_ENABLED(CONFIG_IPV6)
 	else if (req->sdiag_family == AF_INET6) {
 		if (ipv6_addr_v4mapped((struct in6_addr *)req->id.idiag_dst) &&
 		    ipv6_addr_v4mapped((struct in6_addr *)req->id.idiag_src))
 			sk = __udp4_lib_lookup(net,
-					req->id.idiag_dst[3], req->id.idiag_dport,
-					req->id.idiag_src[3], req->id.idiag_sport,
-					req->id.idiag_if, 0, tbl, NULL);
+					       req->id.idiag_dst[3], req->id.idiag_dport,
+					       req->id.idiag_src[3], req->id.idiag_sport,
+					       req->id.idiag_if, 0, NULL);
 
 		else
 			sk = __udp6_lib_lookup(net,
-					(struct in6_addr *)req->id.idiag_dst,
-					req->id.idiag_dport,
-					(struct in6_addr *)req->id.idiag_src,
-					req->id.idiag_sport,
-					req->id.idiag_if, 0, tbl, NULL);
+					       (struct in6_addr *)req->id.idiag_dst,
+					       req->id.idiag_dport,
+					       (struct in6_addr *)req->id.idiag_src,
+					       req->id.idiag_sport,
+					       req->id.idiag_if, 0, NULL);
 	}
 #endif
 	else {
net/ipv4/udp_offload.c +2 -3
index 1f01e15ca24f..fd1a002b99d3 100644
@@ -601,11 +601,10 @@ static struct sock *udp4_gro_lookup_skb(struct sk_buff *skb, __be16 sport,
 					__be16 dport)
 {
 	const struct iphdr *iph = skb_gro_network_header(skb);
-	struct net *net = dev_net(skb->dev);
 
-	return __udp4_lib_lookup(net, iph->saddr, sport,
+	return __udp4_lib_lookup(dev_net(skb->dev), iph->saddr, sport,
 				 iph->daddr, dport, inet_iif(skb),
-				 inet_sdif(skb), net->ipv4.udp_table, NULL);
+				 inet_sdif(skb), NULL);
 }
 
 INDIRECT_CALLABLE_SCOPE
net/ipv6/udp.c +17 -38

155 lines not on this page · raw message

net/ipv6/udp_offload.c +2 -3
index c39c1e32f980..2195ac83f077 100644
@@ -117,11 +117,10 @@ static struct sock *udp6_gro_lookup_skb(struct sk_buff *skb, __be16 sport,
 					__be16 dport)
 {
 	const struct ipv6hdr *iph = skb_gro_network_header(skb);
-	struct net *net = dev_net(skb->dev);
 
-	return __udp6_lib_lookup(net, &iph->saddr, sport,
+	return __udp6_lib_lookup(dev_net(skb->dev), &iph->saddr, sport,
 				 &iph->daddr, dport, inet6_iif(skb),
-				 inet6_sdif(skb), net->ipv4.udp_table, NULL);
+				 inet6_sdif(skb), NULL);
 }
 
 INDIRECT_CALLABLE_SCOPE
Signature · 1 line
2.30.2
maintainer
#20 lore raw
In reply to Kuniyuki Iwashima
Quoted 9 lines · Kuniyuki Iwashima

Recently syzkaller reported a 7-year-old null-ptr-deref [0] that occurs when a UDP-Lite socket tries to allocate a buffer under memory pressure.

Someone should have stumbled on the bug much earlier if UDP-Lite had been used in a real app. Additionally, we do not always need a large UDP-Lite workload to hit the bug since UDP and UDP-Lite share the same memory accounting limit.

Quoted 7 lines

Given no one uses UDP-Lite, we can drop it and simplify UDP code by removing a bunch of conditionals.

This series removes UDP-Lite support from the core networking stack first and incrementally removes the dead code.

[0]: https://lore.kernel.org/netdev/[email protected]/

Even if there is high confidence that this protocol is unused, for which I'm not sure the above is sufficient proof, it should be disabled first and left in place, and removed only when there is no chance that it has to be re-enabled.

We already have code churn here from the split between UDP and UDPLite, which was reverted in commit db8dac20d519 ("[UDP]: Revert udplite and code split."). This series would be an enormous change to revert. And if sufficient time passes in between, there might be ample patch conflicts, the fixups of which are sources for subtle bugs.

#4 lore raw

Re: [PATCH v1 net-next 02/14] udplite: Retire UDP-Lite for IPv6.

In reply to Kuniyuki Iwashima
Quoted 9 lines · Kuniyuki Iwashima

We no longer support IPPROTO_UDPLITE for AF_INET6.

This commit removes udplite.c and udp_impl.h under net/ipv6 and makes some functions static that UDP shared.

Note that udplite.h is included in udp.c temporarily not to introduce breakage, but we will remove it later with dead code.

...

Quoted 21 lines
net/ipv6/udp_impl.h deleted +0 -15
deleted file mode 100644
index 0590f566379d..000000000000
@@ -1,31 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _UDP6_IMPL_H
-#define _UDP6_IMPL_H
-#include <net/udp.h>
-#include <net/udplite.h>
-#include <net/protocol.h>
-#include <net/addrconf.h>
-#include <net/inet_common.h>
-#include <net/transp_v6.h>
-
-int __udp6_lib_rcv(struct sk_buff *, struct udp_table *, int);
-int __udp6_lib_err(struct sk_buff *, struct inet6_skb_parm *, u8, u8, int,
-		   __be32, struct udp_table *);
-
-int udpv6_init_sock(struct sock *sk);

net/ipv6/udp_impl.h line 25

Quoted 10 lines
net/ipv6/udp_impl.h deleted +0 -10
-int udp_v6_get_port(struct sock *sk, unsigned short snum);
-void udp_v6_rehash(struct sock *sk);
-
-int udpv6_getsockopt(struct sock *sk, int level, int optname,
-		     char __user *optval, int __user *optlen);
-int udpv6_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval,
-		     unsigned int optlen);
-int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len);
-int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int flags,
-		  int *addr_len);

clang-16 with W=1 complains that:

+net/ipv6/udp.c:341:5: warning: no previous prototype for 'udpv6_recvmsg' [-Wmissing-prototypes]
+ 341 | int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
+ | ^~~~~~~~~~~~~
+net/ipv6/udp.c:1335:5: warning: no previous prototype for 'udpv6_sendmsg' [-Wmissing-prototypes]
+ 1335 | int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
+ | ^~~~~~~~~~~~~

Likewise it has similar complains about ipv4 in a subsequent patch.

Quoted 6 lines
net/ipv6/udp_impl.h deleted +0 -6
-void udpv6_destroy_sock(struct sock *sk);
-
-#ifdef CONFIG_PROC_FS
-int udp6_seq_show(struct seq_file *seq, void *v);
-#endif
-#endif	/* _UDP6_IMPL_H */

...

Reviewed-by on v1 5/14
#10 lore raw

Re: [PATCH v1 net-next 05/14] udp: Remove UDP-Lite SNMP stats.

In reply to Kuniyuki Iwashima
Quoted 10 lines · Kuniyuki Iwashima

We stored UDP-Lite stats in udplite_statistics and udplite_stats_in6 of struct netns_mib.

Since UDP and UDP-Lite share code, UDP_INC_STATS() always has to check if the socket is UDP-Lite. However, we no longer increment UDP-Lite stats.

Let's remove the stats and save one protocol test.

...

include/net/udp.h static inline int copy_linear_skb(struct sk_buff *skb, int len, int off, · line 393

Quoted 10 lines
include/net/udp.h +1 -1
index bfe62e73552a..d00509873f6f 100644
@@ -390,37 +390,28 @@ static inline int copy_linear_skb(struct sk_buff *skb, int len, int off,
 }
 
 /*
- * 	SNMP statistics for UDP and UDP-Lite
+ * 	SNMP statistics for UDP

nit: While we are here perhaps the space before the tab can be removed.

Otherwise, LGTM.

#21 lore raw
In reply to Willem de Bruijn

From: Willem de Bruijn <[email protected]>
Date: Mon, 29 May 2023 22:15:06 -0400

Quoted 23 lines · Kuniyuki Iwashima
Quoted 9 lines

Recently syzkaller reported a 7-year-old null-ptr-deref [0] that occurs when a UDP-Lite socket tries to allocate a buffer under memory pressure.

Someone should have stumbled on the bug much earlier if UDP-Lite had been used in a real app. Additionally, we do not always need a large UDP-Lite workload to hit the bug since UDP and UDP-Lite share the same memory accounting limit.

Quoted 7 lines

Given no one uses UDP-Lite, we can drop it and simplify UDP code by removing a bunch of conditionals.

This series removes UDP-Lite support from the core networking stack first and incrementally removes the dead code.

[0]: https://lore.kernel.org/netdev/[email protected]/

Even if there is high confidence that this protocol is unused, for which I'm not sure the above is sufficient proof, it should be disabled first and left in place, and removed only when there is no chance that it has to be re-enabled.

Quoted 5 lines

We already have code churn here from the split between UDP and UDPLite, which was reverted in commit db8dac20d519 ("[UDP]: Revert udplite and code split."). This series would be an enormous change to revert. And if sufficient time passes in between, there might be ample patch conflicts, the fixups of which are sources for subtle bugs.

Thanks Willem, I didn't know someone attempted to disable UDP-Lite.

You may prefer this way.
https://lore.kernel.org/netdev/[email protected]/

I'm fine whichever, but the next question will be like how long should we wait ? We happen to know that we have already waited for 7 years.

#5 lore raw

Re: [PATCH v1 net-next 02/14] udplite: Retire UDP-Lite for IPv6.

In reply to Simon Horman

From: Simon Horman <[email protected]>
Date: Tue, 30 May 2023 15:01:11 +0200

Quoted 47 lines · Kuniyuki Iwashima
Quoted 9 lines

We no longer support IPPROTO_UDPLITE for AF_INET6.

This commit removes udplite.c and udp_impl.h under net/ipv6 and makes some functions static that UDP shared.

Note that udplite.h is included in udp.c temporarily not to introduce breakage, but we will remove it later with dead code.

...

Quoted 21 lines
net/ipv6/udp_impl.h deleted +0 -15
deleted file mode 100644
index 0590f566379d..000000000000
@@ -1,31 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _UDP6_IMPL_H
-#define _UDP6_IMPL_H
-#include <net/udp.h>
-#include <net/udplite.h>
-#include <net/protocol.h>
-#include <net/addrconf.h>
-#include <net/inet_common.h>
-#include <net/transp_v6.h>
-
-int __udp6_lib_rcv(struct sk_buff *, struct udp_table *, int);
-int __udp6_lib_err(struct sk_buff *, struct inet6_skb_parm *, u8, u8, int,
-		   __be32, struct udp_table *);
-
-int udpv6_init_sock(struct sock *sk);

net/ipv6/udp_impl.h line 25

Quoted 10 lines
net/ipv6/udp_impl.h deleted +0 -10
-int udp_v6_get_port(struct sock *sk, unsigned short snum);
-void udp_v6_rehash(struct sock *sk);
-
-int udpv6_getsockopt(struct sock *sk, int level, int optname,
-		     char __user *optval, int __user *optlen);
-int udpv6_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval,
-		     unsigned int optlen);
-int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len);
-int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int flags,
-		  int *addr_len);

clang-16 with W=1 complains that:

Quoted 8 lines

+net/ipv6/udp.c:341:5: warning: no previous prototype for 'udpv6_recvmsg' [-Wmissing-prototypes]
+ 341 | int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
+ | ^~~~~~~~~~~~~
+net/ipv6/udp.c:1335:5: warning: no previous prototype for 'udpv6_sendmsg' [-Wmissing-prototypes]
+ 1335 | int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
+ | ^~~~~~~~~~~~~

Likewise it has similar complains about ipv4 in a subsequent patch.

Good catch!

This series survived allmodconfig and allyesconfig with gcc, but I didn't add W=1.

Will fix it, thanks!

Quoted 7 lines
Quoted 7 lines
net/ipv6/udp_impl.h deleted +0 -6
-void udpv6_destroy_sock(struct sock *sk);
-
-#ifdef CONFIG_PROC_FS
-int udp6_seq_show(struct seq_file *seq, void *v);
-#endif
-#endif	/* _UDP6_IMPL_H */
maintainer
#22 lore raw
In reply to Kuniyuki Iwashima
Quoted 32 lines · Kuniyuki Iwashima

From: Willem de Bruijn <[email protected]>
Date: Mon, 29 May 2023 22:15:06 -0400

Quoted 23 lines · Kuniyuki Iwashima
Quoted 9 lines

Recently syzkaller reported a 7-year-old null-ptr-deref [0] that occurs when a UDP-Lite socket tries to allocate a buffer under memory pressure.

Someone should have stumbled on the bug much earlier if UDP-Lite had been used in a real app. Additionally, we do not always need a large UDP-Lite workload to hit the bug since UDP and UDP-Lite share the same memory accounting limit.

Quoted 7 lines

Given no one uses UDP-Lite, we can drop it and simplify UDP code by removing a bunch of conditionals.

This series removes UDP-Lite support from the core networking stack first and incrementally removes the dead code.

[0]: https://lore.kernel.org/netdev/[email protected]/

Even if there is high confidence that this protocol is unused, for which I'm not sure the above is sufficient proof, it should be disabled first and left in place, and removed only when there is no chance that it has to be re-enabled.

Quoted 5 lines

We already have code churn here from the split between UDP and UDPLite, which was reverted in commit db8dac20d519 ("[UDP]: Revert udplite and code split."). This series would be an enormous change to revert. And if sufficient time passes in between, there might be ample patch conflicts, the fixups of which are sources for subtle bugs.

Quoted 7 lines

Thanks Willem, I didn't know someone attempted to disable UDP-Lite.

You may prefer this way.
https://lore.kernel.org/netdev/[email protected]/

I'm fine whichever, but the next question will be like how long should we wait ? We happen to know that we have already waited for 7 years.

Is it a significant burden to keep the protocol, in case anyone is willing to maintain it?

If consensus is that it is time to remove, a warning may not be sufficient for people to notice.

Perhaps break it, but in a way that can be undone trivially, preferably even without recompiling the kernel. Say, returning EOPNOTSUPP on socket creation, unless a sysctl has some magic non-deprecated value. But maybe I'm overthinking it. There must be prior art for this?

maintainer
#23 lore raw
Quoted 11 lines · On Tue, 30 May 2023 16:16:20 -0400 Willem de Bruijn wrote:

Is it a significant burden to keep the protocol, in case anyone is willing to maintain it?

If consensus is that it is time to remove, a warning may not be sufficient for people to notice.

Perhaps break it, but in a way that can be undone trivially, preferably even without recompiling the kernel. Say, returning EOPNOTSUPP on socket creation, unless a sysctl has some magic non-deprecated value. But maybe I'm overthinking it. There must be prior art for this?

It may be the most intertwined feature we attempted to remove. UFO was smaller, right?

Did deprecation warnings ever work?

How about we try to push a WARN_ONCE() on socket creation to net and stable? With a message along the lines of "UDP lite is assumed to have no users, and is been deleted, please contact netdev@.."

Then delete the whole thing in net-next? Hopefully pushing to stable would expedite user reports? We'll find out if Greg throws rotten fruit at us or not..

#24 lore raw

From: Jakub Kicinski <[email protected]>
Date: Tue, 30 May 2023 15:14:01 -0700

Quoted 18 lines · On Tue, 30 May 2023 16:16:20 -0400 Willem de Bruijn wrote:
Quoted 11 lines

Is it a significant burden to keep the protocol, in case anyone is willing to maintain it?

If consensus is that it is time to remove, a warning may not be sufficient for people to notice.

Perhaps break it, but in a way that can be undone trivially, preferably even without recompiling the kernel. Say, returning EOPNOTSUPP on socket creation, unless a sysctl has some magic non-deprecated value. But maybe I'm overthinking it. There must be prior art for this?

It may be the most intertwined feature we attempted to remove. UFO was smaller, right?

Did deprecation warnings ever work?

Quoted 7 lines

How about we try to push a WARN_ONCE() on socket creation to net and stable? With a message along the lines of "UDP lite is assumed to have no users, and is been deleted, please contact netdev@.."

Then delete the whole thing in net-next? Hopefully pushing to stable would expedite user reports? We'll find out if Greg throws rotten fruit at us or not..

Yes, if it's ok, it would be better to add a WARN_ONCE() to stable.

If we added it only in net-next, no one might notice it and we could remove UDP-Lite before the warning is available in the next LTS stable tree.

#25 lore raw
Quoted 29 lines · Kuniyuki Iwashima

From: Jakub Kicinski <[email protected]>
Date: Tue, 30 May 2023 15:14:01 -0700

Quoted 18 lines · On Tue, 30 May 2023 16:16:20 -0400 Willem de Bruijn wrote:
Quoted 11 lines

Is it a significant burden to keep the protocol, in case anyone is willing to maintain it?

If consensus is that it is time to remove, a warning may not be sufficient for people to notice.

Perhaps break it, but in a way that can be undone trivially, preferably even without recompiling the kernel. Say, returning EOPNOTSUPP on socket creation, unless a sysctl has some magic non-deprecated value. But maybe I'm overthinking it. There must be prior art for this?

It may be the most intertwined feature we attempted to remove. UFO was smaller, right?

Did deprecation warnings ever work?

Quoted 7 lines

How about we try to push a WARN_ONCE() on socket creation to net and stable? With a message along the lines of "UDP lite is assumed to have no users, and is been deleted, please contact netdev@.."

Then delete the whole thing in net-next? Hopefully pushing to stable would expedite user reports? We'll find out if Greg throws rotten fruit at us or not..

Quoted 5 lines

Yes, if it's ok, it would be better to add a WARN_ONCE() to stable.

If we added it only in net-next, no one might notice it and we could remove UDP-Lite before the warning is available in the next LTS stable tree.

WARN_ONCE() will fire a syzbot report.

Honestly I do not think UDP-Lite is a significant burden.

What about instead adding a CONFIG_UDPLITE and default it to "CONFIG_UDPLITE is not set" ?

And add a static key, with /proc/sys/net/core/udplite_enable to eventually save some cycles in various fast paths
and let the user opt-in, in case it is using a distro kernel. with CONFIG_UDPLITE=y

DCCP is more interesting because removing it would allow for a better organisation of tcp fields to reduce
number of cache lines hit in the fast path.

maintainer
#26 lore raw
Quoted 10 lines · On Wed, 31 May 2023 06:25:33 +0200 Eric Dumazet wrote:
Quoted 5 lines

Yes, if it's ok, it would be better to add a WARN_ONCE() to stable.

If we added it only in net-next, no one might notice it and we could remove UDP-Lite before the warning is available in the next LTS stable tree.

WARN_ONCE() will fire a syzbot report.

Honestly I do not think UDP-Lite is a significant burden.

Quoted 7 lines

What about instead adding a CONFIG_UDPLITE and default it to "CONFIG_UDPLITE is not set" ?

And add a static key, with /proc/sys/net/core/udplite_enable to eventually save some cycles in various fast paths
and let the user opt-in, in case it is using a distro kernel. with CONFIG_UDPLITE=y

oohm, fair point user-reachable WARN() is a liability. CONFIG_UDPLITE sounds like the best available option :( With an appropriately discouraging config text.
That way syzbot can prevent bitrot but distros will hopefully drop it.

Quoted 3 lines

DCCP is more interesting because removing it would allow for a better organisation of tcp fields to reduce
number of cache lines hit in the fast path.

maintainer
#27 lore raw
Quoted 14 lines · Jakub Kicinski
Quoted 13 lines · On Wed, 31 May 2023 06:25:33 +0200 Eric Dumazet wrote:
Quoted 5 lines

Yes, if it's ok, it would be better to add a WARN_ONCE() to stable.

If we added it only in net-next, no one might notice it and we could remove UDP-Lite before the warning is available in the next LTS stable tree.

WARN_ONCE() will fire a syzbot report.

Honestly I do not think UDP-Lite is a significant burden.

What about instead adding a CONFIG_UDPLITE and default it to "CONFIG_UDPLITE is not set" ?

Quoted 6 lines
Quoted 4 lines

And add a static key, with /proc/sys/net/core/udplite_enable to eventually save some cycles in various fast paths
and let the user opt-in, in case it is using a distro kernel. with CONFIG_UDPLITE=y

oohm, fair point user-reachable WARN() is a liability.

What about a plain pr_warn_once() banner, verbose enough to be noticeable? Alike:

https://lwn.net/ml/linux-fsdevel/[email protected]/

Cheers,

Paolo

maintainer
#28 lore raw
Quoted 6 lines · On Wed, 31 May 2023 08:24:02 +0200 Paolo Abeni wrote:
Quoted 1 line

oohm, fair point user-reachable WARN() is a liability.

What about a plain pr_warn_once() banner, verbose enough to be noticeable? Alike:

https://lwn.net/ml/linux-fsdevel/[email protected]/

SGTM, I think the config option will do the heavy lifting, but doesn't hurt to throw in a print as well.