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]> --- AUTHORS | 1 + ofproto/ofproto.c | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/AUTHORS b/AUTHORS index 2723fd2..b934048 100644 --- a/AUTHORS +++ b/AUTHORS @@ -130,6 +130,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 03ca59b..38b394b 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -1441,12 +1441,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.2.5 _______________________________________________ dev mailing list [email protected] http://openvswitch.org/mailman/listinfo/dev
