summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/net/route.c68
-rw-r--r--sys/net/route.h5
-rw-r--r--sys/net/rtable.c62
-rw-r--r--sys/net/rtable.h7
-rw-r--r--sys/net/rtsock.c15
-rw-r--r--sys/netinet/in.c11
-rw-r--r--sys/netinet/in_pcb.c5
-rw-r--r--sys/netinet/in_proto.c4
-rw-r--r--sys/netinet/in_var.h3
-rw-r--r--sys/netinet6/in6_proto.c4
-rw-r--r--sys/netinet6/nd6.c6
-rw-r--r--sys/netinet6/nd6_rtr.c5
-rw-r--r--sys/netmpls/mpls_proto.c4
13 files changed, 127 insertions, 72 deletions
diff --git a/sys/net/route.c b/sys/net/route.c
index 7b6b640aca3..c2ac0f59da3 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.286 2015/12/03 14:55:17 vgross Exp $ */
+/* $OpenBSD: route.c,v 1.287 2015/12/03 21:57:59 mpi Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
@@ -122,10 +122,12 @@
#include <netinet/in.h>
#include <netinet/ip_var.h>
+#include <netinet/in_var.h>
#ifdef INET6
#include <netinet/ip6.h>
#include <netinet6/ip6_var.h>
+#include <netinet6/in6_var.h>
#endif
#ifdef MPLS
@@ -153,6 +155,8 @@ int rtflushclone1(struct rtentry *, void *, u_int);
void rtflushclone(unsigned int, struct rtentry *);
int rt_if_remove_rtdelete(struct rtentry *, void *, u_int);
struct rtentry *rt_match(struct sockaddr *, uint32_t *, int, unsigned int);
+struct sockaddr *rt_plentosa(sa_family_t, int, struct sockaddr_in6 *);
+
struct ifaddr *ifa_ifwithroute(int, struct sockaddr *, struct sockaddr *,
u_int);
int rtrequest_delete(struct rt_addrinfo *, u_int8_t, struct ifnet *,
@@ -472,11 +476,12 @@ rt_sendmsg(struct rtentry *rt, int cmd, u_int rtableid)
struct rt_addrinfo info;
struct ifnet *ifp;
struct sockaddr_rtlabel sa_rl;
+ struct sockaddr_in6 sa_mask;
memset(&info, 0, sizeof(info));
info.rti_info[RTAX_DST] = rt_key(rt);
info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
- info.rti_info[RTAX_NETMASK] = rt_mask(rt);
+ info.rti_info[RTAX_NETMASK] = rt_plen2mask(rt, &sa_mask);
info.rti_info[RTAX_LABEL] = rtlabel_id2sa(rt->rt_labelid, &sa_rl);
ifp = if_get(rt->rt_ifidx);
if (ifp != NULL) {
@@ -527,7 +532,7 @@ rtredirect(struct sockaddr *dst, struct sockaddr *gateway,
goto out;
}
ifidx = ifa->ifa_ifp->if_index;
- rt = rtalloc(dst, 0, rdomain);
+ rt = rtable_lookup(rdomain, dst, NULL, NULL, RTP_ANY);
/*
* If the redirect isn't from our current router for this dst,
* it's either old or wrong. If it redirects us to ourselves,
@@ -551,7 +556,7 @@ rtredirect(struct sockaddr *dst, struct sockaddr *gateway,
* which use routing redirects generated by smart gateways
* to dynamically build the routing tables.
*/
- if ((rt == NULL) || (rt_mask(rt) && rt_mask(rt)->sa_len < 2))
+ if ((rt == NULL))
goto create;
/*
* Don't listen to the redirect if it's
@@ -617,6 +622,7 @@ rtdeletemsg(struct rtentry *rt, struct ifnet *ifp, u_int tableid)
int error;
struct rt_addrinfo info;
unsigned int ifidx;
+ struct sockaddr_in6 sa_mask;
/*
* Request the new route so that the entry is not actually
@@ -626,7 +632,7 @@ rtdeletemsg(struct rtentry *rt, struct ifnet *ifp, u_int tableid)
bzero((caddr_t)&info, sizeof(info));
info.rti_info[RTAX_DST] = rt_key(rt);
if (!ISSET(rt->rt_flags, RTF_HOST))
- info.rti_info[RTAX_NETMASK] = rt_mask(rt);
+ info.rti_info[RTAX_NETMASK] = rt_plen2mask(rt, &sa_mask);
info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
info.rti_flags = rt->rt_flags;
ifidx = rt->rt_ifidx;
@@ -641,7 +647,7 @@ static inline int
rtequal(struct rtentry *a, struct rtentry *b)
{
if (memcmp(rt_key(a), rt_key(b), rt_key(a)->sa_len) == 0 &&
- memcmp(rt_mask(a), rt_mask(b), rt_mask(a)->sa_len) == 0)
+ rt_plen(a) == rt_plen(b))
return 1;
else
return 0;
@@ -1722,6 +1728,7 @@ int
rt_if_linkstate_change(struct rtentry *rt, void *arg, u_int id)
{
struct ifnet *ifp = arg;
+ struct sockaddr_in6 sa_mask;
if (rt->rt_ifidx != ifp->if_index)
return (0);
@@ -1754,12 +1761,57 @@ rt_if_linkstate_change(struct rtentry *rt, void *arg, u_int id)
rtable_mpath_reprio(rt, rt->rt_priority | RTP_DOWN);
}
}
- if_group_routechange(rt_key(rt), rt_mask(rt));
+ if_group_routechange(rt_key(rt), rt_plen2mask(rt, &sa_mask));
return (0);
}
#endif
+struct sockaddr *
+rt_plentosa(sa_family_t af, int plen, struct sockaddr_in6 *sa_mask)
+{
+ struct sockaddr_in *sin = (struct sockaddr_in *)sa_mask;
+#ifdef INET6
+ struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sa_mask;
+#endif
+
+ KASSERT(plen >= 0 || plen == -1);
+
+ if (plen == -1)
+ return (NULL);
+
+ memset(sa_mask, 0, sizeof(*sa_mask));
+
+ switch (af) {
+ case AF_INET:
+ sin->sin_family = AF_INET;
+ sin->sin_len = sizeof(struct sockaddr_in);
+ in_prefixlen2mask(&sin->sin_addr, plen);
+ break;
+#ifdef INET6
+ case AF_INET6:
+ sin6->sin6_family = AF_INET6;
+ sin6->sin6_len = sizeof(struct sockaddr_in6);
+ in6_prefixlen2mask(&sin6->sin6_addr, plen);
+ break;
+#endif /* INET6 */
+ default:
+ return (NULL);
+ }
+
+ return ((struct sockaddr *)sa_mask);
+}
+
+struct sockaddr *
+rt_plen2mask(struct rtentry *rt, struct sockaddr_in6 *sa_mask)
+{
+#ifndef ART
+ return (rt_mask(rt));
+#else
+ return (rt_plentosa(rt_key(rt)->sa_family, rt_plen(rt), sa_mask));
+#endif /* ART */
+}
+
#ifdef DDB
#include <machine/db_machdep.h>
#include <ddb/db_output.h>
@@ -1816,7 +1868,7 @@ db_show_rtentry(struct rtentry *rt, void *w, unsigned int id)
rt->rt_flags, rt->rt_refcnt, rt->rt_use, rt->rt_expire, id);
db_printf(" key="); db_print_sa(rt_key(rt));
- db_printf(" mask="); db_print_sa(rt_mask(rt));
+ db_printf(" plen=%d", rt_plen(rt));
db_printf(" gw="); db_print_sa(rt->rt_gateway);
db_printf(" ifidx=%u ", rt->rt_ifidx);
db_printf(" ifa=%p\n", rt->rt_ifa);
diff --git a/sys/net/route.h b/sys/net/route.h
index 3186e5de82b..fb61518e4cb 100644
--- a/sys/net/route.h
+++ b/sys/net/route.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.h,v 1.129 2015/12/03 16:27:32 mpi Exp $ */
+/* $OpenBSD: route.h,v 1.130 2015/12/03 21:57:59 mpi Exp $ */
/* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */
/*
@@ -98,7 +98,6 @@ struct rtentry {
#else
struct art_node *rt_node; /* ART entry */
struct sockaddr *rt_dest; /* destination */
- struct sockaddr *rt_mask; /* mask (radix tree compat) */
SRPL_ENTRY(rtentry) rt_next; /* Next multipath entry to our dst. */
#endif
struct sockaddr *rt_gateway; /* value */
@@ -346,6 +345,7 @@ extern const struct sockaddr_rtin rt_defmask4;
struct mbuf;
struct socket;
struct ifnet;
+struct sockaddr_in6;
void route_init(void);
int route_output(struct mbuf *, ...);
@@ -355,6 +355,7 @@ void rt_ifmsg(struct ifnet *);
void rt_ifannouncemsg(struct ifnet *, int);
void rt_maskedcopy(struct sockaddr *,
struct sockaddr *, struct sockaddr *);
+struct sockaddr *rt_plen2mask(struct rtentry *, struct sockaddr_in6 *);
void rt_sendmsg(struct rtentry *, int, u_int);
void rt_sendaddrmsg(struct rtentry *, int);
void rt_missmsg(int, struct rt_addrinfo *, int, u_int, int, u_int);
diff --git a/sys/net/rtable.c b/sys/net/rtable.c
index f553a803298..eed2dd77c2f 100644
--- a/sys/net/rtable.c
+++ b/sys/net/rtable.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtable.c,v 1.31 2015/12/02 16:49:58 bluhm Exp $ */
+/* $OpenBSD: rtable.c,v 1.32 2015/12/03 21:57:59 mpi Exp $ */
/*
* Copyright (c) 2014-2015 Martin Pieuchot
@@ -509,7 +509,6 @@ rtable_mpath_next(struct rtentry *rt)
struct pool an_pool; /* pool for ART node structures */
-static inline int satoplen(struct art_root *, struct sockaddr *);
static inline uint8_t *satoaddr(struct art_root *, struct sockaddr *);
void rtentry_ref(void *, void *);
@@ -553,7 +552,7 @@ rtable_lookup(unsigned int rtableid, struct sockaddr *dst,
if (an == NULL)
return (NULL);
} else {
- plen = satoplen(ar, mask);
+ plen = rtable_satoplen(dst->sa_family, mask);
if (plen == -1)
return (NULL);
@@ -640,7 +639,7 @@ rtable_insert(unsigned int rtableid, struct sockaddr *dst,
return (EAFNOSUPPORT);
addr = satoaddr(ar, dst);
- plen = satoplen(ar, mask);
+ plen = rtable_satoplen(dst->sa_family, mask);
if (plen == -1)
return (EINVAL);
@@ -666,21 +665,6 @@ rtable_insert(unsigned int rtableid, struct sockaddr *dst,
}
#endif /* SMALL_KERNEL */
- /*
- * XXX Allocating a sockaddr for the mask per node wastes a lot
- * of memory, thankfully we'll get rid of that when rt_mask()
- * will be no more.
- */
- if (mask != NULL) {
- struct sockaddr *msk;
-
- msk = malloc(dst->sa_len, M_RTABLE, M_NOWAIT | M_ZERO);
- if (msk == NULL)
- return (ENOMEM);
- memcpy(msk, mask, dst->sa_len);
- rt->rt_mask = msk;
- }
-
an = pool_get(&an_pool, PR_NOWAIT | PR_ZERO);
if (an == NULL)
return (ENOBUFS);
@@ -691,8 +675,6 @@ rtable_insert(unsigned int rtableid, struct sockaddr *dst,
prev = art_insert(ar, an, addr, plen);
if (prev == NULL) {
- free(rt->rt_mask, M_RTABLE, 0);
- rt->rt_mask = NULL;
pool_put(&an_pool, an);
return (ESRCH);
}
@@ -765,8 +747,6 @@ rtable_delete(unsigned int rtableid, struct sockaddr *dst,
npaths++;
if (npaths > 1) {
- free(rt->rt_mask, M_RTABLE, 0);
- rt->rt_mask = NULL;
rt->rt_node = NULL;
KASSERT(rt->rt_refcnt >= 2);
SRPL_REMOVE_LOCKED(&rt_rc, &an->an_rtlist, rt, rtentry,
@@ -788,7 +768,7 @@ rtable_delete(unsigned int rtableid, struct sockaddr *dst,
#ifdef DIAGNOSTIC
if (memcmp(dst, an->an_dst, dst->sa_len))
panic("destination do not match");
- if (mask != NULL && an->an_plen != satoplen(ar, mask))
+ if (mask && an->an_plen != rtable_satoplen(dst->sa_family, mask))
panic("mask do not match");
#endif /* DIAGNOSTIC */
@@ -798,13 +778,7 @@ rtable_delete(unsigned int rtableid, struct sockaddr *dst,
if (art_delete(ar, an, addr, plen) == NULL)
return (ESRCH);
- /*
- * XXX Is it safe to free the mask now? Are we sure rt_mask()
- * is only used when entries are in the table?
- */
- free(rt->rt_mask, M_RTABLE, 0);
rt->rt_node = NULL;
- rt->rt_mask = NULL;
KASSERT(rt->rt_refcnt >= 2);
SRPL_REMOVE_LOCKED(&rt_rc, &an->an_rtlist, rt, rtentry, rt_next);
rtfree(rt);
@@ -981,19 +955,32 @@ satoaddr(struct art_root *at, struct sockaddr *sa)
{
return (((uint8_t *)sa) + at->ar_off);
}
+#endif /* ART */
/*
* Return the prefix length of a mask.
*/
-static inline int
-satoplen(struct art_root *ar, struct sockaddr *mask)
+int
+rtable_satoplen(sa_family_t af, struct sockaddr *mask)
{
- uint8_t *ap, *ep;
- int skip, mlen, plen = 0;
+ struct domain *dp;
+ uint8_t *ap, *ep;
+ int mlen, plen = 0;
+ int i;
+
+ for (i = 0; (dp = domains[i]) != NULL; i++) {
+ if (dp->dom_rtoffset == 0)
+ continue;
+
+ if (af == dp->dom_family)
+ break;
+ }
+ if (dp == NULL)
+ return (-1);
/* Host route */
if (mask == NULL)
- return (ar->ar_alen);
+ return (dp->dom_maxplen);
mlen = mask->sa_len;
@@ -1001,9 +988,7 @@ satoplen(struct art_root *ar, struct sockaddr *mask)
if (mlen == 0)
return (0);
- skip = ar->ar_off;
-
- ap = (uint8_t *)((uint8_t *)mask) + skip;
+ ap = (uint8_t *)((uint8_t *)mask) + dp->dom_rtoffset;
ep = (uint8_t *)((uint8_t *)mask) + mlen;
if (ap > ep)
return (-1);
@@ -1065,4 +1050,3 @@ out:
return (plen);
}
-#endif /* ART */
diff --git a/sys/net/rtable.h b/sys/net/rtable.h
index 765a6b33d43..0ae181f5559 100644
--- a/sys/net/rtable.h
+++ b/sys/net/rtable.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtable.h,v 1.12 2015/12/02 16:49:58 bluhm Exp $ */
+/* $OpenBSD: rtable.h,v 1.13 2015/12/03 21:57:59 mpi Exp $ */
/*
* Copyright (c) 2014-2015 Martin Pieuchot
@@ -31,6 +31,7 @@
#define rt_key(rt) (((struct sockaddr *)(rt)->rt_nodes[0].rn_key))
#define rt_mask(rt) (((struct sockaddr *)(rt)->rt_nodes[0].rn_mask))
+#define rt_plen(rt) (rtable_satoplen(rt_key(rt)->sa_family, rt_mask(rt)))
#define RT_ROOT(rt) ((rt)->rt_nodes[0].rn_flags & RNF_ROOT)
#else /* ART */
@@ -42,11 +43,13 @@
#include <net/art.h>
#define rt_key(rt) ((rt)->rt_dest)
-#define rt_mask(rt) ((rt)->rt_mask)
+#define rt_plen(rt) (((rt)->rt_node != NULL) ? (rt)->rt_node->an_plen : 0)
#define RT_ROOT(rt) (0)
#endif /* ART */
+int rtable_satoplen(sa_family_t, struct sockaddr *);
+
void rtable_init(void);
int rtable_exists(unsigned int);
int rtable_add(unsigned int);
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 6f1ab2bce12..c13b33d6fc3 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtsock.c,v 1.184 2015/12/03 14:19:55 mpi Exp $ */
+/* $OpenBSD: rtsock.c,v 1.185 2015/12/03 21:57:59 mpi Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
@@ -77,6 +77,8 @@
#include <net/route.h>
#include <net/raw_cb.h>
+#include <netinet/in.h>
+
#ifdef MPLS
#include <netmpls/mpls.h>
#endif
@@ -456,6 +458,7 @@ route_output(struct mbuf *m, ...)
struct socket *so;
struct rawcb *rp = NULL;
struct sockaddr_rtlabel sa_rl;
+ struct sockaddr_in6 sa_mask;
#ifdef MPLS
struct sockaddr_mpls sa_mpls, *psa_mpls;
#endif
@@ -660,8 +663,8 @@ route_output(struct mbuf *m, ...)
* if none of them have a netmask both are host routes which is
* also a perfect match.
*/
- if (rtm->rtm_type != RTM_GET &&
- !rt_mask(rt) != !info.rti_info[RTAX_NETMASK]) {
+ if (rtm->rtm_type != RTM_GET && !rt_plen2mask(rt, &sa_mask) !=
+ !info.rti_info[RTAX_NETMASK]) {
error = ESRCH;
goto flush;
}
@@ -671,7 +674,8 @@ route_output(struct mbuf *m, ...)
report:
info.rti_info[RTAX_DST] = rt_key(rt);
info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
- info.rti_info[RTAX_NETMASK] = rt_mask(rt);
+ info.rti_info[RTAX_NETMASK] =
+ rt_plen2mask(rt, &sa_mask);
info.rti_info[RTAX_LABEL] =
rtlabel_id2sa(rt->rt_labelid, &sa_rl);
#ifdef MPLS
@@ -1193,6 +1197,7 @@ sysctl_dumpentry(struct rtentry *rt, void *v, unsigned int id)
struct sockaddr_mpls sa_mpls;
#endif
struct sockaddr_rtlabel sa_rl;
+ struct sockaddr_in6 sa_mask;
if (w->w_op == NET_RT_FLAGS && !(rt->rt_flags & w->w_arg))
return 0;
@@ -1212,7 +1217,7 @@ sysctl_dumpentry(struct rtentry *rt, void *v, unsigned int id)
bzero(&info, sizeof(info));
info.rti_info[RTAX_DST] = rt_key(rt);
info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
- info.rti_info[RTAX_NETMASK] = rt_mask(rt);
+ info.rti_info[RTAX_NETMASK] = rt_plen2mask(rt, &sa_mask);
ifp = if_get(rt->rt_ifidx);
if (ifp != NULL) {
info.rti_info[RTAX_IFP] = sdltosa(ifp->if_sadl);
diff --git a/sys/netinet/in.c b/sys/netinet/in.c
index 4b180bd1862..4450832b380 100644
--- a/sys/netinet/in.c
+++ b/sys/netinet/in.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in.c,v 1.124 2015/11/24 13:37:16 mpi Exp $ */
+/* $OpenBSD: in.c,v 1.125 2015/12/03 21:57:59 mpi Exp $ */
/* $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */
/*
@@ -894,3 +894,12 @@ in_ifdetach(struct ifnet *ifp)
dohooks(ifp->if_addrhooks, 0);
}
}
+
+void
+in_prefixlen2mask(struct in_addr *maskp, int plen)
+{
+ if (plen == 0)
+ maskp->s_addr = 0;
+ else
+ maskp->s_addr = htonl(0xffffffff << (32 - plen));
+}
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index f39fed59609..4600fe12302 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in_pcb.c,v 1.193 2015/12/03 14:55:18 vgross Exp $ */
+/* $OpenBSD: in_pcb.c,v 1.194 2015/12/03 21:57:59 mpi Exp $ */
/* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */
/*
@@ -637,6 +637,7 @@ in_losing(struct inpcb *inp)
{
struct rtentry *rt;
struct rt_addrinfo info;
+ struct sockaddr_in6 sa_mask;
if ((rt = inp->inp_route.ro_rt)) {
inp->inp_route.ro_rt = 0;
@@ -645,7 +646,7 @@ in_losing(struct inpcb *inp)
info.rti_flags = rt->rt_flags;
info.rti_info[RTAX_DST] = &inp->inp_route.ro_dst;
info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
- info.rti_info[RTAX_NETMASK] = rt_mask(rt);
+ info.rti_info[RTAX_NETMASK] = rt_plen2mask(rt, &sa_mask);
rt_missmsg(RTM_LOSING, &info, rt->rt_flags, rt->rt_ifidx, 0,
inp->inp_rtableid);
if (rt->rt_flags & RTF_DYNAMIC)
diff --git a/sys/netinet/in_proto.c b/sys/netinet/in_proto.c
index 51e0e139c65..d7de5402875 100644
--- a/sys/netinet/in_proto.c
+++ b/sys/netinet/in_proto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in_proto.c,v 1.69 2015/12/03 12:42:03 goda Exp $ */
+/* $OpenBSD: in_proto.c,v 1.70 2015/12/03 21:57:59 mpi Exp $ */
/* $NetBSD: in_proto.c,v 1.14 1996/02/18 18:58:32 christos Exp $ */
/*
@@ -323,4 +323,4 @@ struct domain inetdomain =
{ AF_INET, "internet", 0, 0, 0,
inetsw, &inetsw[nitems(inetsw)],
sizeof(struct sockaddr_in),
- offsetof(struct sockaddr_in, sin_addr) };
+ offsetof(struct sockaddr_in, sin_addr), 32 };
diff --git a/sys/netinet/in_var.h b/sys/netinet/in_var.h
index 769faf127f9..2bee960430c 100644
--- a/sys/netinet/in_var.h
+++ b/sys/netinet/in_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: in_var.h,v 1.36 2015/11/11 10:01:46 mpi Exp $ */
+/* $OpenBSD: in_var.h,v 1.37 2015/12/03 21:57:59 mpi Exp $ */
/* $NetBSD: in_var.h,v 1.16 1996/02/13 23:42:15 christos Exp $ */
/*
@@ -156,6 +156,7 @@ struct in_multi *in_addmulti(struct in_addr *, struct ifnet *);
void in_delmulti(struct in_multi *);
void in_ifscrub(struct ifnet *, struct in_ifaddr *);
int in_control(struct socket *, u_long, caddr_t, struct ifnet *);
+void in_prefixlen2mask(struct in_addr *, int);
#endif
#endif /* _NETINET_IN_VAR_H_ */
diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c
index dc75f5486b4..101e36864eb 100644
--- a/sys/netinet6/in6_proto.c
+++ b/sys/netinet6/in6_proto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in6_proto.c,v 1.83 2015/12/03 12:42:03 goda Exp $ */
+/* $OpenBSD: in6_proto.c,v 1.84 2015/12/03 21:57:59 mpi Exp $ */
/* $KAME: in6_proto.c,v 1.66 2000/10/10 15:35:47 itojun Exp $ */
/*
@@ -259,7 +259,7 @@ struct domain inet6domain =
(struct protosw *)inet6sw,
(struct protosw *)&inet6sw[nitems(inet6sw)],
sizeof(struct sockaddr_in6),
- offsetof(struct sockaddr_in6, sin6_addr),
+ offsetof(struct sockaddr_in6, sin6_addr), 128,
in6_domifattach, in6_domifdetach, };
/*
diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c
index 0c0da720fb3..be302ac19d5 100644
--- a/sys/netinet6/nd6.c
+++ b/sys/netinet6/nd6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nd6.c,v 1.175 2015/12/02 16:35:53 bluhm Exp $ */
+/* $OpenBSD: nd6.c,v 1.176 2015/12/03 21:57:59 mpi Exp $ */
/* $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $ */
/*
@@ -893,9 +893,7 @@ nd6_rtrequest(struct ifnet *ifp, int req, struct rtentry *rt)
if (req == RTM_DELETE && (rt->rt_flags & RTF_GATEWAY) &&
(IN6_ARE_ADDR_EQUAL(&(satosin6(rt_key(rt)))->sin6_addr,
- &in6addr_any) && rt_mask(rt) && (rt_mask(rt)->sa_len == 0 ||
- IN6_ARE_ADDR_EQUAL(&(satosin6(rt_mask(rt)))->sin6_addr,
- &in6addr_any)))) {
+ &in6addr_any) && rt_plen(rt) == 0)) {
dr = defrouter_lookup(&satosin6(gate)->sin6_addr,
ifp->if_index);
if (dr)
diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c
index 84bc27c8b96..acaff81da84 100644
--- a/sys/netinet6/nd6_rtr.c
+++ b/sys/netinet6/nd6_rtr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nd6_rtr.c,v 1.135 2015/12/01 21:29:10 mpi Exp $ */
+/* $OpenBSD: nd6_rtr.c,v 1.136 2015/12/03 21:57:59 mpi Exp $ */
/* $KAME: nd6_rtr.c,v 1.97 2001/02/07 11:09:13 itojun Exp $ */
/*
@@ -2056,6 +2056,7 @@ rt6_deleteroute(struct rtentry *rt, void *arg, unsigned int id)
{
struct rt_addrinfo info;
struct in6_addr *gate = (struct in6_addr *)arg;
+ struct sockaddr_in6 sa_mask;
if (rt->rt_gateway == NULL || rt->rt_gateway->sa_family != AF_INET6)
return (0);
@@ -2082,6 +2083,6 @@ rt6_deleteroute(struct rtentry *rt, void *arg, unsigned int id)
info.rti_flags = rt->rt_flags;
info.rti_info[RTAX_DST] = rt_key(rt);
info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
- info.rti_info[RTAX_NETMASK] = rt_mask(rt);
+ info.rti_info[RTAX_NETMASK] = rt_plen2mask(rt, &sa_mask);
return (rtrequest(RTM_DELETE, &info, RTP_ANY, NULL, id));
}
diff --git a/sys/netmpls/mpls_proto.c b/sys/netmpls/mpls_proto.c
index c485c56381a..b35e2b065a1 100644
--- a/sys/netmpls/mpls_proto.c
+++ b/sys/netmpls/mpls_proto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mpls_proto.c,v 1.13 2015/10/07 10:50:35 mpi Exp $ */
+/* $OpenBSD: mpls_proto.c,v 1.14 2015/12/03 21:57:59 mpi Exp $ */
/*
* Copyright (C) 1999, 2000 and 2001 AYAME Project, WIDE Project.
@@ -69,5 +69,5 @@ struct domain mplsdomain = {
mplssw,
&mplssw[nitems(mplssw)],
sizeof(struct sockaddr_mpls),
- offsetof(struct sockaddr_mpls, smpls_label)
+ offsetof(struct sockaddr_mpls, smpls_label), 32
};