Don't crete br-lan and lan0-lan3

one issue observing with this, when ethernet cables(more than one) removed and connected back, ping is failing. somethig link this,

  1. assign IPs,

ifconfig br-lan:1 192.168.2.10

ifconfig br-lan:2 192.168.2.20

ifconfig br-lan:3 192.168.2.30

ifconfig br-lan:4 192.168.2.40

  1. connect BPI-R2 any lan(say lan0) port to the switch, where host is also connected.
  2. ping from host and board, its working fine
  3. connect BPI-R2 one other more port(say lan1) to switch
  4. ping will be stoped.

Any idea why this happening and any fix here.

Please let me know a solution where I can configure all lan ports(lan0-lan3) of BPI-R2 board on the same subnet IP.

you cannot define multiple IPs in same subnet for different interfaces!

you can bridge ports and define 1 IP to the bridge

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

Thanks Frank/Alexey for all the information.

Nor really. It is more complicated as there’s a thing called “policy routing” and even without policy routing it is possible to achieve a lot of interesting and complicated setups using netfilter tables + iproute2. So the main question is the end goal, what does the user try to achieve and - most importantly - why. Linux network stack is very flexible and - as a consequence - is complicated. So to get an idea on how to do something from technical PoV one needs to define the top level “target state” beforehand.

This is plain wrong. You’re creating topology loop here which is bad idea. In case you have STP (spanning tree protocol) enabled in your subnet you might be able to get away with it. Feel free to google on “STP” and “spanning tree in linux bridge” keywords if you want to get familiar with this as this topic is too complicated to describe in a single forum post.

Why do you want to have two ports connected to the same network at a first place? If you’re looking for increased resilience then your best bet would be to use one of ethernet bonding variants here instead of using bridge. Documentation is here: https://www.kernel.org/doc/Documentation/networking/bonding.txt . Depending on your network infrastructure you’d either have to configure the switch your R2 is connected to by enabling “etherchannel” or “trunk group” (there are several marketing names for this kind of bonding depending on the brand name of the switch you use), or enabling LACP/802.3ad link aggregations on resp ports or sticking to using active-backup, balance-tlb or balance-alb bond mode on R2 side.

Upd. Ah, and in case you’re looking for increased throughput by using more than a single 1Gbps port - it won’t work. From the physical PoV R2 has two ethernet cards, one being “hardwired” to wan port of the built-in switch and second one left as a sole interface to exchange traffic with lanX ports. So you wan’t be able to ever get more then 1Gbps of bandwidth in total combined for all 4 lanX ports - this is a physical topology limitation of the board.

Note: Technically speaking wan port is not physically hardwired to eth1 but the default configuration is like this and AFAIK the way DSA is implemented is somewhat limited and do not allow more than one CPU port to be used as master port. So for you it means that the safe approach is to treat wan as a separate interface physically tied to “wan” port and be prepared that rest 4 lanX ports share a single bandwidth limit of 1Gbps.

Gmac connected to Lan-ports can run in trgmii-mode which should support 2.5gbit/s throughput

but i have not get more than 1gbit to cpu

I know policy routing but have not used on multiple lan-interfaces with same subnet. I guessed the thread opener will have an easy configuration :slight_smile:

Ah, so MAC<->PHY connection in R2 uses mediatek’s specific turbo reduced gigabit media interconnect interface? Then the theoretical max bandwidth should be higher, but still is not enough to provide full 1Gbps per each lanX port. Though looking at the bandwidth performance figures I get on my R2 there are big doubts that CPU is capable enough to be able to process anything higher than 1Gbps. Actually it seems to be struggling a lot trying to achieve mere 1Gpbs.

Sure, Alexey I will go through the bonding and try to get a solution. Thanks.

Also, in between just I want to build BPI-R2 openWRT images with openWRT with kernel-4.4? I tried a lot but unable to find any repository

Could you guys please help me on this as well:)

This is the old 4.4 ubuntu kernel: https://github.com/BPI-SINOVOIP/BPI-R2-bsp

Hi Frank, This is for Ubuntu rite. Do we have a similar repository for OpenWRT?

No,official lede/openwrt-repo is bases on kernel 4.9 which has also dsa-ports (lanx,wan).

Maybe you can use 4.4 from ubuntu in openwrt,but i don’t know how to link it into build-process…imho 4.4 is not compilable with newer gcc-versions (4.5+)

yeah, I tried but failed to build.

For now, in my application, I am binding the interfaces(lanx) with the socket with socket option SO_BINDTODEVICE to make sure packet transfer happens though all lan ports are configured on the same subnet. Which is working fine for now:)

But, with all BPI-R2 lan ports (lan0-lan3) set on the same subnet IP, ping is failing from host though ARP entries are created. Is there a way to achieve this.

Thanks, Ashok

Why not bridging the dsa-interfaces and set ip to the bridge?

Requirement is we need 4 different address(either in same subnet or different).

As I’ve shown you earlier it is possible to have more than a single IP/subnet assigned to the same interface in linux. So I second @frank-w and my earlier posts in this topic: your best bet would be to have all dsa ports in a bridge and have all 4 IP addresses assigned to this bridge. You will need to bind your sockets to the particular source IP instead of binding to a particular device.

P.S. And regarding physical connections: it is required and sufficient to have a single cable connected to your R2 into one of lanX ports. Do not connect two or more cables to the same network unless you set up some kind of a bond - it will create a network topology loop otherwise.

your best bet would be to have all dsa ports in a bridge and have all 4 IP addresses assigned to this bridge. You will need to bind your sockets to the particular source IP instead of binding to a particular device.

Yes, I am doing in the same way socket communication also happening.

From R2 I can ping to Host with ‘ping -I’ option. But from host, I am failing to ping R2(when Ips are configured on the same subnet), though arp entries are created. Is there something else I missing here?

One more generic query, today I connected usb-ethernet card to my Ubuntu PC(eth1 is created )and assigned same subnet IP as of eth0 and when I tried to ping from other PC to my Ubuntu PC its not working. May I know why ? and any solution if there are any.

If you have multiple interfaces in same subnet your r2 don’t know to which interface your packet should be sent out.

Basicly such configuration is wrong!

You make some tricks with policy routing but you should think about your topology.

Yep, exactly this. It is possible to have setup like this to be made into a functional state but it is not a trivial task. Read about sysctl (https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt) parameters like rp_filter, arp_filter, arp_ignore and so on. Get familiar with how to use “ip ru” and “ip ro * ta X”. It won’t be a smooth ride to administer a config like this. If you’ve got an option consider changing your network topology or application architecture. It might be a good idea to use docker here or at least split your application into several threads/processes and isolate network namespace for each of them.