Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net backout incomplete hack from KAME codebase (original...
details: https://anonhg.NetBSD.org/src/rev/b654d0e0ecec
branches: trunk
changeset: 482612:b654d0e0ecec
user: itojun <itojun%NetBSD.org@localhost>
date: Thu Feb 17 04:28:00 2000 +0000
description:
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), for the
similar reason as above.
There may be improved hack coming soon, hope the new one does not break others.
diffstat:
sys/net/rtsock.c | 113 +++++++++++++-----------------------------------------
1 files changed, 28 insertions(+), 85 deletions(-)
diffs (164 lines):
diff -r 9f8d1b0a349a -r b654d0e0ecec sys/net/rtsock.c
--- a/sys/net/rtsock.c Thu Feb 17 03:12:22 2000 +0000
+++ b/sys/net/rtsock.c Thu Feb 17 04:28:00 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtsock.c,v 1.34 2000/02/11 06:11:03 itojun Exp $ */
+/* $NetBSD: rtsock.c,v 1.35 2000/02/17 04:28:00 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -104,8 +104,6 @@
int *));
static void rt_xaddrs __P((caddr_t, caddr_t, struct rt_addrinfo *));
static __inline void rt_adjustcount __P((int, int));
-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]
@@ -211,6 +209,7 @@
struct rt_addrinfo info;
int len, error = 0;
struct ifnet *ifp = 0;
+ struct ifaddr *ifa = 0;
struct socket *so;
va_list ap;
@@ -218,7 +217,7 @@
so = va_arg(ap, struct socket *);
va_end(ap);
- bzero(&info, sizeof(info));
+
#define senderr(e) { error = e; goto flush;}
if (m == 0 || ((m->m_len < sizeof(int32_t)) &&
(m = m_pullup(m, sizeof(int32_t))) == 0))
@@ -273,35 +272,6 @@
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@localhost
- */
-
- rt_setif(saved_nrt, ifpaddr, ifaaddr, gate);
rt_setmetrics(rtm->rtm_inits,
&rtm->rtm_rmx, &saved_nrt->rt_rmx);
saved_nrt->rt_refcnt--;
@@ -370,11 +340,33 @@
case RTM_CHANGE:
if (gate && rt_setgate(rt, rt_key(rt), gate))
senderr(EDQUOT);
-
- rt_setif(rt, ifpaddr, ifaaddr, gate);
-
+ /* 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 ((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;
+ IFAREF(rt->rt_ifa);
+ rt->rt_ifp = ifp;
+ }
+ }
rt_setmetrics(rtm->rtm_inits, &rtm->rtm_rmx,
&rt->rt_rmx);
+ if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest)
+ rt->rt_ifa->ifa_rtrequest(RTM_ADD, rt, gate);
if (genmask)
rt->rt_genmask = genmask;
/*
@@ -448,55 +440,6 @@
#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)
- goto call_ifareq;
-
- if (oifa && oifa->ifa_rtrequest)
- oifa->ifa_rtrequest(RTM_DELETE, rt, Gate);
- IFAFREE(rt->rt_ifa);
- rt->rt_ifa = ifa;
- IFAREF(rt->rt_ifa);
- 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);
- 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))
Home |
Main Index |
Thread Index |
Old Index