]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
udp_tunnel: Pass struct sock to udp_tunnel_notify_{add,del}_rx_port().
authorKuniyuki Iwashima <kuniyu@google.com>
Sat, 2 May 2026 03:12:58 +0000 (03:12 +0000)
committerJakub Kicinski <kuba@kernel.org>
Wed, 6 May 2026 00:47:04 +0000 (17:47 -0700)
None of the udp_tunnel users need struct socket in their
fast paths; it is only used for tunnel setup / teardown.

Even udp_tunnel_notify_{add,del}_rx_port() do not need
struct socket.

Let's change udp_tunnel_notify_{add,del}_rx_port() to take
struct sock instead of struct socket.

Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20260502031401.3557229-6-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/geneve.c
drivers/net/vxlan/vxlan_core.c
include/net/udp_tunnel.h
net/ipv4/udp_tunnel_core.c

index 16df8d5c42c9f9f3c8352e96c9eb2c4f873ef412..9cf62d3ee4710605c78182947f4600911e112c01 100644 (file)
@@ -995,7 +995,7 @@ static struct geneve_sock *geneve_socket_create(struct net *net, __be16 port,
                INIT_HLIST_HEAD(&gs->vni_list[h]);
 
        /* Initialize the geneve udp offloads structure */
-       udp_tunnel_notify_add_rx_port(gs->sock, UDP_TUNNEL_TYPE_GENEVE);
+       udp_tunnel_notify_add_rx_port(gs->sock->sk, UDP_TUNNEL_TYPE_GENEVE);
 
        /* Mark socket as an encapsulation socket */
        memset(&tunnel_cfg, 0, sizeof(tunnel_cfg));
@@ -1017,7 +1017,7 @@ static void __geneve_sock_release(struct geneve_sock *gs)
                return;
 
        list_del(&gs->list);
-       udp_tunnel_notify_del_rx_port(gs->sock, UDP_TUNNEL_TYPE_GENEVE);
+       udp_tunnel_notify_del_rx_port(gs->sock->sk, UDP_TUNNEL_TYPE_GENEVE);
        udp_tunnel_sock_release(gs->sock->sk);
        kfree_rcu(gs, rcu);
 }
index 184df57bc7056258e35d78e23864c1a730d06046..0ea88232b985119a091097afab1f15608f94df36 100644 (file)
@@ -1493,7 +1493,7 @@ static bool __vxlan_sock_release_prep(struct vxlan_sock *vs)
                return false;
 
        hlist_del_rcu(&vs->hlist);
-       udp_tunnel_notify_del_rx_port(vs->sock,
+       udp_tunnel_notify_del_rx_port(vs->sock->sk,
                                      (vs->flags & VXLAN_F_GPE) ?
                                      UDP_TUNNEL_TYPE_VXLAN_GPE :
                                      UDP_TUNNEL_TYPE_VXLAN);
@@ -3600,7 +3600,7 @@ static struct vxlan_sock *vxlan_socket_create(struct net *net, bool ipv6,
        vs->flags = (flags & VXLAN_F_RCV_FLAGS);
 
        hlist_add_head_rcu(&vs->hlist, vs_head(net, port));
-       udp_tunnel_notify_add_rx_port(sock,
+       udp_tunnel_notify_add_rx_port(sock->sk,
                                      (vs->flags & VXLAN_F_GPE) ?
                                      UDP_TUNNEL_TYPE_VXLAN_GPE :
                                      UDP_TUNNEL_TYPE_VXLAN);
index 29ead6a38ef646950c4471dbfaccb0e50339911d..498b7b262fa94330bd70b3211ab809fe5bf58add 100644 (file)
@@ -131,8 +131,8 @@ void udp_tunnel_push_rx_port(struct net_device *dev, struct sock *sk,
                             unsigned short type);
 void udp_tunnel_drop_rx_port(struct net_device *dev, struct sock *sk,
                             unsigned short type);
-void udp_tunnel_notify_add_rx_port(struct socket *sock, unsigned short type);
-void udp_tunnel_notify_del_rx_port(struct socket *sock, unsigned short type);
+void udp_tunnel_notify_add_rx_port(struct sock *sk, unsigned short type);
+void udp_tunnel_notify_del_rx_port(struct sock *sk, unsigned short type);
 
 /* Transmit the skb using UDP encapsulation. */
 void udp_tunnel_xmit_skb(struct rtable *rt, struct sock *sk, struct sk_buff *skb,
index 857b51d62ce1140319e49e2aaf93e8d1a4a0574b..44788b95c8235ed6604a2d89cba36beda3a765af 100644 (file)
@@ -124,9 +124,8 @@ void udp_tunnel_drop_rx_port(struct net_device *dev, struct sock *sk,
 EXPORT_SYMBOL_GPL(udp_tunnel_drop_rx_port);
 
 /* Notify netdevs that UDP port started listening */
-void udp_tunnel_notify_add_rx_port(struct socket *sock, unsigned short type)
+void udp_tunnel_notify_add_rx_port(struct sock *sk, unsigned short type)
 {
-       struct sock *sk = sock->sk;
        struct net *net = sock_net(sk);
        struct udp_tunnel_info ti;
        struct net_device *dev;
@@ -146,9 +145,8 @@ void udp_tunnel_notify_add_rx_port(struct socket *sock, unsigned short type)
 EXPORT_SYMBOL_GPL(udp_tunnel_notify_add_rx_port);
 
 /* Notify netdevs that UDP port is no more listening */
-void udp_tunnel_notify_del_rx_port(struct socket *sock, unsigned short type)
+void udp_tunnel_notify_del_rx_port(struct sock *sk, unsigned short type)
 {
-       struct sock *sk = sock->sk;
        struct net *net = sock_net(sk);
        struct udp_tunnel_info ti;
        struct net_device *dev;