Score:0

simple openvswitch forward demo not work

fo flag

What are the details of your problem?

Hi, that is my first time try ovs. i am using Arch Linux, and installed openvswitch.

use sudo ip link add v1 type dummy && sudo ip addr add 10.0.0.1/24 dev v1 && sudo ip link set v1 up created v1, v2 (10.0.0.2/24), v3 (10.0.0.3/24) three virtual network cards.

add v1 v2 v3 to ovs by sudo ovs-vsctl add-port ovsbridge $NETCARDNAME.

add a flow rule by sudo ovs-ofctl add-flow ovsbridge in_port=4,actions=output:5 ( ovs port 4 is v1 netcard, ovs port 5 is v2 netcard). checked by sudo ovs-ofctl show ovsbridge

for now, i use python-scapy send packages to v1 netcard, and i using tcpdump -i INTERFACE_NAME -w tcpdump_output -vnnl catch v1 v2 package nums. v1 received 10 packages, but v2 received 0.

What did you try

# start ovs by systemd

$ sudo ovs-vsctl add-br ovsbridge

$ sudo ovs-vsctl show
7194d04a-66aa-48c2-bfa4-99bbdc6fc4b2
    Bridge ovsbridge
        Port ovsbridge
            Interface ovsbridge
                type: internal

$ ip a # part of
8: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 3e:9a:4c:83:04:43 brd ff:ff:ff:ff:ff:ff
9: ovsbridge: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
    link/ether 96:35:f1:d2:6b:46 brd ff:ff:ff:ff:ff:ff

$ sudo ip link add v1 type dummy
$ sudo ip addr add 10.0.0.1/24 dev v1
$ sudo ip link set v1 up
# and same to v2 v3

# add them to ovs
$ sudo ovs-vsctl add-port ovsbridge v1

$ sudo ovs-vsctl show
7194d04a-66aa-48c2-bfa4-99bbdc6fc4b2
    Bridge ovsbridge
        Port ovsbridge
            Interface ovsbridge
                type: internal
        Port v3
            Interface v3
        Port v2
            Interface v2
        Port v1
            Interface v1

$ ip a # part of
38: v1: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue master ovs-system state UNKNOWN group default qlen 1000
    link/ether da:11:b3:77:37:54 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.1/24 scope global v1
       valid_lft forever preferred_lft forever
    inet6 fe80::d811:b3ff:fe77:3754/64 scope link 
       valid_lft forever preferred_lft forever
39: v2: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue master ovs-system state UNKNOWN group default qlen 1000
    link/ether ca:06:56:9c:af:6d brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.2/24 scope global v2
       valid_lft forever preferred_lft forever
    inet6 fe80::c806:56ff:fe9c:af6d/64 scope link 
       valid_lft forever preferred_lft forever
40: v3: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue master ovs-system state UNKNOWN group default qlen 1000
    link/ether 82:a4:e7:b0:e0:71 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.3/24 scope global v3
       valid_lft forever preferred_lft forever
    inet6 fe80::80a4:e7ff:feb0:e071/64 scope link 
       valid_lft forever preferred_lft forever

# add flow try forward v1 to v2
$ sudo ovs-ofctl add-flow ovsbridge in_port=4,actions=output:5

# check flow rule
$  sudo ovs-ofctl dump-flows ovsbridge
 cookie=0x0, duration=1138.852s, table=0, n_packets=0, n_bytes=0, in_port=v1 actions=output:v2
 cookie=0x0, duration=32571.512s, table=0, n_packets=518, n_bytes=177156, priority=0 actions=NORMAL

$ sudo ovs-appctl fdb/show ovsbridge
 port  VLAN  MAC                Age
LOCAL     0  a8:7e:ea:be:07:e4  278
$ cat rnd_pkt.py # part of

scapy.sendp(get_random_packet(), iface=v1)

# send 10 packages to v1

and sudo ovs-tcpdump -i v1 do not show package that i send by scapy. i am thinking maybe i shouldn't test by use python-scapy?

what were you expecting?

i expect ovs will copy package from v1 to v2.

if you guys need more info, please tell me. :)

Score:0
fo flag

use ip link set $NETCARD promisc on to enable promisc mode, and it works fine.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.