[ovs-dev] [PATCH] datapath: Fully initialize datapath before local port.

Jesse Gross jesse at nicira.com
Fri Sep 16 00:23:51 UTC 2011


On Thu, Sep 15, 2011 at 4:57 PM, Ben Pfaff <blp at nicira.com> wrote:
> On Thu, Sep 15, 2011 at 04:52:39PM -0700, Jesse Gross wrote:
>> It's possible to start receiving packets on a datapath as soon as
>> the internal device is created.  It's therefore important that the
>> datapath be fully initialized before this, which it currently isn't.
>> In particularly, the fact that dp->stats_percpu is not yet set is
>> potentially fatal.  In addition, if allocation of the Netlink response
>> failed it would leak the percpu memory.  This fixes both problems.
>>
>> Found by code inspection, in practice the datapath is probably always
>> done initializing before someone can send a packet on it.
>>
>> Signed-off-by: Jesse Gross <jesse at nicira.com>
>
> Don't we now dereference an uninitialized pointer?
>
>    struct vport *vport;
> ...
>    dp->dp_ifindex = vport_get_ifindex(vport);
> ...
>    vport = new_vport(&parms);

Oops, you're right.  Annoyingly we do need to set dp_ifindex before
the internal port gets going because when it misses the (empy) flow
table we need the ifindex for the upcall.

I guess we have to do the assignment in internal_dev_create() with a
memory barrier before netif_start_queue()...



More information about the dev mailing list