Commit a7965d58 authored by Pablo Neira Ayuso's avatar Pablo Neira Ayuso

netfilter: flowtable: add nf_flow_table_offload_cmd()

Split nf_flow_table_offload_setup() in two functions to make it more
maintainable.
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent ae290450
...@@ -838,12 +838,12 @@ static int nf_flow_table_block_setup(struct nf_flowtable *flowtable, ...@@ -838,12 +838,12 @@ static int nf_flow_table_block_setup(struct nf_flowtable *flowtable,
return err; return err;
} }
int nf_flow_table_offload_setup(struct nf_flowtable *flowtable, static int nf_flow_table_offload_cmd(struct flow_block_offload *bo,
struct net_device *dev, struct nf_flowtable *flowtable,
enum flow_block_command cmd) struct net_device *dev,
enum flow_block_command cmd,
struct netlink_ext_ack *extack)
{ {
struct netlink_ext_ack extack = {};
struct flow_block_offload bo = {};
int err; int err;
if (!nf_flowtable_hw_offload(flowtable)) if (!nf_flowtable_hw_offload(flowtable))
...@@ -852,14 +852,30 @@ int nf_flow_table_offload_setup(struct nf_flowtable *flowtable, ...@@ -852,14 +852,30 @@ int nf_flow_table_offload_setup(struct nf_flowtable *flowtable,
if (!dev->netdev_ops->ndo_setup_tc) if (!dev->netdev_ops->ndo_setup_tc)
return -EOPNOTSUPP; return -EOPNOTSUPP;
bo.net = dev_net(dev); memset(bo, 0, sizeof(*bo));
bo.block = &flowtable->flow_block; bo->net = dev_net(dev);
bo.command = cmd; bo->block = &flowtable->flow_block;
bo.binder_type = FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS; bo->command = cmd;
bo.extack = &extack; bo->binder_type = FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS;
INIT_LIST_HEAD(&bo.cb_list); bo->extack = extack;
INIT_LIST_HEAD(&bo->cb_list);
err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_FT, bo);
if (err < 0)
return err;
return 0;
}
int nf_flow_table_offload_setup(struct nf_flowtable *flowtable,
struct net_device *dev,
enum flow_block_command cmd)
{
struct netlink_ext_ack extack = {};
struct flow_block_offload bo;
int err;
err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_FT, &bo); err = nf_flow_table_offload_cmd(&bo, flowtable, dev, cmd, &extack);
if (err < 0) if (err < 0)
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment