BPI_R2 How to config vlan?


#1

I want to config vlan on R2.

I’m using this image BPI-R2 new image: BPI-R2 OpenWrt(LEDE) Souce code : 2018-05-09

Does someone can tell me how to config it? I don’t know how to do.

And where can i find BPI_R2’s Switch schematics which like this. image

(This is schematics of TP-Link TL-WR1043ND, i found it on openwrt’s official website.)


(Cristian) #2

Check this, there is an schematic that may help you.

https://www.fw-web.de/dokuwiki/doku.php?id=en:bpi-r2:network:start#netbridge


(Frank W.) #3

He talks about openwrt…i don’t know how to do it there…also it is unclear why he needs vlan. The images seems to show internal structure. Normal kernel has only one gmac so he does not need vlan internally. My kernels have fixed gmac (defined in dts). Ports are separated in 4.14+ so you can configure them without needing vlan


#4

Hello frank-w

maybe I don’t need vlan.

There are four LAN on R2, lan0, lan1, lan2, lan3. They are connected to linux bridge (maybe,I’m not sure)

image

I installed Open vSwitch in openwrt, created an ovs bridge named ovs-br and wanted to add lan1 lan2 lan3 into it.

image

But there’s an error when I tried to add lan1 into ovs-br. It showed “Resource busy”.

root@OpenWrt:/# ovs-vsctl add-br ovs-br
[  745.837182] device ovs-system entered promiscuous mode
[  745.921089] device ovs-br entered promiscuous mode
root@OpenWrt:/# ovs-vsctl add-port ovs-br lan1
ovs-vsctl: Error detected while setting up 'lan1': could not add network device lan1 to ofproto (Resource busy).  See ovs-vswitchd log for details.
ovs-vsctl: The default log directory is "/var/log/openvswitch".
root@OpenWrt:/# ovs-vsctl show
65c91378-d41c-439b-b3e4-34aa8cc0fcc8
    Bridge ovs-br
        Port ovs-br
            Interface ovs-br
                type: internal
        Port "lan1"
            Interface "lan1"
                error: "could not add network device lan1 to ofproto (Resource busy)"
    ovs_version: "2.8.2"

How should I config br-lan lan0 lan1 lan2 lan3, making lan1 lan2 lan3 add into ovs-br.

root@OpenWrt:/# ifconfig 
br-lan    Link encap:Ethernet  HWaddr 5A:78:05:9D:9E:29  
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::5878:5ff:fe9d:9e29/64 Scope:Link
          inet6 addr: fd28:6288:f7d9::1/60 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1161 errors:0 dropped:0 overruns:0 frame:0
          TX packets:760 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:113252 (110.5 KiB)  TX bytes:65638 (64.0 KiB)

eth0      Link encap:Ethernet  HWaddr 5A:78:05:9D:9E:29  
          inet6 addr: fe80::5878:5ff:fe9d:9e29/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1165 errors:0 dropped:0 overruns:0 frame:0
          TX packets:775 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:134406 (131.2 KiB)  TX bytes:74512 (72.7 KiB)
          Interrupt:211 

eth1      Link encap:Ethernet  HWaddr D6:A3:AD:DA:B0:DB  
          inet6 addr: fe80::d4a3:adff:feda:b0db/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:764 (764.0 B)
          Interrupt:211 

lan0      Link encap:Ethernet  HWaddr 5A:78:05:9D:9E:29  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1165 errors:0 dropped:4 overruns:0 frame:0
          TX packets:760 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:113436 (110.7 KiB)  TX bytes:65638 (64.0 KiB)

lan1      Link encap:Ethernet  HWaddr 5A:78:05:9D:9E:29  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lan2      Link encap:Ethernet  HWaddr 5A:78:05:9D:9E:29  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lan3      Link encap:Ethernet  HWaddr 5A:78:05:9D:9E:29  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:352 errors:0 dropped:0 overruns:0 frame:0
          TX packets:352 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:23936 (23.3 KiB)  TX bytes:23936 (23.3 KiB)

wan       Link encap:Ethernet  HWaddr D6:A3:AD:DA:B0:DB  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

root@OpenWrt:/# cat /etc/config/network 

config interface 'loopback'
	option ifname 'lo'
	option proto 'static'
	option ipaddr '127.0.0.1'
	option netmask '255.0.0.0'

config globals 'globals'
	option ula_prefix 'fd28:6288:f7d9::/48'
	option default_rps_val '14'
	option default_rps_flow_cnt '256'
	option default_xps_val '14'
	option default_ps '1'

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'

config interface 'wan'
	option ifname 'wan'
	option proto 'dhcp'

config interface 'wan6'
	option ifname 'wan'
	option proto 'dhcpv6'

config device 'eth0'
	option name 'eth0'

config device 'lan0'
	option name 'lan0'

config device 'lan1'
	option name 'lan1'

config device 'lan2'
	option name 'lan2'

config device 'lan3'
	option name 'lan3'

#5

Thank you crisbermud.


(Frank W.) #6

you have to remove lan1-lan3 out of lan-bridge (and reload network-config/reboot) before adding to new

btw. ifconfig is old tool, you should use iproute2 (ip-command) and for bridge brctl

ip a
brctl show br-lan

(Cristian) #7

Hello everybody. I’m trying run OVS on my BPI-R2

I installed Armbian and OVS 2.6 on my board and I can see the 5 interfaces WAN, LAN0-3. I configured different mac address for each interface statically using the /etc/network/interfaces file.

After configuring the OVS bridge I’m facing the problem that the traffic goes through the SW but the replies are being dropped even though the remote host reply properly.

With a normal Linux bridge everything works good and the interfaces are in promiscuous mode.

I found in the OVS website that the problem may be caused because the VLAN configuration of the SW MT7530 does not match the configuration of my OVS bridge. But since I don’t know how the SW is tagging the packets I’m not configuring any VLAN on the OVS bridge.

Have someone of you faced this problem before? Do you know how the MT7530 tags the packets?


(Alexey Loukianov) #8

Openwrt images usually do not contain iproute2 tool in the default image configuration. People who like to use ip instead of legacy ifconfig have two choices:

  1. Build image with changed busybox build configuration enabling busybox’es iproute2 tool implementation. It is a bit limited compared to the “usual” iproute2 ip tool, for example “ip ro ls” won’t work, one would have to use “ip ro sh” instead.
  2. Build and include into the image (or install it later onto the jffs2 partition of the existing image) the “vanilla” iprote2 ip tool. It will consume more space but is what it is - the well-known ip tool from iproute2. For BPi-R2 filesystem space consumption does not seem to be a huge limiting factor so I’d stick with vanilla iproute2-ip tool if one would ask me what to use.

#9

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.

image image image image


(Alexey Loukianov) #10

If you want to have all the setup done automatically for you on boot you’d have to write/integrate the support for OVS type bridges into the OpenWRT configuration system. It might had already been done by the maintainers of the OVS package for OpenWRT. I hadn’t check if that’s the case or even if there’s such package available so please do your research on this and come back with what you find.

Also keep in mind that IIRC ovs bridges are implemented totally in software for linux. It means that you won’t be using hardware assisted bridging that is supported in BPiR2. There’s a thing called DSA that is used on BPiR2 (and other devices with Mtk switches) which is essentially and intelligent hack that allows switch ports to be represented as a “kind-a directly attached separate network interfaces” on a linux host - all these lanX you see on your BPiR2. When you bridge them together using ordinary brctl what you get is not a plain simple linux software bridge. DSA is integrated into the bridging code and essentially you are configuring Mtk switch chip to do the bridging for you in hardware. Same stands for vlan support (at least it should - depends on implementation or lack of it). Thus the performance you might expect from OVS bridge should be significantly lower compared to the linux/DSA bridge. At the same time CPU utilization for OVS expected to be high under heave traffic load.


(Cristian) #11

Hi Tinmad, can you send traffic between the hosts? I’m using OpenDayLight as a controller and I can see the hosts in the topology and install flows. My issue is that ARP replies are not being forwarded back. I can see that the host replies but when I do TCP dump on the SW interface nothing appears.


#12

Hi,crisbermud,I don’t know how to verify your issue in R2, can you tell me how to do it?Only one real computer was connected to the R2 in my experimental environment.This computer can connect to the Internet and use the network normally.


(Cristian) #13

Hi Tinmad,

I will use your topology as example. I will assume that h192.168.1.125 is connected to the interface 1 and one of the hosts h is connected to the interface 2 to the bridge ovslan.

You should add some flows to provide connectivity between the hosts, something like this.

# ovs-ofctl add-flow ovslan in_port=1,priority=1000,actions=2 -O OpenFlow13
# ovs-ofctl add-flow ovslan in_port=2,priority=1000,actions=1 -O OpenFlow13

After doing this, if you run a ping between the hosts h192.168.1.125 and h is it successful?

In another topic, could you please tell me which OpenWRT are you using?

I tried to use the ones from http://wiki.banana-pi.org/Banana_Pi_BPI-R2#Release But with these:

BPI-R2 OpenWrt(LEDE) 20180509: http://forum.banana-pi.org/t/topic/5646
BPI-R2 OpenWrt(LEDE) 20180411: http://forum.banana-pi.org/t/topic/5395
BPI-R2 OpenWrt(LEDE) 20170908: http://forum.banana-pi.org/t/topic/3797

I can install OpenWRT on mi BPR2 but when I’m trying to install Openvswitch using opkg I get this error.

satisfy_dependencies_for: Cannot satisfy the following dependencies for openvswitch:* 	libatomic1 *

And this one:

https://dev.banana-pi.org.cn/Image/BPI-R2/Openwrt/1806/

When I install the pre-built version, i can not connect to my BPIR2 because all packets coming from the LAN SW seem to be malformed. I solve this by changing some parameters in the networking configuration file and compiling the image of OpenWRT. However, I’m having now the problem that the system has no space left to install any package :frowning:

Wow, what a long post. Bye!


#14

Hi, crisbermud.I will test it. I am using this openwrt.

The kernel versions required for OpenvSwitch do not correspond to the kernel versions of these firmware.And opkg isn’t supported in these version.

BPI-R2 OpenWrt(LEDE) 20180509: http://forum.banana-pi.org/t/topic/5646
BPI-R2 OpenWrt(LEDE) 20180411: http://forum.banana-pi.org/t/topic/5395
BPI-R2 OpenWrt(LEDE) 20170908: http://forum.banana-pi.org/t/topic/3797

I can’t upload my firmware…

You can select OVS using make menuconfig. Kernel modules -> Network Support and Network -> Open vSwitch

image

image


(Cristian) #15

Hi Tinmad thanks for your answer :slight_smile:

I tried to build this image:

But after compiling i can not find any .img file, did you have this problem too?

Using my old compiled image, i could install OVS as you suggest using menuconfig, however all changes i do are lost after rebooting, is there any way to make them persistent.

Thanks for all your help!!!


#16

Hi,crisbermud.

Can you find an img which named openwrt-mediatek-mt7623-7623n-bananapi-bpi-r2-squashfs-sysupgrade-sd.img in ./bin/targets/mediatek/mt7623? I can’t save the changes too and i don’t know how to make them persistent. I have a problem, whiche source code can you install OVS using menuconfig?

host h192.168.1.125 can not ping h.


(Frank W.) #17

For saving changes in openwrt imho you need overlayfs/squashfs


(Cristian) #18

Hi Tinmad, thanks for your answer, I think it was OVS 2.8.

I switched again o Armbian because I needed the configuration to be stored permanently. There seem to be an issue regarding the DSA driver and OVS, that prevents unicast traffic to be forwarded, however multicast traffic does not have this problem.

I will be working with a Banapi R1 for a while, since OVS works fine on this board with unicast traffic.

In this article [in Spanish] a BPR2 was configured with OVS but they have the same issue regarding unicast traffic.

If you are interested in configuring a BPIR1 this slides [in Indonesian] show how to:

I tried to configure BPR2 using VLAN how it is done in BP1R1, but i end up having the same issue regarding the unicast traffic :-/

Thanks for your help!