Re: [PATCH nf-next 9/9] netfilter: flowtable: add nf_flow_table_offload_cmd()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/14/2020 2:15 AM, Pablo Neira Ayuso wrote:
> Split nf_flow_table_offload_setup() in two functions to make it more
> maintainable.
>
> Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
> ---
>  net/netfilter/nf_flow_table_offload.c | 38 +++++++++++++++++++++++++----------
>  1 file changed, 27 insertions(+), 11 deletions(-)
>
> diff --git a/net/netfilter/nf_flow_table_offload.c b/net/netfilter/nf_flow_table_offload.c
> index a08756dc96e4..cb10d903cc47 100644
> --- a/net/netfilter/nf_flow_table_offload.c
> +++ b/net/netfilter/nf_flow_table_offload.c
> @@ -838,12 +838,12 @@ static int nf_flow_table_block_setup(struct nf_flowtable *flowtable,
>  	return err;
>  }
>  
> -int nf_flow_table_offload_setup(struct nf_flowtable *flowtable,
> -				struct net_device *dev,
> -				enum flow_block_command cmd)
> +static int nf_flow_table_offload_cmd(struct flow_block_offload *bo,
> +				     struct nf_flowtable *flowtable,
> +				     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;
>  
>  	if (!nf_flowtable_hw_offload(flowtable))
> @@ -852,17 +852,33 @@ int nf_flow_table_offload_setup(struct nf_flowtable *flowtable,
>  	if (!dev->netdev_ops->ndo_setup_tc)
>  		return -EOPNOTSUPP;
>  
> -	bo.net		= dev_net(dev);
> -	bo.block	= &flowtable->flow_block;
> -	bo.command	= cmd;
> -	bo.binder_type	= FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS;
> -	bo.extack	= &extack;
> -	INIT_LIST_HEAD(&bo.cb_list);
> +	memset(bo, 0, sizeof(*bo));
> +	bo->net		= dev_net(dev);
> +	bo->block	= &flowtable->flow_block;
> +	bo->command	= cmd;
> +	bo->binder_type	= FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS;
> +	bo->extack	= extack;
> +	INIT_LIST_HEAD(&bo->cb_list);
>  
>  	err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_FT, &bo);

This callback should be :

                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 = nf_flow_table_offload_cmd(&bo, flowtable, dev, cmd, &extack);
> +	if (err < 0)
> +		return err;
> +
>  	return nf_flow_table_block_setup(flowtable, &bo, cmd);
>  }
>  EXPORT_SYMBOL_GPL(nf_flow_table_offload_setup);



[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux