summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2000-02-17 04:15:30 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2000-02-17 04:15:30 +0000
commit31617df01cf3d0ce7168e8267e08acbf66cb1228 (patch)
tree46ca5454c41802136122f065a0fa9bdd93f20217 /sys
parentf1252793b4455e9bb0a80421006431591d7aead0 (diff)
backout incomplete hack from KAME codebase (originally from bbn).
the hack tries to respect ifa or ifp passed to RTM_ADD. However, the change broke certain link-layers. They include: - midway ethernet card (en*), which uses sockaddr_dl in gateway portion to pass PVC information. with the patch, the gateway portion will be overwritten by empty sockaddr_dl and PVC initialization will fail. - IPv6, which can't set static ND table with the patch (ndp -s) with the similar reason. There may be improved hack coming soon, hope the new one does not break others.
Diffstat (limited to 'sys')
-rw-r--r--sys/net/rtsock.c91
1 files changed, 2 insertions, 89 deletions
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 6df1c2b2613..8e9e56b43fa 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtsock.c,v 1.9 2000/02/07 06:08:04 itojun Exp $ */
+/* $OpenBSD: rtsock.c,v 1.10 2000/02/17 04:15:29 itojun Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
@@ -97,8 +97,6 @@ static struct mbuf *
static int rt_msg2 __P((int,
struct rt_addrinfo *, caddr_t, struct walkarg *));
static void rt_xaddrs __P((caddr_t, caddr_t, struct rt_addrinfo *));
-static void rt_setif __P((struct rtentry *, struct sockaddr *,
- struct sockaddr *, struct sockaddr *));
/* Sleazy use of local variables throughout file, warning!!!! */
#define dst info.rti_info[RTAX_DST]
@@ -194,6 +192,7 @@ route_output(m, va_alist)
struct rt_addrinfo info;
int len, error = 0;
struct ifnet *ifp = 0;
+ struct ifaddr *ifa = 0;
struct socket *so;
va_list ap;
@@ -253,35 +252,6 @@ route_output(m, va_alist)
error = rtrequest(RTM_ADD, dst, gate, netmask,
rtm->rtm_flags, &saved_nrt);
if (error == 0 && saved_nrt) {
- /*
- * If the route request specified an interface with
- * IFA and/or IFP, we set the requested interface on
- * the route with rt_setif. It would be much better
- * to do this inside rtrequest, but that would
- * require passing the desired interface, in some
- * form, to rtrequest. Since rtrequest is called in
- * so many places (roughly 40 in our source), adding
- * a parameter is to much for us to swallow; this is
- * something for the FreeBSD developers to tackle.
- * Instead, we let rtrequest compute whatever
- * interface it wants, then come in behind it and
- * stick in the interface that we really want. This
- * works reasonably well except when rtrequest can't
- * figure out what interface to use (with
- * ifa_withroute) and returns ENETUNREACH. Ideally
- * it shouldn't matter if rtrequest can't figure out
- * the interface if we're going to explicitly set it
- * ourselves anyway. But practically we can't
- * recover here because rtrequest will not do any of
- * the work necessary to add the route if it can't
- * find an interface. As long as there is a default
- * route that leads to some interface, rtrequest will
- * find an interface, so this problem should be
- * rarely encountered.
- * dwiggins@bbn.com
- */
-
- rt_setif(saved_nrt, ifpaddr, ifaaddr, gate);
rt_setmetrics(rtm->rtm_inits,
&rtm->rtm_rmx, &saved_nrt->rt_rmx);
saved_nrt->rt_refcnt--;
@@ -350,10 +320,6 @@ route_output(m, va_alist)
case RTM_CHANGE:
if (gate && rt_setgate(rt, rt_key(rt), gate))
senderr(EDQUOT);
-
-#if 1
- rt_setif(rt, ifpaddr, ifaaddr, gate);
-#else
/* new gateway could require new ifaddr, ifp;
flags may also be different; ifp may be specified
by ll sockaddr when protocol address is ambiguous */
@@ -377,13 +343,10 @@ route_output(m, va_alist)
rt->rt_ifp = ifp;
}
}
-#endif
rt_setmetrics(rtm->rtm_inits, &rtm->rtm_rmx,
&rt->rt_rmx);
-#if 0
if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest)
rt->rt_ifa->ifa_rtrequest(RTM_ADD, rt, gate);
-#endif
if (genmask)
rt->rt_genmask = genmask;
/*
@@ -457,56 +420,6 @@ rt_setmetrics(which, in, out)
#undef metric
}
-/*
- * Set route's interface given ifpaddr, ifaaddr, and gateway.
- */
-static void
-rt_setif(rt, Ifpaddr, Ifaaddr, Gate)
- struct rtentry *rt;
- struct sockaddr *Ifpaddr, *Ifaaddr, *Gate;
-{
- struct ifaddr *ifa = 0;
- struct ifnet *ifp = 0;
-
- /* new gateway could require new ifaddr, ifp;
- flags may also be different; ifp may be specified
- by ll sockaddr when protocol address is ambiguous */
- if (Ifpaddr && (ifa = ifa_ifwithnet(Ifpaddr)) &&
- (ifp = ifa->ifa_ifp) && (Ifaaddr || Gate))
- ifa = ifaof_ifpforaddr(Ifaaddr ? Ifaaddr : Gate,
- ifp);
- else if (Ifpaddr && (ifp = if_withname(Ifpaddr)) ) {
- ifa = Gate ? ifaof_ifpforaddr(Gate, ifp) :
- TAILQ_FIRST(&ifp->if_addrlist);
- }
- else if ((Ifaaddr && (ifa = ifa_ifwithaddr(Ifaaddr))) ||
- (Gate && (ifa = ifa_ifwithroute(rt->rt_flags,
- rt_key(rt), Gate))))
- ifp = ifa->ifa_ifp;
- if (ifa) {
- register struct ifaddr *oifa = rt->rt_ifa;
- if (oifa != ifa) {
- if (oifa && oifa->ifa_rtrequest)
- oifa->ifa_rtrequest(RTM_DELETE,
- rt, Gate);
- IFAFREE(rt->rt_ifa);
- rt->rt_ifa = ifa;
- ifa->ifa_refcnt++;
- rt->rt_ifp = ifp;
- rt->rt_rmx.rmx_mtu = ifp->if_mtu;
- if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest)
- rt->rt_ifa->ifa_rtrequest(RTM_ADD, rt, Gate);
- } else
- goto call_ifareq;
- return;
- }
- call_ifareq:
- /* XXX: to reset gateway to correct value, at RTM_CHANGE */
- if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest)
- rt->rt_ifa->ifa_rtrequest(RTM_ADD, rt, Gate);
-}
-
-
#define ROUNDUP(a) \
((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len))