From 51a4bd63b67539da721dc5a35bb5bb2f89469b03 Mon Sep 17 00:00:00 2001 From: Alexander Bluhm Date: Tue, 13 Feb 2024 12:22:10 +0000 Subject: Merge struct route and struct route_in6. Use a common struct route for both inet and inet6. Unfortunately struct sockaddr is shorter than sockaddr_in6, so netinet/in.h has to be exposed from net/route.h. Struct route has to be bsd visible for userland as netstat kvm code inspects inp_route. Internet PCB and TCP SYN cache can use a plain struct route now. All specific sockaddr types for inet and inet6 are embeded there. OK claudio@ --- sys/net/route.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'sys/net/route.c') diff --git a/sys/net/route.c b/sys/net/route.c index bb9c7b05099..f9915cdf7c1 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.431 2024/02/09 14:02:11 bluhm Exp $ */ +/* $OpenBSD: route.c,v 1.432 2024/02/13 12:22:09 bluhm Exp $ */ /* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */ /* @@ -212,8 +212,8 @@ route_cache(struct route *ro, struct in_addr addr, u_int rtableid) if (rtisvalid(ro->ro_rt) && ro->ro_generation == gen && ro->ro_tableid == rtableid && - ro->ro_dst.sa_family == AF_INET && - satosin(&ro->ro_dst)->sin_addr.s_addr == addr.s_addr) { + ro->ro_dstsa.sa_family == AF_INET && + ro->ro_dstsin.sin_addr.s_addr == addr.s_addr) { ipstat_inc(ips_rtcachehit); return (0); } @@ -225,17 +225,16 @@ route_cache(struct route *ro, struct in_addr addr, u_int rtableid) ro->ro_tableid = rtableid; memset(&ro->ro_dst, 0, sizeof(ro->ro_dst)); - satosin(&ro->ro_dst)->sin_family = AF_INET; - satosin(&ro->ro_dst)->sin_len = sizeof(struct sockaddr_in); - satosin(&ro->ro_dst)->sin_addr = addr; + ro->ro_dstsin.sin_family = AF_INET; + ro->ro_dstsin.sin_len = sizeof(struct sockaddr_in); + ro->ro_dstsin.sin_addr = addr; return (ESRCH); } #ifdef INET6 int -route6_cache(struct route_in6 *ro, const struct in6_addr *addr, - u_int rtableid) +route6_cache(struct route *ro, const struct in6_addr *addr, u_int rtableid) { u_long gen; @@ -245,8 +244,8 @@ route6_cache(struct route_in6 *ro, const struct in6_addr *addr, if (rtisvalid(ro->ro_rt) && ro->ro_generation == gen && ro->ro_tableid == rtableid && - ro->ro_dst.sin6_family == AF_INET6 && - IN6_ARE_ADDR_EQUAL(&ro->ro_dst.sin6_addr, addr)) { + ro->ro_dstsa.sa_family == AF_INET6 && + IN6_ARE_ADDR_EQUAL(&ro->ro_dstsin6.sin6_addr, addr)) { ip6stat_inc(ip6s_rtcachehit); return (0); } @@ -258,9 +257,9 @@ route6_cache(struct route_in6 *ro, const struct in6_addr *addr, ro->ro_tableid = rtableid; memset(&ro->ro_dst, 0, sizeof(ro->ro_dst)); - ro->ro_dst.sin6_family = AF_INET6; - ro->ro_dst.sin6_len = sizeof(struct sockaddr_in6); - ro->ro_dst.sin6_addr = *addr; + ro->ro_dstsin6.sin6_family = AF_INET6; + ro->ro_dstsin6.sin6_len = sizeof(struct sockaddr_in6); + ro->ro_dstsin6.sin6_addr = *addr; return (ESRCH); } -- cgit v1.2.3