diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2024-02-07 23:40:41 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2024-02-07 23:40:41 +0000 |
commit | af84b5e283a349e2b566baeed4bbdd002816897e (patch) | |
tree | a0853b62f1f971a6aa41f094e269d17c255e5dbd /sys/netinet6/in6_pcb.c | |
parent | c6a8baddffcdc9c4853a355600619a55d7055cff (diff) |
Use the route generation number also for IPv6.
Implement route6_cache() to check whether the cached route is still
valid and otherwise fill caching parameter of struct route_in6.
Also count cache hits and misses in netstat. in_pcbrtentry() uses
route cache now.
OK claudio@
Diffstat (limited to 'sys/netinet6/in6_pcb.c')
-rw-r--r-- | sys/netinet6/in6_pcb.c | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index d447beb8329..0be0c4587d0 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_pcb.c,v 1.134 2024/01/31 12:27:57 bluhm Exp $ */ +/* $OpenBSD: in6_pcb.c,v 1.135 2024/02/07 23:40:40 bluhm Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -566,24 +566,10 @@ in6_pcbrtentry(struct inpcb *inp) { struct route_in6 *ro = &inp->inp_route6; - /* check if route is still valid */ - if (!rtisvalid(ro->ro_rt)) { - rtfree(ro->ro_rt); - ro->ro_rt = NULL; - } - - /* - * No route yet, so try to acquire one. - */ + if (IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6)) + return (NULL); + route6_cache(ro, &inp->inp_faddr6, inp->inp_rtableid); if (ro->ro_rt == NULL) { - memset(ro, 0, sizeof(struct route_in6)); - - if (IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6)) - return (NULL); - ro->ro_dst.sin6_family = AF_INET6; - ro->ro_dst.sin6_len = sizeof(struct sockaddr_in6); - ro->ro_dst.sin6_addr = inp->inp_faddr6; - ro->ro_tableid = inp->inp_rtableid; ro->ro_rt = rtalloc_mpath(sin6tosa(&ro->ro_dst), &inp->inp_laddr6.s6_addr32[0], ro->ro_tableid); } |