From f448ef3672f16ab4039c0990f4181b16111956bc Mon Sep 17 00:00:00 2001 From: Martin Pieuchot Date: Thu, 3 Dec 2015 21:58:00 +0000 Subject: Get rid of rt_mask() and stop allocating a "struct sockaddr" for every route entry in ART. rt_plen() now represents the prefix length of a route entry and should be used instead. For now use a "struct sockaddr_in6" to represent the mask when needed, this should be then replaced by the prefix length and RTA_NETMASK only used for compatibility with userland. ok claudio@ --- sys/netinet6/in6_proto.c | 4 ++-- sys/netinet6/nd6.c | 6 ++---- sys/netinet6/nd6_rtr.c | 5 +++-- 3 files changed, 7 insertions(+), 8 deletions(-) (limited to 'sys/netinet6') 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)); } -- cgit v1.2.3