Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FS#3312 - static route being added to wrong table if ip4table is used #8174

Open
openwrt-bot opened this issue Aug 30, 2020 · 1 comment
Open
Labels

Comments

@openwrt-bot
Copy link

petzah:

I have a separate route table called 'lan':

root@btkrgn:~# cat /etc/iproute2/rt_tables

reserved values

128 prelocal
255 local
254 main
253 default
0 unspec

local

#1 inr.ruhep

40 lan

Then I have an interface configured with ip4table:

config interface 'ni'
option type 'bridge'
option delegate '0'
option ifname 'eth0.22 vx22'
option proto 'static'
option ipaddr '192.168.22.248'
option ip4table 'lan'
option netmask '255.255.255.0'

And I also have static route with explicitly defined table 'main':

config route
option interface 'ni'
option target '192.168.22.0'
option netmask '255.255.255.0'
option gateway '192.168.22.253'
option table 'main'
option metric '100'

I expected that this static route will be in the 'main' table however it is being added to 'lan' table:

root@btkrgn:~# ip route show table lan
192.168.22.0/24 dev br-ni proto static scope link
192.168.22.0/24 via 192.168.22.253 dev br-ni proto static metric 100

@openwrt-bot
Copy link
Author

petzah:

I think that this commit is relevant:

commit 4452867c4b34cb0d9dc7fe9dc42ecc86af887176
Author: Steven Barth steven@midlink.org
Date: Fri Jun 20 19:50:13 2014 +0200

interface: don't store table id in route if the default table is used

Use system_is_default_rt_table() to test whether the resolved routing table
is the default one, in this case do not apply the table attribute to the
route object.

This is needed for backwards compatibility - only routes using a non-default
table shall report it in the ifstatus output.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>

diff --git a/interface-ip.c b/interface-ip.c
index 715e498..587826a 100644
--- a/interface-ip.c
+++ b/interface-ip.c
@@ -365,6 +365,10 @@ interface_ip_add_route(struct interface *iface, struct blob_attr *attr, bool v6)
goto error;
}

  •           /* only set the table flag if not using the main (default) table */
    
  •           if (system_is_default_rt_table(route->table))
    
  •                   route->table = 0;
    
  •           if (route->table)
                      route->flags |= DEVROUTE_TABLE;
      }
    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant