From: Kuniyuki Iwashima <kuniyu@google.com>
To: "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
Andrew Lunn <andrew+netdev@lunn.ch>
Cc: Simon Horman <horms@kernel.org>,
Kuniyuki Iwashima <kuniyu@google.com>,
Kuniyuki Iwashima <kuni1840@gmail.com>,
netdev@vger.kernel.org
Subject: [PATCH v1 net-next 13/15] pfcp: Store struct sock in struct pfcp_dev.
Date: Sat, 2 May 2026 03:13:06 +0000 [thread overview]
Message-ID: <20260502031401.3557229-14-kuniyu@google.com> (raw)
In-Reply-To: <20260502031401.3557229-1-kuniyu@google.com>
pfcp does not need to access struct socket itself in the fast
path; it only reads struct sock, and struct socket is only used
for tunnel setup and teardown.
Let's store struct sock directly in struct pfcp_dev.
pfcp_del_sock() is called from dev->netdev_ops->ndo_uninit().
The 2nd synchronize_net() in unregister_netdevice_many_notify()
ensures that inflight pfcp RX fast paths finish before pfcp_dev
is freed.
Note that synchronize_rcu() is added in the error path of
pfcp_newlink() since free_netdev() will free pfcp_dev immediately
once we remove synchronize_rcu() in udp_tunnel_sock_release().
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
---
drivers/net/pfcp.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/net/pfcp.c b/drivers/net/pfcp.c
index 870137695e8a..5f1c9d2c0b49 100644
--- a/drivers/net/pfcp.c
+++ b/drivers/net/pfcp.c
@@ -18,7 +18,7 @@
struct pfcp_dev {
struct list_head list;
- struct socket *sock;
+ struct sock *sk;
struct net_device *dev;
struct net *net;
@@ -104,8 +104,8 @@ static int pfcp_encap_recv(struct sock *sk, struct sk_buff *skb)
static void pfcp_del_sock(struct pfcp_dev *pfcp)
{
- udp_tunnel_sock_release(pfcp->sock->sk);
- pfcp->sock = NULL;
+ udp_tunnel_sock_release(pfcp->sk);
+ pfcp->sk = NULL;
}
static void pfcp_dev_uninit(struct net_device *dev)
@@ -151,7 +151,7 @@ static void pfcp_link_setup(struct net_device *dev)
netif_keep_dst(dev);
}
-static struct socket *pfcp_create_sock(struct pfcp_dev *pfcp)
+static struct sock *pfcp_create_sock(struct pfcp_dev *pfcp)
{
struct udp_tunnel_sock_cfg tuncfg = {};
struct udp_port_cfg udp_conf = {
@@ -174,14 +174,14 @@ static struct socket *pfcp_create_sock(struct pfcp_dev *pfcp)
setup_udp_tunnel_sock(net, sock->sk, &tuncfg);
- return sock;
+ return sock->sk;
}
static int pfcp_add_sock(struct pfcp_dev *pfcp)
{
- pfcp->sock = pfcp_create_sock(pfcp);
+ pfcp->sk = pfcp_create_sock(pfcp);
- return PTR_ERR_OR_ZERO(pfcp->sock);
+ return PTR_ERR_OR_ZERO(pfcp->sk);
}
static int pfcp_newlink(struct net_device *dev,
@@ -216,6 +216,7 @@ static int pfcp_newlink(struct net_device *dev,
exit_del_pfcp_sock:
pfcp_del_sock(pfcp);
+ synchronize_rcu();
exit_err:
pfcp->net = NULL;
return err;
--
2.54.0.545.g6539524ca2-goog
next prev parent reply other threads:[~2026-05-02 3:14 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-02 3:12 [PATCH v1 net-next 00/15] udp_tunnel: Speed up UDP tunnel device destruction (Part I) Kuniyuki Iwashima
2026-05-02 3:12 ` [PATCH v1 net-next 01/15] udp_tunnel: Pass struct sock to udp_tunnel_sock_release() Kuniyuki Iwashima
2026-05-03 18:43 ` Kuniyuki Iwashima
2026-05-02 3:12 ` [PATCH v1 net-next 02/15] udp_tunnel: Pass struct sock to setup_udp_tunnel_sock() Kuniyuki Iwashima
2026-05-02 3:12 ` [PATCH v1 net-next 03/15] udp_tunnel: Pass struct sock to udp_tunnel6_dst_lookup() Kuniyuki Iwashima
2026-05-02 3:12 ` [PATCH v1 net-next 04/15] udp_tunnel: Pass struct sock to udp_tunnel_{push,drop}_rx_port() Kuniyuki Iwashima
2026-05-02 3:12 ` [PATCH v1 net-next 05/15] udp_tunnel: Pass struct sock to udp_tunnel_notify_{add,del}_rx_port() Kuniyuki Iwashima
2026-05-02 3:12 ` [PATCH v1 net-next 06/15] vxlan: Fix potential null-ptr-deref in vxlan_gro_prepare_receive() Kuniyuki Iwashima
2026-05-02 3:13 ` [PATCH v1 net-next 07/15] vxlan: Store struct sock in struct vxlan_sock Kuniyuki Iwashima
2026-05-02 3:13 ` [PATCH v1 net-next 08/15] vxlan: Free vxlan_sock with kfree_rcu() Kuniyuki Iwashima
2026-05-02 3:13 ` [PATCH v1 net-next 09/15] geneve: Store struct sock in struct geneve_sock Kuniyuki Iwashima
2026-05-02 3:13 ` [PATCH v1 net-next 10/15] bareudp: Store struct sock in struct bareudp_dev Kuniyuki Iwashima
2026-05-03 18:47 ` Kuniyuki Iwashima
2026-05-02 3:13 ` [PATCH v1 net-next 11/15] fou: Store struct sock in struct fou Kuniyuki Iwashima
2026-05-03 18:52 ` Kuniyuki Iwashima
2026-05-02 3:13 ` [PATCH v1 net-next 12/15] amt: Store struct sock in struct amt_dev Kuniyuki Iwashima
2026-05-03 18:55 ` Kuniyuki Iwashima
2026-05-02 3:13 ` Kuniyuki Iwashima [this message]
2026-05-03 19:00 ` [PATCH v1 net-next 13/15] pfcp: Store struct sock in struct pfcp_dev Kuniyuki Iwashima
2026-05-02 3:13 ` [PATCH v1 net-next 14/15] tipc: Store struct sock in struct udp_bearer Kuniyuki Iwashima
2026-05-03 19:05 ` Kuniyuki Iwashima
2026-05-02 3:13 ` [PATCH v1 net-next 15/15] udp_tunnel: Remove synchronize_rcu() in udp_tunnel_sock_release() Kuniyuki Iwashima
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260502031401.3557229-14-kuniyu@google.com \
--to=kuniyu@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox