net: pfcp: allocate per-cpu tstats for PFCP netdevs
Subsystems (2)
PATCH v2 1/1 net: pfcp: allocate per-cpu tstats for PFCP netdevs
PFCP uses dev_get_tstats64() as its ndo_get_stats64 callback, but pfcp_link_setup() does not request NETDEV_PCPU_STAT_TSTATS. The net core therefore leaves dev->tstats NULL for PFCP devices.
Creating a PFCP rtnetlink device can immediately ask the new netdev for stats while building the RTM_NEWLINK notification. That reaches dev_get_tstats64() and dereferences the NULL dev->tstats pointer.
Set pcpu_stat_type to NETDEV_PCPU_STAT_TSTATS during PFCP link setup so the net core allocates the storage expected by dev_get_tstats64().
---
Changes in v2:
- Added fixes tag
drivers/net/pfcp.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/pfcp.c +1 -0
@@ -148,6 +148,7 @@ static void pfcp_link_setup(struct net_device *dev) dev->flags =IFF_POINTOPOINT |IFF_NOARP |IFF_MULTICAST ; dev->priv_flags |=IFF_NO_QUEUE ; + dev->pcpu_stat_type =NETDEV_PCPU_STAT_TSTATS ;netif_keep_dst (dev); }
Signature · 1 line
2.43.0
From: Samuel Moelius <[email protected]>
Date: Tue, 9 Jun 2026 23:22:45 +0000
Quoted 8 lines
PFCP uses
dev_get_tstats64()as itsndo_get_stats64callback, butpfcp_link_setup()does not requestNETDEV_PCPU_STAT_TSTATS. The net core therefore leavesdev->tstatsNULL for PFCP devices.Creating a PFCP rtnetlink device can immediately ask the new netdev for stats while building the
RTM_NEWLINKnotification. That reachesdev_get_tstats64()and dereferences the NULLdev->tstatspointer.
Quoted 6 lines
Set
pcpu_stat_typetoNETDEV_PCPU_STAT_TSTATSduring PFCP link setup so the net core allocates the storage expected bydev_get_tstats64().Fixes 76c8764ef36a ("pfcp: add PFCP module")Assisted-by Codex:gpt-5.5-cyber-previewSigned-off-by Samuel Moelius <[email protected]>
Quoted 12 lines
---
Changes in v2:
- Added fixes tagdrivers/net/pfcp.c | 1 + 1 file changed, 1 insertion(+)drivers/net/pfcp.c +0
-0
drivers/net/pfcp.c static void pfcp_link_setup(struct net_device *dev) · line 153
Quoted 6 lines
drivers/net/pfcp.c +1
-0@@ -148,6 +148,7 @@ static void pfcp_link_setup(struct net_device *dev) dev->flags =IFF_POINTOPOINT |IFF_NOARP |IFF_MULTICAST ; dev->priv_flags |=IFF_NO_QUEUE ; + dev->pcpu_stat_type =NETDEV_PCPU_STAT_TSTATS ;netif_keep_dst (dev); }
Thanks,
Olek
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Tue, 9 Jun 2026 23:22:45 +0000 you wrote:
PFCP uses
dev_get_tstats64()as itsndo_get_stats64callback, butpfcp_link_setup()does not requestNETDEV_PCPU_STAT_TSTATS. The net core therefore leavesdev->tstatsNULL for PFCP devices.Creating a PFCP rtnetlink device can immediately ask the new netdev for stats while building the
RTM_NEWLINKnotification. That reachesdev_get_tstats64()and dereferences the NULLdev->tstatspointer.[...]
Here is the summary with links:
- [net,v2] net: pfcp: allocate per-cpu tstats for PFCP netdevs
https://git.kernel.org/netdev/net/c/24041543da8c
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html