Refering to https://stackoverflow.com/questions/44347485/change-linux-bridge-to-openvswitch-in-openwrt ,i maked OVS used in R2 with openwrt .
edit the network configuration /etc/config/netowrk to be like this:
Before the change
config interface 'lan'
option type 'bridge'
option ifname 'lan0 lan1 lan2 lan3'
option proto 'static'
option ipaddr '192.168.1.1'
option netmask '255.255.255.0'
option ip6assign '60'
After the change (ovslan should be replaced by you OVS bridge name)
config interface 'lan'
option ifname 'ovslan'
option proto 'static'
option ipaddr '192.168.1.1'
option netmask '255.255.255.0'
option ip6assign '60'
delele the interfaces of br-lan using brctl delif br-lan lanx
root@OpenWrt:/# brctl show
bridge name bridge id STP enabled interfaces
br-lan 7fff.eaf8a04458ac no lan0
lan1
lan2
lan3
root@OpenWrt:/# brctl delif br-lan lan0
[ 1977.246222] device lan0 left promiscuous mode
[ 1977.252879] br-lan: port 1(lan0) entered disabled state
root@OpenWrt:/# brctl delif br-lan lan1
[ 1980.036088] device lan1 left promiscuous mode
[ 1980.042645] br-lan: port 2(lan1) entered disabled state
root@OpenWrt:/# brctl delif br-lan lan2
[ 1981.962918] device lan2 left promiscuous mode
[ 1981.969840] br-lan: port 3(lan2) entered disabled state
root@OpenWrt:/# brctl delif br-lan lan3
[ 1985.399147] device lan3 left promiscuous mode
[ 1985.403477] device eth0 left promiscuous mode
[ 1985.411113] br-lan: port 4(lan3) entered disabled state
adding lanx to OVS bridge
root@OpenWrt:/# ovs-vsctl add-port ovslan lan0
[ 2070.767912] device lan0 entered promiscuous mode
[ 2070.772523] device eth0 entered promiscuous mode
root@OpenWrt:/# ovs-vsctl add-port ovslan lan1
[ 2072.653795] device lan1 entered promiscuous mode
root@OpenWrt:/# ovs-vsctl add-port ovslan lan2
[ 2074.166352] device lan2 entered promiscuous mode
root@OpenWrt:/# ovs-vsctl add-port ovslan lan3
[ 2075.733949] device lan3 entered promiscuous mode
up the interfaces, restart network, reboot
root@OpenWrt:/# ifconfig lan0 up
root@OpenWrt:/# ifconfig lan1 up
root@OpenWrt:/# ifconfig lan2 up
root@OpenWrt:/# ifconfig lan3 up
root@OpenWrt:/# ifconfig ovslan up
root@OpenWrt:/# ovs-vsctl show
9a467058-940d-4475-82f4-a5094a83562c
Bridge ovslan
Port ovslan
Interface ovslan
type: internal
Port "lan3"
Interface "lan3"
Port "lan2"
Interface "lan2"
Port "lan0"
Interface "lan0"
Port "lan1"
Interface "lan1"
ovs_version: "2.8.2"
root@OpenWrt:/# /etc/init.d/network restart
root@OpenWrt:/# reboot
That’s OK and i can use flow-talbe to control OVS bridge. But each time i power on R2. I must up the interfaces again.I don’t know why?
root@OpenWrt:/# ifconfig eth0 up
[ 54.480140] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[ 54.485988] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
root@OpenWrt:/# ifconfig lan2 up
[ 59.727732] IPv6: ADDRCONF(NETDEV_UP): lan2: link is not ready
root@OpenWrt:/# [ 60.736911] mt7530 3.switch lan2: Link is Down
[ 63.856487] IPv6: ADDRCONF(NETDEV_CHANGE): lan2: link becomes ready
[ 63.862951] mt7530 3.switch lan2: Link is Up - 1Gbps/Full - flow control rx/tx
I check the status of OVS with Floodlight.