Otherwise, if the port add succeeds but the query that looks up the port number fails, then ofproto_port_add() would return zero as the OpenFlow port number and ignore the error.
Reported-by: Guolin Yang <[email protected]> Signed-off-by: Ben Pfaff <[email protected]> --- v1 was posted on March 19. This version is merely a rebase of v1. AUTHORS | 1 + ofproto/ofproto.c | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/AUTHORS b/AUTHORS index ac7886b..8154e40 100644 --- a/AUTHORS +++ b/AUTHORS @@ -154,6 +154,7 @@ Giuseppe de Candia [email protected] Gordon Good [email protected] Greg Dahlman [email protected] Gregor Schaffrath [email protected] +Guolin Yang [email protected] Hassan Khan [email protected] Hector Oron [email protected] Henrik Amren [email protected] diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index b88cd81..b4ddb4d 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -1758,12 +1758,18 @@ ofproto_port_add(struct ofproto *ofproto, struct netdev *netdev, update_port(ofproto, netdev_name); } if (ofp_portp) { - struct ofproto_port ofproto_port; - - ofproto_port_query_by_name(ofproto, netdev_get_name(netdev), - &ofproto_port); - *ofp_portp = error ? OFPP_NONE : ofproto_port.ofp_port; - ofproto_port_destroy(&ofproto_port); + *ofp_portp = OFPP_NONE; + if (!error) { + struct ofproto_port ofproto_port; + + error = ofproto_port_query_by_name(ofproto, + netdev_get_name(netdev), + &ofproto_port); + if (!error) { + *ofp_portp = ofproto_port.ofp_port; + ofproto_port_destroy(&ofproto_port); + } + } } return error; } -- 1.7.10.4 _______________________________________________ dev mailing list [email protected] http://openvswitch.org/mailman/listinfo/dev
