datapath: Honor dp_ifindex, when specified, for vport lookup by name.
authorBen Pfaff <blp@nicira.com>
Wed, 7 Mar 2012 22:11:09 +0000 (14:11 -0800)
committerBen Pfaff <blp@nicira.com>
Wed, 7 Mar 2012 22:11:09 +0000 (14:11 -0800)
When OVS_VPORT_ATTR_NAME is specified and dp_ifindex is nonzero, the
logical behavior would be for the vport name lookup scope to be limited
to the specified datapath, but in fact the dp_ifindex value was ignored.
This commit causes the search scope to be honored.

Bug #9889.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
datapath/datapath.c

index 23fb1dc83b6727944ace1bb476f019e624b4b09a..bb9696735cc45450b96e4a4f4b455461a44877ef 100644 (file)
@@ -1729,6 +1729,9 @@ static struct vport *lookup_vport(struct net *net,
                vport = ovs_vport_locate(net, nla_data(a[OVS_VPORT_ATTR_NAME]));
                if (!vport)
                        return ERR_PTR(-ENODEV);
+               if (ovs_header->dp_ifindex &&
+                   ovs_header->dp_ifindex != get_dpifindex(vport->dp))
+                       return ERR_PTR(-ENODEV);
                return vport;
        } else if (a[OVS_VPORT_ATTR_PORT_NO]) {
                u32 port_no = nla_get_u32(a[OVS_VPORT_ATTR_PORT_NO]);