summaryrefslogtreecommitdiff
path: root/sys/netinet/in_pcb.c
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2024-02-07 23:40:41 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2024-02-07 23:40:41 +0000
commitaf84b5e283a349e2b566baeed4bbdd002816897e (patch)
treea0853b62f1f971a6aa41f094e269d17c255e5dbd /sys/netinet/in_pcb.c
parentc6a8baddffcdc9c4853a355600619a55d7055cff (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/netinet/in_pcb.c')
-rw-r--r--sys/netinet/in_pcb.c22
1 files changed, 4 insertions, 18 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index fd6417eead0..456135a722c 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in_pcb.c,v 1.289 2024/02/02 15:39:23 bluhm Exp $ */
+/* $OpenBSD: in_pcb.c,v 1.290 2024/02/07 23:40:40 bluhm Exp $ */
/* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */
/*
@@ -916,24 +916,10 @@ in_pcbrtentry(struct inpcb *inp)
ro = &inp->inp_route;
- /* 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 (inp->inp_faddr.s_addr == INADDR_ANY)
+ return (NULL);
+ route_cache(ro, inp->inp_faddr, inp->inp_rtableid);
if (ro->ro_rt == NULL) {
- memset(ro, 0, sizeof(struct route));
-
- if (inp->inp_faddr.s_addr == INADDR_ANY)
- return (NULL);
- ro->ro_dst.sa_family = AF_INET;
- ro->ro_dst.sa_len = sizeof(struct sockaddr_in);
- satosin(&ro->ro_dst)->sin_addr = inp->inp_faddr;
- ro->ro_tableid = inp->inp_rtableid;
ro->ro_rt = rtalloc_mpath(&ro->ro_dst,
&inp->inp_laddr.s_addr, ro->ro_tableid);
}