-/* $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 <goda@openbsd.org>
*
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);
-/* $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 $ */
/*
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);
-/* $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 $ */
/*
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);
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);
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);
-/* $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 <dlg@openbsd.org>
/* 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);
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);
-/* $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)
*
#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);
-/* $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.
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);
-/* $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 $ */
/*
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 */
-/* $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
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 */
-/* $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 $ */
/*
#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;
-/* $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 $ */
/*
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;
}
/* 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;
}
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;
}
-/* $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 $ */
/*
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"));
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"));
-/* $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 $ */
/*
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 *);
-/* $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.
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;
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;
-/* $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 $ */
/*
*/
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
* 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;
-/* $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 $ */
/*
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;
-/* $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 $ */
/*
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;
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.
-/* $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 $ */
/*
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;
}