Skip to contentSkip to conversation

net: pfcp: allocate per-cpu tstats for PFCP netdevs

PATCH Superseded Samuel Moelius 2 participants 2 messages Jun 5 – Jun 9

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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().

Assisted-by Codex:gpt-5.5-cyber-preview
---
 drivers/net/pfcp.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/pfcp.c +1 -0
index 28e6bc4a1f14..a6aa30ae0af7 100644
@@ -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
#1 lore raw
Quoted 23 lines · Samuel Moelius

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().

Assisted-by Codex:gpt-5.5-cyber-preview
---
 drivers/net/pfcp.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/pfcp.c +0 -0
index 28e6bc4a1f14..a6aa30ae0af7 100644

drivers/net/pfcp.c static void pfcp_link_setup(struct net_device *dev) · line 154

Quoted 7 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);
 }
 

We request Fixes: tags in networking tree.

Please look at Documentation/process/maintainer-netdev.rst