summaryrefslogtreecommitdiff
path: root/sys/net/route.c
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2024-02-13 12:22:10 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2024-02-13 12:22:10 +0000
commit51a4bd63b67539da721dc5a35bb5bb2f89469b03 (patch)
tree39e4574b40e1dbe7366e3f136571e208bf64a921 /sys/net/route.c
parent3c439a064ae7c61486a17ce1a42cb72e23a6b58f (diff)
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@
Diffstat (limited to 'sys/net/route.c')
-rw-r--r--sys/net/route.c25
1 files changed, 12 insertions, 13 deletions
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);
}