[ovs-dev] [PATCH 1/7] datapath: Move flow allocation into a function.

Ben Pfaff blp at nicira.com
Mon Sep 20 19:02:59 UTC 2010


On Mon, Sep 20, 2010 at 11:13:39AM -0700, Jesse Gross wrote:
> As the process to allocate a flow becomes more involved it becomes
> more cumbersome for the code to be mixed in with the general
> datapath so split it out into a new function.
> 
> Signed-off-by: Jesse Gross <jesse at nicira.com>

Looks OK, one nit is that the line "error = -ENOMEM;" below can now be
dropped:

> diff --git a/datapath/datapath.c b/datapath/datapath.c
> index b3f77b3..1f83f34 100644
> --- a/datapath/datapath.c
> +++ b/datapath/datapath.c
> @@ -1050,11 +1050,12 @@ static int do_put_flow(struct datapath *dp, struct odp_flow_put *uf,
>  
>  		/* Allocate flow. */
>  		error = -ENOMEM;
> -		flow = kmem_cache_alloc(flow_cache, GFP_KERNEL);
> -		if (flow == NULL)
> +		flow = flow_alloc();
> +		if (IS_ERR(flow)) {
> +			error = PTR_ERR(flow);
>  			goto error;
> +		}
>  		flow->key = uf->flow.key;
> -		spin_lock_init(&flow->lock);




More information about the dev mailing list