Bug 13466

Summary: creation of bridge interface via interfaces does not work
Product: buildroot Reporter: Frank Wunderlich <frank-w>
Component: OtherAssignee: unassigned
Status: RESOLVED MOVED    
Severity: normal CC: buildroot, github, yann.morin.1998
Priority: P5    
Version: 2020.11.1   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:

Description Frank Wunderlich 2021-01-20 14:15:22 UTC
Hi,

i try to add bridge-interface via interfaces file (overlay_rootfs), but i got only an error on bootup.

Cannot find device "br0"

bridge-related part of interfaces-file (config of lan0 also there and this works)

auto lan1
iface lan1 inet manual
auto lan2
iface lan2 inet manual

auto br0
iface br0 inet static
    address 192.168.40.1
    netmask 255.255.255.0
    bridge_ports lan1 lan2
    bridge_fd 5
    bridge_stp no

also posted a question at stack-overflow because this is maybe no bug as it looks like for me
https://unix.stackexchange.com/questions/629714/buildroot-adding-bridge-via-interfaces

of course i have added bridge-utils package and can add the bridge manually, but not via /etc/network/interfaces file

regards Frank
Comment 1 Ryan Barnett 2021-02-17 16:26:55 UTC
Hello,

The supports for bridges in the /etc/network/interfaces file is provide by Debian through the combination of having two packages installed: bridge-utils and ifupdown. Debian has customized bridge-utils package to provide support for bridge syntax in the /etc/network/interfaces file with the ifupdown package.

On Debian based distributions, the syntax for bridge in /etc/network/interfaces is accomplished utilizing if-pre-up.d/bridge and if-post-down.d/bridge hooks as seen from the list of the Debian package files [1].

Buildroot utilizes the official bridge-utils source from kernel.org which does not contain any of these ifupdown hooks [2]. 

In order to support this syntax utilizing buildroot, I'd recommend that the full version of ifupdown be built. Support for the bridge hooks could be added by utilizing a BR2_ROOTFS_OVERLAY [3] which installs the hooks for bridge support in the /etc/network/if-pre-up.d/ and fi-post-down.d/ hook locations utilizing the Debian source [4]

Thanks,
-Ryan

[1] - https://packages.debian.org/stretch/amd64/bridge-utils/filelist
[2] - https://git.busybox.net/buildroot/tree/package/bridge-utils/bridge-utils.mk#n9
[3] - https://buildroot.org/downloads/manual/manual.html#rootfs-custom
[4] - https://sources.debian.org/src/bridge-utils/1.6-2/debian/ifupdown.sh/
Comment 2 Frank Wunderlich 2021-02-28 19:47:36 UTC
hi, i've added bridge-utils.sh and ifupdown.sh to /lib/bridge-utils (like it's done in rules of package) including sylinks in /etc/network/if-pre-up.d and if-post-down.d

# ls -l /lib/bridge-utils/                                                                                                                                      
total 16                                                                                                                                                                                                                                
-rwxr-xr-x    1 root     root          1621 Feb 18 14:57 bridge-utils.sh                                                                                        
-rwxr-xr-x    1 root     root          5307 Feb 18 14:57 ifupdown.sh

# ls -l /etc/network/if-post-down.d/bridge                                                                                                                      
lrwxrwxrwx    1 root     root            29 Feb 28 17:51 /etc/network/if-post-down.d/bridge -> /lib/bridge-utils/ifupdown.sh                                    
# ls -l /etc/network/if-pre-up.d/bridge                                                                                                                         
lrwxrwxrwx    1 root     root            29 Feb 28 17:51 /etc/network/if-pre-up.d/bridge -> /lib/bridge-utils/ifupdown.sh                                       
# 

and added BR2_PACKAGE_IFUPDOWN to my config...

but it seems not working, i guess the hooks are not picked up by anything
Comment 3 Frank Wunderlich 2021-04-16 16:32:06 UTC
no more idea?
Comment 4 Arınç ÜNAL 2023-01-16 20:18:16 UTC
I made it work. The brctl check on ifupdown.sh needed to be changed to /usr/sbin/brctl.

I only needed to install bridge-utils. No need for the ifupdown package. Bridge VLAN filtering won't work if iproute2 is not installed. BusyBox's ip command does not support that.

My current rootfs overlay looks like this:

rootfsOverlay
├── etc
│   └── network
│       ├── if-down.d
│       │   └── bridge -> /lib/bridge-utils/ifupdown.sh
│       ├── if-post-down.d
│       │   └── bridge -> /lib/bridge-utils/ifupdown.sh
│       ├── if-pre-up.d
│       │   └── bridge -> /lib/bridge-utils/ifupdown.sh
│       └── interfaces
└── lib
    └── bridge-utils
        ├── bridge-utils.sh
        └── ifupdown.sh

I'm planning to work on the scripts a little to replace brctl with ip so it would be usable without requiring any other packages to be installed.
Comment 5 Yann E. MORIN 2024-06-15 14:56:16 UTC
Thank you for your report.

The issue tracker for the Buildroot project has been moved to
the Gitlab.com issue tracker:
    https://gitlab.com/buildroot.org/buildroot/-/issues

We are taking this opportunity to close old issues in this old
tracker. If you believe your issue is still relevant, please
open one in the new issue tracker.

Thank you!