Bug 1731553

Summary: ovs-vsctl exit code when port being added is unable to work
Product: Red Hat Enterprise Linux Fast Datapath Reporter: Marcelo Ricardo Leitner <mleitner>
Component: openvswitch2.11Assignee: Aaron Conole <aconole>
Status: POST --- QA Contact: qding
Severity: low Docs Contact:
Priority: low    
Version: RHEL 7.7CC: ctrautma, fleitner, jhsiao, qding, ralongi
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Marcelo Ricardo Leitner 2019-07-19 18:14:33 UTC
Description of problem:
When navigating through https://bugzilla.redhat.com/show_bug.cgi?id=1725596, I've seen this behaviour in my scripts:

[root@wsfd-netdev19 ~]# ovs-vsctl add-port br0 gre0 -- set interface gre0 type=ip6gre options:key=100 options:remote_ip=2001::2
ovs-vsctl: Error detected while setting up 'gre0': could not add network device gre0 to ofproto (Address family not supported by protocol).  See ovs-vswitchd log for details.
ovs-vsctl: The default log directory is "/var/log/openvswitch".
[root@wsfd-netdev19 ~]# echo $?
0

Well, it's is correct because the port actually was added:
[root@wsfd-netdev19 ~]# ovs-vsctl show
e904851c-9eed-4041-8dd6-af304d379ca0
    Bridge ovs-sriov
        Port "eth0"
            Interface "eth0"
        Port "bond9"
            Interface "bond9"
        Port ovs-sriov
            Interface ovs-sriov
                type: internal
    Bridge "br0"
        Port "br0"
            Interface "br0"
                type: internal
        Port "ns2-veth-ab"
            Interface "ns2-veth-ab"
        Port "gre0"
            Interface "gre0"
                type: "ip6gre"
                options: {key="100", remote_ip="2001::2"}
                error: "could not add network device gre0 to ofproto (Address family not supported by protocol)"
    ovs_version: "2.11.0"


This happens with unknown interfaces as well:

[root@wsfd-netdev19 ~]# ovs-vsctl add-port br0 foobar
ovs-vsctl: Error detected while setting up 'foobar': could not open network device foobar (No such device).  See ovs-vswitchd log for details.
ovs-vsctl: The default log directory is "/var/log/openvswitch".
[root@wsfd-netdev19 ~]# ovs-vsctl show
e904851c-9eed-4041-8dd6-af304d379ca0
    Bridge ovs-sriov
        Port "eth0"
            Interface "eth0"
        Port "bond9"
            Interface "bond9"
        Port ovs-sriov
            Interface ovs-sriov
                type: internal
    Bridge "br0"
        Port "br0"
            Interface "br0"
                type: internal
        Port foobar
            Interface foobar
                error: "could not open network device foobar (No such device)"


But this is also bad because the script cannot easily detect such error condition, and so would OSP and others when adding this tunnel interface.

Is there a way to make this operation more strict, and error out on such conditions? Is it actually wanted?
Or to query (without parsing ovs-vsctl output) if a port is at least minimally functional?


Version-Release number of selected component (if applicable):
openvswitch2.11-2.11.0-14.el7fdp.x86_64

Comment 1 Matteo Croce 2019-09-20 14:57:15 UTC
If the whole transaction succeded, the command is supposed to succeed too.
Hence a 0 exit status looks reasonable.

Comment 2 Matteo Croce 2019-10-04 16:02:15 UTC
It can be triggered by an invalid ip too:

root@rhel8:~# ovs-vsctl add-port br0 gre0 -- set interface gre0 type=ip6gre options:key=100 options:remote_ip=192.168.0.300
ovs-vsctl: Error detected while setting up 'gre0': gre0: bad ip6gre 'remote_ip'
gre0: ip6gre type requires valid 'remote_ip' argument.  See ovs-vswitchd log for details.
ovs-vsctl: The default log directory is "/var/log/openvswitch".

root@rhel8:~# echo $?
0

Comment 4 Flavio Leitner 2023-06-17 17:43:03 UTC
Posted upstream: http://patchwork.ozlabs.org/project/openvswitch/list/?series=360149

Comment 5 Flavio Leitner 2023-07-05 11:48:48 UTC
Posted v3 upstream: http://patchwork.ozlabs.org/project/openvswitch/list/?series=362382