From 583a8f820434f58fca5a2b710656759ad0fb3d69 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 15 Jan 2024 11:37:38 +0000 Subject: [PATCH] Revert "udp: move udp->accept_udp_{l4|fraglist} to udp->udp_flags" This reverts commit b680a907d17ca3d2b33c6afcf879f032b6065c9b which is commit f5f52f0884a595ff99ab1a608643fe4025fca2d5 upstream. It breaks the Android kernel abi and can be brought back in the future in an abi-safe way if it is really needed. Bug: 161946584 Change-Id: I018f99dc0f55152d577c16dcfcc061ed60c9f70d Signed-off-by: Greg Kroah-Hartman --- include/linux/udp.h | 16 +++++++--------- net/ipv4/udp.c | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/include/linux/udp.h b/include/linux/udp.h index 0e6880856246..f87e2123fe7b 100644 --- a/include/linux/udp.h +++ b/include/linux/udp.h @@ -35,8 +35,6 @@ enum { UDP_FLAGS_NO_CHECK6_TX, /* Send zero UDP6 checksums on TX? */ UDP_FLAGS_NO_CHECK6_RX, /* Allow zero UDP6 checksums on RX? */ UDP_FLAGS_GRO_ENABLED, /* Request GRO aggregation */ - UDP_FLAGS_ACCEPT_FRAGLIST, - UDP_FLAGS_ACCEPT_L4, }; struct udp_sock { @@ -50,11 +48,13 @@ struct udp_sock { int pending; /* Any pending frames ? */ __u8 encap_type; /* Is this an Encapsulation socket? */ - unsigned char encap_enabled:1; /* This socket enabled encap + unsigned char encap_enabled:1, /* This socket enabled encap * processing; UDP tunnels and * different encapsulation layer set * this */ + accept_udp_l4:1, + accept_udp_fraglist:1; /* indicator bits used by pcflag: */ #define UDPLITE_BIT 0x1 /* set by udplite proto init function */ #define UDPLITE_SEND_CC 0x2 /* set via udplite setsockopt */ @@ -146,12 +146,10 @@ static inline bool udp_unexpected_gso(struct sock *sk, struct sk_buff *skb) if (!skb_is_gso(skb)) return false; - if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4 && - !udp_test_bit(ACCEPT_L4, sk)) + if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4 && !udp_sk(sk)->accept_udp_l4) return true; - if (skb_shinfo(skb)->gso_type & SKB_GSO_FRAGLIST && - !udp_test_bit(ACCEPT_FRAGLIST, sk)) + if (skb_shinfo(skb)->gso_type & SKB_GSO_FRAGLIST && !udp_sk(sk)->accept_udp_fraglist) return true; return false; @@ -159,8 +157,8 @@ static inline bool udp_unexpected_gso(struct sock *sk, struct sk_buff *skb) static inline void udp_allow_gso(struct sock *sk) { - udp_set_bit(ACCEPT_L4, sk); - udp_set_bit(ACCEPT_FRAGLIST, sk); + udp_sk(sk)->accept_udp_l4 = 1; + udp_sk(sk)->accept_udp_fraglist = 1; } #define udp_portaddr_for_each_entry(__sk, list) \ diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index df0ea45b8b8f..28292fcf0707 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -2731,7 +2731,7 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname, if (valbool) udp_tunnel_encap_enable(sk->sk_socket); udp_assign_bit(GRO_ENABLED, sk, valbool); - udp_assign_bit(ACCEPT_L4, sk, valbool); + up->accept_udp_l4 = valbool; release_sock(sk); break;