Take steps to hide the radix_node implementation of the forwarding table
from the forwarding table's users: Introduce rt_walktree() for walking the routing table and applying a function to each rtentry. Replace most rn_walktree() calls with it. Use rt_getkey()/rt_setkey() to get/set a route's destination. Keep a pointer to the sockaddr key in the rtentry, so that rtentry users do not have to grovel in the radix_node for the key. Add a RTM_GET method to rtrequest. Use that instead of radix_node lookups in, e.g., carp(4). Add sys/net/link_proto.c, which supplies sockaddr routines for link-layer socket addresses (sockaddr_dl). Cosmetic: Constify. KNF. Stop open-coding LIST_FOREACH, TAILQ_FOREACH, et cetera. Use NULL instead of 0 for null pointers. Use __arraycount(). Reduce gratuitous parenthesization. Stop using variadic arguments for rip6_output(), it is unnecessary. Remove the unnecessary rtentry member rt_genmask and the code to maintain it, since nothing actually used it. Make rt_maskedcopy() easier to read by using meaningful variable names. Extract a subroutine intern_netmask() for looking up a netmask in the masks table. Start converting backslash-ridden IPv6 macros in sys/netinet6/in6_var.h into inline subroutines that one can read without special eyeglasses. One functional change: when the kernel serves an RTM_GET, RTM_LOCK, or RTM_CHANGE request, it applies the netmask (if supplied) to a destination before searching for it in the forwarding table. I have changed sys/netinet/ip_carp.c, carp_setroute(), to remove the unlawful radix_node knowledge. Apart from the changes to carp(4), netiso, ATM, and strip(4), I have run the changes on three nodes in my wireless routing testbed, which involves IPv4 + IPv6 dynamic routing acrobatics, and it's working beautifully so far.
This commit is contained in:
parent
8e15db7550
commit
08e6f22226
19
sys/net/if.c
19
sys/net/if.c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: if.c,v 1.193 2007/07/09 21:10:59 ad Exp $ */
|
||||
/* $NetBSD: if.c,v 1.194 2007/07/19 20:48:52 dyoung Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
|
||||
@ -97,7 +97,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.193 2007/07/09 21:10:59 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.194 2007/07/19 20:48:52 dyoung Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
|
||||
@ -745,7 +745,7 @@ if_rt_walktree(struct rtentry *rt, void *v)
|
||||
|
||||
/* Delete the entry. */
|
||||
++rt->rt_refcnt;
|
||||
error = rtrequest(RTM_DELETE, rt_key(rt), rt->rt_gateway,
|
||||
error = rtrequest(RTM_DELETE, rt_getkey(rt), rt->rt_gateway,
|
||||
rt_mask(rt), rt->rt_flags, NULL);
|
||||
KASSERT((rt->rt_flags & RTF_UP) == 0);
|
||||
rt->rt_ifp = NULL;
|
||||
@ -897,6 +897,12 @@ if_clone_list(struct if_clonereq *ifcr)
|
||||
return error;
|
||||
}
|
||||
|
||||
static inline int
|
||||
equal(const struct sockaddr *sa1, const struct sockaddr *sa2)
|
||||
{
|
||||
return sockaddr_cmp(sa1, sa2) == 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Locate an interface based on a complete address.
|
||||
*/
|
||||
@ -907,9 +913,6 @@ ifa_ifwithaddr(const struct sockaddr *addr)
|
||||
struct ifnet *ifp;
|
||||
struct ifaddr *ifa;
|
||||
|
||||
#define equal(a1, a2) \
|
||||
(memcmp((a1), (a2), ((const struct sockaddr *)(a1))->sa_len) == 0)
|
||||
|
||||
IFNET_FOREACH(ifp) {
|
||||
if (ifp->if_output == if_nulloutput)
|
||||
continue;
|
||||
@ -1113,11 +1116,11 @@ void
|
||||
link_rtrequest(int cmd, struct rtentry *rt, struct rt_addrinfo *info)
|
||||
{
|
||||
struct ifaddr *ifa;
|
||||
struct sockaddr *dst;
|
||||
const struct sockaddr *dst;
|
||||
struct ifnet *ifp;
|
||||
|
||||
if (cmd != RTM_ADD || ((ifa = rt->rt_ifa) == NULL) ||
|
||||
((ifp = ifa->ifa_ifp) == NULL) || ((dst = rt_key(rt)) == NULL))
|
||||
((ifp = ifa->ifa_ifp) == NULL) || ((dst = rt_getkey(rt)) == NULL))
|
||||
return;
|
||||
if ((ifa = ifaof_ifpforaddr(dst, ifp)) != NULL) {
|
||||
rt_replace_ifa(rt, ifa);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: if_strip.c,v 1.76 2007/07/14 21:02:41 ad Exp $ */
|
||||
/* $NetBSD: if_strip.c,v 1.77 2007/07/19 20:48:52 dyoung Exp $ */
|
||||
/* from: NetBSD: if_sl.c,v 1.38 1996/02/13 22:00:23 christos Exp $ */
|
||||
|
||||
/*
|
||||
@ -87,7 +87,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_strip.c,v 1.76 2007/07/14 21:02:41 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_strip.c,v 1.77 2007/07/19 20:48:52 dyoung Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "bpfilter.h"
|
||||
@ -761,10 +761,10 @@ stripoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
|
||||
#ifdef DEBUG
|
||||
if (rt) {
|
||||
printf("stripout, rt: dst af%d gw af%d",
|
||||
rt_key(rt)->sa_family, rt->rt_gateway->sa_family);
|
||||
if (rt_key(rt)->sa_family == AF_INET)
|
||||
rt_getkey(rt)->sa_family, rt->rt_gateway->sa_family);
|
||||
if (rt_getkey(rt)->sa_family == AF_INET)
|
||||
printf(" dst %x",
|
||||
satocsin(rt_key(rt))->sin_addr.s_addr);
|
||||
satocsin(rt_getkey(rt))->sin_addr.s_addr);
|
||||
printf("\n");
|
||||
}
|
||||
#endif
|
||||
|
160
sys/net/link_proto.c
Normal file
160
sys/net/link_proto.c
Normal file
@ -0,0 +1,160 @@
|
||||
/* $NetBSD: link_proto.c,v 1.1 2007/07/19 20:48:52 dyoung Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)uipc_proto.c 8.2 (Berkeley) 2/14/95
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: link_proto.c,v 1.1 2007/07/19 20:48:52 dyoung Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/protosw.h>
|
||||
#include <sys/domain.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/un.h>
|
||||
#include <sys/socketvar.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/raw_cb.h>
|
||||
|
||||
static int sockaddr_dl_cmp(const struct sockaddr *, const struct sockaddr *);
|
||||
|
||||
/*
|
||||
* Definitions of protocols supported in the link-layer domain.
|
||||
*/
|
||||
|
||||
DOMAIN_DEFINE(linkdomain); /* forward define and add to link set */
|
||||
|
||||
POOL_INIT(sockaddr_dl_pool, sizeof(struct sockaddr_dl), 0, 0, 0,
|
||||
"sockaddr_dl_pool", NULL, IPL_NET);
|
||||
|
||||
struct domain linkdomain = {
|
||||
.dom_family = AF_LINK,
|
||||
.dom_name = "link",
|
||||
.dom_externalize = NULL,
|
||||
.dom_dispose = NULL,
|
||||
.dom_protosw = NULL,
|
||||
.dom_protoswNPROTOSW = NULL,
|
||||
.dom_sa_pool = &sockaddr_dl_pool,
|
||||
.dom_sa_len = sizeof(struct sockaddr_dl),
|
||||
.dom_sockaddr_cmp = sockaddr_dl_cmp
|
||||
};
|
||||
|
||||
#define satocsdl(__sa) ((const struct sockaddr_dl *)(__sa))
|
||||
|
||||
/* Compare the field at byte offsets [fieldstart, fieldend) in
|
||||
* two memory regions, [l, l + llen) and [r, r + llen).
|
||||
*/
|
||||
static inline int
|
||||
submemcmp(const void *l, const void *r,
|
||||
const uint_fast8_t llen, const uint_fast8_t rlen,
|
||||
const uint_fast8_t fieldstart, const uint_fast8_t fieldend)
|
||||
{
|
||||
uint_fast8_t cmpend, minlen;
|
||||
const uint8_t *lb = l, *rb = r;
|
||||
int rc;
|
||||
|
||||
minlen = MIN(llen, rlen);
|
||||
|
||||
/* The field is missing from one region. The shorter region is the
|
||||
* lesser region.
|
||||
*/
|
||||
if (fieldstart >= minlen)
|
||||
return llen - rlen;
|
||||
|
||||
/* Two empty, present fields are always equal. */
|
||||
if (fieldstart > fieldend)
|
||||
return 0;
|
||||
|
||||
cmpend = MIN(fieldend, minlen);
|
||||
|
||||
rc = memcmp(&lb[fieldstart], &rb[fieldstart], cmpend - fieldstart);
|
||||
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
/* If one or both fields are truncated, then the shorter is the lesser
|
||||
* field.
|
||||
*/
|
||||
if (minlen < fieldend)
|
||||
return llen - rlen;
|
||||
/* Fields are full-length and equal. The fields are equal. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
sockaddr_dl_cmp(const struct sockaddr *sa1, const struct sockaddr *sa2)
|
||||
{
|
||||
int rc;
|
||||
const uint_fast8_t indexofs = offsetof(struct sockaddr_dl, sdl_index);
|
||||
const uint_fast8_t nlenofs = offsetof(struct sockaddr_dl, sdl_nlen);
|
||||
uint_fast8_t dataofs = offsetof(struct sockaddr_dl, sdl_data[0]);
|
||||
const struct sockaddr_dl *sdl1, *sdl2;
|
||||
|
||||
sdl1 = satocsdl(sa1);
|
||||
sdl2 = satocsdl(sa2);
|
||||
|
||||
rc = submemcmp(sdl1, sdl2, sdl1->sdl_len, sdl2->sdl_len,
|
||||
indexofs, nlenofs);
|
||||
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
|
||||
rc = submemcmp(sdl1, sdl2, sdl1->sdl_len, sdl2->sdl_len,
|
||||
dataofs, dataofs + MIN(sdl1->sdl_nlen, sdl2->sdl_nlen));
|
||||
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
|
||||
if (sdl1->sdl_nlen != sdl2->sdl_nlen)
|
||||
return sdl1->sdl_nlen - sdl2->sdl_nlen;
|
||||
|
||||
dataofs += sdl1->sdl_nlen;
|
||||
|
||||
rc = submemcmp(sdl1, sdl2, sdl1->sdl_len, sdl2->sdl_len,
|
||||
dataofs, dataofs + MIN(sdl1->sdl_alen, sdl2->sdl_alen));
|
||||
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
|
||||
if (sdl1->sdl_alen != sdl2->sdl_alen)
|
||||
return sdl1->sdl_alen - sdl2->sdl_alen;
|
||||
|
||||
dataofs += sdl1->sdl_alen;
|
||||
|
||||
rc = submemcmp(sdl1, sdl2, sdl1->sdl_len, sdl2->sdl_len,
|
||||
dataofs, dataofs + MIN(sdl1->sdl_slen, sdl2->sdl_slen));
|
||||
|
||||
if (sdl1->sdl_slen != sdl2->sdl_slen)
|
||||
return sdl1->sdl_slen - sdl2->sdl_slen;
|
||||
|
||||
return sdl1->sdl_len - sdl2->sdl_len;
|
||||
}
|
162
sys/net/route.c
162
sys/net/route.c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: route.c,v 1.93 2007/07/09 21:11:01 ad Exp $ */
|
||||
/* $NetBSD: route.c,v 1.94 2007/07/19 20:48:53 dyoung Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
@ -100,7 +100,7 @@
|
||||
#include "opt_route.h"
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.93 2007/07/09 21:11:01 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.94 2007/07/19 20:48:53 dyoung Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/sysctl.h>
|
||||
@ -187,7 +187,7 @@ rt_get_ifa(struct rtentry *rt)
|
||||
return ifa;
|
||||
#endif
|
||||
else {
|
||||
ifa = (*ifa->ifa_getifa)(ifa, rt_key(rt));
|
||||
ifa = (*ifa->ifa_getifa)(ifa, rt_getkey(rt));
|
||||
rt_replace_ifa(rt, ifa);
|
||||
return ifa;
|
||||
}
|
||||
@ -334,7 +334,7 @@ rtalloc1(const struct sockaddr *dst, int report)
|
||||
}
|
||||
/* Inform listeners of the new route */
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.rti_info[RTAX_DST] = rt_key(rt);
|
||||
info.rti_info[RTAX_DST] = rt_getkey(rt);
|
||||
info.rti_info[RTAX_NETMASK] = rt_mask(rt);
|
||||
info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
|
||||
if (rt->rt_ifp != NULL) {
|
||||
@ -378,7 +378,7 @@ rtfree(struct rtentry *rt)
|
||||
rt->rt_ifa = NULL;
|
||||
IFAFREE(ifa);
|
||||
rt->rt_ifp = NULL;
|
||||
Free(rt_key(rt));
|
||||
rt_destroy(rt);
|
||||
pool_put(&rtentry_pool, rt);
|
||||
}
|
||||
}
|
||||
@ -399,6 +399,12 @@ ifafree(struct ifaddr *ifa)
|
||||
free(ifa, M_IFADDR);
|
||||
}
|
||||
|
||||
static inline int
|
||||
equal(const struct sockaddr *sa1, const struct sockaddr *sa2)
|
||||
{
|
||||
return sockaddr_cmp(sa1, sa2) == 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Force a routing table entry to the specified
|
||||
* destination to go through the given gateway.
|
||||
@ -430,9 +436,6 @@ rtredirect(const struct sockaddr *dst, const struct sockaddr *gateway,
|
||||
* we have a routing loop, perhaps as a result of an interface
|
||||
* going down recently.
|
||||
*/
|
||||
#define equal(a1, a2) \
|
||||
((a1)->sa_len == (a2)->sa_len && \
|
||||
memcmp((a1), (a2), (a1)->sa_len) == 0)
|
||||
if (!(flags & RTF_DONE) && rt &&
|
||||
(!equal(src, rt->rt_gateway) || rt->rt_ifa != ifa))
|
||||
error = EINVAL;
|
||||
@ -480,7 +483,7 @@ rtredirect(const struct sockaddr *dst, const struct sockaddr *gateway,
|
||||
rt->rt_flags |= RTF_MODIFIED;
|
||||
flags |= RTF_MODIFIED;
|
||||
stat = &rtstat.rts_newgateway;
|
||||
rt_setgate(rt, rt_key(rt), gateway);
|
||||
rt_setgate(rt, gateway);
|
||||
}
|
||||
} else
|
||||
error = EHOSTUNREACH;
|
||||
@ -519,7 +522,7 @@ rtdeletemsg(struct rtentry *rt)
|
||||
* be accurate (and consistent with route_output()).
|
||||
*/
|
||||
memset((void *)&info, 0, sizeof(info));
|
||||
info.rti_info[RTAX_DST] = rt_key(rt);
|
||||
info.rti_info[RTAX_DST] = rt_getkey(rt);
|
||||
info.rti_info[RTAX_NETMASK] = rt_mask(rt);
|
||||
info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
|
||||
info.rti_flags = rt->rt_flags;
|
||||
@ -677,7 +680,7 @@ rtrequest1(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt)
|
||||
struct radix_node *rn;
|
||||
struct radix_node_head *rnh;
|
||||
struct ifaddr *ifa;
|
||||
struct sockaddr_storage deldst;
|
||||
struct sockaddr_storage maskeddst;
|
||||
const struct sockaddr *dst = info->rti_info[RTAX_DST];
|
||||
const struct sockaddr *gateway = info->rti_info[RTAX_GATEWAY];
|
||||
const struct sockaddr *netmask = info->rti_info[RTAX_NETMASK];
|
||||
@ -691,8 +694,9 @@ rtrequest1(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt)
|
||||
switch (req) {
|
||||
case RTM_DELETE:
|
||||
if (netmask) {
|
||||
rt_maskedcopy(dst, (struct sockaddr *)&deldst, netmask);
|
||||
dst = (struct sockaddr *)&deldst;
|
||||
rt_maskedcopy(dst, (struct sockaddr *)&maskeddst,
|
||||
netmask);
|
||||
dst = (struct sockaddr *)&maskeddst;
|
||||
}
|
||||
if ((rn = rnh->rnh_lookup(dst, netmask, rnh)) == NULL)
|
||||
senderr(ESRCH);
|
||||
@ -735,8 +739,7 @@ rtrequest1(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt)
|
||||
flags = rt->rt_flags & ~(RTF_CLONING | RTF_STATIC);
|
||||
flags |= RTF_CLONED;
|
||||
gateway = rt->rt_gateway;
|
||||
if ((netmask = rt->rt_genmask) == NULL)
|
||||
flags |= RTF_HOST;
|
||||
flags |= RTF_HOST;
|
||||
goto makeroute;
|
||||
|
||||
case RTM_ADD:
|
||||
@ -751,43 +754,70 @@ rtrequest1(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt)
|
||||
Bzero(rt, sizeof(*rt));
|
||||
rt->rt_flags = RTF_UP | flags;
|
||||
LIST_INIT(&rt->rt_timer);
|
||||
if (rt_setgate(rt, dst, gateway)) {
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__, __LINE__,
|
||||
(void *)rt->_rt_key);
|
||||
if (rt_setkey(rt, dst, PR_NOWAIT) == NULL ||
|
||||
rt_setgate(rt, gateway) != 0) {
|
||||
pool_put(&rtentry_pool, rt);
|
||||
senderr(ENOBUFS);
|
||||
}
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__, __LINE__,
|
||||
(void *)rt->_rt_key);
|
||||
if (netmask) {
|
||||
rt_maskedcopy(dst, rt_key(rt), netmask);
|
||||
} else
|
||||
Bcopy(dst, rt_key(rt), dst->sa_len);
|
||||
rt_maskedcopy(dst, (struct sockaddr *)&maskeddst,
|
||||
netmask);
|
||||
rt_setkey(rt, (struct sockaddr *)&maskeddst, PR_NOWAIT);
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
} else {
|
||||
rt_setkey(rt, dst, PR_NOWAIT);
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
}
|
||||
rt_set_ifa(rt, ifa);
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
rt->rt_ifp = ifa->ifa_ifp;
|
||||
if (req == RTM_RESOLVE) {
|
||||
rt->rt_rmx = (*ret_nrt)->rt_rmx; /* copy metrics */
|
||||
rt->rt_parent = *ret_nrt;
|
||||
rt->rt_parent->rt_refcnt++;
|
||||
}
|
||||
rn = rnh->rnh_addaddr(rt_key(rt), netmask, rnh, rt->rt_nodes);
|
||||
if (rn == NULL && (crt = rtalloc1(rt_key(rt), 0)) != NULL) {
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
rn = rnh->rnh_addaddr(rt_getkey(rt), netmask, rnh,
|
||||
rt->rt_nodes);
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
if (rn == NULL && (crt = rtalloc1(rt_getkey(rt), 0)) != NULL) {
|
||||
/* overwrite cloned route */
|
||||
if ((crt->rt_flags & RTF_CLONED) != 0) {
|
||||
rtdeletemsg(crt);
|
||||
rn = rnh->rnh_addaddr(rt_key(rt),
|
||||
rn = rnh->rnh_addaddr(rt_getkey(rt),
|
||||
netmask, rnh, rt->rt_nodes);
|
||||
}
|
||||
RTFREE(crt);
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
}
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
if (rn == NULL) {
|
||||
IFAFREE(ifa);
|
||||
if ((rt->rt_flags & RTF_CLONED) != 0 && rt->rt_parent)
|
||||
rtfree(rt->rt_parent);
|
||||
if (rt->rt_gwroute)
|
||||
rtfree(rt->rt_gwroute);
|
||||
Free(rt_key(rt));
|
||||
rt_destroy(rt);
|
||||
pool_put(&rtentry_pool, rt);
|
||||
senderr(EEXIST);
|
||||
}
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
if (ifa->ifa_rtrequest)
|
||||
ifa->ifa_rtrequest(req, rt, info);
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
if (ret_nrt) {
|
||||
*ret_nrt = rt;
|
||||
rt->rt_refcnt++;
|
||||
@ -799,6 +829,11 @@ rtrequest1(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt)
|
||||
rtflushall(dst->sa_family);
|
||||
break;
|
||||
case RTM_GET:
|
||||
if (netmask != NULL) {
|
||||
rt_maskedcopy(dst, (struct sockaddr *)&maskeddst,
|
||||
netmask);
|
||||
dst = (struct sockaddr *)&maskeddst;
|
||||
}
|
||||
rn = rnh->rnh_lookup(dst, netmask, rnh);
|
||||
if (rn == NULL || (rn->rn_flags & RNF_ROOT) != 0)
|
||||
senderr(ESRCH);
|
||||
@ -815,34 +850,36 @@ bad:
|
||||
}
|
||||
|
||||
int
|
||||
rt_setgate( struct rtentry *rt0, const struct sockaddr *dst,
|
||||
const struct sockaddr *gate)
|
||||
rt_setgate(struct rtentry *rt, const struct sockaddr *gate)
|
||||
{
|
||||
char *new, *old;
|
||||
u_int dlen = ROUNDUP(dst->sa_len), glen = ROUNDUP(gate->sa_len);
|
||||
struct rtentry *rt = rt0;
|
||||
KASSERT(rt != rt->rt_gwroute);
|
||||
|
||||
KASSERT(rt->_rt_key != NULL);
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
|
||||
if (rt->rt_gateway == NULL || glen > ROUNDUP(rt->rt_gateway->sa_len)) {
|
||||
old = (void *)rt_key(rt);
|
||||
R_Malloc(new, void *, dlen + glen);
|
||||
if (new == NULL)
|
||||
return 1;
|
||||
Bzero(new, dlen + glen);
|
||||
rt->rt_nodes->rn_key = new;
|
||||
} else {
|
||||
new = __UNCONST(rt->rt_nodes->rn_key); /*XXXUNCONST*/
|
||||
old = NULL;
|
||||
}
|
||||
Bcopy(gate, (rt->rt_gateway = (struct sockaddr *)(new + dlen)), glen);
|
||||
if (old) {
|
||||
Bcopy(dst, new, dlen);
|
||||
Free(old);
|
||||
}
|
||||
if (rt->rt_gwroute) {
|
||||
RTFREE(rt->rt_gwroute);
|
||||
rt->rt_gwroute = NULL;
|
||||
}
|
||||
KASSERT(rt->_rt_key != NULL);
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
if (rt->rt_gateway != NULL)
|
||||
sockaddr_free(rt->rt_gateway);
|
||||
KASSERT(rt->_rt_key != NULL);
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
if ((rt->rt_gateway = sockaddr_dup(gate, PR_NOWAIT)) == NULL)
|
||||
return ENOMEM;
|
||||
KASSERT(rt->_rt_key != NULL);
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
|
||||
if (rt->rt_flags & RTF_GATEWAY) {
|
||||
KASSERT(rt->_rt_key != NULL);
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
rt->rt_gwroute = rtalloc1(gate, 1);
|
||||
/*
|
||||
* If we switched gateways, grab the MTU from the new
|
||||
@ -851,6 +888,9 @@ rt_setgate( struct rtentry *rt0, const struct sockaddr *dst,
|
||||
* Note that, if the MTU of gateway is 0, we will reset the
|
||||
* MTU of the route to run PMTUD again from scratch. XXX
|
||||
*/
|
||||
KASSERT(rt->_rt_key != NULL);
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
if (rt->rt_gwroute
|
||||
&& !(rt->rt_rmx.rmx_locks & RTV_MTU)
|
||||
&& rt->rt_rmx.rmx_mtu
|
||||
@ -858,6 +898,9 @@ rt_setgate( struct rtentry *rt0, const struct sockaddr *dst,
|
||||
rt->rt_rmx.rmx_mtu = rt->rt_gwroute->rt_rmx.rmx_mtu;
|
||||
}
|
||||
}
|
||||
KASSERT(rt->_rt_key != NULL);
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -865,20 +908,19 @@ void
|
||||
rt_maskedcopy(const struct sockaddr *src, struct sockaddr *dst,
|
||||
const struct sockaddr *netmask)
|
||||
{
|
||||
const u_char *cp1 = (const u_char *)src;
|
||||
u_char *cp2 = (u_char *)dst;
|
||||
const u_char *cp3 = (const u_char *)netmask;
|
||||
u_char *cplim = cp2 + *cp3;
|
||||
u_char *cplim2 = cp2 + *cp1;
|
||||
const char *netmaskp = &netmask->sa_data[0],
|
||||
*srcp = &src->sa_data[0];
|
||||
char *dstp = &dst->sa_data[0];
|
||||
const char *maskend = dstp + MIN(netmask->sa_len, src->sa_len);
|
||||
const char *srcend = dstp + src->sa_len;
|
||||
|
||||
*cp2++ = *cp1++; *cp2++ = *cp1++; /* copies sa_len & sa_family */
|
||||
cp3 += 2;
|
||||
if (cplim > cplim2)
|
||||
cplim = cplim2;
|
||||
while (cp2 < cplim)
|
||||
*cp2++ = *cp1++ & *cp3++;
|
||||
if (cp2 < cplim2)
|
||||
memset(cp2, 0, (unsigned)(cplim2 - cp2));
|
||||
dst->sa_len = src->sa_len;
|
||||
dst->sa_family = src->sa_family;
|
||||
|
||||
while (dstp < maskend)
|
||||
*dstp++ = *srcp++ & *netmaskp++;
|
||||
if (dstp < srcend)
|
||||
memset(dstp, 0, (size_t)(srcend - dstp));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -890,7 +932,7 @@ rtinit(struct ifaddr *ifa, int cmd, int flags)
|
||||
{
|
||||
struct rtentry *rt;
|
||||
struct sockaddr *dst, *odst;
|
||||
struct sockaddr_storage deldst;
|
||||
struct sockaddr_storage maskeddst;
|
||||
struct rtentry *nrt = NULL;
|
||||
int error;
|
||||
struct rt_addrinfo info;
|
||||
@ -900,7 +942,7 @@ rtinit(struct ifaddr *ifa, int cmd, int flags)
|
||||
if ((flags & RTF_HOST) == 0 && ifa->ifa_netmask) {
|
||||
/* Delete subnet route for this interface */
|
||||
odst = dst;
|
||||
dst = (struct sockaddr *)&deldst;
|
||||
dst = (struct sockaddr *)&maskeddst;
|
||||
rt_maskedcopy(odst, dst, ifa->ifa_netmask);
|
||||
}
|
||||
if ((rt = rtalloc1(dst, 0)) != NULL) {
|
||||
@ -964,7 +1006,7 @@ static int rt_init_done = 0;
|
||||
(*r->rtt_func)(r->rtt_rt, r); \
|
||||
} else { \
|
||||
rtrequest((int) RTM_DELETE, \
|
||||
(struct sockaddr *)rt_key(r->rtt_rt), \
|
||||
rt_getkey(r->rtt_rt), \
|
||||
0, 0, 0, 0); \
|
||||
} \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: route.h,v 1.56 2007/06/09 03:07:22 dyoung Exp $ */
|
||||
/* $NetBSD: route.h,v 1.57 2007/07/19 20:48:53 dyoung Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1986, 1993
|
||||
@ -95,10 +95,7 @@ struct rt_metrics {
|
||||
#endif
|
||||
struct rtentry {
|
||||
struct radix_node rt_nodes[2]; /* tree glue, and other values */
|
||||
/*XXXUNCONST*/
|
||||
#define rt_key(r) ((struct sockaddr *)__UNCONST((r)->rt_nodes->rn_key))
|
||||
/*XXXUNCONST*/
|
||||
#define rt_mask(r) ((struct sockaddr *)__UNCONST((r)->rt_nodes->rn_mask))
|
||||
#define rt_mask(r) ((const struct sockaddr *)((r)->rt_nodes->rn_mask))
|
||||
struct sockaddr *rt_gateway; /* value */
|
||||
int rt_flags; /* up/down?, host/net */
|
||||
int rt_refcnt; /* # held references */
|
||||
@ -106,14 +103,20 @@ struct rtentry {
|
||||
struct ifnet *rt_ifp; /* the answer: interface to use */
|
||||
struct ifaddr *rt_ifa; /* the answer: interface to use */
|
||||
uint32_t rt_ifa_seqno;
|
||||
const struct sockaddr *rt_genmask; /* for generation of cloned routes */
|
||||
void * rt_llinfo; /* pointer to link level info cache */
|
||||
struct rt_metrics rt_rmx; /* metrics used by rx'ing protocols */
|
||||
struct rtentry *rt_gwroute; /* implied entry for gatewayed routes */
|
||||
LIST_HEAD(, rttimer) rt_timer; /* queue of timeouts for misc funcs */
|
||||
struct rtentry *rt_parent; /* parent of cloned route */
|
||||
struct sockaddr *_rt_key;
|
||||
};
|
||||
|
||||
static inline const struct sockaddr *
|
||||
rt_getkey(const struct rtentry *rt)
|
||||
{
|
||||
return rt->_rt_key;
|
||||
}
|
||||
|
||||
/*
|
||||
* Following structure necessary for 4.3 compatibility;
|
||||
* We should eventually move it to a compat file.
|
||||
@ -271,6 +274,12 @@ struct rttimer_queue {
|
||||
|
||||
|
||||
#ifdef _KERNEL
|
||||
#if 0
|
||||
#define RT_DPRINTF(__fmt, ...) do { } while (/*CONSTCOND*/0)
|
||||
#else
|
||||
#define RT_DPRINTF(__fmt, ...) /* do nothing */
|
||||
#endif
|
||||
|
||||
struct rtwalk {
|
||||
int (*rw_f)(struct rtentry *, void *);
|
||||
void *rw_v;
|
||||
@ -292,8 +301,7 @@ void rt_maskedcopy(const struct sockaddr *,
|
||||
struct sockaddr *, const struct sockaddr *);
|
||||
void rt_missmsg(int, struct rt_addrinfo *, int, int);
|
||||
void rt_newaddrmsg(int, struct ifaddr *, int, struct rtentry *);
|
||||
int rt_setgate(struct rtentry *,
|
||||
const struct sockaddr *, const struct sockaddr *);
|
||||
int rt_setgate(struct rtentry *, const struct sockaddr *);
|
||||
void rt_setmetrics(u_long, const struct rt_metrics *, struct rt_metrics *);
|
||||
int rt_timer_add(struct rtentry *,
|
||||
void(*)(struct rtentry *, struct rttimer *),
|
||||
@ -329,6 +337,31 @@ int rtrequest1(int, struct rt_addrinfo *, struct rtentry **);
|
||||
struct ifaddr *rt_get_ifa(struct rtentry *);
|
||||
void rt_replace_ifa(struct rtentry *, struct ifaddr *);
|
||||
|
||||
static inline void
|
||||
rt_destroy(struct rtentry *rt)
|
||||
{
|
||||
if (rt->_rt_key != NULL)
|
||||
sockaddr_free(rt->_rt_key);
|
||||
if (rt->rt_gateway != NULL)
|
||||
sockaddr_free(rt->rt_gateway);
|
||||
rt->_rt_key = rt->rt_gateway = NULL;
|
||||
}
|
||||
|
||||
static inline const struct sockaddr *
|
||||
rt_setkey(struct rtentry *rt, const struct sockaddr *key, int flags)
|
||||
{
|
||||
if (rt->_rt_key == key)
|
||||
goto out;
|
||||
|
||||
if (rt->_rt_key != NULL)
|
||||
sockaddr_free(rt->_rt_key);
|
||||
rt->_rt_key = sockaddr_dup(key, flags);
|
||||
out:
|
||||
KASSERT(rt->_rt_key != NULL);
|
||||
rt->rt_nodes->rn_key = (const char *)rt->_rt_key;
|
||||
return rt->_rt_key;
|
||||
}
|
||||
|
||||
struct rtentry *rtfindparent(struct radix_node_head *, struct route *);
|
||||
|
||||
#ifdef RTCACHE_DEBUG
|
||||
|
206
sys/net/rtsock.c
206
sys/net/rtsock.c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rtsock.c,v 1.94 2007/06/09 03:07:22 dyoung Exp $ */
|
||||
/* $NetBSD: rtsock.c,v 1.95 2007/07/19 20:48:53 dyoung Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
@ -61,7 +61,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.94 2007/06/09 03:07:22 dyoung Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.95 2007/07/19 20:48:53 dyoung Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
|
||||
@ -116,7 +116,6 @@ static inline void rt_adjustcount(int, int);
|
||||
#define dst info.rti_info[RTAX_DST]
|
||||
#define gate info.rti_info[RTAX_GATEWAY]
|
||||
#define netmask info.rti_info[RTAX_NETMASK]
|
||||
#define genmask info.rti_info[RTAX_GENMASK]
|
||||
#define ifpaddr info.rti_info[RTAX_IFP]
|
||||
#define ifaaddr info.rti_info[RTAX_IFA]
|
||||
#define brdaddr info.rti_info[RTAX_BRD]
|
||||
@ -171,7 +170,7 @@ route_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
|
||||
* and send "safe" commands to the routing socket.
|
||||
*/
|
||||
if (req == PRU_ATTACH) {
|
||||
if (l == 0)
|
||||
if (l == NULL)
|
||||
error = EACCES;
|
||||
else
|
||||
error = raw_attach(so, (int)(long)nam);
|
||||
@ -183,7 +182,7 @@ route_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
|
||||
if (error) {
|
||||
free((void *)rp, M_PCB);
|
||||
splx(s);
|
||||
return (error);
|
||||
return error;
|
||||
}
|
||||
rt_adjustcount(rp->rcb_proto.sp_protocol, 1);
|
||||
rp->rcb_laddr = &route_src;
|
||||
@ -192,22 +191,33 @@ route_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
|
||||
so->so_options |= SO_USELOOPBACK;
|
||||
}
|
||||
splx(s);
|
||||
return (error);
|
||||
return error;
|
||||
}
|
||||
|
||||
static const struct sockaddr *
|
||||
intern_netmask(const struct sockaddr *mask)
|
||||
{
|
||||
struct radix_node *rn;
|
||||
extern struct radix_node_head *mask_rnhead;
|
||||
|
||||
if (mask != NULL &&
|
||||
(rn = rn_search(mask, mask_rnhead->rnh_treetop)))
|
||||
mask = (const struct sockaddr *)rn->rn_key;
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
route_output(struct mbuf *m, ...)
|
||||
{
|
||||
struct rt_msghdr *rtm = 0;
|
||||
struct radix_node *rn = 0;
|
||||
struct rtentry *rt = 0;
|
||||
struct rtentry *saved_nrt = 0;
|
||||
struct radix_node_head *rnh;
|
||||
struct rt_msghdr *rtm = NULL;
|
||||
struct rtentry *rt = NULL;
|
||||
struct rtentry *saved_nrt = NULL;
|
||||
struct rt_addrinfo info;
|
||||
int len, error = 0;
|
||||
struct ifnet *ifp = 0;
|
||||
struct ifaddr *ifa = 0;
|
||||
struct ifnet *ifp = NULL;
|
||||
struct ifaddr *ifa = NULL;
|
||||
struct socket *so;
|
||||
va_list ap;
|
||||
sa_family_t family;
|
||||
@ -217,25 +227,25 @@ route_output(struct mbuf *m, ...)
|
||||
va_end(ap);
|
||||
|
||||
#define senderr(e) do { error = e; goto flush;} while (/*CONSTCOND*/ 0)
|
||||
if (m == 0 || ((m->m_len < sizeof(int32_t)) &&
|
||||
(m = m_pullup(m, sizeof(int32_t))) == 0))
|
||||
return (ENOBUFS);
|
||||
if (m == NULL || ((m->m_len < sizeof(int32_t)) &&
|
||||
(m = m_pullup(m, sizeof(int32_t))) == NULL))
|
||||
return ENOBUFS;
|
||||
if ((m->m_flags & M_PKTHDR) == 0)
|
||||
panic("route_output");
|
||||
len = m->m_pkthdr.len;
|
||||
if (len < sizeof(*rtm) ||
|
||||
len != mtod(m, struct rt_msghdr *)->rtm_msglen) {
|
||||
dst = 0;
|
||||
dst = NULL;
|
||||
senderr(EINVAL);
|
||||
}
|
||||
R_Malloc(rtm, struct rt_msghdr *, len);
|
||||
if (rtm == 0) {
|
||||
dst = 0;
|
||||
if (rtm == NULL) {
|
||||
dst = NULL;
|
||||
senderr(ENOBUFS);
|
||||
}
|
||||
m_copydata(m, 0, len, (void *)rtm);
|
||||
if (rtm->rtm_version != RTM_VERSION) {
|
||||
dst = 0;
|
||||
dst = NULL;
|
||||
senderr(EPROTONOSUPPORT);
|
||||
}
|
||||
rtm->rtm_pid = curproc->p_pid;
|
||||
@ -250,20 +260,10 @@ route_output(struct mbuf *m, ...)
|
||||
inet_ntoa(((const struct sockaddr_in *)dst)->sin_addr));
|
||||
}
|
||||
#endif /* RTSOCK_DEBUG */
|
||||
if (dst == 0 || (dst->sa_family >= AF_MAX))
|
||||
if (dst == NULL || (dst->sa_family >= AF_MAX))
|
||||
senderr(EINVAL);
|
||||
if (gate != 0 && (gate->sa_family >= AF_MAX))
|
||||
if (gate != NULL && (gate->sa_family >= AF_MAX))
|
||||
senderr(EINVAL);
|
||||
if (genmask) {
|
||||
struct radix_node *t;
|
||||
t = rn_addmask(genmask, 0, 1);
|
||||
if (t && genmask->sa_len >= ((const struct sockaddr *)t->rn_key)->sa_len &&
|
||||
Bcmp((const char *const *)genmask + 1, (const char *const *)t->rn_key + 1,
|
||||
((const struct sockaddr *)t->rn_key)->sa_len) - 1)
|
||||
genmask = (const struct sockaddr *)(t->rn_key);
|
||||
else
|
||||
senderr(ENOBUFS);
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify that the caller has the appropriate privilege; RTM_GET
|
||||
@ -276,14 +276,13 @@ route_output(struct mbuf *m, ...)
|
||||
switch (rtm->rtm_type) {
|
||||
|
||||
case RTM_ADD:
|
||||
if (gate == 0)
|
||||
if (gate == NULL)
|
||||
senderr(EINVAL);
|
||||
error = rtrequest1(rtm->rtm_type, &info, &saved_nrt);
|
||||
if (error == 0 && saved_nrt) {
|
||||
rt_setmetrics(rtm->rtm_inits,
|
||||
&rtm->rtm_rmx, &saved_nrt->rt_rmx);
|
||||
saved_nrt->rt_refcnt--;
|
||||
saved_nrt->rt_genmask = genmask;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -298,39 +297,32 @@ route_output(struct mbuf *m, ...)
|
||||
case RTM_GET:
|
||||
case RTM_CHANGE:
|
||||
case RTM_LOCK:
|
||||
if ((rnh = rt_tables[dst->sa_family]) == 0) {
|
||||
senderr(EAFNOSUPPORT);
|
||||
}
|
||||
rn = rnh->rnh_lookup(dst, netmask, rnh);
|
||||
if (rn == NULL || (rn->rn_flags & RNF_ROOT) != 0) {
|
||||
senderr(ESRCH);
|
||||
}
|
||||
rt = (struct rtentry *)rn;
|
||||
rt->rt_refcnt++;
|
||||
/* XXX This will mask dst with netmask before
|
||||
* searching. It did not used to do that. --dyoung
|
||||
*/
|
||||
error = rtrequest(RTM_GET, dst, gate, netmask, 0, &rt);
|
||||
if (error != 0)
|
||||
senderr(error);
|
||||
if (rtm->rtm_type != RTM_GET) {/* XXX: too grotty */
|
||||
struct radix_node *rnn;
|
||||
extern struct radix_node_head *mask_rnhead;
|
||||
struct radix_node *rn;
|
||||
|
||||
if (Bcmp(dst, rt_key(rt), dst->sa_len) != 0)
|
||||
if (memcmp(dst, rt_getkey(rt), dst->sa_len) != 0)
|
||||
senderr(ESRCH);
|
||||
if (netmask && (rnn = rn_search(netmask,
|
||||
mask_rnhead->rnh_treetop)))
|
||||
netmask = (const struct sockaddr *)rnn->rn_key;
|
||||
for (rnn = rt->rt_nodes; rnn; rnn = rnn->rn_dupedkey)
|
||||
if (netmask == (const struct sockaddr *)rnn->rn_mask)
|
||||
netmask = intern_netmask(netmask);
|
||||
for (rn = rt->rt_nodes; rn; rn = rn->rn_dupedkey)
|
||||
if (netmask == (const struct sockaddr *)rn->rn_mask)
|
||||
break;
|
||||
if (rnn == 0)
|
||||
if (rn == NULL)
|
||||
senderr(ETOOMANYREFS);
|
||||
rt = (struct rtentry *)rnn;
|
||||
rt = (struct rtentry *)rn;
|
||||
}
|
||||
|
||||
switch (rtm->rtm_type) {
|
||||
case RTM_GET:
|
||||
report:
|
||||
dst = rt_key(rt);
|
||||
dst = rt_getkey(rt);
|
||||
gate = rt->rt_gateway;
|
||||
netmask = rt_mask(rt);
|
||||
genmask = rt->rt_genmask;
|
||||
if ((rtm->rtm_addrs & (RTA_IFP | RTA_IFA)) == 0)
|
||||
;
|
||||
else if ((ifp = rt->rt_ifp) != NULL) {
|
||||
@ -356,24 +348,23 @@ route_output(struct mbuf *m, ...)
|
||||
if (ifp->if_flags & IFF_POINTOPOINT)
|
||||
brdaddr = rtifa->ifa_dstaddr;
|
||||
else
|
||||
brdaddr = 0;
|
||||
brdaddr = NULL;
|
||||
rtm->rtm_index = ifp->if_index;
|
||||
} else {
|
||||
ifpaddr = 0;
|
||||
ifaaddr = 0;
|
||||
ifpaddr = NULL;
|
||||
ifaaddr = NULL;
|
||||
}
|
||||
(void)rt_msg2(rtm->rtm_type, &info, (void *)0,
|
||||
(struct walkarg *)0, &len);
|
||||
(void)rt_msg2(rtm->rtm_type, &info, NULL, NULL, &len);
|
||||
if (len > rtm->rtm_msglen) {
|
||||
struct rt_msghdr *new_rtm;
|
||||
R_Malloc(new_rtm, struct rt_msghdr *, len);
|
||||
if (new_rtm == 0)
|
||||
if (new_rtm == NULL)
|
||||
senderr(ENOBUFS);
|
||||
Bcopy(rtm, new_rtm, rtm->rtm_msglen);
|
||||
Free(rtm); rtm = new_rtm;
|
||||
}
|
||||
(void)rt_msg2(rtm->rtm_type, &info, (void *)rtm,
|
||||
(struct walkarg *)0, 0);
|
||||
NULL, 0);
|
||||
rtm->rtm_flags = rt->rt_flags;
|
||||
rtm->rtm_rmx = rt->rt_rmx;
|
||||
rtm->rtm_addrs = info.rti_addrs;
|
||||
@ -387,7 +378,7 @@ route_output(struct mbuf *m, ...)
|
||||
*/
|
||||
if ((error = rt_getifa(&info)) != 0)
|
||||
senderr(error);
|
||||
if (gate && rt_setgate(rt, rt_key(rt), gate))
|
||||
if (gate && rt_setgate(rt, gate))
|
||||
senderr(EDQUOT);
|
||||
/* new gateway could require new ifaddr, ifp;
|
||||
flags may also be different; ifp may be specified
|
||||
@ -398,7 +389,7 @@ route_output(struct mbuf *m, ...)
|
||||
ifp);
|
||||
else if ((ifaaddr && (ifa = ifa_ifwithaddr(ifaaddr))) ||
|
||||
(gate && (ifa = ifa_ifwithroute(rt->rt_flags,
|
||||
rt_key(rt), gate))))
|
||||
rt_getkey(rt), gate))))
|
||||
ifp = ifa->ifa_ifp;
|
||||
if (ifa) {
|
||||
struct ifaddr *oifa = rt->rt_ifa;
|
||||
@ -415,8 +406,6 @@ route_output(struct mbuf *m, ...)
|
||||
&rt->rt_rmx);
|
||||
if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest)
|
||||
rt->rt_ifa->ifa_rtrequest(RTM_ADD, rt, &info);
|
||||
if (genmask)
|
||||
rt->rt_genmask = genmask;
|
||||
/*
|
||||
* Fall into
|
||||
*/
|
||||
@ -443,7 +432,7 @@ flush:
|
||||
if (rt)
|
||||
rtfree(rt);
|
||||
{
|
||||
struct rawcb *rp = 0;
|
||||
struct rawcb *rp = NULL;
|
||||
/*
|
||||
* Check to see if we don't want our own messages.
|
||||
*/
|
||||
@ -452,7 +441,7 @@ flush:
|
||||
if (rtm)
|
||||
Free(rtm);
|
||||
m_freem(m);
|
||||
return (error);
|
||||
return error;
|
||||
}
|
||||
/* There is another listener, so construct message */
|
||||
rp = sotorawcb(so);
|
||||
@ -475,7 +464,7 @@ flush:
|
||||
if (rp)
|
||||
rp->rcb_proto.sp_family = PF_ROUTE;
|
||||
}
|
||||
return (error);
|
||||
return error;
|
||||
}
|
||||
|
||||
void
|
||||
@ -513,10 +502,10 @@ rt_xaddrs(u_char rtmtype, const char *cp, const char *cplim, struct rt_addrinfo
|
||||
/* Check for extra addresses specified, except RTM_GET asking for interface info. */
|
||||
if (rtmtype == RTM_GET) {
|
||||
if (((rtinfo->rti_addrs & (~((1 << RTAX_IFP) | (1 << RTAX_IFA)))) & (~0 << i)) != 0)
|
||||
return (1);
|
||||
return 1;
|
||||
} else {
|
||||
if ((rtinfo->rti_addrs & (~0 << i)) != 0)
|
||||
return (1);
|
||||
return 1;
|
||||
}
|
||||
/* Check for bad data length. */
|
||||
if (cp != cplim) {
|
||||
@ -529,9 +518,9 @@ rt_xaddrs(u_char rtmtype, const char *cp, const char *cplim, struct rt_addrinfo
|
||||
*/
|
||||
;
|
||||
else
|
||||
return (1);
|
||||
return 1;
|
||||
}
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct mbuf *
|
||||
@ -544,8 +533,8 @@ rt_msg1(int type, struct rt_addrinfo *rtinfo, void *data, int datalen)
|
||||
int len, dlen;
|
||||
|
||||
m = m_gethdr(M_DONTWAIT, MT_DATA);
|
||||
if (m == 0)
|
||||
return (m);
|
||||
if (m == NULL)
|
||||
return m;
|
||||
MCLAIM(m, &routedomain.dom_mowner);
|
||||
switch (type) {
|
||||
|
||||
@ -578,7 +567,7 @@ rt_msg1(int type, struct rt_addrinfo *rtinfo, void *data, int datalen)
|
||||
m->m_next = m_get(M_DONTWAIT, MT_DATA);
|
||||
if (m->m_next == NULL) {
|
||||
m_freem(m);
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
MCLAIM(m->m_next, m->m_owner);
|
||||
m->m_pkthdr.len = len;
|
||||
@ -587,7 +576,7 @@ rt_msg1(int type, struct rt_addrinfo *rtinfo, void *data, int datalen)
|
||||
} else {
|
||||
m->m_pkthdr.len = m->m_len = len;
|
||||
}
|
||||
m->m_pkthdr.rcvif = 0;
|
||||
m->m_pkthdr.rcvif = NULL;
|
||||
m_copyback(m, 0, datalen, data);
|
||||
rtm = mtod(m, struct rt_msghdr *);
|
||||
for (i = 0; i < RTAX_MAX; i++) {
|
||||
@ -600,12 +589,12 @@ rt_msg1(int type, struct rt_addrinfo *rtinfo, void *data, int datalen)
|
||||
}
|
||||
if (m->m_pkthdr.len != len) {
|
||||
m_freem(m);
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
rtm->rtm_msglen = len;
|
||||
rtm->rtm_version = RTM_VERSION;
|
||||
rtm->rtm_type = type;
|
||||
return (m);
|
||||
return m;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -655,7 +644,7 @@ again:
|
||||
for (i = 0; i < RTAX_MAX; i++) {
|
||||
const struct sockaddr *sa;
|
||||
|
||||
if ((sa = rtinfo->rti_info[i]) == 0)
|
||||
if ((sa = rtinfo->rti_info[i]) == NULL)
|
||||
continue;
|
||||
rtinfo->rti_addrs |= (1 << i);
|
||||
dlen = ROUNDUP(sa->sa_len);
|
||||
@ -665,7 +654,7 @@ again:
|
||||
}
|
||||
len += dlen;
|
||||
}
|
||||
if (cp == 0 && w != NULL && !second_time) {
|
||||
if (cp == NULL && w != NULL && !second_time) {
|
||||
struct walkarg *rw = w;
|
||||
|
||||
rw->w_needed += len;
|
||||
@ -684,7 +673,7 @@ again:
|
||||
goto again;
|
||||
} else {
|
||||
rw->w_tmemneeded = len;
|
||||
return (ENOBUFS);
|
||||
return ENOBUFS;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -697,7 +686,7 @@ again:
|
||||
}
|
||||
if (lenp)
|
||||
*lenp = len;
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -719,7 +708,7 @@ rt_missmsg(int type, struct rt_addrinfo *rtinfo, int flags, int error)
|
||||
rtm.rtm_flags = RTF_DONE | flags;
|
||||
rtm.rtm_errno = error;
|
||||
m = rt_msg1(type, rtinfo, (void *)&rtm, sizeof(rtm));
|
||||
if (m == 0)
|
||||
if (m == NULL)
|
||||
return;
|
||||
mtod(m, struct rt_msghdr *)->rtm_addrs = rtinfo->rti_addrs;
|
||||
route_proto.sp_protocol = sa ? sa->sa_family : 0;
|
||||
@ -749,7 +738,7 @@ rt_ifmsg(struct ifnet *ifp)
|
||||
ifm.ifm_data = ifp->if_data;
|
||||
ifm.ifm_addrs = 0;
|
||||
m = rt_msg1(RTM_IFINFO, &info, (void *)&ifm, sizeof(ifm));
|
||||
if (m == 0)
|
||||
if (m == NULL)
|
||||
return;
|
||||
route_proto.sp_protocol = 0;
|
||||
raw_input(m, &route_proto, &route_src, &route_dst);
|
||||
@ -778,7 +767,7 @@ rt_ifmsg(struct ifnet *ifp)
|
||||
oifm.ifm_data.ifi_lastchange = ifp->if_data.ifi_lastchange;
|
||||
oifm.ifm_addrs = 0;
|
||||
m = rt_msg1(RTM_OIFINFO, &info, (void *)&oifm, sizeof(oifm));
|
||||
if (m == 0)
|
||||
if (m == NULL)
|
||||
return;
|
||||
route_proto.sp_protocol = 0;
|
||||
raw_input(m, &route_proto, &route_src, &route_dst);
|
||||
@ -797,7 +786,7 @@ void
|
||||
rt_newaddrmsg(int cmd, struct ifaddr *ifa, int error, struct rtentry *rt)
|
||||
{
|
||||
struct rt_addrinfo info;
|
||||
struct sockaddr *sa = NULL;
|
||||
const struct sockaddr *sa = NULL;
|
||||
int pass;
|
||||
struct mbuf *m = NULL;
|
||||
struct ifnet *ifp = ifa->ifa_ifp;
|
||||
@ -829,10 +818,10 @@ rt_newaddrmsg(int cmd, struct ifaddr *ifa, int error, struct rtentry *rt)
|
||||
(cmd == RTM_DELETE && pass == 1)) {
|
||||
struct rt_msghdr rtm;
|
||||
|
||||
if (rt == 0)
|
||||
if (rt == NULL)
|
||||
continue;
|
||||
netmask = rt_mask(rt);
|
||||
dst = sa = rt_key(rt);
|
||||
dst = sa = rt_getkey(rt);
|
||||
gate = rt->rt_gateway;
|
||||
memset(&rtm, 0, sizeof(rtm));
|
||||
rtm.rtm_index = ifp->if_index;
|
||||
@ -937,10 +926,9 @@ sysctl_dumpentry(struct rtentry *rt, void *v)
|
||||
if (w->w_op == NET_RT_FLAGS && !(rt->rt_flags & w->w_arg))
|
||||
return 0;
|
||||
memset(&info, 0, sizeof(info));
|
||||
dst = rt_key(rt);
|
||||
dst = rt_getkey(rt);
|
||||
gate = rt->rt_gateway;
|
||||
netmask = rt_mask(rt);
|
||||
genmask = rt->rt_genmask;
|
||||
if (rt->rt_ifp) {
|
||||
const struct ifaddr *rtifa;
|
||||
ifpaddr = TAILQ_FIRST(&rt->rt_ifp->if_addrlist)->ifa_addr;
|
||||
@ -954,7 +942,7 @@ sysctl_dumpentry(struct rtentry *rt, void *v)
|
||||
brdaddr = rtifa->ifa_dstaddr;
|
||||
}
|
||||
if ((error = rt_msg2(RTM_GET, &info, 0, w, &size)))
|
||||
return (error);
|
||||
return error;
|
||||
if (w->w_where && w->w_tmem && w->w_needed <= 0) {
|
||||
struct rt_msghdr *rtm = (struct rt_msghdr *)w->w_tmem;
|
||||
|
||||
@ -970,7 +958,7 @@ sysctl_dumpentry(struct rtentry *rt, void *v)
|
||||
else
|
||||
w->w_where = (char *)w->w_where + size;
|
||||
}
|
||||
return (error);
|
||||
return error;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -992,20 +980,20 @@ sysctl_iflist(int af, struct walkarg *w, int type)
|
||||
switch (type) {
|
||||
case NET_RT_IFLIST:
|
||||
error =
|
||||
rt_msg2(RTM_IFINFO, &info, (void *)0, w, &len);
|
||||
rt_msg2(RTM_IFINFO, &info, NULL, w, &len);
|
||||
break;
|
||||
#ifdef COMPAT_14
|
||||
case NET_RT_OIFLIST:
|
||||
error =
|
||||
rt_msg2(RTM_OIFINFO, &info, (void *)0, w, &len);
|
||||
rt_msg2(RTM_OIFINFO, &info, NULL, w, &len);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
panic("sysctl_iflist(1)");
|
||||
}
|
||||
if (error)
|
||||
return (error);
|
||||
ifpaddr = 0;
|
||||
return error;
|
||||
ifpaddr = NULL;
|
||||
if (w->w_where && w->w_tmem && w->w_needed <= 0) {
|
||||
switch (type) {
|
||||
case NET_RT_IFLIST: {
|
||||
@ -1018,7 +1006,7 @@ sysctl_iflist(int af, struct walkarg *w, int type)
|
||||
ifm->ifm_addrs = info.rti_addrs;
|
||||
error = copyout(ifm, w->w_where, len);
|
||||
if (error)
|
||||
return (error);
|
||||
return error;
|
||||
w->w_where = (char *)w->w_where + len;
|
||||
break;
|
||||
}
|
||||
@ -1067,7 +1055,7 @@ sysctl_iflist(int af, struct walkarg *w, int type)
|
||||
ifm->ifm_addrs = info.rti_addrs;
|
||||
error = copyout(ifm, w->w_where, len);
|
||||
if (error)
|
||||
return (error);
|
||||
return error;
|
||||
w->w_where = (char *)w->w_where + len;
|
||||
break;
|
||||
}
|
||||
@ -1083,7 +1071,7 @@ sysctl_iflist(int af, struct walkarg *w, int type)
|
||||
netmask = ifa->ifa_netmask;
|
||||
brdaddr = ifa->ifa_dstaddr;
|
||||
if ((error = rt_msg2(RTM_NEWADDR, &info, 0, w, &len)))
|
||||
return (error);
|
||||
return error;
|
||||
if (w->w_where && w->w_tmem && w->w_needed <= 0) {
|
||||
struct ifa_msghdr *ifam;
|
||||
|
||||
@ -1094,13 +1082,13 @@ sysctl_iflist(int af, struct walkarg *w, int type)
|
||||
ifam->ifam_addrs = info.rti_addrs;
|
||||
error = copyout(w->w_tmem, w->w_where, len);
|
||||
if (error)
|
||||
return (error);
|
||||
return error;
|
||||
w->w_where = (char *)w->w_where + len;
|
||||
}
|
||||
}
|
||||
ifaaddr = netmask = brdaddr = 0;
|
||||
ifaaddr = netmask = brdaddr = NULL;
|
||||
}
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -1114,12 +1102,12 @@ sysctl_rtable(SYSCTLFN_ARGS)
|
||||
struct walkarg w;
|
||||
|
||||
if (namelen == 1 && name[0] == CTL_QUERY)
|
||||
return (sysctl_query(SYSCTLFN_CALL(rnode)));
|
||||
return sysctl_query(SYSCTLFN_CALL(rnode));
|
||||
|
||||
if (new)
|
||||
return (EPERM);
|
||||
return EPERM;
|
||||
if (namelen != 3)
|
||||
return (EINVAL);
|
||||
return EINVAL;
|
||||
af = name[0];
|
||||
w.w_tmemneeded = 0;
|
||||
w.w_tmemsize = 0;
|
||||
@ -1169,11 +1157,11 @@ again:
|
||||
if (where) {
|
||||
*given = (char *)w.w_where - (char *)where;
|
||||
if (*given < w.w_needed)
|
||||
return (ENOMEM);
|
||||
return ENOMEM;
|
||||
} else {
|
||||
*given = (11 * w.w_needed) / 10;
|
||||
}
|
||||
return (error);
|
||||
return error;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1198,7 +1186,7 @@ struct domain routedomain = {
|
||||
.dom_name = "route",
|
||||
.dom_init = route_init,
|
||||
.dom_protosw = routesw,
|
||||
.dom_protoswNPROTOSW = &routesw[sizeof(routesw)/sizeof(routesw[0])],
|
||||
.dom_protoswNPROTOSW = &routesw[__arraycount(routesw)],
|
||||
};
|
||||
|
||||
SYSCTL_SETUP(sysctl_net_route_setup, "sysctl net.route subtree setup")
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: if_arp.c,v 1.124 2007/07/09 21:11:11 ad Exp $ */
|
||||
/* $NetBSD: if_arp.c,v 1.125 2007/07/19 20:48:53 dyoung Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
|
||||
@ -75,7 +75,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.124 2007/07/09 21:11:11 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.125 2007/07/19 20:48:53 dyoung Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_inet.h"
|
||||
@ -370,7 +370,7 @@ arptimer(void *arg)
|
||||
*/
|
||||
arprequest(rt->rt_ifp,
|
||||
&satocsin(rt->rt_ifa->ifa_addr)->sin_addr,
|
||||
&satocsin(rt_key(rt))->sin_addr,
|
||||
&satocsin(rt_getkey(rt))->sin_addr,
|
||||
LLADDR(rt->rt_ifp->if_sadl));
|
||||
} else if (rt->rt_expire <= time_second)
|
||||
arptfree(la); /* timer has expired; clear */
|
||||
@ -462,14 +462,13 @@ arp_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info)
|
||||
* restore cloning bit.
|
||||
*/
|
||||
if ((rt->rt_flags & RTF_HOST) == 0 &&
|
||||
SIN(rt_mask(rt))->sin_addr.s_addr != 0xffffffff)
|
||||
satocsin(rt_mask(rt))->sin_addr.s_addr != 0xffffffff)
|
||||
rt->rt_flags |= RTF_CLONING;
|
||||
if (rt->rt_flags & RTF_CLONING) {
|
||||
/*
|
||||
* Case 1: This route should come from a route to iface.
|
||||
*/
|
||||
rt_setgate(rt, rt_key(rt),
|
||||
(const struct sockaddr *)&null_sdl);
|
||||
rt_setgate(rt, (const struct sockaddr *)&null_sdl);
|
||||
gate = rt->rt_gateway;
|
||||
SDL(gate)->sdl_type = rt->rt_ifp->if_type;
|
||||
SDL(gate)->sdl_index = rt->rt_ifp->if_index;
|
||||
@ -515,8 +514,8 @@ arp_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info)
|
||||
/* Announce a new entry if requested. */
|
||||
if (rt->rt_flags & RTF_ANNOUNCE)
|
||||
arprequest(rt->rt_ifp,
|
||||
&satocsin(rt_key(rt))->sin_addr,
|
||||
&satocsin(rt_key(rt))->sin_addr,
|
||||
&satocsin(rt_getkey(rt))->sin_addr,
|
||||
&satocsin(rt_getkey(rt))->sin_addr,
|
||||
(u_char *)LLADDR(SDL(gate)));
|
||||
/*FALLTHROUGH*/
|
||||
case RTM_RESOLVE:
|
||||
@ -554,7 +553,7 @@ arp_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info)
|
||||
rt->rt_flags |= RTF_LLINFO;
|
||||
LIST_INSERT_HEAD(&llinfo_arp, la, la_list);
|
||||
|
||||
INADDR_TO_IA(satocsin(rt_key(rt))->sin_addr, ia);
|
||||
INADDR_TO_IA(satocsin(rt_getkey(rt))->sin_addr, ia);
|
||||
while (ia && ia->ia_ifp != rt->rt_ifp)
|
||||
NEXT_IA_WITH_SAME_ADDR(ia);
|
||||
if (ia) {
|
||||
@ -570,7 +569,7 @@ arp_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info)
|
||||
* traffic out to the hardware.
|
||||
*
|
||||
* In 4.4BSD, the above "if" statement checked
|
||||
* rt->rt_ifa against rt_key(rt). It was changed
|
||||
* rt->rt_ifa against rt_getkey(rt). It was changed
|
||||
* to the current form so that we can provide a
|
||||
* better support for multiple IPv4 addresses on a
|
||||
* interface.
|
||||
@ -1083,7 +1082,7 @@ in_arpinput(struct mbuf *m)
|
||||
|
||||
if (mold) {
|
||||
arpstat.as_dfrsent++;
|
||||
(*ifp->if_output)(ifp, mold, rt_key(rt), rt);
|
||||
(*ifp->if_output)(ifp, mold, rt_getkey(rt), rt);
|
||||
}
|
||||
}
|
||||
reply:
|
||||
@ -1163,8 +1162,7 @@ static void arptfree(struct llinfo_arp *la)
|
||||
rt->rt_flags &= ~RTF_REJECT;
|
||||
return;
|
||||
}
|
||||
rtrequest(RTM_DELETE, rt_key(rt), (struct sockaddr *)0, rt_mask(rt),
|
||||
0, (struct rtentry **)0);
|
||||
rtrequest(RTM_DELETE, rt_getkey(rt), NULL, rt_mask(rt), 0, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1208,7 +1206,7 @@ arplookup(struct mbuf *m, const struct in_addr *addr, int create, int proxy)
|
||||
in_fmtaddr(*addr), lla_snprintf(ar_sha(ah), ah->ar_hln),
|
||||
(ifp) ? ifp->if_xname : 0, why);
|
||||
if (rt->rt_refcnt <= 0 && (rt->rt_flags & RTF_CLONED) != 0) {
|
||||
rtrequest(RTM_DELETE, (struct sockaddr *)rt_key(rt),
|
||||
rtrequest(RTM_DELETE, rt_getkey(rt),
|
||||
rt->rt_gateway, rt_mask(rt), rt->rt_flags, 0);
|
||||
}
|
||||
}
|
||||
@ -1475,7 +1473,7 @@ db_show_rtentry(struct rtentry *rt, void *w)
|
||||
rt->rt_flags, rt->rt_refcnt,
|
||||
rt->rt_use, rt->rt_expire);
|
||||
|
||||
db_printf(" key="); db_print_sa(rt_key(rt));
|
||||
db_printf(" key="); db_print_sa(rt_getkey(rt));
|
||||
db_printf(" mask="); db_print_sa(rt_mask(rt));
|
||||
db_printf(" gw="); db_print_sa(rt->rt_gateway);
|
||||
|
||||
@ -1488,8 +1486,6 @@ db_show_rtentry(struct rtentry *rt, void *w)
|
||||
db_printf(" ifa=%p\n", rt->rt_ifa);
|
||||
db_print_ifa(rt->rt_ifa);
|
||||
|
||||
db_printf(" genmask="); db_print_sa(rt->rt_genmask);
|
||||
|
||||
db_printf(" gwroute=%p llinfo=%p\n",
|
||||
rt->rt_gwroute, rt->rt_llinfo);
|
||||
db_print_llinfo(rt->rt_llinfo);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: if_atm.c,v 1.23 2007/03/04 06:03:20 christos Exp $ */
|
||||
/* $NetBSD: if_atm.c,v 1.24 2007/07/19 20:48:54 dyoung Exp $ */
|
||||
|
||||
/*
|
||||
*
|
||||
@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_atm.c,v 1.23 2007/03/04 06:03:20 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_atm.c,v 1.24 2007/07/19 20:48:54 dyoung Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_natm.h"
|
||||
@ -87,7 +87,7 @@ atm_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info)
|
||||
struct sockaddr *gate = rt->rt_gateway;
|
||||
struct atm_pseudoioctl api;
|
||||
#ifdef NATM
|
||||
struct sockaddr_in *sin;
|
||||
const struct sockaddr_in *sin;
|
||||
struct natmpcb *npcb = NULL;
|
||||
struct atm_pseudohdr *aph;
|
||||
#endif
|
||||
@ -115,8 +115,7 @@ atm_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info)
|
||||
*/
|
||||
|
||||
if ((rt->rt_flags & RTF_HOST) == 0) {
|
||||
rt_setgate(rt, rt_key(rt),
|
||||
(const struct sockaddr *)&null_sdl);
|
||||
rt_setgate(rt, (const struct sockaddr *)&null_sdl);
|
||||
gate = rt->rt_gateway;
|
||||
SDL(gate)->sdl_type = rt->rt_ifp->if_type;
|
||||
SDL(gate)->sdl_index = rt->rt_ifp->if_index;
|
||||
@ -142,7 +141,7 @@ atm_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info)
|
||||
* let native ATM know we are using this VCI/VPI
|
||||
* (i.e. reserve it)
|
||||
*/
|
||||
sin = (struct sockaddr_in *) rt_key(rt);
|
||||
sin = satocsin(rt_getkey(rt));
|
||||
if (sin->sin_family != AF_INET)
|
||||
goto failed;
|
||||
aph = (struct atm_pseudohdr *) LLADDR(SDL(gate));
|
||||
@ -180,8 +179,8 @@ failed:
|
||||
rt->rt_flags &= ~RTF_LLINFO;
|
||||
}
|
||||
#endif
|
||||
rtrequest(RTM_DELETE, rt_key(rt), (struct sockaddr *)0,
|
||||
rt_mask(rt), 0, (struct rtentry **) 0);
|
||||
rtrequest(RTM_DELETE, rt_getkey(rt), NULL,
|
||||
rt_mask(rt), 0, NULL);
|
||||
break;
|
||||
|
||||
case RTM_DELETE:
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: in_pcb.c,v 1.117 2007/05/02 20:40:24 dyoung Exp $ */
|
||||
/* $NetBSD: in_pcb.c,v 1.118 2007/07/19 20:48:54 dyoung Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
@ -98,7 +98,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.117 2007/05/02 20:40:24 dyoung Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.118 2007/07/19 20:48:54 dyoung Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_ipsec.h"
|
||||
@ -681,7 +681,7 @@ in_losing(struct inpcb *inp)
|
||||
info.rti_info[RTAX_NETMASK] = rt_mask(rt);
|
||||
rt_missmsg(RTM_LOSING, &info, rt->rt_flags, 0);
|
||||
if (rt->rt_flags & RTF_DYNAMIC)
|
||||
(void) rtrequest(RTM_DELETE, rt_key(rt),
|
||||
(void) rtrequest(RTM_DELETE, rt_getkey(rt),
|
||||
rt->rt_gateway, rt_mask(rt), rt->rt_flags,
|
||||
NULL);
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ip_carp.c,v 1.13 2007/07/09 21:11:11 ad Exp $ */
|
||||
/* $NetBSD: ip_carp.c,v 1.14 2007/07/19 20:48:54 dyoung Exp $ */
|
||||
/* $OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $ */
|
||||
|
||||
/*
|
||||
@ -344,11 +344,7 @@ carp_setroute(struct carp_softc *sc, int cmd)
|
||||
switch (ifa->ifa_addr->sa_family) {
|
||||
case AF_INET: {
|
||||
int count = 0;
|
||||
struct sockaddr sa;
|
||||
struct rtentry *rt;
|
||||
struct radix_node_head *rnh =
|
||||
rt_tables[ifa->ifa_addr->sa_family];
|
||||
struct radix_node *rn;
|
||||
int hr_otherif, nr_ourif;
|
||||
|
||||
/*
|
||||
@ -371,18 +367,21 @@ carp_setroute(struct carp_softc *sc, int cmd)
|
||||
ifa->ifa_addr, ifa->ifa_netmask,
|
||||
RTF_HOST, NULL);
|
||||
|
||||
/* Check for our address on another interface */
|
||||
rn = rnh->rnh_matchaddr(ifa->ifa_addr, rnh);
|
||||
rt = (struct rtentry *)rn;
|
||||
rt = NULL;
|
||||
(void)rtrequest(RTM_GET, ifa->ifa_addr, ifa->ifa_addr,
|
||||
ifa->ifa_netmask, RTF_HOST, &rt);
|
||||
hr_otherif = (rt && rt->rt_ifp != &sc->sc_if &&
|
||||
rt->rt_flags & (RTF_CLONING|RTF_CLONED));
|
||||
if (rt != NULL) {
|
||||
RTFREE(rt);
|
||||
rt = NULL;
|
||||
}
|
||||
|
||||
/* Check for a network route on our interface */
|
||||
bcopy(ifa->ifa_addr, &sa, sizeof(sa));
|
||||
satosin(&sa)->sin_addr.s_addr = satosin(ifa->ifa_netmask
|
||||
)->sin_addr.s_addr & satosin(&sa)->sin_addr.s_addr;
|
||||
rn = rnh->rnh_lookup(&sa, ifa->ifa_netmask, rnh);
|
||||
rt = (struct rtentry *)rn;
|
||||
|
||||
rt = NULL;
|
||||
(void)rtrequest(RTM_GET, ifa->ifa_addr, ifa->ifa_addr,
|
||||
ifa->ifa_netmask, 0, &rt);
|
||||
nr_ourif = (rt && rt->rt_ifp == &sc->sc_if);
|
||||
|
||||
switch (cmd) {
|
||||
@ -398,7 +397,8 @@ carp_setroute(struct carp_softc *sc, int cmd)
|
||||
if (!hr_otherif || nr_ourif || !rt) {
|
||||
if (nr_ourif && !(rt->rt_flags &
|
||||
RTF_CLONING))
|
||||
rtrequest(RTM_DELETE, &sa,
|
||||
rtrequest(RTM_DELETE,
|
||||
ifa->ifa_addr,
|
||||
ifa->ifa_addr,
|
||||
ifa->ifa_netmask, 0, NULL);
|
||||
|
||||
@ -416,6 +416,10 @@ carp_setroute(struct carp_softc *sc, int cmd)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (rt != NULL) {
|
||||
RTFREE(rt);
|
||||
rt = NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ip_icmp.c,v 1.111 2007/03/04 06:03:21 christos Exp $ */
|
||||
/* $NetBSD: ip_icmp.c,v 1.112 2007/07/19 20:48:54 dyoung Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
@ -101,7 +101,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.111 2007/03/04 06:03:21 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.112 2007/07/19 20:48:54 dyoung Exp $");
|
||||
|
||||
#include "opt_ipsec.h"
|
||||
|
||||
@ -1187,7 +1187,7 @@ icmp_mtudisc_timeout(struct rtentry *rt, struct rttimer *r)
|
||||
panic("icmp_mtudisc_timeout: bad route to timeout");
|
||||
if ((rt->rt_flags & (RTF_DYNAMIC | RTF_HOST)) ==
|
||||
(RTF_DYNAMIC | RTF_HOST)) {
|
||||
rtrequest((int) RTM_DELETE, (struct sockaddr *)rt_key(rt),
|
||||
rtrequest((int) RTM_DELETE, rt_getkey(rt),
|
||||
rt->rt_gateway, rt_mask(rt), rt->rt_flags, 0);
|
||||
} else {
|
||||
if ((rt->rt_rmx.rmx_locks & RTV_MTU) == 0) {
|
||||
@ -1203,7 +1203,7 @@ icmp_redirect_timeout(struct rtentry *rt, struct rttimer *r)
|
||||
panic("icmp_redirect_timeout: bad route to timeout");
|
||||
if ((rt->rt_flags & (RTF_DYNAMIC | RTF_HOST)) ==
|
||||
(RTF_DYNAMIC | RTF_HOST)) {
|
||||
rtrequest((int) RTM_DELETE, (struct sockaddr *)rt_key(rt),
|
||||
rtrequest((int) RTM_DELETE, rt_getkey(rt),
|
||||
rt->rt_gateway, rt_mask(rt), rt->rt_flags, 0);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ip_input.c,v 1.249 2007/05/02 20:40:25 dyoung Exp $ */
|
||||
/* $NetBSD: ip_input.c,v 1.250 2007/07/19 20:48:55 dyoung Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
@ -98,7 +98,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.249 2007/05/02 20:40:25 dyoung Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.250 2007/07/19 20:48:55 dyoung Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_gateway.h"
|
||||
@ -904,9 +904,7 @@ ours:
|
||||
*/
|
||||
IPQ_LOCK();
|
||||
hash = IPREASS_HASH(ip->ip_src.s_addr, ip->ip_id);
|
||||
/* XXX LIST_FOREACH(fp, &ipq[hash], ipq_q) */
|
||||
for (fp = LIST_FIRST(&ipq[hash]); fp != NULL;
|
||||
fp = LIST_NEXT(fp, ipq_q)) {
|
||||
LIST_FOREACH(fp, &ipq[hash], ipq_q) {
|
||||
if (ip->ip_id == fp->ipq_id &&
|
||||
in_hosteq(ip->ip_src, fp->ipq_src) &&
|
||||
in_hosteq(ip->ip_dst, fp->ipq_dst) &&
|
||||
@ -1895,7 +1893,7 @@ ip_forward(struct mbuf *m, int srcrt)
|
||||
*/
|
||||
if (rt->rt_ifp == m->m_pkthdr.rcvif &&
|
||||
(rt->rt_flags & (RTF_DYNAMIC|RTF_MODIFIED)) == 0 &&
|
||||
!in_nullhost(satosin(rt_key(rt))->sin_addr) &&
|
||||
!in_nullhost(satocsin(rt_getkey(rt))->sin_addr) &&
|
||||
ipsendredirects && !srcrt) {
|
||||
if (rt->rt_ifa &&
|
||||
(ip->ip_src.s_addr & ifatoia(rt->rt_ifa)->ia_subnetmask) ==
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: tcp_subr.c,v 1.216 2007/07/09 21:11:12 ad Exp $ */
|
||||
/* $NetBSD: tcp_subr.c,v 1.217 2007/07/19 20:48:55 dyoung Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
@ -98,7 +98,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.216 2007/07/09 21:11:12 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.217 2007/07/19 20:48:55 dyoung Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_ipsec.h"
|
||||
@ -1171,7 +1171,7 @@ tcp_close(struct tcpcb *tp)
|
||||
*/
|
||||
if (SEQ_LT(tp->iss + so->so_snd.sb_hiwat * 16, tp->snd_max) &&
|
||||
ro && (rt = ro->ro_rt) &&
|
||||
!in_nullhost(satosin(rt_key(rt))->sin_addr)) {
|
||||
!in_nullhost(satocsin(rt_getkey(rt))->sin_addr)) {
|
||||
u_long i = 0;
|
||||
|
||||
if ((rt->rt_rmx.rmx_locks & RTV_RTT) == 0) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: icmp6.c,v 1.134 2007/06/13 05:03:19 dyoung Exp $ */
|
||||
/* $NetBSD: icmp6.c,v 1.135 2007/07/19 20:48:55 dyoung Exp $ */
|
||||
/* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */
|
||||
|
||||
/*
|
||||
@ -62,7 +62,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.134 2007/06/13 05:03:19 dyoung Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.135 2007/07/19 20:48:55 dyoung Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_ipsec.h"
|
||||
@ -2726,7 +2726,7 @@ icmp6_mtudisc_timeout(struct rtentry *rt, struct rttimer *r)
|
||||
panic("icmp6_mtudisc_timeout: bad route to timeout");
|
||||
if ((rt->rt_flags & (RTF_DYNAMIC | RTF_HOST)) ==
|
||||
(RTF_DYNAMIC | RTF_HOST)) {
|
||||
rtrequest((int) RTM_DELETE, (struct sockaddr *)rt_key(rt),
|
||||
rtrequest((int) RTM_DELETE, rt_getkey(rt),
|
||||
rt->rt_gateway, rt_mask(rt), rt->rt_flags, 0);
|
||||
} else {
|
||||
if (!(rt->rt_rmx.rmx_locks & RTV_MTU))
|
||||
@ -2741,7 +2741,7 @@ icmp6_redirect_timeout(struct rtentry *rt, struct rttimer *r)
|
||||
panic("icmp6_redirect_timeout: bad route to timeout");
|
||||
if ((rt->rt_flags & (RTF_GATEWAY | RTF_DYNAMIC | RTF_HOST)) ==
|
||||
(RTF_GATEWAY | RTF_DYNAMIC | RTF_HOST)) {
|
||||
rtrequest((int) RTM_DELETE, (struct sockaddr *)rt_key(rt),
|
||||
rtrequest((int) RTM_DELETE, rt_getkey(rt),
|
||||
rt->rt_gateway, rt_mask(rt), rt->rt_flags, 0);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: in6.c,v 1.130 2007/06/28 21:03:47 christos Exp $ */
|
||||
/* $NetBSD: in6.c,v 1.131 2007/07/19 20:48:56 dyoung Exp $ */
|
||||
/* $KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $ */
|
||||
|
||||
/*
|
||||
@ -62,7 +62,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.130 2007/06/28 21:03:47 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.131 2007/07/19 20:48:56 dyoung Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_pfil_hooks.h"
|
||||
@ -1153,7 +1153,7 @@ in6_update_ifa1(struct ifnet *ifp, struct in6_aliasreq *ifra,
|
||||
rt = rtalloc1((struct sockaddr *)&mltaddr, 0);
|
||||
if (rt) {
|
||||
if (memcmp(&mltaddr.sin6_addr,
|
||||
&((struct sockaddr_in6 *)rt_key(rt))->sin6_addr,
|
||||
&satocsin6(rt_getkey(rt))->sin6_addr,
|
||||
MLTMASK_LEN)) {
|
||||
RTFREE(rt);
|
||||
rt = NULL;
|
||||
@ -1163,8 +1163,8 @@ in6_update_ifa1(struct ifnet *ifp, struct in6_aliasreq *ifra,
|
||||
__func__, rt->rt_ifp, ifp, ifp->if_xname,
|
||||
ntohs(mltaddr.sin6_addr.s6_addr16[0]),
|
||||
ntohs(mltaddr.sin6_addr.s6_addr16[1]),
|
||||
((struct sockaddr_in6 *)rt_key(rt))->sin6_addr.s6_addr16[0],
|
||||
((struct sockaddr_in6 *)rt_key(rt))->sin6_addr.s6_addr16[1]);
|
||||
satocsin6(rt_getkey(rt))->sin6_addr.s6_addr16[0],
|
||||
satocsin6(rt_getkey(rt))->sin6_addr.s6_addr16[1]);
|
||||
rt_replace_ifa(rt, &ia->ia_ifa);
|
||||
rt->rt_ifp = ifp;
|
||||
}
|
||||
@ -1238,7 +1238,7 @@ in6_update_ifa1(struct ifnet *ifp, struct in6_aliasreq *ifra,
|
||||
if (rt) {
|
||||
/* 32bit came from "mltmask" */
|
||||
if (memcmp(&mltaddr.sin6_addr,
|
||||
&((struct sockaddr_in6 *)rt_key(rt))->sin6_addr,
|
||||
&satocsin6(rt_getkey(rt))->sin6_addr,
|
||||
32 / NBBY)) {
|
||||
RTFREE(rt);
|
||||
rt = NULL;
|
||||
@ -1248,8 +1248,8 @@ in6_update_ifa1(struct ifnet *ifp, struct in6_aliasreq *ifra,
|
||||
__func__, rt->rt_ifp, ifp, ifp->if_xname,
|
||||
ntohs(mltaddr.sin6_addr.s6_addr16[0]),
|
||||
ntohs(mltaddr.sin6_addr.s6_addr16[1]),
|
||||
((struct sockaddr_in6 *)rt_key(rt))->sin6_addr.s6_addr16[0],
|
||||
((struct sockaddr_in6 *)rt_key(rt))->sin6_addr.s6_addr16[1]);
|
||||
satocsin6(rt_getkey(rt))->sin6_addr.s6_addr16[0],
|
||||
satocsin6(rt_getkey(rt))->sin6_addr.s6_addr16[1]);
|
||||
rt_replace_ifa(rt, &ia->ia_ifa);
|
||||
rt->rt_ifp = ifp;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: in6_pcb.c,v 1.87 2007/05/23 17:15:01 christos Exp $ */
|
||||
/* $NetBSD: in6_pcb.c,v 1.88 2007/07/19 20:48:56 dyoung Exp $ */
|
||||
/* $KAME: in6_pcb.c,v 1.84 2001/02/08 18:02:08 itojun Exp $ */
|
||||
|
||||
/*
|
||||
@ -62,7 +62,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.87 2007/05/23 17:15:01 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.88 2007/07/19 20:48:56 dyoung Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_ipsec.h"
|
||||
@ -794,8 +794,8 @@ in6_losing(struct in6pcb *in6p)
|
||||
info.rti_info[RTAX_NETMASK] = rt_mask(rt);
|
||||
rt_missmsg(RTM_LOSING, &info, rt->rt_flags, 0);
|
||||
if (rt->rt_flags & RTF_DYNAMIC) {
|
||||
(void)rtrequest(RTM_DELETE, rt_key(rt), rt->rt_gateway,
|
||||
rt_mask(rt), rt->rt_flags, NULL);
|
||||
(void)rtrequest(RTM_DELETE, rt_getkey(rt),
|
||||
rt->rt_gateway, rt_mask(rt), rt->rt_flags, NULL);
|
||||
}
|
||||
rtcache_free(&in6p->in6p_route);
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: in6_var.h,v 1.51 2007/03/07 22:20:04 liamjfoy Exp $ */
|
||||
/* $NetBSD: in6_var.h,v 1.52 2007/07/19 20:48:56 dyoung Exp $ */
|
||||
/* $KAME: in6_var.h,v 1.81 2002/06/08 11:16:51 itojun Exp $ */
|
||||
|
||||
/*
|
||||
@ -484,20 +484,25 @@ extern unsigned long in6_maxmtu;
|
||||
* Macro for finding the internet address structure (in6_ifaddr) corresponding
|
||||
* to a given interface (ifnet structure).
|
||||
*/
|
||||
static inline struct in6_ifaddr *
|
||||
ifp_to_ia6(struct ifnet *ifp)
|
||||
{
|
||||
struct ifaddr *ifa;
|
||||
|
||||
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
|
||||
if (ifa->ifa_addr == NULL)
|
||||
continue;
|
||||
if (ifa->ifa_addr->sa_family == AF_INET6)
|
||||
break;
|
||||
}
|
||||
return (struct in6_ifaddr *)ifa;
|
||||
}
|
||||
|
||||
#define IFP_TO_IA6(__ifp, __ia) \
|
||||
do { \
|
||||
(__ia) = ifp_to_ia6((__ifp)); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define IFP_TO_IA6(ifp, ia) \
|
||||
/* struct ifnet *ifp; */ \
|
||||
/* struct in6_ifaddr *ia; */ \
|
||||
do { \
|
||||
struct ifaddr *_ifa; \
|
||||
TAILQ_FOREACH(_ifa, &(ifp)->if_addrlist, ifa_list) { \
|
||||
if (!_ifa->ifa_addr) \
|
||||
continue; \
|
||||
if (_ifa->ifa_addr->sa_family == AF_INET6) \
|
||||
break; \
|
||||
} \
|
||||
(ia) = (struct in6_ifaddr *)_ifa; \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
@ -544,22 +549,27 @@ struct in6_multistep {
|
||||
* returns NULL.
|
||||
*/
|
||||
|
||||
#define IN6_LOOKUP_MULTI(addr, ifp, in6m) \
|
||||
/* struct in6_addr addr; */ \
|
||||
/* struct ifnet *ifp; */ \
|
||||
/* struct in6_multi *in6m; */ \
|
||||
static inline struct in6_multi *
|
||||
in6_lookup_multi(struct in6_addr *addr, struct ifnet *ifp)
|
||||
{
|
||||
struct in6_multi *in6m;
|
||||
struct in6_ifaddr *ia;
|
||||
|
||||
if ((ia = ifp_to_ia6(ifp)) == NULL)
|
||||
return NULL;
|
||||
LIST_FOREACH(in6m, &ia->ia6_multiaddrs, in6m_entry) {
|
||||
if (IN6_ARE_ADDR_EQUAL(&in6m->in6m_addr, addr))
|
||||
break;
|
||||
}
|
||||
return in6m;
|
||||
}
|
||||
|
||||
#define IN6_LOOKUP_MULTI(__addr, __ifp, __in6m) \
|
||||
/* struct in6_addr __addr; */ \
|
||||
/* struct ifnet *__ifp; */ \
|
||||
/* struct in6_multi *__in6m; */ \
|
||||
do { \
|
||||
struct in6_ifaddr *_ia; \
|
||||
\
|
||||
IFP_TO_IA6((ifp), _ia); \
|
||||
if (_ia == NULL) { \
|
||||
(in6m) = NULL; \
|
||||
break; \
|
||||
} \
|
||||
LIST_FOREACH((in6m), &_ia->ia6_multiaddrs, in6m_entry) {\
|
||||
if (IN6_ARE_ADDR_EQUAL(&(in6m)->in6m_addr, &(addr)))\
|
||||
break; \
|
||||
} \
|
||||
(__in6m) = in6_lookup_multi(&(__addr), (__ifp)); \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
/*
|
||||
@ -569,53 +579,80 @@ do { \
|
||||
* and get the first record. Both macros return a NULL "in6m" when there
|
||||
* are no remaining records.
|
||||
*/
|
||||
#define IN6_NEXT_MULTI(step, in6m) \
|
||||
/* struct in6_multistep step; */ \
|
||||
/* struct in6_multi *in6m; */ \
|
||||
do { \
|
||||
if (((in6m) = (step).i_in6m) != NULL) { \
|
||||
(step).i_in6m = LIST_NEXT((in6m), in6m_entry); \
|
||||
break; \
|
||||
} \
|
||||
while ((step).i_ia != NULL) { \
|
||||
(in6m) = LIST_FIRST(&(step).i_ia->ia6_multiaddrs); \
|
||||
(step).i_ia = (step).i_ia->ia_next; \
|
||||
if ((in6m) != NULL) { \
|
||||
(step).i_in6m = LIST_NEXT((in6m), in6m_entry); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
static inline struct in6_multi *
|
||||
in6_next_multi(struct in6_multistep *step)
|
||||
{
|
||||
struct in6_multi *in6m;
|
||||
|
||||
#define IN6_FIRST_MULTI(step, in6m) \
|
||||
/* struct in6_multistep step; */ \
|
||||
/* struct in6_multi *in6m */ \
|
||||
if ((in6m = step->i_in6m) != NULL) {
|
||||
step->i_in6m = LIST_NEXT(in6m, in6m_entry);
|
||||
return in6m;
|
||||
}
|
||||
while (step->i_ia != NULL) {
|
||||
in6m = LIST_FIRST(&step->i_ia->ia6_multiaddrs);
|
||||
step->i_ia = step->i_ia->ia_next;
|
||||
if (in6m != NULL) {
|
||||
step->i_in6m = LIST_NEXT(in6m, in6m_entry);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return in6m;
|
||||
}
|
||||
|
||||
static inline struct in6_multi *
|
||||
in6_first_multi(struct in6_multistep *step)
|
||||
{
|
||||
step->i_ia = in6_ifaddr;
|
||||
step->i_in6m = NULL;
|
||||
return in6_next_multi(step);
|
||||
}
|
||||
|
||||
#define IN6_NEXT_MULTI(__step, __in6m) \
|
||||
/* struct in6_multistep __step; */ \
|
||||
/* struct in6_multi *__in6m; */ \
|
||||
do { \
|
||||
(step).i_ia = in6_ifaddr; \
|
||||
(step).i_in6m = NULL; \
|
||||
IN6_NEXT_MULTI((step), (in6m)); \
|
||||
(__in6m) = in6_next_multi(&(__step)); \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
#define IN6_FIRST_MULTI(__step, __in6m) \
|
||||
/* struct in6_multistep __step; */ \
|
||||
/* struct in6_multi *__in6m */ \
|
||||
do { \
|
||||
(__in6m) = in6_first_multi(&(__step)); \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* Macros for looking up the in6_multi_mship record for a given IP6 multicast
|
||||
* address on a given interface. If no matching record is found, "imm"
|
||||
* returns NULL.
|
||||
*/
|
||||
#define IN6_LOOKUP_MSHIP(addr, ifp, imop, imm) \
|
||||
/* struct in6_addr addr; */ \
|
||||
/* struct ifnet *ifp; */ \
|
||||
/* struct ip6_moptions *imop */ \
|
||||
/* struct in6_multi_mship *imm; */ \
|
||||
static inline struct in6_multi_mship *
|
||||
in6_lookup_mship(struct in6_addr *addr, struct ifnet *ifp,
|
||||
struct ip6_moptions *imop)
|
||||
{
|
||||
struct in6_multi_mship *imm;
|
||||
|
||||
LIST_FOREACH(imm, &imop->im6o_memberships, i6mm_chain) {
|
||||
if (imm->i6mm_maddr->in6m_ifp != ifp)
|
||||
continue;
|
||||
if (IN6_ARE_ADDR_EQUAL(&imm->i6mm_maddr->in6m_addr,
|
||||
addr))
|
||||
break;
|
||||
}
|
||||
return imm;
|
||||
}
|
||||
|
||||
#define IN6_LOOKUP_MSHIP(__addr, __ifp, __imop, __imm) \
|
||||
/* struct in6_addr __addr; */ \
|
||||
/* struct ifnet *__ifp; */ \
|
||||
/* struct ip6_moptions *__imop */ \
|
||||
/* struct in6_multi_mship *__imm; */ \
|
||||
do { \
|
||||
LIST_FOREACH((imm), &(imop)->im6o_memberships, i6mm_chain) { \
|
||||
if ((imm)->i6mm_maddr->in6m_ifp != (ifp)) \
|
||||
continue; \
|
||||
if (IN6_ARE_ADDR_EQUAL(&(imm)->i6mm_maddr->in6m_addr, \
|
||||
&(addr))) \
|
||||
break; \
|
||||
} \
|
||||
(__imm) = in6_lookup_mship(&(__addr), (__ifp), (__imop)); \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
#endif
|
||||
|
||||
struct in6_multi *in6_addmulti(struct in6_addr *, struct ifnet *,
|
||||
int *, int);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ip6_input.c,v 1.108 2007/07/09 21:11:12 ad Exp $ */
|
||||
/* $NetBSD: ip6_input.c,v 1.109 2007/07/19 20:48:56 dyoung Exp $ */
|
||||
/* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */
|
||||
|
||||
/*
|
||||
@ -62,7 +62,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.108 2007/07/09 21:11:12 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.109 2007/07/19 20:48:56 dyoung Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_inet6.h"
|
||||
@ -490,7 +490,7 @@ ip6_input(struct mbuf *m)
|
||||
else
|
||||
ip6stat.ip6s_forward_cachemiss++;
|
||||
|
||||
#define rt6_key(r) ((struct sockaddr_in6 *)((r)->rt_nodes->rn_key))
|
||||
#define rt6_getkey(__rt) satocsin6(rt_getkey(__rt))
|
||||
|
||||
/*
|
||||
* Accept the packet if the forwarding interface to the destination
|
||||
@ -510,7 +510,7 @@ ip6_input(struct mbuf *m)
|
||||
* the destination and the key of the rtentry has
|
||||
* already done through looking up the routing table.
|
||||
*/
|
||||
IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst, &rt6_key(rt)->sin6_addr) &&
|
||||
IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst, &rt6_getkey(rt)->sin6_addr) &&
|
||||
#endif
|
||||
rt->rt_ifp->if_type == IFT_LOOP) {
|
||||
struct in6_ifaddr *ia6 = (struct in6_ifaddr *)rt->rt_ifa;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ip6_var.h,v 1.44 2007/05/17 11:48:42 yamt Exp $ */
|
||||
/* $NetBSD: ip6_var.h,v 1.45 2007/07/19 20:48:57 dyoung Exp $ */
|
||||
/* $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $ */
|
||||
|
||||
/*
|
||||
@ -369,7 +369,8 @@ void rip6_init(void);
|
||||
int rip6_input(struct mbuf **, int *, int);
|
||||
void rip6_ctlinput(int, const struct sockaddr *, void *);
|
||||
int rip6_ctloutput(int, struct socket *, int, int, struct mbuf **);
|
||||
int rip6_output(struct mbuf *, ...);
|
||||
int rip6_output(struct mbuf *, struct socket *, struct sockaddr_in6 *,
|
||||
struct mbuf *);
|
||||
int rip6_usrreq(struct socket *,
|
||||
int, struct mbuf *, struct mbuf *, struct mbuf *, struct lwp *);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ip6protosw.h,v 1.18 2007/02/17 22:34:14 dyoung Exp $ */
|
||||
/* $NetBSD: ip6protosw.h,v 1.19 2007/07/19 20:48:57 dyoung Exp $ */
|
||||
/* $KAME: ip6protosw.h,v 1.22 2001/02/08 18:02:08 itojun Exp $ */
|
||||
|
||||
/*
|
||||
@ -121,7 +121,8 @@ struct ip6protosw {
|
||||
int (*pr_input) /* input to protocol (from below) */
|
||||
(struct mbuf **, int *, int);
|
||||
int (*pr_output) /* output to protocol (from above) */
|
||||
(struct mbuf *, ...);
|
||||
(struct mbuf *, struct socket *, struct sockaddr_in6 *,
|
||||
struct mbuf *);
|
||||
void (*pr_ctlinput) /* control input (from below) */
|
||||
(int, const struct sockaddr *, void *);
|
||||
int (*pr_ctloutput) /* control output (from above) */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: nd6.c,v 1.116 2007/07/09 21:11:13 ad Exp $ */
|
||||
/* $NetBSD: nd6.c,v 1.117 2007/07/19 20:48:57 dyoung Exp $ */
|
||||
/* $KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $ */
|
||||
|
||||
/*
|
||||
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.116 2007/07/09 21:11:13 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.117 2007/07/19 20:48:57 dyoung Exp $");
|
||||
|
||||
#include "opt_ipsec.h"
|
||||
|
||||
@ -433,7 +433,7 @@ nd6_llinfo_timer(void *arg)
|
||||
if ((ifp = rt->rt_ifp) == NULL)
|
||||
panic("ln->ln_rt->rt_ifp == NULL");
|
||||
ndi = ND_IFINFO(ifp);
|
||||
dst = (struct sockaddr_in6 *)rt_key(rt);
|
||||
dst = satocsin6(rt_getkey(rt));
|
||||
|
||||
/* sanity check */
|
||||
if (rt->rt_llinfo && (struct llinfo_nd6 *)rt->rt_llinfo != ln)
|
||||
@ -964,7 +964,7 @@ static struct llinfo_nd6 *
|
||||
nd6_free(struct rtentry *rt, int gc)
|
||||
{
|
||||
struct llinfo_nd6 *ln = (struct llinfo_nd6 *)rt->rt_llinfo, *next;
|
||||
struct in6_addr in6 = ((struct sockaddr_in6 *)rt_key(rt))->sin6_addr;
|
||||
struct in6_addr in6 = satocsin6(rt_getkey(rt))->sin6_addr;
|
||||
struct nd_defrouter *dr;
|
||||
|
||||
/*
|
||||
@ -978,7 +978,7 @@ nd6_free(struct rtentry *rt, int gc)
|
||||
if (!ip6_forwarding) {
|
||||
int s;
|
||||
s = splsoftnet();
|
||||
dr = defrouter_lookup(&((struct sockaddr_in6 *)rt_key(rt))->sin6_addr,
|
||||
dr = defrouter_lookup(&satocsin6(rt_getkey(rt))->sin6_addr,
|
||||
rt->rt_ifp);
|
||||
|
||||
if (dr != NULL && dr->expire &&
|
||||
@ -1058,7 +1058,7 @@ nd6_free(struct rtentry *rt, int gc)
|
||||
* caches, and disable the route entry not to be used in already
|
||||
* cached routes.
|
||||
*/
|
||||
rtrequest(RTM_DELETE, rt_key(rt), (struct sockaddr *)0,
|
||||
rtrequest(RTM_DELETE, rt_getkey(rt), (struct sockaddr *)0,
|
||||
rt_mask(rt), 0, (struct rtentry **)0);
|
||||
|
||||
return next;
|
||||
@ -1126,10 +1126,15 @@ nd6_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info)
|
||||
struct ifnet *ifp = rt->rt_ifp;
|
||||
struct ifaddr *ifa;
|
||||
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
|
||||
if ((rt->rt_flags & RTF_GATEWAY) != 0)
|
||||
return;
|
||||
|
||||
if (nd6_need_cache(ifp) == 0 && (rt->rt_flags & RTF_HOST) == 0) {
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
/*
|
||||
* This is probably an interface direct route for a link
|
||||
* which does not need neighbor caches (e.g. fe80::%lo0/64).
|
||||
@ -1142,7 +1147,9 @@ nd6_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info)
|
||||
|
||||
if (req == RTM_RESOLVE &&
|
||||
(nd6_need_cache(ifp) == 0 || /* stf case */
|
||||
!nd6_is_addr_neighbor(satocsin6(rt_key(rt)), ifp))) {
|
||||
!nd6_is_addr_neighbor(satocsin6(rt_getkey(rt)), ifp))) {
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
/*
|
||||
* FreeBSD and BSD/OS often make a cloned host route based
|
||||
* on a less-specific route (e.g. the default route).
|
||||
@ -1163,6 +1170,8 @@ nd6_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info)
|
||||
|
||||
switch (req) {
|
||||
case RTM_ADD:
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
/*
|
||||
* There is no backward compatibility :)
|
||||
*
|
||||
@ -1178,16 +1187,21 @@ nd6_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info)
|
||||
* treated as on-link but is currently not
|
||||
* (RTF_LLINFO && !ln case).
|
||||
*/
|
||||
rt_setgate(rt, rt_key(rt),
|
||||
(const struct sockaddr *)&null_sdl);
|
||||
rt_setgate(rt, (const struct sockaddr *)&null_sdl);
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
gate = rt->rt_gateway;
|
||||
SDL(gate)->sdl_type = ifp->if_type;
|
||||
SDL(gate)->sdl_index = ifp->if_index;
|
||||
if (ln)
|
||||
nd6_llinfo_settimer(ln, 0);
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
if ((rt->rt_flags & RTF_CLONING) != 0)
|
||||
break;
|
||||
}
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
/*
|
||||
* In IPv4 code, we try to annonuce new RTF_ANNOUNCE entry here.
|
||||
* We don't do that here since llinfo is not ready yet.
|
||||
@ -1210,14 +1224,16 @@ nd6_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info)
|
||||
/* XXX it does not work */
|
||||
if (rt->rt_flags & RTF_ANNOUNCE)
|
||||
nd6_na_output(ifp,
|
||||
&SIN6(rt_key(rt))->sin6_addr,
|
||||
&SIN6(rt_key(rt))->sin6_addr,
|
||||
&SIN6(rt_getkey(rt))->sin6_addr,
|
||||
&SIN6(rt_getkey(rt))->sin6_addr,
|
||||
ip6_forwarding ? ND_NA_FLAG_ROUTER : 0,
|
||||
1, NULL);
|
||||
#endif
|
||||
/* FALLTHROUGH */
|
||||
case RTM_RESOLVE:
|
||||
if ((ifp->if_flags & (IFF_POINTOPOINT | IFF_LOOPBACK)) == 0) {
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
/*
|
||||
* Address resolution isn't necessary for a point to
|
||||
* point link, so we can skip this test for a p2p link.
|
||||
@ -1231,19 +1247,27 @@ nd6_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info)
|
||||
}
|
||||
SDL(gate)->sdl_type = ifp->if_type;
|
||||
SDL(gate)->sdl_index = ifp->if_index;
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
}
|
||||
if (ln != NULL)
|
||||
break; /* This happens on a route change */
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
/*
|
||||
* Case 2: This route may come from cloning, or a manual route
|
||||
* add with a LL address.
|
||||
*/
|
||||
R_Malloc(ln, struct llinfo_nd6 *, sizeof(*ln));
|
||||
rt->rt_llinfo = (void *)ln;
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
if (ln == NULL) {
|
||||
log(LOG_DEBUG, "nd6_rtrequest: malloc failed\n");
|
||||
break;
|
||||
}
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
nd6_inuse++;
|
||||
nd6_allocated++;
|
||||
bzero(ln, sizeof(*ln));
|
||||
@ -1266,18 +1290,24 @@ nd6_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info)
|
||||
ln->ln_state = ND6_LLINFO_NOSTATE;
|
||||
nd6_llinfo_settimer(ln, 0);
|
||||
}
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
rt->rt_flags |= RTF_LLINFO;
|
||||
ln->ln_next = llinfo_nd6.ln_next;
|
||||
llinfo_nd6.ln_next = ln;
|
||||
ln->ln_prev = &llinfo_nd6;
|
||||
ln->ln_next->ln_prev = ln;
|
||||
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
/*
|
||||
* check if rt_key(rt) is one of my address assigned
|
||||
* check if rt_getkey(rt) is an address assigned
|
||||
* to the interface.
|
||||
*/
|
||||
ifa = (struct ifaddr *)in6ifa_ifpwithaddr(rt->rt_ifp,
|
||||
&SIN6(rt_key(rt))->sin6_addr);
|
||||
&SIN6(rt_getkey(rt))->sin6_addr);
|
||||
RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__,
|
||||
__LINE__, (void *)rt->_rt_key);
|
||||
if (ifa) {
|
||||
void *macp = nd6_ifptomac(ifp);
|
||||
nd6_llinfo_settimer(ln, -1);
|
||||
@ -1311,7 +1341,7 @@ nd6_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info)
|
||||
struct in6_addr llsol;
|
||||
int error;
|
||||
|
||||
llsol = SIN6(rt_key(rt))->sin6_addr;
|
||||
llsol = SIN6(rt_getkey(rt))->sin6_addr;
|
||||
llsol.s6_addr32[0] = htonl(0xff020000);
|
||||
llsol.s6_addr32[1] = 0;
|
||||
llsol.s6_addr32[2] = htonl(1);
|
||||
@ -1336,7 +1366,7 @@ nd6_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info)
|
||||
struct in6_addr llsol;
|
||||
struct in6_multi *in6m;
|
||||
|
||||
llsol = SIN6(rt_key(rt))->sin6_addr;
|
||||
llsol = SIN6(rt_getkey(rt))->sin6_addr;
|
||||
llsol.s6_addr32[0] = htonl(0xff020000);
|
||||
llsol.s6_addr32[1] = 0;
|
||||
llsol.s6_addr32[2] = htonl(1);
|
||||
@ -1604,7 +1634,7 @@ nd6_llinfo_release_pkts(struct llinfo_nd6 *ln, struct ifnet *ifp,
|
||||
* just set the 2nd argument as the
|
||||
* 1st one.
|
||||
*/
|
||||
nd6_output(ifp, ifp, m_hold, satocsin6(rt_key(rt)), rt);
|
||||
nd6_output(ifp, ifp, m_hold, satocsin6(rt_getkey(rt)), rt);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: nd6.h,v 1.47 2007/05/17 00:53:26 dyoung Exp $ */
|
||||
/* $NetBSD: nd6.h,v 1.48 2007/07/19 20:48:57 dyoung Exp $ */
|
||||
/* $KAME: nd6.h,v 1.95 2002/06/08 11:31:06 itojun Exp $ */
|
||||
|
||||
/*
|
||||
@ -431,7 +431,7 @@ int nd6_prelist_add(struct nd_prefixctl *, struct nd_defrouter *,
|
||||
int nd6_prefix_onlink(struct nd_prefix *);
|
||||
int nd6_prefix_offlink(struct nd_prefix *);
|
||||
void pfxlist_onlink_check(void);
|
||||
struct nd_defrouter *defrouter_lookup(struct in6_addr *, struct ifnet *);
|
||||
struct nd_defrouter *defrouter_lookup(const struct in6_addr *, struct ifnet *);
|
||||
struct nd_prefix *nd6_prefix_lookup(struct nd_prefixctl *);
|
||||
int in6_ifdel(struct ifnet *, struct in6_addr *);
|
||||
void rt6_flush(struct in6_addr *, struct ifnet *);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: nd6_nbr.c,v 1.76 2007/07/09 21:11:13 ad Exp $ */
|
||||
/* $NetBSD: nd6_nbr.c,v 1.77 2007/07/19 20:48:58 dyoung Exp $ */
|
||||
/* $KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $ */
|
||||
|
||||
/*
|
||||
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: nd6_nbr.c,v 1.76 2007/07/09 21:11:13 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: nd6_nbr.c,v 1.77 2007/07/19 20:48:58 dyoung Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_ipsec.h"
|
||||
@ -775,10 +775,10 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
|
||||
* update the Destination Cache entries.
|
||||
*/
|
||||
struct nd_defrouter *dr;
|
||||
struct in6_addr *in6;
|
||||
const struct in6_addr *in6;
|
||||
int s;
|
||||
|
||||
in6 = &((struct sockaddr_in6 *)rt_key(rt))->sin6_addr;
|
||||
in6 = &satocsin6(rt_getkey(rt))->sin6_addr;
|
||||
|
||||
/*
|
||||
* Lock to protect the default router list.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: nd6_rtr.c,v 1.65 2007/06/09 03:25:32 dyoung Exp $ */
|
||||
/* $NetBSD: nd6_rtr.c,v 1.66 2007/07/19 20:48:58 dyoung Exp $ */
|
||||
/* $KAME: nd6_rtr.c,v 1.95 2001/02/07 08:09:47 itojun Exp $ */
|
||||
|
||||
/*
|
||||
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.65 2007/06/09 03:25:32 dyoung Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.66 2007/07/19 20:48:58 dyoung Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -430,7 +430,7 @@ nd6_rtmsg(int cmd, struct rtentry *rt)
|
||||
struct rt_addrinfo info;
|
||||
|
||||
bzero((void *)&info, sizeof(info));
|
||||
info.rti_info[RTAX_DST] = rt_key(rt);
|
||||
info.rti_info[RTAX_DST] = rt_getkey(rt);
|
||||
info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
|
||||
info.rti_info[RTAX_NETMASK] = rt_mask(rt);
|
||||
if (rt->rt_ifp) {
|
||||
@ -477,18 +477,16 @@ defrouter_addreq(struct nd_defrouter *new)
|
||||
}
|
||||
|
||||
struct nd_defrouter *
|
||||
defrouter_lookup(struct in6_addr *addr, struct ifnet *ifp)
|
||||
defrouter_lookup(const struct in6_addr *addr, struct ifnet *ifp)
|
||||
{
|
||||
struct nd_defrouter *dr;
|
||||
|
||||
for (dr = TAILQ_FIRST(&nd_defrouter); dr;
|
||||
dr = TAILQ_NEXT(dr, dr_entry)) {
|
||||
if (dr->ifp == ifp && IN6_ARE_ADDR_EQUAL(addr, &dr->rtaddr)) {
|
||||
return (dr);
|
||||
}
|
||||
TAILQ_FOREACH(dr, &nd_defrouter, dr_entry) {
|
||||
if (dr->ifp == ifp && IN6_ARE_ADDR_EQUAL(addr, &dr->rtaddr))
|
||||
break;
|
||||
}
|
||||
|
||||
return (NULL); /* search failed */
|
||||
return dr; /* search failed */
|
||||
}
|
||||
|
||||
void
|
||||
@ -2076,7 +2074,7 @@ rt6_deleteroute(struct rtentry *rt, void *arg)
|
||||
if ((rt->rt_flags & RTF_HOST) == 0)
|
||||
return (0);
|
||||
|
||||
return (rtrequest(RTM_DELETE, rt_key(rt), rt->rt_gateway,
|
||||
return (rtrequest(RTM_DELETE, rt_getkey(rt), rt->rt_gateway,
|
||||
rt_mask(rt), rt->rt_flags, 0));
|
||||
#undef SIN6
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: raw_ip6.c,v 1.85 2007/05/23 17:15:04 christos Exp $ */
|
||||
/* $NetBSD: raw_ip6.c,v 1.86 2007/07/19 20:48:58 dyoung Exp $ */
|
||||
/* $KAME: raw_ip6.c,v 1.82 2001/07/23 18:57:56 jinmei Exp $ */
|
||||
|
||||
/*
|
||||
@ -62,7 +62,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.85 2007/05/23 17:15:04 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.86 2007/07/19 20:48:58 dyoung Exp $");
|
||||
|
||||
#include "opt_ipsec.h"
|
||||
|
||||
@ -104,8 +104,6 @@ __KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.85 2007/05/23 17:15:04 christos Exp $"
|
||||
#include <netipsec/ipsec6.h>
|
||||
#endif
|
||||
|
||||
#include <machine/stdarg.h>
|
||||
|
||||
#include "faith.h"
|
||||
#if defined(NFAITH) && 0 < NFAITH
|
||||
#include <net/if_faith.h>
|
||||
@ -388,17 +386,9 @@ rip6_ctlinput(int cmd, const struct sockaddr *sa, void *d)
|
||||
* Tack on options user may have setup with control call.
|
||||
*/
|
||||
int
|
||||
#if __STDC__
|
||||
rip6_output(struct mbuf *m, ...)
|
||||
#else
|
||||
rip6_output(m, va_alist)
|
||||
struct mbuf *m;
|
||||
va_dcl
|
||||
#endif
|
||||
rip6_output(struct mbuf *m, struct socket *so, struct sockaddr_in6 *dstsock,
|
||||
struct mbuf *control)
|
||||
{
|
||||
struct socket *so;
|
||||
struct sockaddr_in6 *dstsock;
|
||||
struct mbuf *control;
|
||||
struct in6_addr *dst;
|
||||
struct ip6_hdr *ip6;
|
||||
struct in6pcb *in6p;
|
||||
@ -410,13 +400,6 @@ rip6_output(m, va_alist)
|
||||
int priv = 0;
|
||||
int scope_ambiguous = 0;
|
||||
struct in6_addr *in6a;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, m);
|
||||
so = va_arg(ap, struct socket *);
|
||||
dstsock = va_arg(ap, struct sockaddr_in6 *);
|
||||
control = va_arg(ap, struct mbuf *);
|
||||
va_end(ap);
|
||||
|
||||
in6p = sotoin6pcb(so);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: clnp_subr.c,v 1.28 2007/05/02 20:40:28 dyoung Exp $ */
|
||||
/* $NetBSD: clnp_subr.c,v 1.29 2007/07/19 20:48:59 dyoung Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
@ -59,7 +59,7 @@ SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: clnp_subr.c,v 1.28 2007/05/02 20:40:28 dyoung Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: clnp_subr.c,v 1.29 2007/07/19 20:48:59 dyoung Exp $");
|
||||
|
||||
#include "opt_iso.h"
|
||||
|
||||
@ -644,7 +644,7 @@ clnp_badmtu(
|
||||
rt, line, file);
|
||||
#ifdef ARGO_DEBUG
|
||||
printf("route dst is ");
|
||||
dump_isoaddr((struct sockaddr_iso *) rt_key(rt));
|
||||
dump_isoaddr(satocsiso(rt_getkey(rt)));
|
||||
#endif
|
||||
return ifp->if_mtu;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: esis.c,v 1.46 2007/07/09 21:11:14 ad Exp $ */
|
||||
/* $NetBSD: esis.c,v 1.47 2007/07/19 20:48:59 dyoung Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
@ -59,7 +59,7 @@ SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: esis.c,v 1.46 2007/07/09 21:11:14 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: esis.c,v 1.47 2007/07/19 20:48:59 dyoung Exp $");
|
||||
|
||||
#include "opt_iso.h"
|
||||
#ifdef ISO
|
||||
@ -361,13 +361,13 @@ esis_rdoutput(
|
||||
struct sockaddr_iso siso;
|
||||
struct ifnet *ifp = inbound_shp->snh_ifp;
|
||||
struct sockaddr_dl *sdl;
|
||||
struct iso_addr *rd_gwnsap;
|
||||
const struct iso_addr *rd_gwnsap;
|
||||
|
||||
if (rt->rt_flags & RTF_GATEWAY) {
|
||||
rd_gwnsap = &satosiso(rt->rt_gateway)->siso_addr;
|
||||
rt = rtalloc1(rt->rt_gateway, 0);
|
||||
} else
|
||||
rd_gwnsap = &satosiso(rt_key(rt))->siso_addr;
|
||||
rd_gwnsap = &satocsiso(rt_getkey(rt))->siso_addr;
|
||||
if (rt == 0 || (sdl = (struct sockaddr_dl *) rt->rt_gateway) == 0 ||
|
||||
sdl->sdl_family != AF_LINK) {
|
||||
/*
|
||||
@ -518,15 +518,14 @@ int
|
||||
esis_insert_addr(
|
||||
void **bufv, /* ptr to buffer to put address into */
|
||||
int *len, /* ptr to length of buffer so far */
|
||||
struct iso_addr *isoa, /* ptr to address */
|
||||
const struct iso_addr *isoa, /* ptr to address */
|
||||
struct mbuf *m, /* determine if there remains space */
|
||||
int nsellen)
|
||||
{
|
||||
char *buf = *bufv;
|
||||
int newlen, result = 0;
|
||||
|
||||
isoa->isoa_len -= nsellen;
|
||||
newlen = isoa->isoa_len + 1;
|
||||
newlen = isoa->isoa_len - nsellen + 1;
|
||||
if (newlen <= M_TRAILINGSPACE(m)) {
|
||||
memcpy(buf, isoa, newlen);
|
||||
*len += newlen;
|
||||
@ -534,7 +533,6 @@ esis_insert_addr(
|
||||
m->m_len += newlen;
|
||||
result = 1;
|
||||
}
|
||||
isoa->isoa_len += nsellen;
|
||||
*bufv = buf;
|
||||
return (result);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: esis.h,v 1.21 2007/03/04 06:03:32 christos Exp $ */
|
||||
/* $NetBSD: esis.h,v 1.22 2007/07/19 20:48:59 dyoung Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
@ -134,7 +134,7 @@ int esis_usrreq (struct socket *, int, struct mbuf *, struct mbuf *,
|
||||
void esis_input (struct mbuf *, ...);
|
||||
void esis_rdoutput (struct snpa_hdr *, struct mbuf *, struct clnp_optidx *,
|
||||
struct iso_addr *, struct rtentry *);
|
||||
int esis_insert_addr (void **, int *, struct iso_addr *, struct mbuf *,
|
||||
int esis_insert_addr (void **, int *, const struct iso_addr *, struct mbuf *,
|
||||
int);
|
||||
void esis_eshinput (struct mbuf *, struct snpa_hdr *);
|
||||
void esis_ishinput (struct mbuf *, struct snpa_hdr *);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: iso_snpac.c,v 1.43 2007/03/04 06:03:32 christos Exp $ */
|
||||
/* $NetBSD: iso_snpac.c,v 1.44 2007/07/19 20:48:59 dyoung Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
@ -59,7 +59,7 @@ SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: iso_snpac.c,v 1.43 2007/03/04 06:03:32 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: iso_snpac.c,v 1.44 2007/07/19 20:48:59 dyoung Exp $");
|
||||
|
||||
#include "opt_iso.h"
|
||||
#ifdef ISO
|
||||
@ -208,8 +208,8 @@ llc_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info)
|
||||
*/
|
||||
if (rt->rt_flags & RTF_CLONING) {
|
||||
iso_setmcasts(ifp, req);
|
||||
rt_setgate(rt, rt_key(rt),
|
||||
(struct sockaddr *) & blank_dl);
|
||||
rt_setgate(rt,
|
||||
(const struct sockaddr *)&blank_dl);
|
||||
return;
|
||||
}
|
||||
if (lc != 0)
|
||||
@ -391,8 +391,8 @@ snpac_free(
|
||||
if (rt && (rt->rt_flags & RTF_UP) &&
|
||||
(rt->rt_flags & (RTF_DYNAMIC | RTF_MODIFIED))) {
|
||||
RTFREE(rt);
|
||||
rtrequest(RTM_DELETE, rt_key(rt), rt->rt_gateway, rt_mask(rt),
|
||||
rt->rt_flags, (struct rtentry **) 0);
|
||||
rtrequest(RTM_DELETE, rt_getkey(rt), rt->rt_gateway,
|
||||
rt_mask(rt), rt->rt_flags, NULL);
|
||||
RTFREE(rt);
|
||||
}
|
||||
}
|
||||
@ -602,13 +602,13 @@ snpac_logdefis(struct rtentry *sc)
|
||||
known_is = sc;
|
||||
sc->rt_refcnt++;
|
||||
rt = rtalloc1((struct sockaddr *) & zsi, 0);
|
||||
if (rt == 0)
|
||||
rtrequest(RTM_ADD, sisotosa(&zsi), rt_key(sc), sisotosa(&zmk),
|
||||
RTF_DYNAMIC | RTF_GATEWAY, 0);
|
||||
else {
|
||||
if (rt == 0) {
|
||||
rtrequest(RTM_ADD, sisotosa(&zsi), rt_getkey(sc),
|
||||
sisotosa(&zmk), RTF_DYNAMIC | RTF_GATEWAY, 0);
|
||||
} else {
|
||||
if ((rt->rt_flags & RTF_DYNAMIC) &&
|
||||
(rt->rt_flags & RTF_GATEWAY) && rt_mask(rt)->sa_len == 0)
|
||||
rt_setgate(rt, rt_key(rt), rt_key(sc));
|
||||
rt_setgate(rt, rt_getkey(sc));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: nfs_boot.c,v 1.67 2007/06/09 02:32:34 dyoung Exp $ */
|
||||
/* $NetBSD: nfs_boot.c,v 1.68 2007/07/19 20:49:00 dyoung Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995, 1997 The NetBSD Foundation, Inc.
|
||||
@ -42,7 +42,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: nfs_boot.c,v 1.67 2007/06/09 02:32:34 dyoung Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: nfs_boot.c,v 1.68 2007/07/19 20:49:00 dyoung Exp $");
|
||||
|
||||
#include "opt_nfs.h"
|
||||
#include "opt_tftproot.h"
|
||||
@ -98,7 +98,7 @@ int nfs_boot_bootstatic = 1; /* BOOTSTATIC enabled (default) */
|
||||
static int md_mount(struct sockaddr_in *mdsin, char *path,
|
||||
struct nfs_args *argp, struct lwp *l);
|
||||
|
||||
static int nfs_boot_delroute(struct radix_node *, void *);
|
||||
static int nfs_boot_delroute(struct rtentry *, void *);
|
||||
static void nfs_boot_defrt(struct in_addr *);
|
||||
static int nfs_boot_getfh(struct nfs_dlmount *ndm, struct lwp *);
|
||||
|
||||
@ -536,26 +536,26 @@ nfs_boot_defrt(gw_ip)
|
||||
}
|
||||
|
||||
static int
|
||||
nfs_boot_delroute(struct radix_node *rn, void *w)
|
||||
nfs_boot_delroute(struct rtentry *rt, void *w)
|
||||
{
|
||||
struct rtentry *rt = (struct rtentry *)rn;
|
||||
int error;
|
||||
|
||||
if (rt->rt_ifp != (struct ifnet *)w)
|
||||
return (0);
|
||||
if ((void *)rt->rt_ifp != w)
|
||||
return 0;
|
||||
|
||||
error = rtrequest(RTM_DELETE, rt_key(rt), NULL, rt_mask(rt), 0, NULL);
|
||||
if (error)
|
||||
printf("nfs_boot: del route, error=%d\n", error);
|
||||
error = rtrequest(RTM_DELETE, rt_getkey(rt), NULL, rt_mask(rt), 0,
|
||||
NULL);
|
||||
if (error != 0)
|
||||
printf("%s: del route, error=%d\n", __func__, error);
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
nfs_boot_flushrt(struct ifnet *ifp)
|
||||
{
|
||||
|
||||
rn_walktree(rt_tables[AF_INET], nfs_boot_delroute, ifp);
|
||||
rt_walktree(AF_INET, nfs_boot_delroute, ifp);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user