sync with OpenBSD -current

This commit is contained in:
purplerain 2023-11-28 11:53:04 +00:00
parent 1bc98b3538
commit 388947454d
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
30 changed files with 670 additions and 327 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: vmm_support.S,v 1.23 2023/04/14 23:56:57 dv Exp $ */
/* $OpenBSD: vmm_support.S,v 1.24 2023/11/28 00:17:48 dv Exp $ */
/*
* Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
*
@ -129,9 +129,19 @@ ENTRY(vmread)
lfence
END(vmread)
/*
* Intel SDM Vol 3C, 31.2 defines different "vmfail" types, but there's no
* need to distinguish between CF=1 and ZF=1 for invvpid or invept.
*/
ENTRY(invvpid)
RETGUARD_SETUP(invvpid, r11)
invvpid (%rsi), %rdi
jbe invvpid_fail
xorq %rax, %rax
jmp invvpid_ret
invvpid_fail:
movq $1, %rax
invvpid_ret:
RETGUARD_CHECK(invvpid, r11)
ret
lfence
@ -139,7 +149,13 @@ END(invvpid)
ENTRY(invept)
RETGUARD_SETUP(invept, r11)
invept (%rsi), %rdi
invept (%rsi), %rdi
jbe invept_fail
xorq %rax, %rax
jmp invept_ret
invept_fail:
movq $1, %rax
invept_ret:
RETGUARD_CHECK(invept, r11)
ret
lfence

View file

@ -1,4 +1,4 @@
/* $OpenBSD: vmmvar.h,v 1.94 2023/09/06 03:35:57 dv Exp $ */
/* $OpenBSD: vmmvar.h,v 1.95 2023/11/28 00:17:48 dv Exp $ */
/*
* Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
*
@ -919,8 +919,8 @@ int vmptrld(paddr_t *);
int vmptrst(paddr_t *);
int vmwrite(uint64_t, uint64_t);
int vmread(uint64_t, uint64_t *);
void invvpid(uint64_t, struct vmx_invvpid_descriptor *);
void invept(uint64_t, struct vmx_invept_descriptor *);
int invvpid(uint64_t, struct vmx_invvpid_descriptor *);
int invept(uint64_t, struct vmx_invept_descriptor *);
int vmx_enter_guest(paddr_t *, struct vcpu_gueststate *, int, uint8_t);
int svm_enter_guest(uint64_t, struct vcpu_gueststate *,
struct region_descriptor *);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: cac.c,v 1.76 2022/04/16 19:19:59 naddy Exp $ */
/* $OpenBSD: cac.c,v 1.77 2023/11/28 09:29:20 jsg Exp $ */
/* $NetBSD: cac.c,v 1.15 2000/11/08 19:20:35 ad Exp $ */
/*
@ -959,7 +959,7 @@ cac_sensor_refresh(void *arg)
break;
case BIOC_SVINVALID:
/* FALLTRHOUGH */
/* FALLTHROUGH */
default:
sc->sc_sensors[i].value = 0; /* unknown */
sc->sc_sensors[i].status = SENSOR_S_UNKNOWN;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: mfi.c,v 1.190 2023/07/06 10:17:43 visa Exp $ */
/* $OpenBSD: mfi.c,v 1.191 2023/11/28 09:29:20 jsg Exp $ */
/*
* Copyright (c) 2006 Marco Peereboom <marco@peereboom.us>
*
@ -2506,7 +2506,7 @@ mfi_refresh_sensors(void *arg)
break;
case BIOC_SVINVALID:
/* FALLTRHOUGH */
/* FALLTHROUGH */
default:
sc->sc_sensors[i].value = 0; /* unknown */
sc->sc_sensors[i].status = SENSOR_S_UNKNOWN;

View file

@ -1,4 +1,4 @@
$OpenBSD: usbdevs,v 1.759 2023/09/09 14:23:37 kevlo Exp $
$OpenBSD: usbdevs,v 1.760 2023/11/27 20:03:50 miod Exp $
/* $NetBSD: usbdevs,v 1.322 2003/05/10 17:47:14 hamajima Exp $ */
/*
@ -654,6 +654,7 @@ vendor DYNABOOK 0x30f3 Dynabook
vendor LINKINSTRUMENTS 0x3195 Link Instruments
vendor AEI 0x3334 AEI
vendor PQI 0x3538 PQI
vendor RDING 0x3553 RDing TECH
vendor DAISY 0x3579 Daisy Technology
vendor NI 0x3923 National Instruments
vendor MICRONET 0x3980 Micronet Communications
@ -3773,6 +3774,9 @@ product RALINK RT2573_2 0x9021 RT2573
product RATOC REXUSB60 0xb000 USB serial REX-USB60
product RATOC REXUSB60F 0xb020 REX-USB60F
/* RDing TECH products */
product RDING TEMPER 0xa001 TEMPer sensor
/* Realtek products */
product REALTEK RTL8188ETV 0x0179 RTL8188ETV
product REALTEK RTL8188CTV 0x018a RTL8188CTV

View file

