Skip to content

Commit bbaef95

Browse files
committed
netfilter: nf_tables_offload: remove rules on unregistered device only
After unbinding the list of flow_block callbacks, iterate over it to remove the existing rules in the netdevice that has just been unregistered. Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent c5d2752 commit bbaef95

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

net/netfilter/nf_tables_offload.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,16 @@ static int nft_flow_offload_unbind(struct flow_block_offload *bo,
206206
struct nft_base_chain *basechain)
207207
{
208208
struct flow_block_cb *block_cb, *next;
209+
struct flow_cls_offload cls_flow;
210+
struct nft_chain *chain;
211+
struct nft_rule *rule;
212+
213+
chain = &basechain->chain;
214+
list_for_each_entry(rule, &chain->rules, list) {
215+
nft_flow_cls_offload_setup(&cls_flow, basechain, rule, NULL,
216+
FLOW_CLS_DESTROY);
217+
nft_setup_cb_call(TC_SETUP_CLSFLOWER, &cls_flow, &bo->cb_list);
218+
}
209219

210220
list_for_each_entry_safe(block_cb, next, &bo->cb_list, list) {
211221
list_del(&block_cb->list);
@@ -445,18 +455,6 @@ static void nft_indr_block_cb(struct net_device *dev,
445455
mutex_unlock(&net->nft.commit_mutex);
446456
}
447457

448-
static void nft_offload_chain_clean(struct nft_chain *chain)
449-
{
450-
struct nft_rule *rule;
451-
452-
list_for_each_entry(rule, &chain->rules, list) {
453-
nft_flow_offload_rule(chain, rule,
454-
NULL, FLOW_CLS_DESTROY);
455-
}
456-
457-
nft_flow_offload_chain(chain, NULL, FLOW_BLOCK_UNBIND);
458-
}
459-
460458
static int nft_offload_netdev_event(struct notifier_block *this,
461459
unsigned long event, void *ptr)
462460
{
@@ -467,7 +465,9 @@ static int nft_offload_netdev_event(struct notifier_block *this,
467465
mutex_lock(&net->nft.commit_mutex);
468466
chain = __nft_offload_get_chain(dev);
469467
if (chain)
470-
nft_offload_chain_clean(chain);
468+
nft_flow_block_chain(nft_base_chain(chain), dev,
469+
FLOW_BLOCK_UNBIND);
470+
471471
mutex_unlock(&net->nft.commit_mutex);
472472

473473
return NOTIFY_DONE;

0 commit comments

Comments
 (0)