Skip to content

Commit 5f71d45

Browse files
committed
Merge: geneve: fetching stats vs destroy race
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/6932 JIRA: https://issues.redhat.com/browse/RHEL-93467 the device per cpu tstats are destroyed at uninit time, but OVS (and even NL I suspect) could still reach for them even later. Using the core helpers move the stats free at netdevice deallocation time, closing the race. Signed-off-by: Paolo Abeni <pabeni@redhat.com> Approved-by: Guillaume Nault <gnault@redhat.com> Approved-by: Lenny Szubowicz <lszubowi@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Augusto Caringi <acaringi@redhat.com>
2 parents 7e1f5d4 + 61d8c33 commit 5f71d45

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

drivers/net/geneve.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -328,19 +328,12 @@ static int geneve_init(struct net_device *dev)
328328
struct geneve_dev *geneve = netdev_priv(dev);
329329
int err;
330330

331-
dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
332-
if (!dev->tstats)
333-
return -ENOMEM;
334-
335331
err = gro_cells_init(&geneve->gro_cells, dev);
336-
if (err) {
337-
free_percpu(dev->tstats);
332+
if (err)
338333
return err;
339-
}
340334

341335
err = dst_cache_init(&geneve->cfg.info.dst_cache, GFP_KERNEL);
342336
if (err) {
343-
free_percpu(dev->tstats);
344337
gro_cells_destroy(&geneve->gro_cells);
345338
return err;
346339
}
@@ -354,7 +347,6 @@ static void geneve_uninit(struct net_device *dev)
354347

355348
dst_cache_destroy(&geneve->cfg.info.dst_cache);
356349
gro_cells_destroy(&geneve->gro_cells);
357-
free_percpu(dev->tstats);
358350
}
359351

360352
/* Callback from net/ipv4/udp.c to receive packets */
@@ -1190,6 +1182,7 @@ static void geneve_setup(struct net_device *dev)
11901182
dev->hw_features |= NETIF_F_RXCSUM;
11911183
dev->hw_features |= NETIF_F_GSO_SOFTWARE;
11921184

1185+
dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS;
11931186
/* MTU range: 68 - (something less than 65535) */
11941187
dev->min_mtu = ETH_MIN_MTU;
11951188
/* The max_mtu calculation does not take account of GENEVE

0 commit comments

Comments
 (0)