openwrt / routing

OpenWrt Routing Packages
334 stars 377 forks source link

batman-adv: Failed to set interface MTU #991

Closed marek22k closed 1 year ago

marek22k commented 1 year ago

Maintainer: @ecsv @PolynomialDivision @djselbeck @simonwunderlich @adschm @NeoRaider @elektra42 @lindnermarek @lynxis @sbyx @bittorf @jow- Environment: OpenWrt 22.03.5 r20134-5f15225c1e / LuCI openwrt-22.03 branch git-23.119.80898-65ef406

Description: Hello,

I have two OpenWrt VMs in GNS3 which are connected via a switch. The switch is on eth1. On this one is running Batman. The batman interface is bat0. The MTU for eth1 is 9032 and for bat0 is 9000, but the MTU for bat0 is not changed.

Network configuration:

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

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

config globals 'globals'
    option ula_prefix 'fd0e:a1cb:282e::/48'

config interface 'wan'
    option proto 'dhcp'
    option device 'eth0'

config interface 'wan6'
    option proto 'dhcpv6'
    option device 'eth0'
    option reqaddress 'try'
    option reqprefix 'auto'

config interface 'mesh'
    option device 'eth1'
    list ip6addr 'fe80::2/64'
    option defaultroute '0'
    option delegate '0'
    option master 'bat0'
    option proto 'batadv_hardif'
    option mtu '9032'

config interface 'bat0'
    option proto 'batadv'
    option routing_algo 'BATMAN_IV'
    option mtu '9000'

Interfaces:

root@OpenWrt:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP qlen 1000
    link/ether 0c:29:c3:16:00:00 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.30/24 brd 192.168.122.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::e29:c3ff:fe16:0/64 scope link 
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9032 qdisc fq_codel master bat0 state UP qlen 1000
    link/ether 0c:29:c3:16:00:01 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::e29:c3ff:fe16:1/64 scope link 
       valid_lft forever preferred_lft forever
4: eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 0c:29:c3:16:00:02 brd ff:ff:ff:ff:ff:ff
5: eth3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 0c:29:c3:16:00:03 brd ff:ff:ff:ff:ff:ff
6: eth4: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 0c:29:c3:16:00:04 brd ff:ff:ff:ff:ff:ff
7: eth5: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 0c:29:c3:16:00:05 brd ff:ff:ff:ff:ff:ff
8: eth6: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 0c:29:c3:16:00:06 brd ff:ff:ff:ff:ff:ff
9: eth7: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 0c:29:c3:16:00:07 brd ff:ff:ff:ff:ff:ff
10: bat0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN qlen 1000
    link/ether aa:71:d0:a7:61:d7 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::a871:d0ff:fea7:61d7/64 scope link 
       valid_lft forever preferred_lft forever

OpenWrt version: QEMU Standard PC (i440FX + PIIX, 1996) QEMU Virtual CPU version 2.5+ OpenWrt 22.03.5 r20134-5f15225c1e / LuCI openwrt-22.03 branch git-23.119.80898-65ef406

root@OpenWrt:~# cat /etc/openwrt_release
DISTRIB_ID='OpenWrt'
DISTRIB_RELEASE='22.03.5'
DISTRIB_REVISION='r20134-5f15225c1e'
DISTRIB_TARGET='x86/generic'
DISTRIB_ARCH='i386_pentium4'
DISTRIB_DESCRIPTION='OpenWrt 22.03.5 r20134-5f15225c1e'
DISTRIB_TAINTS=''
ecsv commented 1 year ago

This is not an OpenWrt routing or luci bug. batman-adv doesn't support jumbo frames and it limited to an MTU of 1500

See https://www.open-mesh.org/issues/365

Btw. please don't spam people. Most people mentioned here are not the actual maintainer (Simon Wunderlich).

marek22k commented 1 year ago

Thanks for the answer!

Is there a label for "upstream bug" or something?

In the issue template it said to mark the people in the git history of the makefile. The marked people were all in there. Maybe I went back a little too far.... in which case I'm sorry. I didn't mean to spam.

BKPepe commented 1 year ago

There is nothing what we can do here. It was reported to upstream as feature request and because of that, closing.

