Skip to contentSkip to conversation

Fix "ip rule delete table 256"

PATCH In review Andreas Henriksson 2 participants 2 messages Nov 7, 2013 – Nov 8, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix "ip rule delete table 256"

When trying to delete a table >= 256 using iproute2 the local table will be deleted.
The table id is specified as a netlink attribute when it needs more then 8 bits and iproute2 then sets the table field to RT_TABLE_UNSPEC (0). Preconditions to matching the table id in the rule delete code doesn't seem to take the "table id in netlink attribute" into condition so the frh_get_table helper function never gets to do its job when matching against current rule.
Use the helper function twice instead of peaking at the table value directly.

Originally reported at: http://bugs.debian.org/724783

---
 net/core/fib_rules.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

An alternative would be to say RT_TABLE_UNSPEC is incorrect value to use for the rule->table when using the netlink attribute and change iproute2 instead....
... but RT_TABLE_UNSPEC sounds quite suitable, so why not change the kernel to be more forgiving.

net/core/fib_rules.c +2 -1
index 2e65413..f409e0b 100644
@@ -460,7 +460,8 @@ static int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh)
 		if (frh->action && (frh->action != rule->action))
 			continue;
 
-		if (frh->table && (frh_get_table(frh, tb) != rule->table))
+		if (frh_get_table(frh, tb) &&
+		    (frh_get_table(frh, tb) != rule->table))
 			continue;
 
 		if (tb[FRA_PRIORITY] &&
Signature · 1 line
1.8.4.2
maintainer
#1 lore raw

From: Andreas Henriksson <[email protected]>
Date: Thu, 7 Nov 2013 18:26:38 +0100

Quoted 10 lines

When trying to delete a table >= 256 using iproute2 the local table will be deleted.
The table id is specified as a netlink attribute when it needs more then 8 bits and iproute2 then sets the table field to RT_TABLE_UNSPEC (0). Preconditions to matching the table id in the rule delete code doesn't seem to take the "table id in netlink attribute" into condition so the frh_get_table helper function never gets to do its job when matching against current rule.
Use the helper function twice instead of peaking at the table value directly.

Quoted 4 lines

Originally reported at: http://bugs.debian.org/724783

Good catch, applied and queued up for -stable, thanks!