patch-1.3.6 linux/net/ipv4/route.c

Next file: linux/net/ipv4/tcp.c
Previous file: linux/net/ipv4/raw.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.5/linux/net/ipv4/route.c linux/net/ipv4/route.c
@@ -28,6 +28,7 @@
  *		Alan Cox	:	Removed compatibility cruft.
  *		Alan Cox	:	RTF_REJECT support.
  *		Alan Cox	:	TCP irtt support.
+ *		Jonathan Naylor	:	Added Metric support.
  *
  *		This program is free software; you can redistribute it and/or
  *		modify it under the terms of the GNU General Public License
@@ -209,7 +210,7 @@
  */
  
 void ip_rt_add(short flags, unsigned long dst, unsigned long mask,
-	unsigned long gw, struct device *dev, unsigned short mtu, unsigned long window, unsigned short irtt)
+	unsigned long gw, struct device *dev, unsigned short mtu, unsigned long window, unsigned short irtt, unsigned char metric)
 {
 	struct rtable *r, *rt;
 	struct rtable **rp;
@@ -282,6 +283,7 @@
 	rt->rt_gateway = gw;
 	rt->rt_mask = mask;
 	rt->rt_mss = dev->mtu - HEADER_SIZE;
+	rt->rt_metric = metric;
 	rt->rt_window = 0;	/* Default is no clamping */
 
 	/* Are the MSS/Window valid ? */
@@ -312,7 +314,8 @@
 	while ((r = *rp) != NULL) 
 	{
 		if (r->rt_dst != dst || 
-		    r->rt_mask != mask) 
+		    r->rt_mask != mask ||
+		    r->rt_metric < metric)
 		{
 			rp = &r->rt_next;
 			continue;
@@ -472,7 +475,7 @@
 	 *	Add the route
 	 */
 	 
-	ip_rt_add(flags, daddr, mask, gw, dev, r->rt_mss, r->rt_window, r->rt_irtt);
+	ip_rt_add(flags, daddr, mask, gw, dev, r->rt_mss, r->rt_window, r->rt_irtt, r->rt_metric);
 	return 0;
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this