marek22k commented 1 year ago

I think it is a bit nonsensical to open an extra issue for this. Therefore I post my problem here. Setting a smaller MTU does not work either.

root@OpenWrt:/# ip a s bat0
10: bat0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN qlen 1000
    link/ether 42:ea:ba:65:ba:11 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::40ea:baff:fe65:ba11/64 scope link 
       valid_lft forever preferred_lft forever
root@OpenWrt:/# uci get network.bat0.mtu
1300

@BKPepe @ecsv

ecsv commented 1 year ago

@marek22k Did you test this with the patch from https://www.open-mesh.org/issues/365 ?

I have now also split the (non-jumbo frame) relevant parts into a separate patchset https://patchwork.open-mesh.org/project/b.a.t.m.a.n./list/?series=536. It can be downloaded as one file from https://patchwork.open-mesh.org/series/536/mbox/ and then placed in feeds/routing/batman-adv/patches/

marek22k commented 1 year ago

@marek22k Did you test this with the patch from https://www.open-mesh.org/issues/365 ?

No, I tested it with the OpenWrt package. When the patch goes through, it would be best to also include that in the UCI command.

I have now also split the (non-jumbo frame) relevant parts into a separate patchset https://patchwork.open-mesh.org/project/b.a.t.m.a.n./list/?series=536. It can be downloaded as one file from https://patchwork.open-mesh.org/series/536/mbox/ and then placed in feeds/routing/batman-adv/patches/

I should probably look into how to compile individual OpenWrt packages again sometime.

ecsv commented 1 year ago

No, I tested it with the OpenWrt package. When the patch goes through, it would be best to also include that in the UCI command.

The patch will not go through when no one works on it. Especially if it is just an RFC patch in some ticket. Btw. what does this patch have to do with a "uci command"?

marek22k commented 1 year ago

