summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2008-11-21 18:01:31 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2008-11-21 18:01:31 +0000
commit8e06c6f5dc2471f74afaba2d2165f15df7ccccb0 (patch)
tree360aefddde5c037a78d1da81fcde1cbb01aa9c25 /sys/net
parent070dd156775d8869751bd9b8b48fa3df30d11948 (diff)
Change rn_mpath_next() to be able to walk over the full multipath list
not only over routes of the same prio. This makes it possible to modify rt_mpath_matchgate() so that if only gateway is specified without a specific priority it will scan the full list and not only the first routes. This is also needed for upcoming link state tracking.
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if.c6
-rw-r--r--sys/net/pf.c4
-rw-r--r--sys/net/radix.c4
-rw-r--r--sys/net/radix_mpath.c43
-rw-r--r--sys/net/radix_mpath.h4
-rw-r--r--sys/net/route.c6
-rw-r--r--sys/net/rtsock.c4
7 files changed, 35 insertions, 36 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index c83b5bbc9b8..916df0176eb 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.174 2008/11/10 18:08:42 claudio Exp $ */
+/* $OpenBSD: if.c,v 1.175 2008/11/21 18:01:30 claudio Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@@ -1914,7 +1914,7 @@ if_group_egress_build(void)
if (rt->rt_ifp)
if_addgroup(rt->rt_ifp, IFG_EGRESS);
#ifndef SMALL_KERNEL
- rn = rn_mpath_next(rn);
+ rn = rn_mpath_next(rn, 0);
#else
rn = NULL;
#endif
@@ -1929,7 +1929,7 @@ if_group_egress_build(void)
if (rt->rt_ifp)
if_addgroup(rt->rt_ifp, IFG_EGRESS);
#ifndef SMALL_KERNEL
- rn = rn_mpath_next(rn);
+ rn = rn_mpath_next(rn, 0);
#else
rn = NULL;
#endif
diff --git a/sys/net/pf.c b/sys/net/pf.c
index 5cb55844445..35200c96fc3 100644
--- a/sys/net/pf.c
+++ b/sys/net/pf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf.c,v 1.625 2008/10/28 22:57:01 mpf Exp $ */
+/* $OpenBSD: pf.c,v 1.626 2008/11/21 18:01:30 claudio Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -5153,7 +5153,7 @@ pf_routable(struct pf_addr *addr, sa_family_t af, struct pfi_kif *kif)
if (kif->pfik_ifp == ifp)
ret = 1;
- rn = rn_mpath_next(rn);
+ rn = rn_mpath_next(rn, 0);
} while (check_mpath == 1 && rn != NULL && ret == 0);
} else
ret = 0;
diff --git a/sys/net/radix.c b/sys/net/radix.c
index bbc8a779b16..3da7a554702 100644
--- a/sys/net/radix.c
+++ b/sys/net/radix.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: radix.c,v 1.23 2008/05/09 07:39:31 claudio Exp $ */
+/* $OpenBSD: radix.c,v 1.24 2008/11/21 18:01:30 claudio Exp $ */
/* $NetBSD: radix.c,v 1.20 2003/08/07 16:32:56 agc Exp $ */
/*
@@ -569,7 +569,7 @@ rn_addroute(void *v_arg, void *n_arg, struct radix_node_head *head,
mid = rn_mpath_count(tt) / 2;
do {
t = tt;
- tt = rn_mpath_next(tt);
+ tt = rn_mpath_next(tt, 0);
} while (tt && --mid > 0);
break;
}
diff --git a/sys/net/radix_mpath.c b/sys/net/radix_mpath.c
index 0c7b07b61ef..c2718c206c0 100644
--- a/sys/net/radix_mpath.c
+++ b/sys/net/radix_mpath.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: radix_mpath.c,v 1.11 2008/05/07 05:14:21 claudio Exp $ */
+/* $OpenBSD: radix_mpath.c,v 1.12 2008/11/21 18:01:30 claudio Exp $ */
/* $KAME: radix_mpath.c,v 1.13 2002/10/28 21:05:59 itojun Exp $ */
/*
@@ -65,7 +65,7 @@ rn_mpath_capable(struct radix_node_head *rnh)
}
struct radix_node *
-rn_mpath_next(struct radix_node *rn)
+rn_mpath_next(struct radix_node *rn, int all)
{
struct radix_node *next;
struct rtentry *rt = (struct rtentry *)rn;
@@ -73,8 +73,8 @@ rn_mpath_next(struct radix_node *rn)
if (!rn->rn_dupedkey)
return NULL;
next = rn->rn_dupedkey;
- if (rn->rn_mask == next->rn_mask &&
- rt->rt_priority == ((struct rtentry *)next)->rt_priority)
+ if (rn->rn_mask == next->rn_mask && (all ||
+ rt->rt_priority == ((struct rtentry *)next)->rt_priority))
return next;
else
return NULL;
@@ -112,7 +112,7 @@ rn_mpath_count(struct radix_node *rn)
int i;
i = 1;
- while ((rn = rn_mpath_next(rn)) != NULL)
+ while ((rn = rn_mpath_next(rn, 0)) != NULL)
i++;
return i;
}
@@ -122,27 +122,26 @@ rt_mpath_matchgate(struct rtentry *rt, struct sockaddr *gate, u_int8_t prio)
{
struct radix_node *rn = (struct radix_node *)rt;
- rn = rn_mpath_prio((struct radix_node *)rt, prio);
- rt = (struct rtentry *)rn;
- /* check if returned node has same priority */
- if (prio != RTP_ANY && rt->rt_priority != prio)
- return NULL;
-
- /*
- * if gate is set it must be compared, if not set the route must be
- * a non-multipath one.
- */
- if (!gate && !rn_mpath_next(rn))
- return rt;
- if (!gate)
- return NULL;
-
do {
rt = (struct rtentry *)rn;
+
+ /* first find routes with correct priority */
+ if (prio != RTP_ANY &&
+ (rt->rt_priority & RTP_MASK) != (prio & RTP_MASK))
+ continue;
+ /*
+ * if gate is set it must be compared, if not set the route
+ * must be a non-multipath one.
+ */
+ if (!gate && !rn_mpath_next(rn, 0))
+ return rt;
+ if (!gate)
+ return NULL;
+
if (rt->rt_gateway->sa_len == gate->sa_len &&
!memcmp(rt->rt_gateway, gate, gate->sa_len))
break;
- } while ((rn = rn_mpath_next(rn)) != NULL);
+ } while ((rn = rn_mpath_next(rn, 1)) != NULL);
return (struct rtentry *)rn;
}
@@ -247,7 +246,7 @@ rt_mpath_conflict(struct radix_node_head *rnh, struct rtentry *rt,
/* all key/mask/gateway are the same. conflicting entry. */
return EEXIST;
- } while ((rn1 = rn_mpath_next(rn1)) != NULL);
+ } while ((rn1 = rn_mpath_next(rn1, 0)) != NULL);
different:
return 0;
diff --git a/sys/net/radix_mpath.h b/sys/net/radix_mpath.h
index 46c39a9414b..2829397870a 100644
--- a/sys/net/radix_mpath.h
+++ b/sys/net/radix_mpath.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: radix_mpath.h,v 1.6 2008/05/07 05:14:21 claudio Exp $ */
+/* $OpenBSD: radix_mpath.h,v 1.7 2008/11/21 18:01:30 claudio Exp $ */
/* $KAME: radix_mpath.h,v 1.9 2004/03/30 11:21:49 keiichi Exp $ */
/*
@@ -45,7 +45,7 @@ struct route;
struct rtentry;
struct sockaddr;
int rn_mpath_capable(struct radix_node_head *);
-struct radix_node *rn_mpath_next(struct radix_node *);
+struct radix_node *rn_mpath_next(struct radix_node *, int);
struct radix_node *rn_mpath_prio(struct radix_node *, u_int8_t);
int rn_mpath_count(struct radix_node *);
struct rtentry *rt_mpath_matchgate(struct rtentry *, struct sockaddr *,
diff --git a/sys/net/route.c b/sys/net/route.c
index 74ee0fe4d47..f35317bbf7d 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.97 2008/09/10 14:01:23 blambert Exp $ */
+/* $OpenBSD: route.c,v 1.98 2008/11/21 18:01:30 claudio Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
@@ -771,7 +771,7 @@ rtrequest1(int req, struct rt_addrinfo *info, u_int8_t prio,
if (rn_mpath_capable(rnh)) {
if ((rn = rnh->rnh_lookup(info->rti_info[RTAX_DST],
info->rti_info[RTAX_NETMASK], rnh)) != NULL &&
- rn_mpath_next(rn) == NULL)
+ rn_mpath_next(rn, 0) == NULL)
((struct rtentry *)rn)->rt_flags &= ~RTF_MPATH;
}
#endif
@@ -887,7 +887,7 @@ makeroute:
(rn = rnh->rnh_lookup(info->rti_info[RTAX_DST],
info->rti_info[RTAX_NETMASK], rnh)) != NULL &&
(rn = rn_mpath_prio(rn, prio)) != NULL) {
- if (rn_mpath_next(rn) == NULL)
+ if (rn_mpath_next(rn, 0) == NULL)
((struct rtentry *)rn)->rt_flags &= ~RTF_MPATH;
else
((struct rtentry *)rn)->rt_flags |= RTF_MPATH;
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 745678ca20b..9191c1120ea 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtsock.c,v 1.76 2008/08/07 21:32:08 claudio Exp $ */
+/* $OpenBSD: rtsock.c,v 1.77 2008/11/21 18:01:30 claudio Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
@@ -356,7 +356,7 @@ route_output(struct mbuf *m, ...)
}
/* if multipath routes */
- if (rn_mpath_next(rn)) {
+ if (rn_mpath_next(rn, 0)) {
if (gate)
rt = rt_mpath_matchgate(rt, gate, prio);
else if (rtm->rtm_type != RTM_GET)