[ovs-dev] [1.4 backports 1/6] datapath: Honor dp_ifindex, when specified, for vport lookup by name.

Ben Pfaff blp at nicira.com
Wed Oct 24 19:47:37 UTC 2012

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.

This is a crossport of commit 24ce832d5e076e5686b15d2aadd39e8c0818e932
from master.

Bug #9889.
Signed-off-by: Ben Pfaff <blp at nicira.com>
Acked-by: Pravin B Shelar <pshelar at nicira.com>
Acked-by: Jesse Gross <jesse at nicira.com>
 datapath/datapath.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/datapath/datapath.c b/datapath/datapath.c
index 4ee8f86..11a74da 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -1693,6 +1693,9 @@ static struct vport *lookup_vport(struct ovs_header *ovs_header,
 		vport = ovs_vport_locate(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]);

More information about the dev mailing list