@ -1,10 +1,10 @@
/* $OpenBSD: usbdevs.h,v 1.771 2023/09/09 14:24:06 kevlo Exp $ */
/* $OpenBSD: usbdevs.h,v 1.772 2023/11/27 20:04:07 miod Exp $ */
/*
* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
*
* generated from:
* OpenBSD: usbdevs,v 1.759 2023/09/09 14:23:37 kevlo Exp
* OpenBSD: usbdevs,v 1.760 2023/11/27 20:03:50 miod Exp
*/
/* $NetBSD: usbdevs,v 1.322 2003/05/10 17:47:14 hamajima Exp $ */
@ -661,6 +661,7 @@
#define USB_VENDOR_LINKINSTRUMENTS 0x3195 /* Link Instruments */
#define USB_VENDOR_AEI 0x3334 /* AEI */
#define USB_VENDOR_PQI 0x3538 /* PQI */
#define USB_VENDOR_RDING 0x3553 /* RDing TECH */
#define USB_VENDOR_DAISY 0x3579 /* Daisy Technology */
#define USB_VENDOR_NI 0x3923 /* National Instruments */
#define USB_VENDOR_MICRONET 0x3980 /* Micronet Communications */
@ -3780,6 +3781,9 @@
#define USB_PRODUCT_RATOC_REXUSB60 0xb000 /* USB serial REX-USB60 */
#define USB_PRODUCT_RATOC_REXUSB60F 0xb020 /* REX-USB60F */
/* RDing TECH products */
#define USB_PRODUCT_RDING_TEMPER 0xa001 /* TEMPer sensor */
/* Realtek products */
#define USB_PRODUCT_REALTEK_RTL8188ETV 0x0179 /* RTL8188ETV */
#define USB_PRODUCT_REALTEK_RTL8188CTV 0x018a /* RTL8188CTV */

View file

@ -1,10 +1,10 @@
/* $OpenBSD: usbdevs_data.h,v 1.765 2023/09/09 14:24:06 kevlo Exp $ */
/* $OpenBSD: usbdevs_data.h,v 1.766 2023/11/27 20:04:07 miod Exp $ */
/*
* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
*
* generated from:
* OpenBSD: usbdevs,v 1.759 2023/09/09 14:23:37 kevlo Exp
* OpenBSD: usbdevs,v 1.760 2023/11/27 20:03:50 miod Exp
*/
/* $NetBSD: usbdevs,v 1.322 2003/05/10 17:47:14 hamajima Exp $ */
@ -9393,6 +9393,10 @@ const struct usb_known_product usb_known_products[] = {
USB_VENDOR_RATOC, USB_PRODUCT_RATOC_REXUSB60F,
"REX-USB60F",
},
{
USB_VENDOR_RDING, USB_PRODUCT_RDING_TEMPER,
"TEMPer sensor",
},
{
USB_VENDOR_REALTEK, USB_PRODUCT_REALTEK_RTL8188ETV,
"RTL8188ETV",
@ -14725,6 +14729,10 @@ const struct usb_known_vendor usb_known_vendors[] = {
USB_VENDOR_PQI,
"PQI",
},
{
USB_VENDOR_RDING,
"RDing TECH",
},
{
USB_VENDOR_DAISY,
"Daisy Technology",

View file

@ -1,4 +1,4 @@
/* $OpenBSD: uipc_usrreq.c,v 1.199 2023/03/31 12:35:24 jsg Exp $ */
/* $OpenBSD: uipc_usrreq.c,v 1.200 2023/11/28 09:29:20 jsg Exp $ */
/* $NetBSD: uipc_usrreq.c,v 1.18 1996/02/09 19:00:50 christos Exp $ */
/*
@ -718,7 +718,7 @@ uipc_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
name + 1, namelen - 1, oldp, oldlenp, newp, newlen);
case NET_UNIX_INFLIGHT:
valp = &unp_rights;
/* FALLTHOUGH */
/* FALLTHROUGH */
case NET_UNIX_DEFERRED:
if (namelen != 1)
return (ENOTDIR);

View file

@ -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 <goda@openbsd.org>
*
@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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 <dlg@openbsd.org>
@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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 */

View file

@ -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 */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: tcp_input.c,v 1.393 2023/11/26 22:08:10 bluhm Exp $ */
/* $OpenBSD: tcp_input.c,v 1.394 2023/11/27 20:37:15 bluhm Exp $ */
/* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */
/*
@ -586,7 +586,7 @@ findpcb:
&tdbi->dst, tdbi->proto);
}
error = ipsp_spd_lookup(m, af, iphlen, IPSP_DIRECTION_IN,
tdb, inp->inp_seclevel, NULL, NULL);
tdb, inp ? inp->inp_seclevel : NULL, NULL, NULL);
tdb_unref(tdb);
if (error) {
tcpstat_inc(tcps_rcvnosec);
@ -4162,7 +4162,8 @@ syn_cache_respond(struct syn_cache *sc, struct mbuf *m, uint64_t now)
ip->ip_tos = inp->inp_ip.ip_tos;
error = ip_output(m, sc->sc_ipopts, &sc->sc_route4,
(ip_mtudisc ? IP_MTUDISC : 0), NULL, inp->inp_seclevel, 0);
(ip_mtudisc ? IP_MTUDISC : 0), NULL,
inp ? inp->inp_seclevel : NULL, 0);
break;
#ifdef INET6
case AF_INET6:

View file

@ -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;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: udp_usrreq.c,v 1.307 2023/11/26 22:08:10 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 $ */
/*
@ -543,7 +543,7 @@ udp_input(struct mbuf **mp, int *offp, int proto, int af)
} else
tdb = NULL;
error = ipsp_spd_lookup(m, af, iphlen, IPSP_DIRECTION_IN,
tdb, inp->inp_seclevel, NULL, NULL);
tdb, inp ? inp->inp_seclevel : NULL, NULL, NULL);
if (error) {
udpstat_inc(udps_nosec);
tdb_unref(tdb);
@ -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;
}

View file

@ -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"));

View file

@ -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 *);

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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.

View file

@ -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;
}