Skip to content

Commit b48c05a

Browse files
committed
xfrm: Fix warning in xfrm6_tunnel_net_exit.
We need to make sure that all states are really deleted before we check that the state lists are empty. Otherwise we trigger a warning. Fixes: baeb0db ("xfrm6_tunnel: exit_net cleanup check added") Reported-and-tested-by:[email protected] Signed-off-by: Steffen Klassert <[email protected]>
1 parent 4b66af2 commit b48c05a

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

include/net/xfrm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ struct xfrm_input_afinfo {
375375
int xfrm_input_register_afinfo(const struct xfrm_input_afinfo *afinfo);
376376
int xfrm_input_unregister_afinfo(const struct xfrm_input_afinfo *afinfo);
377377

378+
void xfrm_flush_gc(void);
378379
void xfrm_state_delete_tunnel(struct xfrm_state *x);
379380

380381
struct xfrm_type {

net/ipv6/xfrm6_tunnel.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,9 @@ static void __net_exit xfrm6_tunnel_net_exit(struct net *net)
341341
struct xfrm6_tunnel_net *xfrm6_tn = xfrm6_tunnel_pernet(net);
342342
unsigned int i;
343343

344+
xfrm_state_flush(net, IPSEC_PROTO_ANY, false);
345+
xfrm_flush_gc();
346+
344347
for (i = 0; i < XFRM6_TUNNEL_SPI_BYADDR_HSIZE; i++)
345348
WARN_ON_ONCE(!hlist_empty(&xfrm6_tn->spi_byaddr[i]));
346349

net/xfrm/xfrm_state.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,6 +2175,12 @@ struct xfrm_state_afinfo *xfrm_state_get_afinfo(unsigned int family)
21752175
return afinfo;
21762176
}
21772177

2178+
void xfrm_flush_gc(void)
2179+
{
2180+
flush_work(&xfrm_state_gc_work);
2181+
}
2182+
EXPORT_SYMBOL(xfrm_flush_gc);
2183+
21782184
/* Temporarily located here until net/xfrm/xfrm_tunnel.c is created */
21792185
void xfrm_state_delete_tunnel(struct xfrm_state *x)
21802186
{

0 commit comments

Comments
 (0)