BPI-SINOVOIP / BPI-M2U-bsp

Supports Banana Pi BPI-M2 Ultra (R40) / BPI-M2 Berry (V40) (Kernel3.10)
54 stars 48 forks source link

ip rule fwmark doesn't work #11

Open xedoc opened 6 years ago

xedoc commented 6 years ago

To reproduce it, add a rule: ip rule add to 1.1.1.1 fwmark 1 lookup 1 ip route add default via 127.0.0.1

and check route for 1.1.1.1 with and without the mark: ip route get 1.1.1.1 ip route get 1.1.1.1 mark 1

Both will return the same result and that's wrong behavior. First command should return default gateway from the main table (ip route show) Second command should return dev lo

What is weird - it works if I use tos instead of fwmark.

I've tried different distros (ubuntu, debian, centos) for my M2 Berry. It doesn't work. Seems there is some problem with the kernel options or something else. CONFIG_IP_ADVANCED_ROUTER is set to y in /proc/config.gz

bytescreator commented 4 years ago

It's not working because the default route you added is at the wrong table, you are adding it to the main table instead of table 1.

Here's my terminal output (Arch Linux 5.6.7-arch1-1)

#ip rule add to 1.1.1.1 fwmark 1 table 1 #ip rule 0: from all lookup local 32765: from all to 1.1.1.1 fwmark 0x1 lookup 1 32766: from all lookup main 32767: from all lookup default # ip route get 1.1.1.1 1.1.1.1 via 192.168.42.129 dev enp0s4f1u5 src 192.168.42.143 uid 0 cache # ip route get 1.1.1.1 mark 1 1.1.1.1 via 192.168.42.129 dev enp0s4f1u5 src 192.168.42.143 mark 1 uid 0 cache

As you could see it's not working but when I add the default route

# ip route add default via 192.168.1.1 table 1 # ip route get 1.1.1.1 mark 1 1.1.1.1 via 192.168.1.1 dev enp3s0 table 1 src 192.168.1.254 mark 1 uid 0 cache # ip route get 1.1.1.1 1.1.1.1 via 192.168.42.129 dev enp0s4f1u5 src 192.168.42.143 uid 0 cache

it wasn't working because it was using the backup main table