I mean that currently in the UCI configuration file the command "mtu" is not implemented yet, if I am not mistaken. (No MTU configuration option in https://github.com/openwrt/routing/blob/master/batman-adv/files/lib/netifd/proto/batadv.sh) If you create an IPK package for me, I'll be happy to test it :-)

ecsv commented 1 year ago

I mean that currently in the UCI configuration file the command "mtu" is not implemented yet

But mtu is not an batman-adv option. It is a generic netifd option.

And I think you had to configure it in a different section - for example the dhcp/static IP section:

config interface 'bat0'
        option proto 'batadv'
        option routing_algo 'BATMAN_IV'

config interface 'bat0_whatever'
        option ifname 'bat0'
        option mtu 9000
ecsv commented 1 year ago

If you create an IPK package for me, I'll be happy to test it :-)

That can easily go wrong when we have slightly different configurations.

I have prepared an OpenWrt 22.03.5 ipk with the patch (for feeds/routing) in 0001-TODO-batman-adv-batman-adv-Merge-bugfixes-from-2023..zip

And the config:

CONFIG_TARGET_x86=y
CONFIG_TARGET_x86_generic=y
CONFIG_TARGET_x86_generic_DEVICE_generic=y
CONFIG_BATMAN_ADV_BATMAN_V=y
CONFIG_BATMAN_ADV_BLA=y
CONFIG_BATMAN_ADV_DAT=y
CONFIG_BATMAN_ADV_MCAST=y
CONFIG_PACKAGE_batctl-default=y
CONFIG_PACKAGE_iw=y
CONFIG_PACKAGE_iwinfo=y
CONFIG_PACKAGE_kmod-batman-adv=y
CONFIG_PACKAGE_kmod-cfg80211=y
CONFIG_PACKAGE_kmod-lib-crc16=y
CONFIG_PACKAGE_libiwinfo=y
CONFIG_PACKAGE_libiwinfo-data=y
CONFIG_PACKAGE_wireless-regdb=y

kmod-batman-adv_5.10.176+2022.0-7_i386_pentium4.ipk.zip

marek22k commented 1 year ago

kmod-batman-adv_5.10.176+2022.0-7_i386_pentium4.ipk.zip

root@OpenWrt:~# opkg install ./kmod-batman-adv_5.10.176+2022.0-7_i386_pentium4.ipk
Package kmod-batman-adv (5.10.176+2022.0-6) installed in root is up to date.
Collected errors:
 * pkg_hash_check_unresolved: cannot find dependency kernel (= 5.10.176-1-108015c34741628272e040dcd8c3ec14) for kmod-batman-adv
root@OpenWrt:~# uname -srm
Linux 5.10.176 i686

If you tell me what I need to change in the instructions at https://openwrt.org/docs/guide-developer/toolchain/single.package to use the patch, I could also compile the package myself.

ecsv commented 1 year ago

Do yourself a favor and build a complete image (at least at the beginning) - avoids all the kernel dependency problem when everything comes from the same build. And you can apply the modification to the routing feed via:

# i think you already got this part but i just wanted to mention it
git clone -b openwrt-22.03 https://github.com/openwrt/openwrt.git openwrt-22.03
cd openwrt-22.03
git checkout v22.03.5
./scripts/feeds update
./scripts/feeds install -a

cat > .config << "EOF"
CONFIG_TARGET_x86=y
CONFIG_TARGET_x86_generic=y
CONFIG_TARGET_MULTI_PROFILE=y
CONFIG_TARGET_DEVICE_x86_generic_DEVICE_generic=y
CONFIG_TARGET_DEVICE_PACKAGES_x86_generic_DEVICE_generic=""
CONFIG_ALL_KMODS=y
CONFIG_ALL_NONSHARED=y
CONFIG_DEVEL=y
CONFIG_TARGET_PER_DEVICE_ROOTFS=y
CONFIG_AUTOREMOVE=y
CONFIG_BPF_TOOLCHAIN_BUILD_LLVM=y
# CONFIG_BPF_TOOLCHAIN_NONE is not set
CONFIG_BUILDBOT=y
CONFIG_COLLECT_KERNEL_DEBUG=y
CONFIG_HAS_BPF_TOOLCHAIN=y
CONFIG_IB=y
CONFIG_IMAGEOPT=y
CONFIG_KERNEL_BUILD_DOMAIN="buildhost"
CONFIG_KERNEL_BUILD_USER="builder"
# CONFIG_KERNEL_KALLSYMS is not set
CONFIG_MAKE_TOOLCHAIN=y
CONFIG_PACKAGE_cgi-io=y
CONFIG_PACKAGE_libbpf=m
CONFIG_PACKAGE_libelf=m
CONFIG_PACKAGE_libiwinfo=y
CONFIG_PACKAGE_libiwinfo-data=y
CONFIG_PACKAGE_libiwinfo-lua=y
CONFIG_PACKAGE_liblua=y
CONFIG_PACKAGE_liblucihttp=y
CONFIG_PACKAGE_liblucihttp-lua=y
CONFIG_PACKAGE_libubus-lua=y
CONFIG_PACKAGE_lua=y
CONFIG_PACKAGE_luci=y
CONFIG_PACKAGE_luci-app-firewall=y
CONFIG_PACKAGE_luci-app-opkg=y
CONFIG_PACKAGE_luci-base=y
CONFIG_PACKAGE_luci-lib-base=y
CONFIG_PACKAGE_luci-lib-ip=y
CONFIG_PACKAGE_luci-lib-jsonc=y
CONFIG_PACKAGE_luci-lib-nixio=y
CONFIG_PACKAGE_luci-mod-admin-full=y
CONFIG_PACKAGE_luci-mod-network=y
CONFIG_PACKAGE_luci-mod-status=y
CONFIG_PACKAGE_luci-mod-system=y
CONFIG_PACKAGE_luci-proto-ipv6=y
CONFIG_PACKAGE_luci-proto-ppp=y
CONFIG_PACKAGE_luci-ssl=y
CONFIG_PACKAGE_luci-theme-bootstrap=y
CONFIG_PACKAGE_px5g-wolfssl=y
CONFIG_PACKAGE_qosify=m
CONFIG_PACKAGE_rpcd=y
CONFIG_PACKAGE_rpcd-mod-file=y
CONFIG_PACKAGE_rpcd-mod-iwinfo=y
CONFIG_PACKAGE_rpcd-mod-luci=y
CONFIG_PACKAGE_rpcd-mod-rrdns=y
CONFIG_PACKAGE_tc-full=m
CONFIG_PACKAGE_tc-mod-iptables=m
CONFIG_PACKAGE_uhttpd=y
CONFIG_PACKAGE_uhttpd-mod-ubus=y
CONFIG_PACKAGE_zlib=m
CONFIG_REPRODUCIBLE_DEBUG_INFO=y
CONFIG_SDK=y
CONFIG_SDK_LLVM_BPF=y
CONFIG_TARGET_ALL_PROFILES=y
CONFIG_USE_LLVM_BUILD=y
CONFIG_VERSIONOPT=y
CONFIG_VERSION_BUG_URL=""
CONFIG_VERSION_CODE=""
CONFIG_VERSION_DIST="OpenWrt"
CONFIG_VERSION_FILENAMES=y
CONFIG_VERSION_HOME_URL=""
CONFIG_VERSION_HWREV=""
CONFIG_VERSION_MANUFACTURER=""
CONFIG_VERSION_MANUFACTURER_URL=""
CONFIG_VERSION_NUMBER=""
CONFIG_VERSION_PRODUCT=""
CONFIG_VERSION_REPO="https://downloads.openwrt.org/releases/22.03.5"
CONFIG_VERSION_SUPPORT_URL=""
EOF

make defconfig

# now add the patches
 unzip ~/Downloads/0001-TODO-batman-adv-batman-adv-Merge-bugfixes-from-2023.zip
git -C feeds/routing am ../../0001-TODO-batman-adv-batman-adv-Merge-bugfixes-from-2023..patch

# build your image (or ttry building tools+toolchain + `package/batman-adv/compile` if you want to try the route from the single-package-wiki page)
make -j$(nproc)

# something like this would be the "single package" build - only the last command would be required if you already did the full make before (without changing the config or modifying any other package)
make -j$(nproc) tools/install
make -j$(nproc) toolchain/install
make -j$(nproc) target/linux/compile
make -j$(nproc) package/batman-adv/compile

Here is also the kmod for this config: kmod-batman-adv_5.10.176+2022.0-7_i386_pentium4.ipk.zip

marek22k commented 1 year ago

Thanks for the tutorial! That worked.

The following MTU configuration does not seem to work:

config interface 'bat0'
    option proto 'batadv'
    option routing_algo 'BATMAN_IV'
    option mtu '9000'
10: bat0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN qlen 1000
    link/ether e6:95:90:e2:d2:db brd ff:ff:ff:ff:ff:ff
    inet6 fe80::e495:90ff:fee2:d2db/64 scope link 
       valid_lft forever preferred_lft forever

Setting a smaller MTU than 1500 does not work either.

Setting the MTU manually with the following command works.

ip link set dev bat0 mtu 9000

After that I could send non-fragmented ping packets up to 8952 bytes ICMP payload.

# ping -s 8952 -c 4 fe80::e495:90ff:fee2:d2db%bat0
PING fe80::e495:90ff:fee2:d2db%bat0 (fe80::e495:90ff:fee2:d2db%10): 8952 data bytes
8960 bytes from fe80::e495:90ff:fee2:d2db: seq=0 ttl=64 time=0.591 ms
8960 bytes from fe80::e495:90ff:fee2:d2db: seq=1 ttl=64 time=1.656 ms
8960 bytes from fe80::e495:90ff:fee2:d2db: seq=2 ttl=64 time=1.109 ms
8960 bytes from fe80::e495:90ff:fee2:d2db: seq=3 ttl=64 time=0.908 ms

--- fe80::e495:90ff:fee2:d2db%bat0 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 0.591/1.066/1.656 ms

PCAP: big_ping.pcapng.txt (Remove the .txt, GitHub does not allow .pcapng)

Setting and pinging an MTU of 1300 also worked.

marek22k commented 1 year ago

I mean that currently in the UCI configuration file the command "mtu" is not implemented yet

But mtu is not an batman-adv option. It is a generic netifd option.

And I think you had to configure it in a different section - for example the dhcp/static IP section:

config interface 'bat0'
        option proto 'batadv'
        option routing_algo 'BATMAN_IV'

config interface 'bat0_whatever'
        option ifname 'bat0'
        option mtu 9000

That works.