diff options
author | Qing Li <qingli@FreeBSD.org> | 2008-04-13 05:45:14 +0000 |
---|---|---|
committer | Qing Li <qingli@FreeBSD.org> | 2008-04-13 05:45:14 +0000 |
commit | e440aed958ab32b6828b78ca6cec13c71cd2f4f2 (patch) | |
tree | 03815f4a4313c90b705a6c025d169df0eddd29c1 /sys/net/rtsock.c | |
parent | 22dd228d5d8b093829d5e35a0f7f032cf7cea8b9 (diff) | |
download | src-e440aed958ab32b6828b78ca6cec13c71cd2f4f2.tar.gz src-e440aed958ab32b6828b78ca6cec13c71cd2f4f2.zip |
This patch provides the back end support for equal-cost multi-path
(ECMP) for both IPv4 and IPv6. Previously, multipath route insertion
is disallowed. For example,
route add -net 192.103.54.0/24 10.9.44.1
route add -net 192.103.54.0/24 10.9.44.2
The second route insertion will trigger an error message of
"add net 192.103.54.0/24: gateway 10.2.5.2: route already in table"
Multiple default routes can also be inserted. Here is the netstat
output:
default 10.2.5.1 UGS 0 3074 bge0 =>
default 10.2.5.2 UGS 0 0 bge0
When multipath routes exist, the "route delete" command requires
a specific gateway to be specified or else an error message would
be displayed. For example,
route delete default
would fail and trigger the following error message:
"route: writing to routing socket: No such process"
"delete net default: not in table"
On the other hand,
route delete default 10.2.5.2
would be successful: "delete net default: gateway 10.2.5.2"
One does not have to specify a gateway if there is only a single
route for a particular destination.
I need to perform more testings on address aliases and multiple
interfaces that have the same IP prefixes. This patch as it
stands today is not yet ready for prime time. Therefore, the ECMP
code fragments are fully guarded by the RADIX_MPATH macro.
Include the "options RADIX_MPATH" in the kernel configuration
to enable this feature.
Reviewed by: robert, sam, gnn, julian, kmacy
Notes
Notes:
svn path=/head/; revision=178167
Diffstat (limited to 'sys/net/rtsock.c')
-rw-r--r-- | sys/net/rtsock.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 2893f4b297ce..5ea93d37aaba 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -30,6 +30,8 @@ * $FreeBSD$ */ #include "opt_sctp.h" +#include "opt_mpath.h" + #include <sys/param.h> #include <sys/domain.h> #include <sys/kernel.h> @@ -420,6 +422,24 @@ route_output(struct mbuf *m, struct socket *so) RADIX_NODE_HEAD_UNLOCK(rnh); senderr(ESRCH); } +#ifdef RADIX_MPATH + /* + * for RTM_CHANGE/LOCK, if we got multipath routes, + * we require users to specify a matching RTAX_GATEWAY. + * + * for RTM_GET, gate is optional even with multipath. + * if gate == NULL the first match is returned. + * (no need to call rt_mpath_matchgate if gate == NULL) + */ + if (rn_mpath_capable(rnh) && + (rtm->rtm_type != RTM_GET || info.rti_info[RTAX_GATEWAY])) { + rt = rt_mpath_matchgate(rt, info.rti_info[RTAX_GATEWAY]); + if (!rt) { + RADIX_NODE_HEAD_UNLOCK(rnh); + senderr(ESRCH); + } + } +#endif RT_LOCK(rt); RT_ADDREF(rt); RADIX_NODE_HEAD_UNLOCK(rnh); |