-/* $OpenBSD: in_pcb.c,v 1.287 2024/01/28 20:34:25 bluhm Exp $ */
+/* $OpenBSD: in_pcb.c,v 1.288 2024/01/31 12:27:57 bluhm Exp $ */
/* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */
/*
{
struct route *ro;
+#ifdef INET6
+ if (ISSET(inp->inp_flags, INP_IPV6))
+ in6_pcbrtentry(inp);
+#endif
+
ro = &inp->inp_route;
/* check if route is still valid */
* No route yet, so try to acquire one.
*/
if (ro->ro_rt == NULL) {
-#ifdef INET6
- memset(ro, 0, sizeof(struct route_in6));
-#else
memset(ro, 0, sizeof(struct route));
-#endif
-#ifdef INET6
- if (ISSET(inp->inp_flags, INP_IPV6)) {
- if (IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6))
- return (NULL);
- ro->ro_dst.sa_family = AF_INET6;
- ro->ro_dst.sa_len = sizeof(struct sockaddr_in6);
- satosin6(&ro->ro_dst)->sin6_addr = inp->inp_faddr6;
- ro->ro_tableid = inp->inp_rtableid;
- ro->ro_rt = rtalloc_mpath(&ro->ro_dst,
- &inp->inp_laddr6.s6_addr32[0], ro->ro_tableid);
- } else
-#endif /* INET6 */
- {
- 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);
- }
+ 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);
}
return (ro->ro_rt);
}
-/* $OpenBSD: in_pcb.h,v 1.149 2024/01/28 20:34:25 bluhm Exp $ */
+/* $OpenBSD: in_pcb.h,v 1.150 2024/01/31 12:27:57 bluhm Exp $ */
/* $NetBSD: in_pcb.h,v 1.14 1996/02/13 23:42:00 christos Exp $ */
/*
in_pcbrtentry(struct inpcb *);
/* INET6 stuff */
+struct rtentry *
+ in6_pcbrtentry(struct inpcb *);
void in6_pcbnotify(struct inpcbtable *, const struct sockaddr_in6 *,
u_int, const struct sockaddr_in6 *, u_int, u_int, int, void *,
void (*)(struct inpcb *, int));
-/* $OpenBSD: in6_pcb.c,v 1.133 2024/01/28 20:34:25 bluhm Exp $ */
+/* $OpenBSD: in6_pcb.c,v 1.134 2024/01/31 12:27:57 bluhm Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
rw_exit_write(&table->inpt_notify);
}
+struct rtentry *
+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 (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);
+ }
+ return (ro->ro_rt);
+}
+
struct inpcb *
in6_pcbhash_lookup(struct inpcbtable *table, uint64_t hash, u_int rdomain,
const struct in6_addr *faddr, u_short fport,
-/* $OpenBSD: ip6_output.c,v 1.283 2024/01/18 11:03:16 claudio Exp $ */
+/* $OpenBSD: ip6_output.c,v 1.284 2024/01/31 12:27:57 bluhm Exp $ */
/* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */
/*
if (!(so->so_state & SS_ISCONNECTED))
return (ENOTCONN);
- rt = in_pcbrtentry(inp);
+ rt = in6_pcbrtentry(inp);
if (!rtisvalid(rt))
return (EHOSTUNREACH);