From: Ben Pfaff Date: Tue, 19 Mar 2013 20:30:33 +0000 (-0700) Subject: ofproto: Check ofproto_port_query_by_name() return value when adding port. X-Git-Tag: v2.1.0~310 X-Git-Url: http://git.cascardo.eti.br/?a=commitdiff_plain;h=17f69db575069b403cfaf24e9e00c0ce37195250;p=cascardo%2Fovs.git ofproto: Check ofproto_port_query_by_name() return value when adding port. 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 Signed-off-by: Ben Pfaff --- diff --git a/AUTHORS b/AUTHORS index ac7886b0a..8154e4060 100644 --- a/AUTHORS +++ b/AUTHORS @@ -154,6 +154,7 @@ Giuseppe de Candia giuseppe.decandia@gmail.com Gordon Good ggood@nicira.com Greg Dahlman gdahlman@hotmail.com Gregor Schaffrath grsch@net.t-labs.tu-berlin.de +Guolin Yang gyang@vmware.com Hassan Khan hassan.khan@seecs.edu.pk Hector Oron hector.oron@gmail.com Henrik Amren henrik@nicira.com diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index d565b199b..2ccbcee16 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -1772,12 +1772,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; }