From: bluhm Date: Tue, 28 Nov 2023 13:23:20 +0000 (+0000) Subject: Remove struct inpcb from in6_embedscope() parameters. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=952c6363a519d5ecee6717646d7c24b911461cd2;p=openbsd Remove struct inpcb from in6_embedscope() parameters. rip6_output() did modify inp_outputopts6 temporarily to provide different ip6_pktopts to in6_embedscope(). Better pass inp_outputopts6 and inp_moptions6 as separate arguments to in6_embedscope(). Simplify the code that deals with these options in in6_embedscope(). Doucument inp_moptions and inp_moptions6 as protected by net lock. OK kn@ --- diff --git a/sys/net/if_etherip.c b/sys/net/if_etherip.c index 4abd3f167e4..e9b9896e47f 100644 --- a/sys/net/if_etherip.c +++ b/sys/net/if_etherip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_etherip.c,v 1.51 2023/09/16 09:33:27 mpi Exp $ */ +/* $OpenBSD: if_etherip.c,v 1.52 2023/11/28 13:23:20 bluhm Exp $ */ /* * Copyright (c) 2015 Kazuya GODA * @@ -422,11 +422,11 @@ etherip_set_tunnel(struct etherip_softc *sc, struct if_laddrreq *req) IN6_IS_ADDR_MULTICAST(&dst6->sin6_addr)) return (EINVAL); - error = in6_embedscope(&sc->sc_tunnel.t_src6, src6, NULL); + error = in6_embedscope(&sc->sc_tunnel.t_src6, src6, NULL, NULL); if (error != 0) return (error); - error = in6_embedscope(&sc->sc_tunnel.t_dst6, dst6, NULL); + error = in6_embedscope(&sc->sc_tunnel.t_dst6, dst6, NULL, NULL); if (error != 0) return (error); diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c index 93e99a79650..1084251e618 100644 --- a/sys/net/if_gif.c +++ b/sys/net/if_gif.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_gif.c,v 1.133 2021/05/16 15:10:20 deraadt Exp $ */ +/* $OpenBSD: if_gif.c,v 1.134 2023/11/28 13:23:20 bluhm Exp $ */ /* $KAME: if_gif.c,v 1.43 2001/02/20 08:51:07 itojun Exp $ */ /* @@ -687,11 +687,11 @@ gif_set_tunnel(struct gif_softc *sc, struct if_laddrreq *req) if (IN6_IS_ADDR_MULTICAST(&dst6->sin6_addr)) return (EINVAL); - error = in6_embedscope(&tunnel->t_src6, src6, NULL); + error = in6_embedscope(&tunnel->t_src6, src6, NULL, NULL); if (error != 0) return (error); - error = in6_embedscope(&tunnel->t_dst6, dst6, NULL); + error = in6_embedscope(&tunnel->t_dst6, dst6, NULL, NULL); if (error != 0) return (error); diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c index 6204ed40a74..830e5c14312 100644 --- a/sys/net/if_gre.c +++ b/sys/net/if_gre.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_gre.c,v 1.175 2023/10/27 20:56:47 jan Exp $ */ +/* $OpenBSD: if_gre.c,v 1.176 2023/11/28 13:23:20 bluhm Exp $ */ /* $NetBSD: if_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */ /* @@ -2379,7 +2379,7 @@ mgre_set_tunnel(struct mgre_softc *sc, struct if_laddrreq *req) IN6_IS_ADDR_MULTICAST(&addr6->sin6_addr)) return (EINVAL); - error = in6_embedscope(&tunnel->t_src6, addr6, NULL); + error = in6_embedscope(&tunnel->t_src6, addr6, NULL, NULL); if (error != 0) return (error); @@ -3122,11 +3122,11 @@ gre_set_tunnel(struct gre_tunnel *tunnel, struct if_laddrreq *req, int ucast) if (src6->sin6_scope_id != dst6->sin6_scope_id) return (EINVAL); - error = in6_embedscope(&tunnel->t_src6, src6, NULL); + error = in6_embedscope(&tunnel->t_src6, src6, NULL, NULL); if (error != 0) return (error); - error = in6_embedscope(&tunnel->t_dst6, dst6, NULL); + error = in6_embedscope(&tunnel->t_dst6, dst6, NULL, NULL); if (error != 0) return (error); @@ -3609,7 +3609,7 @@ nvgre_add_addr(struct nvgre_softc *sc, const struct ifbareq *ifba) if (src6.sin6_scope_id != sin6->sin6_scope_id) return (EADDRNOTAVAIL); - error = in6_embedscope(&endpoint.in6, sin6, NULL); + error = in6_embedscope(&endpoint.in6, sin6, NULL, NULL); if (error != 0) return (error); diff --git a/sys/net/if_vxlan.c b/sys/net/if_vxlan.c index 42d2347a87e..3a82ca3366a 100644 --- a/sys/net/if_vxlan.c +++ b/sys/net/if_vxlan.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vxlan.c,v 1.95 2023/11/18 00:23:38 dlg Exp $ */ +/* $OpenBSD: if_vxlan.c,v 1.96 2023/11/28 13:23:20 bluhm Exp $ */ /* * Copyright (c) 2021 David Gwynne @@ -1385,12 +1385,12 @@ vxlan_set_tunnel(struct vxlan_softc *sc, const struct if_laddrreq *req) /* all good */ mode = IN6_IS_ADDR_MULTICAST(&dst6->sin6_addr) ? VXLAN_TMODE_LEARNING : VXLAN_TMODE_P2P; - error = in6_embedscope(&daddr.in6, dst6, NULL); + error = in6_embedscope(&daddr.in6, dst6, NULL, NULL); if (error != 0) return (error); } - error = in6_embedscope(&saddr.in6, src6, NULL); + error = in6_embedscope(&saddr.in6, src6, NULL, NULL); if (error != 0) return (error); @@ -1703,7 +1703,7 @@ vxlan_add_addr(struct vxlan_softc *sc, const struct ifbareq *ifba) if (sin6->sin6_port != htons(0)) return (EADDRNOTAVAIL); - error = in6_embedscope(&endpoint.in6, sin6, NULL); + error = in6_embedscope(&endpoint.in6, sin6, NULL, NULL); if (error != 0) return (error); diff --git a/sys/net/pfkeyv2_convert.c b/sys/net/pfkeyv2_convert.c index 2a7e1d94c45..47b9743ec84 100644 --- a/sys/net/pfkeyv2_convert.c +++ b/sys/net/pfkeyv2_convert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfkeyv2_convert.c,v 1.82 2023/10/11 22:13:16 tobhe Exp $ */ +/* $OpenBSD: pfkeyv2_convert.c,v 1.83 2023/11/28 13:23:20 bluhm Exp $ */ /* * The author of this code is Angelos D. Keromytis (angelos@keromytis.org) * @@ -484,10 +484,8 @@ import_flow(struct sockaddr_encap *flow, struct sockaddr_encap *flowmask, #ifdef INET6 case AF_INET6: - in6_embedscope(&src->sin6.sin6_addr, &src->sin6, - NULL); - in6_embedscope(&dst->sin6.sin6_addr, &dst->sin6, - NULL); + in6_embedscope(&src->sin6.sin6_addr, &src->sin6, NULL, NULL); + in6_embedscope(&dst->sin6.sin6_addr, &dst->sin6, NULL, NULL); /* netmask handling */ rt_maskedcopy(&src->sa, &src->sa, &srcmask->sa); diff --git a/sys/net/pipex.c b/sys/net/pipex.c index 71bd7bbec25..ac42168076b 100644 --- a/sys/net/pipex.c +++ b/sys/net/pipex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pipex.c,v 1.149 2023/09/16 09:33:27 mpi Exp $ */ +/* $OpenBSD: pipex.c,v 1.150 2023/11/28 13:23:20 bluhm Exp $ */ /*- * Copyright (c) 2009 Internet Initiative Japan Inc. @@ -1920,8 +1920,7 @@ pipex_l2tp_output(struct mbuf *m0, struct pipex_session *session) ip6->ip6_vfc |= IPV6_VERSION; ip6->ip6_nxt = IPPROTO_UDP; ip6->ip6_src = session->local.sin6.sin6_addr; - (void)in6_embedscope(&ip6->ip6_dst, - &session->peer.sin6, NULL); + in6_embedscope(&ip6->ip6_dst, &session->peer.sin6, NULL, NULL); /* ip6->ip6_plen will be filled in ip6_output. */ ip6_send(m0); diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index 7118488fd68..088d59c4885 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.h,v 1.138 2023/11/26 22:08:10 bluhm Exp $ */ +/* $OpenBSD: in_pcb.h,v 1.139 2023/11/28 13:23:20 bluhm Exp $ */ /* $NetBSD: in_pcb.h,v 1.14 1996/02/13 23:42:00 christos Exp $ */ /* @@ -136,11 +136,11 @@ struct inpcb { struct ip6_pktopts *inp_outputopts6; /* IP6 options for outgoing packets */ int inp_hops; union { - struct ip_moptions *mou_mo; /* IPv4 multicast options */ - struct ip6_moptions *mou_mo6; /* IPv6 multicast options */ + struct ip_moptions *mou_mo; + struct ip6_moptions *mou_mo6; } inp_mou; -#define inp_moptions inp_mou.mou_mo -#define inp_moptions6 inp_mou.mou_mo6 +#define inp_moptions inp_mou.mou_mo /* [N] IPv4 multicast options */ +#define inp_moptions6 inp_mou.mou_mo6 /* [N] IPv6 multicast options */ u_char inp_seclevel[4]; /* [N] IPsec level of socket */ #define SL_AUTH 0 /* Authentication level */ #define SL_ESP_TRANS 1 /* ESP transport level */ diff --git a/sys/netinet/ip_ipip.c b/sys/netinet/ip_ipip.c index f56caca9841..86e4c0d0c91 100644 --- a/sys/netinet/ip_ipip.c +++ b/sys/netinet/ip_ipip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_ipip.c,v 1.99 2023/09/16 09:33:27 mpi Exp $ */ +/* $OpenBSD: ip_ipip.c,v 1.100 2023/11/28 13:23:20 bluhm Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr) and @@ -481,8 +481,8 @@ ipip_output(struct mbuf **mp, struct tdb *tdb) ip6o->ip6_vfc |= IPV6_VERSION; ip6o->ip6_plen = htons(m->m_pkthdr.len - sizeof(*ip6o)); ip6o->ip6_hlim = ip_defttl; - in6_embedscope(&ip6o->ip6_src, &tdb->tdb_src.sin6, NULL); - in6_embedscope(&ip6o->ip6_dst, &tdb->tdb_dst.sin6, NULL); + in6_embedscope(&ip6o->ip6_src, &tdb->tdb_src.sin6, NULL, NULL); + in6_embedscope(&ip6o->ip6_dst, &tdb->tdb_dst.sin6, NULL, NULL); if (tp == IPVERSION) { /* Save ECN notification */ diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 5cb98fba0b2..e83ad108289 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_usrreq.c,v 1.223 2023/11/16 18:27:48 bluhm Exp $ */ +/* $OpenBSD: tcp_usrreq.c,v 1.224 2023/11/28 13:23:20 bluhm Exp $ */ /* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */ /* @@ -1154,11 +1154,11 @@ tcp_ident(void *oldp, size_t *oldlenp, void *newp, size_t newlen, int dodrop) #ifdef INET6 case AF_INET6: fin6 = (struct sockaddr_in6 *)&tir.faddr; - error = in6_embedscope(&f6, fin6, NULL); + error = in6_embedscope(&f6, fin6, NULL, NULL); if (error) return EINVAL; /*?*/ lin6 = (struct sockaddr_in6 *)&tir.laddr; - error = in6_embedscope(&l6, lin6, NULL); + error = in6_embedscope(&l6, lin6, NULL, NULL); if (error) return EINVAL; /*?*/ break; diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 0ab353d8f28..f4250a833ce 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp_usrreq.c,v 1.308 2023/11/27 20:37:15 bluhm Exp $ */ +/* $OpenBSD: udp_usrreq.c,v 1.309 2023/11/28 13:23:20 bluhm Exp $ */ /* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */ /* @@ -751,7 +751,7 @@ udp6_ctlinput(int cmd, struct sockaddr *sa, u_int rdomain, void *d) cmdarg = NULL; /* XXX: translate addresses into internal form */ sa6 = *satosin6(sa); - if (in6_embedscope(&sa6.sin6_addr, &sa6, NULL)) { + if (in6_embedscope(&sa6.sin6_addr, &sa6, NULL, NULL)) { /* should be impossible */ return; } @@ -765,14 +765,14 @@ udp6_ctlinput(int cmd, struct sockaddr *sa, u_int rdomain, void *d) /* XXX: assuming M is valid in this case */ sa6.sin6_scope_id = in6_addr2scopeid(m->m_pkthdr.ph_ifidx, ip6cp->ip6c_finaldst); - if (in6_embedscope(ip6cp->ip6c_finaldst, &sa6, NULL)) { + if (in6_embedscope(ip6cp->ip6c_finaldst, &sa6, NULL, NULL)) { /* should be impossible */ return; } } else { /* XXX: translate addresses into internal form */ sa6 = *satosin6(sa); - if (in6_embedscope(&sa6.sin6_addr, &sa6, NULL)) { + if (in6_embedscope(&sa6.sin6_addr, &sa6, NULL, NULL)) { /* should be impossible */ return; } @@ -798,7 +798,7 @@ udp6_ctlinput(int cmd, struct sockaddr *sa, u_int rdomain, void *d) sa6_src.sin6_addr = ip6->ip6_src; sa6_src.sin6_scope_id = in6_addr2scopeid(m->m_pkthdr.ph_ifidx, &ip6->ip6_src); - if (in6_embedscope(&sa6_src.sin6_addr, &sa6_src, NULL)) { + if (in6_embedscope(&sa6_src.sin6_addr, &sa6_src, NULL, NULL)) { /* should be impossible */ return; } diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c index 868f3f5d755..aece612d01f 100644 --- a/sys/netinet6/icmp6.c +++ b/sys/netinet6/icmp6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: icmp6.c,v 1.249 2023/09/16 09:33:27 mpi Exp $ */ +/* $OpenBSD: icmp6.c,v 1.250 2023/11/28 13:23:20 bluhm Exp $ */ /* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */ /* @@ -910,7 +910,8 @@ icmp6_notify_error(struct mbuf *m, int off, int icmp6len, int code) icmp6dst.sin6_addr = *finaldst; icmp6dst.sin6_scope_id = in6_addr2scopeid(m->m_pkthdr.ph_ifidx, &icmp6dst.sin6_addr); - if (in6_embedscope(&icmp6dst.sin6_addr, &icmp6dst, NULL)) { + if (in6_embedscope(&icmp6dst.sin6_addr, &icmp6dst, + NULL, NULL)) { /* should be impossible */ nd6log((LOG_DEBUG, "icmp6_notify_error: in6_embedscope failed\n")); @@ -927,7 +928,8 @@ icmp6_notify_error(struct mbuf *m, int off, int icmp6len, int code) icmp6src.sin6_addr = eip6->ip6_src; icmp6src.sin6_scope_id = in6_addr2scopeid(m->m_pkthdr.ph_ifidx, &icmp6src.sin6_addr); - if (in6_embedscope(&icmp6src.sin6_addr, &icmp6src, NULL)) { + if (in6_embedscope(&icmp6src.sin6_addr, &icmp6src, + NULL, NULL)) { /* should be impossible */ nd6log((LOG_DEBUG, "icmp6_notify_error: in6_embedscope failed\n")); diff --git a/sys/netinet6/in6.h b/sys/netinet6/in6.h index 1a022f4c2e4..936ef6c9465 100644 --- a/sys/netinet6/in6.h +++ b/sys/netinet6/in6.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in6.h,v 1.110 2023/11/10 20:05:23 bluhm Exp $ */ +/* $OpenBSD: in6.h,v 1.111 2023/11/28 13:23:20 bluhm Exp $ */ /* $KAME: in6.h,v 1.83 2001/03/29 02:55:07 jinmei Exp $ */ /* @@ -427,10 +427,11 @@ int in6_mask2len(struct in6_addr *, u_char *); int in6_nam2sin6(const struct mbuf *, struct sockaddr_in6 **); int in6_sa2sin6(struct sockaddr *, struct sockaddr_in6 **); -struct inpcb; +struct ip6_pktopts; +struct ip6_moptions; int in6_embedscope(struct in6_addr *, const struct sockaddr_in6 *, - struct inpcb *); + const struct ip6_pktopts *, const struct ip6_moptions *); void in6_recoverscope(struct sockaddr_in6 *, const struct in6_addr *); void in6_clearscope(struct in6_addr *); diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index 5feb33c820c..dc7e6144801 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_pcb.c,v 1.124 2023/06/24 20:54:46 bluhm Exp $ */ +/* $OpenBSD: in6_pcb.c,v 1.125 2023/11/28 13:23:20 bluhm Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -157,7 +157,8 @@ in6_pcbaddrisavail(struct inpcb *inp, struct sockaddr_in6 *sin6, int wild, wild |= INPLOOKUP_IPV6; /* KAME hack: embed scopeid */ - if (in6_embedscope(&sin6->sin6_addr, sin6, inp) != 0) + if (in6_embedscope(&sin6->sin6_addr, sin6, + inp->inp_outputopts6, inp->inp_moptions6) != 0) return (EINVAL); /* this must be cleared for ifa_ifwithaddr() */ sin6->sin6_scope_id = 0; @@ -265,8 +266,9 @@ in6_pcbconnect(struct inpcb *inp, struct mbuf *nam) sin6 = &tmp; /* KAME hack: embed scopeid */ - if (in6_embedscope(&sin6->sin6_addr, sin6, inp) != 0) - return EINVAL; + if (in6_embedscope(&sin6->sin6_addr, sin6, + inp->inp_outputopts6, inp->inp_moptions6) != 0) + return (EINVAL); /* this must be cleared for ifa_ifwithaddr() */ sin6->sin6_scope_id = 0; diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c index 3825e5e45bc..a3741c0892d 100644 --- a/sys/netinet6/in6_src.c +++ b/sys/netinet6/in6_src.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_src.c,v 1.86 2022/02/22 01:15:02 guenther Exp $ */ +/* $OpenBSD: in6_src.c,v 1.87 2023/11/28 13:23:20 bluhm Exp $ */ /* $KAME: in6_src.c,v 1.36 2001/02/06 04:08:17 itojun Exp $ */ /* @@ -447,13 +447,11 @@ in6_selecthlim(struct inpcb *in6p) */ int in6_embedscope(struct in6_addr *in6, const struct sockaddr_in6 *sin6, - struct inpcb *in6p) + const struct ip6_pktopts *outputopts6, const struct ip6_moptions *moptions6) { - struct ifnet *ifp = NULL; u_int32_t scopeid; *in6 = sin6->sin6_addr; - scopeid = sin6->sin6_scope_id; /* * don't try to read sin6->sin6_addr beyond here, since the caller may @@ -467,25 +465,25 @@ in6_embedscope(struct in6_addr *in6, const struct sockaddr_in6 *sin6, * KAME assumption: link id == interface id */ - if (in6p && in6p->inp_outputopts6 && - (pi = in6p->inp_outputopts6->ip6po_pktinfo) && - pi->ipi6_ifindex) { - ifp = if_get(pi->ipi6_ifindex); - if (ifp == NULL) - return ENXIO; /* XXX EINVAL? */ - in6->s6_addr16[1] = htons(pi->ipi6_ifindex); - } else if (in6p && IN6_IS_ADDR_MULTICAST(in6) && - in6p->inp_moptions6 && - (ifp = if_get(in6p->inp_moptions6->im6o_ifidx))) { - in6->s6_addr16[1] = htons(ifp->if_index); - } else if (scopeid) { + if (outputopts6 && (pi = outputopts6->ip6po_pktinfo) && + pi->ipi6_ifindex) + scopeid = pi->ipi6_ifindex; + else if (moptions6 && IN6_IS_ADDR_MULTICAST(in6) && + moptions6->im6o_ifidx) + scopeid = moptions6->im6o_ifidx; + else + scopeid = sin6->sin6_scope_id; + + if (scopeid) { + struct ifnet *ifp; + ifp = if_get(scopeid); if (ifp == NULL) return ENXIO; /* XXX EINVAL? */ /*XXX assignment to 16bit from 32bit variable */ in6->s6_addr16[1] = htons(scopeid & 0xffff); + if_put(ifp); } - if_put(ifp); } return 0; diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index df8fecdc9ed..96e0bea3b98 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_output.c,v 1.280 2023/11/26 22:08:10 bluhm Exp $ */ +/* $OpenBSD: ip6_output.c,v 1.281 2023/11/28 13:23:20 bluhm Exp $ */ /* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */ /* @@ -2808,7 +2808,7 @@ ip6_output_ipsec_pmtu_update(struct tdb *tdb, struct route_in6 *ro, sin6.sin6_len = sizeof(sin6); sin6.sin6_addr = *dst; sin6.sin6_scope_id = in6_addr2scopeid(ifidx, dst); - error = in6_embedscope(dst, &sin6, NULL); + error = in6_embedscope(dst, &sin6, NULL, NULL); if (error) { /* should be impossible */ return error; diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c index e4ff181897d..0a91302e407 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raw_ip6.c,v 1.174 2023/11/26 22:08:10 bluhm Exp $ */ +/* $OpenBSD: raw_ip6.c,v 1.175 2023/11/28 13:23:20 bluhm Exp $ */ /* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */ /* @@ -384,7 +384,7 @@ rip6_output(struct mbuf *m, struct socket *so, struct sockaddr *dstaddr, struct inpcb *in6p; u_int plen = m->m_pkthdr.len; int error = 0; - struct ip6_pktopts opt, *optp = NULL, *origoptp; + struct ip6_pktopts opt, *optp = NULL; int type; /* for ICMPv6 output statistics only */ int priv = 0; int flags; @@ -441,13 +441,11 @@ rip6_output(struct mbuf *m, struct socket *so, struct sockaddr *dstaddr, ip6->ip6_dst = *dst; /* KAME hack: embed scopeid */ - origoptp = in6p->inp_outputopts6; - in6p->inp_outputopts6 = optp; - if (in6_embedscope(&ip6->ip6_dst, satosin6(dstaddr), in6p) != 0) { + if (in6_embedscope(&ip6->ip6_dst, satosin6(dstaddr), + optp, in6p->inp_moptions6) != 0) { error = EINVAL; goto bad; } - in6p->inp_outputopts6 = origoptp; /* * Source address selection. diff --git a/sys/netinet6/udp6_output.c b/sys/netinet6/udp6_output.c index 15f7ad06a39..876b9b753a8 100644 --- a/sys/netinet6/udp6_output.c +++ b/sys/netinet6/udp6_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp6_output.c,v 1.60 2023/11/26 22:08:10 bluhm Exp $ */ +/* $OpenBSD: udp6_output.c,v 1.61 2023/11/28 13:23:20 bluhm Exp $ */ /* $KAME: udp6_output.c,v 1.21 2001/02/07 11:51:54 itojun Exp $ */ /* @@ -143,7 +143,8 @@ udp6_output(struct inpcb *in6p, struct mbuf *m, struct mbuf *addr6, fport = sin6->sin6_port; /* allow 0 port */ /* KAME hack: embed scopeid */ - if (in6_embedscope(&sin6->sin6_addr, sin6, in6p) != 0) { + if (in6_embedscope(&sin6->sin6_addr, sin6, + in6p->inp_outputopts6, in6p->inp_moptions6) != 0) { error = EINVAL; goto release; }