Skip to content

Commit

Permalink
netfilter: nf_tables: check if bind callback fails and unbind if hook…
Browse files Browse the repository at this point in the history
… registration fails

Undo the callback binding before unregistering the existing hooks. This
should also check for error of the bind setup call.

Fixes: c29f74e ("netfilter: nf_flow_table: hardware offload support")
Signed-off-by: wenxu <wenxu@ucloud.cn>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
wenxu authored and Pablo Neira Ayuso committed Nov 15, 2019
1 parent 63b48c7 commit d7c03a9
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions net/netfilter/nf_tables_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -6006,12 +6006,20 @@ static int nft_register_flowtable_net_hooks(struct net *net,
}
}

flowtable->data.type->setup(&flowtable->data, hook->ops.dev,
FLOW_BLOCK_BIND);
err = nf_register_net_hook(net, &hook->ops);
err = flowtable->data.type->setup(&flowtable->data,
hook->ops.dev,
FLOW_BLOCK_BIND);
if (err < 0)
goto err_unregister_net_hooks;

err = nf_register_net_hook(net, &hook->ops);
if (err < 0) {
flowtable->data.type->setup(&flowtable->data,
hook->ops.dev,
FLOW_BLOCK_UNBIND);
goto err_unregister_net_hooks;
}

i++;
}

Expand Down

0 comments on commit d7c03a9

Please sign in to comment.