Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'net-enable-udp-v6-sockets-receiving-v4-packets-with-udp'

Xin Long says:

====================
net: enable udp v6 sockets receiving v4 packets with UDP

Currently, udp v6 socket can not process v4 packets with UDP GRO, as
udp_encap_needed_key is not increased when udp_tunnel_encap_enable()
is called for v6 socket.

This patchset is to increase it and remove the unnecessary code in
bareudp in Patch 1/2, and improve rxrpc encap_enable by calling
udp_tunnel_encap_enable().
====================

Link: https://lore.kernel.org/r/cover.1612342376.git.lucien.xin@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+13 -14
-6
drivers/net/bareudp.c
··· 240 240 tunnel_cfg.encap_destroy = NULL; 241 241 setup_udp_tunnel_sock(bareudp->net, sock, &tunnel_cfg); 242 242 243 - /* As the setup_udp_tunnel_sock does not call udp_encap_enable if the 244 - * socket type is v6 an explicit call to udp_encap_enable is needed. 245 - */ 246 - if (sock->sk->sk_family == AF_INET6) 247 - udp_encap_enable(); 248 - 249 243 rcu_assign_pointer(bareudp->sock, sock); 250 244 return 0; 251 245 }
+1
include/net/udp.h
··· 467 467 468 468 DECLARE_STATIC_KEY_FALSE(udp_encap_needed_key); 469 469 void udp_encap_enable(void); 470 + void udp_encap_disable(void); 470 471 #if IS_ENABLED(CONFIG_IPV6) 471 472 DECLARE_STATIC_KEY_FALSE(udpv6_encap_needed_key); 472 473 void udpv6_encap_enable(void);
+1 -2
include/net/udp_tunnel.h
··· 181 181 #if IS_ENABLED(CONFIG_IPV6) 182 182 if (sock->sk->sk_family == PF_INET6) 183 183 ipv6_stub->udpv6_encap_enable(); 184 - else 185 184 #endif 186 - udp_encap_enable(); 185 + udp_encap_enable(); 187 186 } 188 187 189 188 #define UDP_TUNNEL_NIC_MAX_TABLES 4
+6
net/ipv4/udp.c
··· 596 596 } 597 597 EXPORT_SYMBOL(udp_encap_enable); 598 598 599 + void udp_encap_disable(void) 600 + { 601 + static_branch_dec(&udp_encap_needed_key); 602 + } 603 + EXPORT_SYMBOL(udp_encap_disable); 604 + 599 605 /* Handler for tunnels with arbitrary destination ports: no socket lookup, go 600 606 * through error handlers in encapsulations looking for a match. 601 607 */
+3 -1
net/ipv6/udp.c
··· 1608 1608 if (encap_destroy) 1609 1609 encap_destroy(sk); 1610 1610 } 1611 - if (up->encap_enabled) 1611 + if (up->encap_enabled) { 1612 1612 static_branch_dec(&udpv6_encap_needed_key); 1613 + udp_encap_disable(); 1614 + } 1613 1615 } 1614 1616 1615 1617 inet6_destroy_sock(sk);
+2 -5
net/rxrpc/local_object.c
··· 16 16 #include <linux/hashtable.h> 17 17 #include <net/sock.h> 18 18 #include <net/udp.h> 19 + #include <net/udp_tunnel.h> 19 20 #include <net/af_rxrpc.h> 20 21 #include "ar-internal.h" 21 22 ··· 136 135 udp_sk(usk)->gro_receive = NULL; 137 136 udp_sk(usk)->gro_complete = NULL; 138 137 139 - udp_encap_enable(); 140 - #if IS_ENABLED(CONFIG_AF_RXRPC_IPV6) 141 - if (local->srx.transport.family == AF_INET6) 142 - udpv6_encap_enable(); 143 - #endif 138 + udp_tunnel_encap_enable(local->socket); 144 139 usk->sk_error_report = rxrpc_error_report; 145 140 146 141 /* if a local address was supplied then bind it */