wk pisze:
Hello,
Some time ago we were faced with a problem with multiple network
interfaces in the same subnetwork.
We would like to use several NIC's with IP addresses from the same
subnetwork with link redundancy functionality.
(...)
Sorry - I forgot to sent the patch in attachment in previous email.
WK
diff -rNup ./include/net/ip_fib.h ./include/net/ip_fib.h
--- ./include/net/ip_fib.h 2010-03-17 08:39:10.000000000 +0100
+++ ./include/net/ip_fib.h 2010-03-18 15:06:46.000000000 +0100
@@ -264,6 +264,10 @@ static inline void fib_res_put(struct fi
#endif
}
+#if defined(CONFIG_IP_MULTIPLE_TABLES) && defined(CONFIG_PROC_FS)
+extern int nexthop_alg;
+#endif
+
#ifdef CONFIG_PROC_FS
extern int __net_init fib_proc_init(struct net *net);
extern void __net_exit fib_proc_exit(struct net *net);
diff -rNup ./net/ipv4/fib_semantics.c ./net/ipv4/fib_semantics.c
--- ./net/ipv4/fib_semantics.c 2010-02-24 19:52:17.000000000 +0100
+++ ./net/ipv4/fib_semantics.c 2010-03-18 14:53:04.000000000 +0100
@@ -1173,7 +1173,7 @@ int fib_sync_up(struct net_device *dev)
fair weighted route distribution.
*/
-void fib_select_multipath(const struct flowi *flp, struct fib_result *res)
+void fib_select_multipath_orig(const struct flowi *flp, struct fib_result *res)
{
struct fib_info *fi = res->fi;
int w;
@@ -1219,4 +1219,31 @@ void fib_select_multipath(const struct f
res->nh_sel = 0;
spin_unlock_bh(&fib_multipath_lock);
}
+
+void fib_select_multipath_wk(const struct flowi *flp, struct fib_result *res)
+{
+ struct fib_info *fi = res->fi;
+
+ spin_lock_bh(&fib_multipath_lock);
+
+ change_nexthops(fi) {
+ if (!(nh->nh_flags&RTNH_F_DEAD) && netif_carrier_ok(nh->nh_dev)) {
+ res->nh_sel = nhsel;
+ spin_unlock_bh(&fib_multipath_lock);
+ return;
+ }
+ } endfor_nexthops(fi);
+
+ /* Race condition: route has just become dead. */
+ res->nh_sel = 0;
+ spin_unlock_bh(&fib_multipath_lock);
+}
+
+void fib_select_multipath(const struct flowi *flp, struct fib_result *res)
+{
+ if (nexthop_alg==0)
+ return fib_select_multipath_orig(flp, res);
+ else if (nexthop_alg>=1)
+ return fib_select_multipath_wk(flp, res);
+}
#endif
diff -rNup ./net/ipv4/route.c ./net/ipv4/route.c
--- ./net/ipv4/route.c 2010-02-24 19:52:17.000000000 +0100
+++ ./net/ipv4/route.c 2010-03-18 15:09:19.000000000 +0100
@@ -133,6 +133,9 @@ static int rt_chain_length_max __read_mo
static struct delayed_work expires_work;
static unsigned long expires_ljiffies;
+#if defined(CONFIG_IP_MULTIPLE_TABLES) && defined(CONFIG_PROC_FS)
+int nexthop_alg=0;
+#endif
/*
* Interface to generic destination cache.
@@ -3219,6 +3222,15 @@ static ctl_table ipv4_route_table[] = {
.mode = 0644,
.proc_handler = ipv4_sysctl_rt_secret_interval,
},
+#ifdef CONFIG_IP_MULTIPLE_TABLES
+ {
+ .procname = "nexthop_alg",
+ .data = &nexthop_alg,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = proc_dointvec,
+ },
+#endif
{ }
};