2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-30 22:05:19 +00:00

ofproto-dpif: Let the dpif report when a port is a duplicate.

The port_add() function checks whether the port about to be added to the
dpif is already present and adds it only if it is not.  This duplicates a
check also present (and necessary) in each dpif and races with it as well.
When a dpif has a large number of ports, the check can be expensive (it is
not efficiently implemented).  It would be nice to made the check cheaper,
but it also seems reasonable to do as done in this patch and just let the
dpif report the duplication.

Reported-by: Haifeng Lin <haifeng.lin@huawei.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
Ben Pfaff
2018-06-21 15:53:53 -07:00
parent e3b5d7c536
commit 7521e0cf9e
2 changed files with 10 additions and 6 deletions

View File

@@ -591,8 +591,13 @@ dpif_port_add(struct dpif *dpif, struct netdev *netdev, odp_port_t *port_nop)
netdev_ports_insert(netdev, dpif->dpif_class, &dpif_port);
}
} else {
VLOG_WARN_RL(&error_rl, "%s: failed to add %s as port: %s",
dpif_name(dpif), netdev_name, ovs_strerror(error));
if (error != EEXIST) {
VLOG_WARN_RL(&error_rl, "%s: failed to add %s as port: %s",
dpif_name(dpif), netdev_name, ovs_strerror(error));
} else {
/* It's fairly common for upper layers to try to add a duplicate
* port, and they know how to handle it properly. */
}
port_no = ODPP_NONE;
}
if (port_nop) {

View File

@@ -3683,11 +3683,10 @@ port_add(struct ofproto *ofproto_, struct netdev *netdev)
}
dp_port_name = netdev_vport_get_dpif_port(netdev, namebuf, sizeof namebuf);
if (!dpif_port_exists(ofproto->backer->dpif, dp_port_name)) {
odp_port_t port_no = ODPP_NONE;
int error;
error = dpif_port_add(ofproto->backer->dpif, netdev, &port_no);
odp_port_t port_no = ODPP_NONE;
int error = dpif_port_add(ofproto->backer->dpif, netdev, &port_no);
if (error != EEXIST) {
if (error) {
return error;
}