net: remove indirect block netdev event registration
Drivers do not register to netdev events to set up indirect blocks anymore. Remove __flow_indr_block_cb_register() and __flow_indr_block_cb_unregister(). The frontends set up the callbacks through flow_indr_dev_setup_block() Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
e445e30cf7
commit
709ffbe19b
@@ -1008,69 +1008,6 @@ int nf_flow_table_offload_setup(struct nf_flowtable *flowtable,
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(nf_flow_table_offload_setup);
|
||||
|
||||
static void nf_flow_table_indr_block_ing_cmd(struct net_device *dev,
|
||||
struct nf_flowtable *flowtable,
|
||||
flow_indr_block_bind_cb_t *cb,
|
||||
void *cb_priv,
|
||||
enum flow_block_command cmd)
|
||||
{
|
||||
struct netlink_ext_ack extack = {};
|
||||
struct flow_block_offload bo;
|
||||
|
||||
if (!flowtable)
|
||||
return;
|
||||
|
||||
nf_flow_table_block_offload_init(&bo, dev_net(dev), cmd, flowtable,
|
||||
&extack);
|
||||
|
||||
cb(dev, cb_priv, TC_SETUP_FT, &bo);
|
||||
|
||||
nf_flow_table_block_setup(flowtable, &bo, cmd);
|
||||
}
|
||||
|
||||
static void nf_flow_table_indr_block_cb_cmd(struct nf_flowtable *flowtable,
|
||||
struct net_device *dev,
|
||||
flow_indr_block_bind_cb_t *cb,
|
||||
void *cb_priv,
|
||||
enum flow_block_command cmd)
|
||||
{
|
||||
if (!(flowtable->flags & NF_FLOWTABLE_HW_OFFLOAD))
|
||||
return;
|
||||
|
||||
nf_flow_table_indr_block_ing_cmd(dev, flowtable, cb, cb_priv, cmd);
|
||||
}
|
||||
|
||||
static void nf_flow_table_indr_block_cb(struct net_device *dev,
|
||||
flow_indr_block_bind_cb_t *cb,
|
||||
void *cb_priv,
|
||||
enum flow_block_command cmd)
|
||||
{
|
||||
struct net *net = dev_net(dev);
|
||||
struct nft_flowtable *nft_ft;
|
||||
struct nft_table *table;
|
||||
struct nft_hook *hook;
|
||||
|
||||
mutex_lock(&net->nft.commit_mutex);
|
||||
list_for_each_entry(table, &net->nft.tables, list) {
|
||||
list_for_each_entry(nft_ft, &table->flowtables, list) {
|
||||
list_for_each_entry(hook, &nft_ft->hook_list, list) {
|
||||
if (hook->ops.dev != dev)
|
||||
continue;
|
||||
|
||||
nf_flow_table_indr_block_cb_cmd(&nft_ft->data,
|
||||
dev, cb,
|
||||
cb_priv, cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
mutex_unlock(&net->nft.commit_mutex);
|
||||
}
|
||||
|
||||
static struct flow_indr_block_entry block_ing_entry = {
|
||||
.cb = nf_flow_table_indr_block_cb,
|
||||
.list = LIST_HEAD_INIT(block_ing_entry.list),
|
||||
};
|
||||
|
||||
int nf_flow_table_offload_init(void)
|
||||
{
|
||||
nf_flow_offload_wq = alloc_workqueue("nf_flow_table_offload",
|
||||
@@ -1078,13 +1015,10 @@ int nf_flow_table_offload_init(void)
|
||||
if (!nf_flow_offload_wq)
|
||||
return -ENOMEM;
|
||||
|
||||
flow_indr_add_block_cb(&block_ing_entry);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void nf_flow_table_offload_exit(void)
|
||||
{
|
||||
flow_indr_del_block_cb(&block_ing_entry);
|
||||
destroy_workqueue(nf_flow_offload_wq);
|
||||
}
|
||||
|
||||
@@ -285,25 +285,6 @@ static int nft_block_offload_cmd(struct nft_base_chain *chain,
|
||||
return nft_block_setup(chain, &bo, cmd);
|
||||
}
|
||||
|
||||
static void nft_indr_block_ing_cmd(struct net_device *dev,
|
||||
struct nft_base_chain *chain,
|
||||
flow_indr_block_bind_cb_t *cb,
|
||||
void *cb_priv,
|
||||
enum flow_block_command cmd)
|
||||
{
|
||||
struct netlink_ext_ack extack = {};
|
||||
struct flow_block_offload bo;
|
||||
|
||||
if (!chain)
|
||||
return;
|
||||
|
||||
nft_flow_block_offload_init(&bo, dev_net(dev), cmd, chain, &extack);
|
||||
|
||||
cb(dev, cb_priv, TC_SETUP_BLOCK, &bo);
|
||||
|
||||
nft_block_setup(chain, &bo, cmd);
|
||||
}
|
||||
|
||||
static void nft_indr_block_cleanup(struct flow_block_cb *block_cb)
|
||||
{
|
||||
struct nft_base_chain *basechain = block_cb->indr.data;
|
||||
@@ -575,24 +556,6 @@ static struct nft_chain *__nft_offload_get_chain(struct net_device *dev)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void nft_indr_block_cb(struct net_device *dev,
|
||||
flow_indr_block_bind_cb_t *cb, void *cb_priv,
|
||||
enum flow_block_command cmd)
|
||||
{
|
||||
struct net *net = dev_net(dev);
|
||||
struct nft_chain *chain;
|
||||
|
||||
mutex_lock(&net->nft.commit_mutex);
|
||||
chain = __nft_offload_get_chain(dev);
|
||||
if (chain && chain->flags & NFT_CHAIN_HW_OFFLOAD) {
|
||||
struct nft_base_chain *basechain;
|
||||
|
||||
basechain = nft_base_chain(chain);
|
||||
nft_indr_block_ing_cmd(dev, basechain, cb, cb_priv, cmd);
|
||||
}
|
||||
mutex_unlock(&net->nft.commit_mutex);
|
||||
}
|
||||
|
||||
static int nft_offload_netdev_event(struct notifier_block *this,
|
||||
unsigned long event, void *ptr)
|
||||
{
|
||||
@@ -614,30 +577,16 @@ static int nft_offload_netdev_event(struct notifier_block *this,
|
||||
return NOTIFY_DONE;
|
||||
}
|
||||
|
||||
static struct flow_indr_block_entry block_ing_entry = {
|
||||
.cb = nft_indr_block_cb,
|
||||
.list = LIST_HEAD_INIT(block_ing_entry.list),
|
||||
};
|
||||
|
||||
static struct notifier_block nft_offload_netdev_notifier = {
|
||||
.notifier_call = nft_offload_netdev_event,
|
||||
};
|
||||
|
||||
int nft_offload_init(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = register_netdevice_notifier(&nft_offload_netdev_notifier);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
flow_indr_add_block_cb(&block_ing_entry);
|
||||
|
||||
return 0;
|
||||
return register_netdevice_notifier(&nft_offload_netdev_notifier);
|
||||
}
|
||||
|
||||
void nft_offload_exit(void)
|
||||
{
|
||||
flow_indr_del_block_cb(&block_ing_entry);
|
||||
unregister_netdevice_notifier(&nft_offload_netdev_notifier);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user