Skip to content

Commit a7965d5

Browse files
committed
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: Pablo Neira Ayuso <[email protected]>
1 parent ae29045 commit a7965d5

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

net/netfilter/nf_flow_table_offload.c

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -838,12 +838,12 @@ static int nf_flow_table_block_setup(struct nf_flowtable *flowtable,
838838
return err;
839839
}
840840

841-
int nf_flow_table_offload_setup(struct nf_flowtable *flowtable,
842-
struct net_device *dev,
843-
enum flow_block_command cmd)
841+
static int nf_flow_table_offload_cmd(struct flow_block_offload *bo,
842+
struct nf_flowtable *flowtable,
843+
struct net_device *dev,
844+
enum flow_block_command cmd,
845+
struct netlink_ext_ack *extack)
844846
{
845-
struct netlink_ext_ack extack = {};
846-
struct flow_block_offload bo = {};
847847
int err;
848848

849849
if (!nf_flowtable_hw_offload(flowtable))
@@ -852,14 +852,30 @@ int nf_flow_table_offload_setup(struct nf_flowtable *flowtable,
852852
if (!dev->netdev_ops->ndo_setup_tc)
853853
return -EOPNOTSUPP;
854854

855-
bo.net = dev_net(dev);
856-
bo.block = &flowtable->flow_block;
857-
bo.command = cmd;
858-
bo.binder_type = FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS;
859-
bo.extack = &extack;
860-
INIT_LIST_HEAD(&bo.cb_list);
855+
memset(bo, 0, sizeof(*bo));
856+
bo->net = dev_net(dev);
857+
bo->block = &flowtable->flow_block;
858+
bo->command = cmd;
859+
bo->binder_type = FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS;
860+
bo->extack = extack;
861+
INIT_LIST_HEAD(&bo->cb_list);
862+
863+
err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_FT, bo);
864+
if (err < 0)
865+
return err;
866+
867+
return 0;
868+
}
869+
870+
int nf_flow_table_offload_setup(struct nf_flowtable *flowtable,
871+
struct net_device *dev,
872+
enum flow_block_command cmd)
873+
{
874+
struct netlink_ext_ack extack = {};
875+
struct flow_block_offload bo;
876+
int err;
861877

862-
err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_FT, &bo);
878+
err = nf_flow_table_offload_cmd(&bo, flowtable, dev, cmd, &extack);
863879
if (err < 0)
864880
return err;
865881

0 commit comments

Comments
 (0)