ofproto: Detect and handle errors in ofproto_port_add().
authorBen Pfaff <blp@ovn.org>
Wed, 3 Feb 2016 01:57:46 +0000 (17:57 -0800)
committerBen Pfaff <blp@ovn.org>
Wed, 3 Feb 2016 22:51:48 +0000 (14:51 -0800)
commit6108ead19335aaa7006e71d58acd9167962dcd82
tree06854db763d2b1771d41fe79a6b85676c1f2558d
parentc0e327583c133acf6bdaa3cbbdcb154d92c08f31
ofproto: Detect and handle errors in ofproto_port_add().

The update_port() function called in ofproto_port_add() can encounter
errors that prevent a port from being added, but nothing was checking for
the error and in fact update_port() didn't even pass the error along to
its caller.  This commit fixes the problem.

The scenario that led me to examine this code can be triggered as follows
from the sandbox, as long as you change --enable-dummy=override to
--enable-dummy=system in ovs-sandbox:

ovs-vsctl add-br br0
ovs-vsctl add-port br0 tun0 \
    -- set interface tun0 type=stt options:remote_ip=1.2.3.4
ovs-vsctl add-port br0 tun1 \
    -- set interface tun1 type=stt options:remote_ip=1.2.3.4

The second add-port will fail due to the duplicate tunnel options, but
ofproto_port_add() will not return the error.  Instead, it will report to
the caller that it succeeded and tell it that it has ofp_port OFPP_NONE
(65535), which is invalid and it obviously does not.  The result is that
you get bizarre log messages like this:

    tunnel|WARN|tun1: attempting to add tunnel port with same config as port 'tun0' (::->1.2.3.4, key=0, dp port=7471, pkt mark=0)
    ofproto|WARN|br0: could not add port tun1 (File exists)
    bridge|INFO|bridge br0: added interface tun1 on port 65535
    ofproto|WARN|br0: cannot configure bfd on nonexistent port 65535
    ofproto|WARN|br0: cannot configure LLDP on nonexistent port 65535
    ofproto|WARN|br0: cannot get STP status on nonexistent port 65535
    ofproto|WARN|br0: cannot get RSTP status on nonexistent port 65535
    ofproto|WARN|br0: cannot get STP stats on nonexistent port 65535
    ofproto|WARN|br0: cannot get STP stats on nonexistent port 65535

VMware-BZ: #1598643
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
ofproto/ofproto.c