OpenWrt/LEDE Project

  • Status Unconfirmed
  • Percent Complete
  • Task Type Bug Report
  • Category Base system
  • Assigned To No-one
  • Operating System All
  • Severity Low
  • Priority Very Low
  • Reported Version Trunk
  • Due in Version Undecided
  • Due Date Undecided
  • Private
Attached to Project: OpenWrt/LEDE Project
Opened by Peter - 30.08.2020

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

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 ''
	option ip4table 'lan'
	option netmask ''

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

config route
	option interface 'ni'
	option target ''
	option netmask ''
	option gateway ''
	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 dev br-ni proto static scope link via dev br-ni proto static metric 100
Peter commented on 31.08.2020 16:09

I think that this commit is relevant:

commit 4452867c4b34cb0d9dc7fe9dc42ecc86af887176
Author: Steven Barth <>
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 <>

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;


Available keyboard shortcuts


Task Details

Task Editing