Skip to contentSkip to conversation

Age Entry For IPv4 Route Table

PATCH In review Varun Chandramohan 4 participants 6 messages Jun 25, 2007 1 message not in the archive

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

PATCH 1/1 Age Entry For IPv4 Route Table

According to the RFC 4292 (IP Forwarding Table MIB) there is a need for an age entry for all the routes in the routing table. The entry in the RFC is inetCidrRouteAge and oid is inetCidrRouteAge.1.10. Many snmp application require this age entry. So iam adding the age field in the routing table and providing
the interface for this value via /proc/net/route.

---
 net/ipv4/fib_hash.c   |   16 +++++++++++-----
 net/ipv4/fib_lookup.h |    1 +
 2 files changed, 12 insertions(+), 5 deletions(-)
net/ipv4/fib_hash.c +11 -5
index 07e843a..2000f1e 100644
@@ -448,6 +448,7 @@ static int fn_hash_insert(struct fib_tab
 			fa->fa_info = fi;
 			fa->fa_type = cfg->fc_type;
 			fa->fa_scope = cfg->fc_scope;
+			fa->fa_age = jiffies;
 			state = fa->fa_state;
 			fa->fa_state &= ~FA_S_ACCESSED;
 			fib_hash_genid++;
@@ -507,6 +508,7 @@ static int fn_hash_insert(struct fib_tab
 	new_fa->fa_type = cfg->fc_type;
 	new_fa->fa_scope = cfg->fc_scope;
 	new_fa->fa_state = 0;
+	new_fa->fa_age = jiffies;
 
 	/*
 	 * Insert new entry to the list.
@@ -998,10 +1000,11 @@ static int fib_seq_show(struct seq_file
 	struct fib_alias *fa;
 	struct fib_info *fi;
 
+#define JIFFIES_TO_SECS(jiffies)   ((jiffies)/HZ)
 	if (v == SEQ_START_TOKEN) {
 		seq_printf(seq, "%-127s\n", "Iface\tDestination\tGateway "
 			   "\tFlags\tRefCnt\tUse\tMetric\tMask\t\tMTU"
-			   "\tWindow\tIRTT");
+			   "\tWindow\tIRTT\tAge");
 		goto out;
 	}
 
@@ -1014,17 +1017,20 @@ static int fib_seq_show(struct seq_file
 	flags	= fib_flag_trans(fa->fa_type, mask, fi);
 	if (fi)
 		snprintf(bf, sizeof(bf),
-			 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u",
+			 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u\t%lu",
 			 fi->fib_dev ? fi->fib_dev->name : "*", prefix,
 			 fi->fib_nh->nh_gw, flags, 0, 0, fi->fib_priority,
 			 mask, (fi->fib_advmss ? fi->fib_advmss + 40 : 0),
 			 fi->fib_window,
-			 fi->fib_rtt >> 3);
+			 fi->fib_rtt >> 3,
+			 JIFFIES_TO_SECS(jiffies - fa->fa_age));	
 	else
 		snprintf(bf, sizeof(bf),
-			 "*\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u",
-			 prefix, 0, flags, 0, 0, 0, mask, 0, 0, 0);
+			 "*\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u\t%lu",
+			 prefix, 0, flags, 0, 0, 0, mask, 0, 0, 0, 0);
 	seq_printf(seq, "%-127s\n", bf);
+
+#undef JIFFIES_TO_SECS
 out:
 	return 0;
 }
net/ipv4/fib_lookup.h +1 -0
index eef9eec..cc403d4 100644
@@ -13,6 +13,7 @@ struct fib_alias {
 	u8			fa_type;
 	u8			fa_scope;
 	u8			fa_state;
+	unsigned long		fa_age;
 };
 
 #define FA_S_ACCESSED	0x01
Signature · 1 line
1.4.3.4
#1 lore raw

In article <[email protected]> (at Mon, 25 Jun 2007 10:28:38 +0530), Varun Chandramohan <[email protected]> says:

Quoted 3 lines

According to the RFC 4292 (IP Forwarding Table MIB) there is a need for an age entry for all the routes in the routing table. The entry in the RFC is inetCidrRouteAge and oid is inetCidrRouteAge.1.10. Many snmp application require this age entry. So iam adding the age field in the routing table and providing
the interface for this value via /proc/net/route.

I'm not in favor of adding new field(s) to /proc/net/route.

--yoshfuji

#2 lore raw
Quoted 11 lines · YOSHIFUJI Hideaki / 吉藤英明

In article <[email protected]> (at Mon, 25 Jun 2007 10:28:38 +0530), Varun Chandramohan <[email protected]> says:

Quoted 4 lines

According to the RFC 4292 (IP Forwarding Table MIB) there is a need for an age entry for all the routes in the routing table. The entry in the RFC is inetCidrRouteAge and oid is inetCidrRouteAge.1.10. Many snmp application require this age entry. So iam adding the age field in the routing table and providing
the interface for this value via /proc/net/route.

I'm not in favor of adding new field(s) to /proc/net/route.

Do you think it will break any user level functionality? I have tested with netstat, route and net-snmp which reads from the same /proc interface. They seem to work fine.

Quoted 6 lines

--yoshfuji
-
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 24 lines · David Miller

From: Varun Chandramohan <[email protected]>
Date: Mon, 25 Jun 2007 10:51:39 +0530

Quoted 11 lines
Quoted 9 lines · YOSHIFUJI Hideaki / ������������

In article <[email protected]> (at Mon, 25 Jun 2007 10:28:38 +0530), Varun Chandramohan <[email protected]> says:

Quoted 5 lines

According to the RFC 4292 (IP Forwarding Table MIB) there is a need for an age entry for all the routes in the routing table. The entry in the RFC is inetCidrRouteAge and oid is inetCidrRouteAge.1.10. Many snmp application require this age entry. So iam adding the age field in the routing table and providing
the interface for this value via /proc/net/route.

Quoted 8 lines
Quoted 4 lines

I'm not in favor of adding new field(s) to /proc/net/route.

Do you think it will break any user level functionality? I have tested with netstat, route and net-snmp which reads from the same /proc interface. They seem to work fine.

Quoted 6 lines

You can't change procfs file output format, someone's shell scripts or whatever out there will break. Just testing some common packages isn't a way to be able to change procfs file output, it's a user exported API and just like system calls you cannot change them.

Hi Dave,

Ok i understand. But can you suggest anyother way to do the above?

Regards,
Varun

maintainer
#5 lore raw

From: Varun Chandramohan <[email protected]>
Date: Mon, 25 Jun 2007 13:28:37 +0530

Quoted 1 line

Ok i understand. But can you suggest anyother way to do the above?

Just because I found a fault in your patch doesn't mean that it becomes my job isn't to implement the feature for you.

#6 lore raw
In reply to Varun Chandramohan
Quoted 4 lines · On Mon, 25 Jun 2007 10:28:38 +0530 Varun Chandramohan…

According to the RFC 4292 (IP Forwarding Table MIB) there is a need for an age entry for all the routes in the routing table. The entry in the RFC is inetCidrRouteAge and oid is inetCidrRouteAge.1.10. Many snmp application require this age entry. So iam adding the age field in the routing table and providing
the interface for this value via /proc/net/route.

Hi Varun

If you find a way to expose this information without breaking /proc/net/route, please consider that jiffies can wrap every 49 days on 32 bit platforms.
So you probably want to use an other time infrastructure if you want meaningfull Age information.