[PATCH] udp: Move back definition of udpv6_encap_needed_key to ipv6 file.

Siddh Raman Pant posted 1 patch 3 months, 2 weeks ago
net/ipv4/udp.c | 5 -----
net/ipv6/udp.c | 4 +++-
2 files changed, 3 insertions(+), 6 deletions(-)
[PATCH] udp: Move back definition of udpv6_encap_needed_key to ipv6 file.
Posted by Siddh Raman Pant 3 months, 2 weeks ago
It makes less sense to remove define of ipv6 variable from ipv6 file
and put it in ipv4 file and declare it in ipv6 file, which was done
in 3d010c8031e3 ("udp: do not accept non-tunnel GSO skbs landing in
a tunnel").

So let's move it back to ipv6 file. It also makes the code similar -
the key is defined right above the respective enable function.

Signed-off-by: Siddh Raman Pant <siddh.raman.pant@oracle.com>
---
I'm not sure why ipv4 key is exported using EXPORT_IPV6_MOD?

 net/ipv4/udp.c | 5 -----
 net/ipv6/udp.c | 4 +++-
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 30dfbf73729d..44b08ede7133 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -810,11 +810,6 @@ static inline bool __udp_is_mcast_sock(struct net *net, const struct sock *sk,
 DEFINE_STATIC_KEY_FALSE(udp_encap_needed_key);
 EXPORT_IPV6_MOD(udp_encap_needed_key);
 
-#if IS_ENABLED(CONFIG_IPV6)
-DEFINE_STATIC_KEY_FALSE(udpv6_encap_needed_key);
-EXPORT_IPV6_MOD(udpv6_encap_needed_key);
-#endif
-
 void udp_encap_enable(void)
 {
 	static_branch_inc(&udp_encap_needed_key);
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 813a2ba75824..6b92d4f466d5 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -596,7 +596,9 @@ int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
 	goto try_again;
 }
 
-DECLARE_STATIC_KEY_FALSE(udpv6_encap_needed_key);
+DEFINE_STATIC_KEY_FALSE(udpv6_encap_needed_key);
+EXPORT_IPV6_MOD(udpv6_encap_needed_key);
+
 void udpv6_encap_enable(void)
 {
 	static_branch_inc(&udpv6_encap_needed_key);
-- 
2.51.0
Re: [PATCH] udp: Move back definition of udpv6_encap_needed_key to ipv6 file.
Posted by kernel test robot 3 months, 2 weeks ago
Hi Siddh,

kernel test robot noticed the following build errors:

[auto build test ERROR on net-next/main]
[also build test ERROR on net/main linus/master v6.18-rc2 next-20251024]
[cannot apply to horms-ipvs/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Siddh-Raman-Pant/udp-Move-back-definition-of-udpv6_encap_needed_key-to-ipv6-file/20251023-171157
base:   net-next/main
patch link:    https://lore.kernel.org/r/20251023090736.99644-1-siddh.raman.pant%40oracle.com
patch subject: [PATCH] udp: Move back definition of udpv6_encap_needed_key to ipv6 file.
config: arm64-defconfig (https://download.01.org/0day-ci/archive/20251024/202510242214.RjDUfVB7-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 15.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251024/202510242214.RjDUfVB7-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202510242214.RjDUfVB7-lkp@intel.com/

All errors (new ones prefixed by >>):

>> aarch64-linux-ld: net/ipv4/udp.o:(__jump_table+0xe8): undefined reference to `udpv6_encap_needed_key'

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH] udp: Move back definition of udpv6_encap_needed_key to ipv6 file.
Posted by Sabrina Dubroca 3 months, 2 weeks ago
2025-10-23, 14:37:36 +0530, Siddh Raman Pant wrote:
> It makes less sense to remove define of ipv6 variable from ipv6 file
> and put it in ipv4 file and declare it in ipv6 file, which was done
> in 3d010c8031e3 ("udp: do not accept non-tunnel GSO skbs landing in
> a tunnel").

It would be good to CC all the authors and reviewers of the patch(es)
you're mentioning.

> So let's move it back to ipv6 file. It also makes the code similar -
> the key is defined right above the respective enable function.

I don't think that works with CONFIG_IPV6=m. The ipv4 code will need
to access the key via udp_encap_needed().


> Signed-off-by: Siddh Raman Pant <siddh.raman.pant@oracle.com>
> ---
> I'm not sure why ipv4 key is exported using EXPORT_IPV6_MOD?

So that the ipv6 code can use it via
udp_encap_needed()/udp_unexpected_gso() when it's built as a module.

-- 
Sabrina
Re: [PATCH] udp: Move back definition of udpv6_encap_needed_key to ipv6 file.
Posted by Siddh Raman Pant 3 months, 2 weeks ago
On Thu, Oct 23 2025 at 15:47:37 +0530, Sabrina Dubroca wrote:
> 2025-10-23, 14:37:36 +0530, Siddh Raman Pant wrote:
> > It makes less sense to remove define of ipv6 variable from ipv6 file
> > and put it in ipv4 file and declare it in ipv6 file, which was done
> > in 3d010c8031e3 ("udp: do not accept non-tunnel GSO skbs landing in
> > a tunnel").
> 
> It would be good to CC all the authors and reviewers of the patch(es)
> you're mentioning.
> 
> > So let's move it back to ipv6 file. It also makes the code similar -
> > the key is defined right above the respective enable function.
> 
> I don't think that works with CONFIG_IPV6=m. The ipv4 code will need
> to access the key via udp_encap_needed().
> 
> 
> > Signed-off-by: Siddh Raman Pant <siddh.raman.pant@oracle.com>
> > ---
> > I'm not sure why ipv4 key is exported using EXPORT_IPV6_MOD?
> 
> So that the ipv6 code can use it via
> udp_encap_needed()/udp_unexpected_gso() when it's built as a module.

Cool, thank you very much for the explanation! That was what I was
missing.

Please ignore this patch then.

Thanks,
Siddh