To know port numbers in openvswitch

6.1k views Asked by At

I am running a switch test Switch Test on real environment with one openvswitch and real sdn switch.

I created a bridge on openvswitch and added ports (ex. eth0, eht1). But I want to know logical port numbers (like 1, 2) which command gives me correct information. ovs-ofctl show bridge s1 shows

1(eth3): mac address etc
2(eth4):
5(eth5):

and ovs-dpctl show

port 2: eth3
port 3: eth4
port 4: eth5

But results are not showing proper mapping of physical to logical ports. Observer eth5 in both cases for ofctl it gives 5 and for dpctl it gives 4. Is there any way to get correct port id's.

I personally feel both these commands are not giving correct port ids. To isolate this scenario. On Mininet I created 2 openvswitchs and run dpctl command as above it gives me 1,2,3,4,5,6 as port numbers but I am not able to run the test with these port numbers. For both switches I used 1,2,3 test executes successfully. What I mean it, if I give 1,2,3 port numbers for one switch and 4,5,6 for another switch tests doesn't execute. Any help is much appreciated.

5

There are 5 answers

0
slowr On BEST ANSWER

You can use this command to specify the ofport of the port you are adding in the bridge:

ovs-vsctl add-port br0 eth0 -- set Interface eth0 ofport=1
1
Tuan.LC On

you can use to show ofport

sudo ovs-vsctl -- --columns=name,ofport list Interface
0
Zohreh Rezaei On

in mininet:

for switch in self.mySwitches:
        print('switch ports  :',switch.ports)
             for value in switch.ports.values():
                 print(value)

in ryu:

for value in datapath.ports.values():
    print(value.port_no)

I hope it is helpful

0
Carl On

I like this command to show me a clear picture of port numbers in OVS. For each interface, it shows ofport/dpport. Most of the time, you want to pay attention to ofport.

sudo ovs-appctl dpif/show

The ofport is the open flow port number and dpport is the port number in the underlying datapath (e.g. kernel, dpdk). Some interfaces, such as patch ports, do not have a datapath port number because they are optimized out of the real datapath.

1
keniee van On

i think you can try ovs-vsctl list Interface