Skip to contentSkip to conversation

net: ipv4: fix table id in getroute response

PATCH In review David Ahern 2 participants 2 messages Jan 11, 2017 – Jan 12, 2017

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

PATCH 1/1 net: ipv4: fix table id in getroute response

rtm_table is an 8-bit field while table ids are allowed up to u32. Commit 709772e6e065 ("net: Fix routing tables with id > 255 for legacy software") added the preference to set rtm_table in dumps to RT_TABLE_COMPAT if the table id is > 255. The table id returned on get route requests should do the same.

Fixes c36ba6603a11 ("net: Allow user to get table id from route lookup")
---
 net/ipv4/route.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/route.c +1 -1
index 0fcac8e7a2b2..709ffe67d1de 100644
@@ -2472,7 +2472,7 @@ static int rt_fill_info(struct net *net,  __be32 dst, __be32 src, u32 table_id,
 	r->rtm_dst_len	= 32;
 	r->rtm_src_len	= 0;
 	r->rtm_tos	= fl4->flowi4_tos;
-	r->rtm_table	= table_id;
+	r->rtm_table	= table_id < 256 ? table_id : RT_TABLE_COMPAT;
 	if (nla_put_u32(skb, RTA_TABLE, table_id))
 		goto nla_put_failure;
 	r->rtm_type	= rt->rt_type;
Signature · 1 line
2.1.4
maintainer
#1 lore raw

From: David Ahern <[email protected]>
Date: Wed, 11 Jan 2017 15:42:17 -0800

Quoted 8 lines

rtm_table is an 8-bit field while table ids are allowed up to u32. Commit 709772e6e065 ("net: Fix routing tables with id > 255 for legacy software") added the preference to set rtm_table in dumps to RT_TABLE_COMPAT if the table id is > 255. The table id returned on get route requests should do the same.

Fixes c36ba6603a11 ("net: Allow user to get table id from route lookup")

Good catch, applied and queued up for -stable.