Subject: Re: source route ignored in favor of local interface

From: Joe Buehler <[email-masked]>
Date: Thu, 09 Jun 2011 12:27:43 -0400

Ben Greear wrote:

> You can do this on more modern kernels (2.6.36 and later definately
> works..not sure
> about earlier).
> 
>         ip rule add pref 512 lookup local
>         ip rule del pref 0 lookup local
> 

The kernel change for this in later kernels was simple enough -- there
is a flag that prevents deletion of the "local" table rule, just remove
the flag.  Here is a patch for 2.6.24.7.  The patch for 2.6.27.7 (I am
using both versions) is almost the same.

--- old/net/ipv4/fib_rules.c	2008-01-24 17:58:37.000000000 -0500
+++ new/net/ipv4/fib_rules.c	2011-06-08 14:01:19.000000000 -0400
@@ -297,7 +297,7 @@
 	int err;

 	err = fib_default_rule_add(&fib4_rules_ops, 0,
-				   RT_TABLE_LOCAL, FIB_RULE_PERMANENT);
+				   RT_TABLE_LOCAL, 0);
 	if (err < 0)
 		return err;
 	err = fib_default_rule_add(&fib4_rules_ops, 0x7FFE,
--- old/net/ipv6/fib6_rules.c	2008-01-24 17:58:37.000000000 -0500
+++ new/net/ipv6/fib6_rules.c	2011-06-08 14:01:34.000000000 -0400
@@ -256,7 +256,7 @@
 	int err;

 	err = fib_default_rule_add(&fib6_rules_ops, 0,
-				   RT6_TABLE_LOCAL, FIB_RULE_PERMANENT);
+				   RT6_TABLE_LOCAL, 0);
 	if (err < 0)
 		return err;
 	err = fib_default_rule_add(&fib6_rules_ops, 0x7FFE, RT6_TABLE_MAIN, 0);

Joe Buehler