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

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

diff -u --recursive --new-file v1.3.9/linux/net/ipv4/route.c linux/net/ipv4/route.c
@@ -29,6 +29,7 @@
  *		Alan Cox	:	RTF_REJECT support.
  *		Alan Cox	:	TCP irtt support.
  *		Jonathan Naylor	:	Added Metric support.
+ *	Miquel van Smoorenburg	:	BSD API fixes.
  *
  *		This program is free software; you can redistribute it and/or
  *		modify it under the terms of the GNU General Public License
@@ -314,8 +315,7 @@
 	while ((r = *rp) != NULL) 
 	{
 		if (r->rt_dst != dst || 
-		    r->rt_mask != mask ||
-		    r->rt_metric < metric)
+		    r->rt_mask != mask)
 		{
 			rp = &r->rt_next;
 			continue;
@@ -381,6 +381,7 @@
 	char * devname;
 	struct device * dev = NULL;
 	unsigned long flags, daddr, mask, gw;
+	unsigned char metric;
 
 	/*
 	 *	If a device is specified find it.
@@ -406,13 +407,14 @@
 
 	/*
 	 *	Make local copies of the important bits
+	 *	We decrement the metric by one for BSD compatibility.
 	 */
 	 
 	flags = r->rt_flags;
 	daddr = ((struct sockaddr_in *) &r->rt_dst)->sin_addr.s_addr;
 	mask = ((struct sockaddr_in *) &r->rt_genmask)->sin_addr.s_addr;
 	gw = ((struct sockaddr_in *) &r->rt_gateway)->sin_addr.s_addr;
-
+	metric = r->rt_metric > 0 ? r->rt_metric - 1 : 0;
 
 	/*
 	 *	BSD emulation: Permits route add someroute gw one-of-my-addresses
@@ -475,7 +477,7 @@
 	 *	Add the route
 	 */
 	 
-	ip_rt_add(flags, daddr, mask, gw, dev, r->rt_mss, r->rt_window, r->rt_irtt, r->rt_metric);
+	ip_rt_add(flags, daddr, mask, gw, dev, r->rt_mss, r->rt_window, r->rt_irtt, 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