sync with OpenBSD -current

This commit is contained in:
purplerain 2023-11-27 15:39:41 +00:00
parent 7a404394cf
commit 1bc98b3538
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
54 changed files with 733 additions and 467 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: vmm_machdep.c,v 1.10 2023/11/24 21:48:25 dv Exp $ */
/* $OpenBSD: vmm_machdep.c,v 1.11 2023/11/26 13:02:44 dv Exp $ */
/*
* Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
*
@ -4155,7 +4155,7 @@ vcpu_run_vmx(struct vcpu *vcpu, struct vm_run_params *vrp)
if (vcpu->vc_vmx_vpid_enabled) {
/* Invalidate old TLB mappings */
vid.vid_vpid = vcpu->vc_parent->vm_id;
vid.vid_vpid = vcpu->vc_vpid;
vid.vid_addr = 0;
invvpid(IA32_VMX_INVVPID_SINGLE_CTX_GLB, &vid);
}
@ -5447,7 +5447,7 @@ vmx_handle_cr0_write(struct vcpu *vcpu, uint64_t r)
/* Paging was disabled (prev. enabled) - Flush TLB */
if (vmm_softc->mode == VMM_MODE_EPT &&
vcpu->vc_vmx_vpid_enabled) {
vid.vid_vpid = vcpu->vc_parent->vm_id;
vid.vid_vpid = vcpu->vc_vpid;
vid.vid_addr = 0;
invvpid(IA32_VMX_INVVPID_SINGLE_CTX_GLB, &vid);
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: rtkit.c,v 1.12 2023/04/07 09:31:59 jsg Exp $ */
/* $OpenBSD: rtkit.c,v 1.13 2023/11/25 18:12:20 kettenis Exp $ */
/*
* Copyright (c) 2021 Mark Kettenis <kettenis@openbsd.org>
*
@ -77,9 +77,14 @@
#define RTKIT_IOREPORT_UNKNOWN2 12
#define RTKIT_OSLOG_TYPE(x) (((x) >> 56) & 0xff)
#define RTKIT_OSLOG_TYPE_SHIFT 56
#define RTKIT_OSLOG_INIT 1ULL
#define RTKIT_OSLOG_ACK 3ULL
#define RTKIT_OSLOG_TYPE_SHIFT (56 - RTKIT_MGMT_TYPE_SHIFT)
#define RTKIT_OSLOG_BUFFER_REQUEST 1
#define RTKIT_OSLOG_BUFFER_ADDR(x) (((x) >> 0) & 0xfffffffff)
#define RTKIT_OSLOG_BUFFER_SIZE(x) (((x) >> 36) & 0xfffff)
#define RTKIT_OSLOG_BUFFER_SIZE_SHIFT 36
#define RTKIT_OSLOG_UNKNOWN1 3
#define RTKIT_OSLOG_UNKNOWN2 4
#define RTKIT_OSLOG_UNKNOWN3 5
/* Versions we support. */
#define RTKIT_MINVER 11
@ -253,7 +258,7 @@ rtkit_handle_mgmt(struct rtkit_state *state, struct aplmbox_msg *msg)
default:
printf("%s: unhandled management event 0x%016lld\n",
__func__, msg->data0);
return EIO;
break;
}
return 0;
@ -289,7 +294,7 @@ rtkit_handle_crashlog(struct rtkit_state *state, struct aplmbox_msg *msg)
default:
printf("%s: unhandled crashlog event 0x%016llx\n",
__func__, msg->data0);
return EIO;
break;
}
return 0;
@ -333,7 +338,7 @@ rtkit_handle_syslog(struct rtkit_state *state, struct aplmbox_msg *msg)
default:
printf("%s: unhandled syslog event 0x%016llx\n",
__func__, msg->data0);
return EIO;
break;
}
return 0;
@ -377,7 +382,7 @@ rtkit_handle_ioreport(struct rtkit_state *state, struct aplmbox_msg *msg)
default:
printf("%s: unhandled ioreport event 0x%016llx\n",
__func__, msg->data0);
return EIO;
break;
}
return 0;
@ -387,19 +392,39 @@ int
rtkit_handle_oslog(struct rtkit_state *state, struct aplmbox_msg *msg)
{
struct mbox_channel *mc = state->mc;
struct rtkit *rk = state->rk;
bus_addr_t addr;
bus_size_t size;
int error;
switch (RTKIT_OSLOG_TYPE(msg->data0)) {
case RTKIT_OSLOG_INIT:
case RTKIT_OSLOG_BUFFER_REQUEST:
addr = RTKIT_OSLOG_BUFFER_ADDR(msg->data0) << PAGE_SHIFT;
size = RTKIT_OSLOG_BUFFER_SIZE(msg->data0);
if (addr)
break;
if (rk) {
addr = rtkit_alloc(state, size);
if (addr == (bus_addr_t)-1)
return ENOMEM;
}
error = rtkit_send(mc, RTKIT_EP_OSLOG,
0, RTKIT_OSLOG_ACK << RTKIT_OSLOG_TYPE_SHIFT);
(RTKIT_OSLOG_BUFFER_REQUEST << RTKIT_OSLOG_TYPE_SHIFT),
(size << RTKIT_OSLOG_BUFFER_SIZE_SHIFT) |
(addr >> PAGE_SHIFT));
if (error)
return error;
break;
case RTKIT_OSLOG_UNKNOWN1:
case RTKIT_OSLOG_UNKNOWN2:
case RTKIT_OSLOG_UNKNOWN3:
break;
default:
printf("%s: unhandled oslog event 0x%016llx\n",
__func__, msg->data0);
return EIO;
break;
}
return 0;
@ -456,7 +481,7 @@ rtkit_poll(struct rtkit_state *state)
}
printf("%s: unhandled endpoint %d\n", __func__, msg.data1);
return EIO;
break;
}
return 0;
@ -549,8 +574,9 @@ rtkit_set_ap_pwrstate(struct rtkit_state *state, uint16_t pwrstate)
delay(10);
continue;
}
if (error)
return error;
KASSERT(error == 0);
if (state->ap_pwrstate == pwrstate)
break;
}
@ -578,8 +604,9 @@ rtkit_set_iop_pwrstate(struct rtkit_state *state, uint16_t pwrstate)
delay(10);
continue;
}
if (error)
return error;
KASSERT(error == 0);
if (state->iop_pwrstate == pwrstate)
break;
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: pchgpio.c,v 1.14 2022/10/20 20:40:57 kettenis Exp $ */
/* $OpenBSD: pchgpio.c,v 1.15 2023/11/27 00:39:42 jsg Exp $ */
/*
* Copyright (c) 2020 Mark Kettenis
* Copyright (c) 2020 James Hastings
@ -115,6 +115,9 @@ const char *pchgpio_hids[] = {
"INT34C5",
"INT34C6",
"INTC1055",
"INTC1056",
"INTC1057",
"INTC1085",
NULL
};
@ -311,6 +314,78 @@ const struct pchgpio_device tgl_h_device =
.npins = 480,
};
/* Alder Lake-S */
const struct pchgpio_group adl_s_groups[] =
{
/* Community 0 */
{ 0, 0, 0, 24, 0 }, /* GPP_I */
{ 0, 1, 25, 47, 32 }, /* GPP_R */
{ 0, 2, 48, 59, 64 }, /* GPP_J */
/* Community 1 */
{ 1, 0, 95, 118, 160 }, /* GPP_B */
{ 1, 1, 119, 126, 192 }, /* GPP_G */
{ 1, 2, 127, 150, 224 }, /* GPP_H */
/* Community 3 */
{ 2, 1, 160, 175, 256 }, /* GPP_A */
{ 2, 2, 176, 199, 288 }, /* GPP_C */
/* Community 4 */
{ 3, 0, 200, 207, 320 }, /* GPP_S */
{ 3, 1, 208, 230, 352 }, /* GPP_E */
{ 3, 2, 231, 245, 384 }, /* GPP_K */
{ 3, 3, 246, 269, 416 }, /* GPP_F */
/* Community 5 */
{ 4, 0, 270, 294, 448 }, /* GPP_D */
};
const struct pchgpio_device adl_s_device =
{
.pad_size = 16,
.gpi_is = 0x200,
.gpi_ie = 0x220,
.groups = adl_s_groups,
.ngroups = nitems(adl_s_groups),
.npins = 480,
};
/* Alder Lake-N */
const struct pchgpio_group adl_n_groups[] =
{
/* Community 0 */
{ 0, 0, 0, 25, 0 }, /* GPP_B */
{ 0, 1, 26, 41, 32 }, /* GPP_T */
{ 0, 2, 42, 66, 64 }, /* GPP_A */
/* Community 1 */
{ 1, 0, 67, 74, 96 }, /* GPP_S */
{ 1, 1, 75, 94, 128 }, /* GPP_I */
{ 1, 2, 95, 118, 160 }, /* GPP_H */
{ 1, 3, 119, 139, 192 }, /* GPP_D */
/* Community 4 */
{ 2, 0, 169, 192, 256 }, /* GPP_C */
{ 2, 1, 193, 217, 288 }, /* GPP_F */
{ 2, 3, 224, 248, 320 }, /* GPP_E */
/* Community 5 */
{ 3, 0, 249, 256, 352 }, /* GPP_R */
};
const struct pchgpio_device adl_n_device =
{
.pad_size = 16,
.gpi_is = 0x100,
.gpi_ie = 0x120,
.groups = adl_n_groups,
.ngroups = nitems(adl_n_groups),
.npins = 384,
};
struct pchgpio_match pchgpio_devices[] = {
{ "INT344B", &spt_lp_device },
{ "INT3450", &cnl_h_device },
@ -320,6 +395,9 @@ struct pchgpio_match pchgpio_devices[] = {
{ "INT34C5", &tgl_lp_device },
{ "INT34C6", &tgl_h_device },
{ "INTC1055", &tgl_lp_device },
{ "INTC1056", &adl_s_device },
{ "INTC1057", &adl_n_device },
{ "INTC1085", &adl_s_device },
};
int pchgpio_read_pin(void *, int);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: rkclock.c,v 1.83 2023/09/29 15:51:48 kettenis Exp $ */
/* $OpenBSD: rkclock.c,v 1.84 2023/11/26 13:47:45 kettenis Exp $ */
/*
* Copyright (c) 2017, 2018 Mark Kettenis <kettenis@openbsd.org>
*
@ -4107,6 +4107,11 @@ const struct rkclock rk3588_clocks[] = {
{ RK3588_CLK_GPU_SRC },
SET_PARENT
},
{
RK3588_CCLK_SRC_SDIO, RK3588_CRU_CLKSEL_CON(172),
SEL(9, 8), DIV(7, 2),
{ RK3588_PLL_GPLL, RK3588_PLL_CPLL, RK3588_XIN24M }
},
{
RK3588_ACLK_VOP_ROOT, RK3588_CRU_CLKSEL_CON(110),
SEL(7, 5), DIV(4, 0),
@ -4292,6 +4297,9 @@ rk3588_set_pll(struct rkclock_softc *sc, bus_size_t base, uint32_t freq)
case 1188000000U:
p = 2; m = 198; s = 1; k = 0;
break;
case 1100000000U:
p = 3; m = 550; s = 2; k = 0;
break;
case 850000000U:
p = 3; m = 425; s = 2; k = 0;
break;
@ -4476,6 +4484,10 @@ rk3588_reset(void *cookie, uint32_t *cells, int on)
reg = RK3588_CRU_SOFTRST_CON(34);
bit = 0;
break;
case RK3588_SRST_A_USB3OTG2:
reg = RK3588_CRU_SOFTRST_CON(35);
bit = 7;
break;
case RK3588_SRST_A_USB3OTG0:
reg = RK3588_CRU_SOFTRST_CON(42);
bit = 4;

View file

@ -458,6 +458,7 @@
#define RK3588_ACLK_LOW_TOP_ROOT 258
#define RK3588_CLK_GPU_SRC 261
#define RK3588_CLK_GPU 262
#define RK3588_CCLK_SRC_SDIO 395
#define RK3588_ACLK_VOP_ROOT 600
#define RK3588_ACLK_VOP 605
#define RK3588_ACLK_VOP_SUB_SRC 619
@ -497,6 +498,7 @@
#define RK3588_SRST_P_PCIE2 301
#define RK3588_SRST_P_PCIE3 302
#define RK3588_SRST_P_PCIE4 303
#define RK3588_SRST_A_USB3OTG2 308
#define RK3588_SRST_A_USB3OTG0 338
#define RK3588_SRST_A_USB3OTG1 339
#define RK3588_SRST_REF_PIPE_PHY0 572

View file

@ -309,10 +309,14 @@ static const struct pci_matchid i915_devices[] = {
{ 0x8086, 0xa789 },
{ 0x8086, 0xa78a },
{ 0x8086, 0xa78b },
{ 0x8086, 0xa720 },
{ 0x8086, 0xa721 },
{ 0x8086, 0xa7a0 },
{ 0x8086, 0xa7a1 },
{ 0x8086, 0xa7a8 },
{ 0x8086, 0xa7a9 },
{ 0x8086, 0xa7ac },
{ 0x8086, 0xa7ad },
{ 0x8086, 0xa720 },
{ 0x8086, 0xa7a0 },
{ 0x8086, 0xa7a8 },
{ 0x8086, 0xa7aa },
{ 0x8086, 0xa7ab },
};

View file

@ -685,14 +685,22 @@
INTEL_VGA_DEVICE(0xA78A, info), \
INTEL_VGA_DEVICE(0xA78B, info)
/* RPL-U */
#define INTEL_RPLU_IDS(info) \
INTEL_VGA_DEVICE(0xA721, info), \
INTEL_VGA_DEVICE(0xA7A1, info), \
INTEL_VGA_DEVICE(0xA7A9, info), \
INTEL_VGA_DEVICE(0xA7AC, info), \
INTEL_VGA_DEVICE(0xA7AD, info)
/* RPL-P */
#define INTEL_RPLP_IDS(info) \
INTEL_RPLU_IDS(info), \
INTEL_VGA_DEVICE(0xA720, info), \
INTEL_VGA_DEVICE(0xA721, info), \
INTEL_VGA_DEVICE(0xA7A0, info), \
INTEL_VGA_DEVICE(0xA7A1, info), \
INTEL_VGA_DEVICE(0xA7A8, info), \
INTEL_VGA_DEVICE(0xA7A9, info)
INTEL_VGA_DEVICE(0xA7AA, info), \
INTEL_VGA_DEVICE(0xA7AB, info)
/* DG2 */
#define INTEL_DG2_G10_IDS(info) \

View file

@ -1,4 +1,4 @@
$OpenBSD: pcidevs,v 1.2056 2023/11/24 04:34:09 jmatthew Exp $
$OpenBSD: pcidevs,v 1.2057 2023/11/26 05:47:21 jsg Exp $
/* $NetBSD: pcidevs,v 1.30 1997/06/24 06:20:24 thorpej Exp $ */
/*
@ -7026,7 +7026,7 @@ product INTEL RPL_DTT 0xa71d Core 13G DTT
product INTEL RPL_XHCI 0xa71e Core 13G xHCI
product INTEL RPL_TBT_PCIE3 0xa71f Core 13G PCIE
product INTEL RPL_P_GT_1 0xa720 Graphics
product INTEL RPL_P_GT_2 0xa721 Graphics
product INTEL RPL_U_GT_1 0xa721 Graphics
product INTEL RPL_HX_HB_4 0xa728 Core 13G Host
product INTEL RPL_HX_HB_5 0xa729 Core 13G Host
product INTEL RPL_HX_HB_6 0xa72a Core 13G Host
@ -7050,10 +7050,14 @@ product INTEL RPL_S_GT_5 0xa788 Graphics
product INTEL RPL_S_GT_6 0xa789 Graphics
product INTEL RPL_S_GT_7 0xa78a Graphics
product INTEL RPL_S_GT_8 0xa78b Graphics
product INTEL RPL_P_GT_3 0xa7a0 Graphics
product INTEL RPL_P_GT_4 0xa7a1 Graphics
product INTEL RPL_P_GT_5 0xa7a8 Graphics
product INTEL RPL_P_GT_6 0xa7a9 Graphics
product INTEL RPL_P_GT_2 0xa7a0 Graphics
product INTEL RPL_U_GT_2 0xa7a1 Graphics
product INTEL RPL_P_GT_3 0xa7a8 Graphics
product INTEL RPL_U_GT_3 0xa7a9 Graphics
product INTEL RPL_P_GT_4 0xa7aa Graphics
product INTEL RPL_P_GT_5 0xa7ab Graphics
product INTEL RPL_U_GT_4 0xa7ac Graphics
product INTEL RPL_U_GT_5 0xa7ad Graphics
product INTEL 21152 0xb152 S21152BB
product INTEL 21154 0xb154 21154AE/BE
product INTEL CORE_DMI_0 0xd130 Core DMI

View file

@ -2,7 +2,7 @@
* THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.
*
* generated from:
* OpenBSD: pcidevs,v 1.2056 2023/11/24 04:34:09 jmatthew Exp
* OpenBSD: pcidevs,v 1.2057 2023/11/26 05:47:21 jsg Exp
*/
/* $NetBSD: pcidevs,v 1.30 1997/06/24 06:20:24 thorpej Exp $ */
@ -7031,7 +7031,7 @@
#define PCI_PRODUCT_INTEL_RPL_XHCI 0xa71e /* Core 13G xHCI */
#define PCI_PRODUCT_INTEL_RPL_TBT_PCIE3 0xa71f /* Core 13G PCIE */
#define PCI_PRODUCT_INTEL_RPL_P_GT_1 0xa720 /* Graphics */
#define PCI_PRODUCT_INTEL_RPL_P_GT_2 0xa721 /* Graphics */
#define PCI_PRODUCT_INTEL_RPL_U_GT_1 0xa721 /* Graphics */
#define PCI_PRODUCT_INTEL_RPL_HX_HB_4 0xa728 /* Core 13G Host */
#define PCI_PRODUCT_INTEL_RPL_HX_HB_5 0xa729 /* Core 13G Host */
#define PCI_PRODUCT_INTEL_RPL_HX_HB_6 0xa72a /* Core 13G Host */
@ -7055,10 +7055,14 @@
#define PCI_PRODUCT_INTEL_RPL_S_GT_6 0xa789 /* Graphics */
#define PCI_PRODUCT_INTEL_RPL_S_GT_7 0xa78a /* Graphics */
#define PCI_PRODUCT_INTEL_RPL_S_GT_8 0xa78b /* Graphics */
#define PCI_PRODUCT_INTEL_RPL_P_GT_3 0xa7a0 /* Graphics */
#define PCI_PRODUCT_INTEL_RPL_P_GT_4 0xa7a1 /* Graphics */
#define PCI_PRODUCT_INTEL_RPL_P_GT_5 0xa7a8 /* Graphics */
#define PCI_PRODUCT_INTEL_RPL_P_GT_6 0xa7a9 /* Graphics */
#define PCI_PRODUCT_INTEL_RPL_P_GT_2 0xa7a0 /* Graphics */
#define PCI_PRODUCT_INTEL_RPL_U_GT_2 0xa7a1 /* Graphics */
#define PCI_PRODUCT_INTEL_RPL_P_GT_3 0xa7a8 /* Graphics */
#define PCI_PRODUCT_INTEL_RPL_U_GT_3 0xa7a9 /* Graphics */
#define PCI_PRODUCT_INTEL_RPL_P_GT_4 0xa7aa /* Graphics */
#define PCI_PRODUCT_INTEL_RPL_P_GT_5 0xa7ab /* Graphics */
#define PCI_PRODUCT_INTEL_RPL_U_GT_4 0xa7ac /* Graphics */
#define PCI_PRODUCT_INTEL_RPL_U_GT_5 0xa7ad /* Graphics */
#define PCI_PRODUCT_INTEL_21152 0xb152 /* S21152BB */
#define PCI_PRODUCT_INTEL_21154 0xb154 /* 21154AE/BE */
#define PCI_PRODUCT_INTEL_CORE_DMI_0 0xd130 /* Core DMI */

View file

@ -2,7 +2,7 @@
* THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.
*
* generated from:
* OpenBSD: pcidevs,v 1.2056 2023/11/24 04:34:09 jmatthew Exp
* OpenBSD: pcidevs,v 1.2057 2023/11/26 05:47:21 jsg Exp
*/
/* $NetBSD: pcidevs,v 1.30 1997/06/24 06:20:24 thorpej Exp $ */
@ -25464,7 +25464,7 @@ static const struct pci_known_product pci_known_products[] = {
"Graphics",
},
{
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_P_GT_2,
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_U_GT_1,
"Graphics",
},
{
@ -25559,10 +25559,22 @@ static const struct pci_known_product pci_known_products[] = {
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_S_GT_8,
"Graphics",
},
{
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_P_GT_2,
"Graphics",
},
{
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_U_GT_2,
"Graphics",
},
{
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_P_GT_3,
"Graphics",
},
{
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_U_GT_3,
"Graphics",
},
{
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_P_GT_4,
"Graphics",
@ -25572,7 +25584,11 @@ static const struct pci_known_product pci_known_products[] = {
"Graphics",
},
{
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_P_GT_6,
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_U_GT_4,
"Graphics",
},
{
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_RPL_U_GT_5,
"Graphics",
},
{

View file

@ -1,4 +1,4 @@
/* $OpenBSD: in_pcb.h,v 1.137 2023/11/12 23:19:15 bluhm Exp $ */
/* $OpenBSD: in_pcb.h,v 1.138 2023/11/26 22:08:10 bluhm Exp $ */
/* $NetBSD: in_pcb.h,v 1.14 1996/02/13 23:42:00 christos Exp $ */
/*
@ -141,7 +141,7 @@ struct inpcb {
} inp_mou;
#define inp_moptions inp_mou.mou_mo
#define inp_moptions6 inp_mou.mou_mo6
u_char inp_seclevel[4];
u_char inp_seclevel[4]; /* [N] IPsec level of socket */
#define SL_AUTH 0 /* Authentication level */
#define SL_ESP_TRANS 1 /* ESP transport level */
#define SL_ESP_NETWORK 2 /* ESP network (encapsulation) level */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip_ipsp.h,v 1.243 2023/10/11 22:13:16 tobhe Exp $ */
/* $OpenBSD: ip_ipsp.h,v 1.244 2023/11/26 22:08:10 bluhm Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr),
@ -671,7 +671,7 @@ int checkreplaywindow(struct tdb *, u_int64_t, u_int32_t, u_int32_t *, int);
int ipsp_process_packet(struct mbuf *, struct tdb *, int, int);
int ipsp_process_done(struct mbuf *, struct tdb *);
int ipsp_spd_lookup(struct mbuf *, int, int, int, struct tdb *,
struct inpcb *, struct tdb **, struct ipsec_ids *);
const u_char[], struct tdb **, struct ipsec_ids *);
int ipsp_is_unspecified(union sockaddr_union);
int ipsp_aux_match(struct tdb *, struct ipsec_ids *,
struct sockaddr_encap *, struct sockaddr_encap *);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip_output.c,v 1.390 2023/07/07 08:05:02 bluhm Exp $ */
/* $OpenBSD: ip_output.c,v 1.391 2023/11/26 22:08:10 bluhm Exp $ */
/* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */
/*
@ -84,7 +84,7 @@ void ip_mloopback(struct ifnet *, struct mbuf *, struct sockaddr_in *);
static u_int16_t in_cksum_phdr(u_int32_t, u_int32_t, u_int32_t);
void in_delayed_cksum(struct mbuf *);
int ip_output_ipsec_lookup(struct mbuf *m, int hlen, struct inpcb *inp,
int ip_output_ipsec_lookup(struct mbuf *m, int hlen, const u_char seclevel[],
struct tdb **, int ipsecflowinfo);
void ip_output_ipsec_pmtu_update(struct tdb *, struct route *, struct in_addr,
int, int);
@ -98,7 +98,7 @@ int ip_output_ipsec_send(struct tdb *, struct mbuf *, struct route *, int);
*/
int
ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags,
struct ip_moptions *imo, struct inpcb *inp, u_int32_t ipsecflowinfo)
struct ip_moptions *imo, const u_char seclevel[], u_int32_t ipsecflowinfo)
{
struct ip *ip;
struct ifnet *ifp = NULL;
@ -115,11 +115,6 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags,
NET_ASSERT_LOCKED();
#ifdef IPSEC
if (inp && (inp->inp_flags & INP_IPV6) != 0)
panic("ip_output: IPv6 pcb is passed");
#endif /* IPSEC */
#ifdef DIAGNOSTIC
if ((m->m_flags & M_PKTHDR) == 0)
panic("ip_output no HDR");
@ -240,9 +235,9 @@ reroute:
}
#ifdef IPSEC
if (ipsec_in_use || inp != NULL) {
if (ipsec_in_use || seclevel != NULL) {
/* Do we have any pending SAs to apply ? */
error = ip_output_ipsec_lookup(m, hlen, inp, &tdb,
error = ip_output_ipsec_lookup(m, hlen, seclevel, &tdb,
ipsecflowinfo);
if (error) {
/* Should silently drop packet */
@ -514,7 +509,7 @@ bad:
#ifdef IPSEC
int
ip_output_ipsec_lookup(struct mbuf *m, int hlen, struct inpcb *inp,
ip_output_ipsec_lookup(struct mbuf *m, int hlen, const u_char seclevel[],
struct tdb **tdbout, int ipsecflowinfo)
{
struct m_tag *mtag;
@ -527,7 +522,7 @@ ip_output_ipsec_lookup(struct mbuf *m, int hlen, struct inpcb *inp,
if (ipsecflowinfo)
ids = ipsp_ids_lookup(ipsecflowinfo);
error = ipsp_spd_lookup(m, AF_INET, hlen, IPSP_DIRECTION_OUT,
NULL, inp, &tdb, ids);
NULL, seclevel, &tdb, ids);
ipsp_ids_free(ids);
if (error || tdb == NULL) {
*tdbout = NULL;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip_spd.c,v 1.118 2023/04/22 20:51:56 mvs Exp $ */
/* $OpenBSD: ip_spd.c,v 1.119 2023/11/26 22:08:10 bluhm Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
*
@ -39,7 +39,7 @@
#include <netinet/ip_ipsp.h>
#include <net/pfkeyv2.h>
int ipsp_spd_inp(struct mbuf *, struct inpcb *, struct ipsec_policy *,
int ipsp_spd_inp(struct mbuf *, const u_char *, struct ipsec_policy *,
struct tdb **);
int ipsp_acquire_sa(struct ipsec_policy *, union sockaddr_union *,
union sockaddr_union *, struct sockaddr_encap *, struct mbuf *);
@ -153,7 +153,7 @@ spd_table_walk(unsigned int rtableid,
*/
int
ipsp_spd_lookup(struct mbuf *m, int af, int hlen, int direction,
struct tdb *tdbin, struct inpcb *inp, struct tdb **tdbout,
struct tdb *tdbin, const u_char seclevel[], struct tdb **tdbout,
struct ipsec_ids *ipsecflowinfo_ids)
{
struct radix_node_head *rnh;
@ -172,15 +172,15 @@ ipsp_spd_lookup(struct mbuf *m, int af, int hlen, int direction,
* continuing with the SPD lookup.
*/
if (!ipsec_in_use)
return ipsp_spd_inp(m, inp, NULL, tdbout);
return ipsp_spd_inp(m, seclevel, NULL, tdbout);
/*
* If an input packet is destined to a BYPASS socket, just accept it.
*/
if ((inp != NULL) && (direction == IPSP_DIRECTION_IN) &&
(inp->inp_seclevel[SL_ESP_TRANS] == IPSEC_LEVEL_BYPASS) &&
(inp->inp_seclevel[SL_ESP_NETWORK] == IPSEC_LEVEL_BYPASS) &&
(inp->inp_seclevel[SL_AUTH] == IPSEC_LEVEL_BYPASS)) {
if ((seclevel != NULL) && (direction == IPSP_DIRECTION_IN) &&
(seclevel[SL_ESP_TRANS] == IPSEC_LEVEL_BYPASS) &&
(seclevel[SL_ESP_NETWORK] == IPSEC_LEVEL_BYPASS) &&
(seclevel[SL_AUTH] == IPSEC_LEVEL_BYPASS)) {
if (tdbout != NULL)
*tdbout = NULL;
return 0;
@ -311,13 +311,13 @@ ipsp_spd_lookup(struct mbuf *m, int af, int hlen, int direction,
* Return whatever the socket requirements are, there are no
* system-wide policies.
*/
return ipsp_spd_inp(m, inp, NULL, tdbout);
return ipsp_spd_inp(m, seclevel, NULL, tdbout);
}
ipo = (struct ipsec_policy *)rn;
switch (ipo->ipo_type) {
case IPSP_PERMIT:
return ipsp_spd_inp(m, inp, ipo, tdbout);
return ipsp_spd_inp(m, seclevel, ipo, tdbout);
case IPSP_DENY:
return EHOSTUNREACH;
@ -384,11 +384,10 @@ ipsp_spd_lookup(struct mbuf *m, int af, int hlen, int direction,
* gateway/endhost, and the socket has the BYPASS
* option set, skip IPsec processing.
*/
if ((inp != NULL) &&
(inp->inp_seclevel[SL_ESP_TRANS] == IPSEC_LEVEL_BYPASS) &&
(inp->inp_seclevel[SL_ESP_NETWORK] ==
IPSEC_LEVEL_BYPASS) &&
(inp->inp_seclevel[SL_AUTH] == IPSEC_LEVEL_BYPASS)) {
if ((seclevel != NULL) &&
(seclevel[SL_ESP_TRANS] == IPSEC_LEVEL_BYPASS) &&
(seclevel[SL_ESP_NETWORK] == IPSEC_LEVEL_BYPASS) &&
(seclevel[SL_AUTH] == IPSEC_LEVEL_BYPASS)) {
/* Direct match. */
if (dignore ||
!memcmp(&sdst, &ipo->ipo_dst, sdst.sa.sa_len)) {
@ -414,7 +413,7 @@ ipsp_spd_lookup(struct mbuf *m, int af, int hlen, int direction,
goto nomatchout;
/* Cached entry is good. */
error = ipsp_spd_inp(m, inp, ipo, tdbout);
error = ipsp_spd_inp(m, seclevel, ipo, tdbout);
mtx_leave(&ipo_tdb_mtx);
return error;
@ -475,7 +474,7 @@ ipsp_spd_lookup(struct mbuf *m, int af, int hlen, int direction,
TAILQ_INSERT_TAIL(
&ipo->ipo_tdb->tdb_policy_head,
ipo, ipo_tdb_next);
error = ipsp_spd_inp(m, inp, ipo, tdbout);
error = ipsp_spd_inp(m, seclevel, ipo, tdbout);
mtx_leave(&ipo_tdb_mtx);
return error;
}
@ -503,7 +502,7 @@ ipsp_spd_lookup(struct mbuf *m, int af, int hlen, int direction,
/* FALLTHROUGH */
case IPSP_IPSEC_USE:
return ipsp_spd_inp(m, inp, ipo, tdbout);
return ipsp_spd_inp(m, seclevel, ipo, tdbout);
}
} else { /* IPSP_DIRECTION_IN */
if (tdbin != NULL) {
@ -528,7 +527,7 @@ ipsp_spd_lookup(struct mbuf *m, int af, int hlen, int direction,
/* Direct match in the cache. */
mtx_enter(&ipo_tdb_mtx);
if (ipo->ipo_tdb == tdbin) {
error = ipsp_spd_inp(m, inp, ipo, tdbout);
error = ipsp_spd_inp(m, seclevel, ipo, tdbout);
mtx_leave(&ipo_tdb_mtx);
return error;
}
@ -556,7 +555,7 @@ ipsp_spd_lookup(struct mbuf *m, int af, int hlen, int direction,
ipo->ipo_tdb = tdb_ref(tdbin);
TAILQ_INSERT_TAIL(&tdbin->tdb_policy_head, ipo,
ipo_tdb_next);
error = ipsp_spd_inp(m, inp, ipo, tdbout);
error = ipsp_spd_inp(m, seclevel, ipo, tdbout);
mtx_leave(&ipo_tdb_mtx);
return error;
@ -647,7 +646,7 @@ ipsp_spd_lookup(struct mbuf *m, int af, int hlen, int direction,
case IPSP_IPSEC_ACQUIRE:
/* If appropriate SA exists, don't acquire another. */
if (ipo->ipo_tdb != NULL)
return ipsp_spd_inp(m, inp, ipo, tdbout);
return ipsp_spd_inp(m, seclevel, ipo, tdbout);
/* Acquire SA through key management. */
ipsp_acquire_sa(ipo, dignore ? &ssrc : &ipo->ipo_dst,
@ -655,7 +654,7 @@ ipsp_spd_lookup(struct mbuf *m, int af, int hlen, int direction,
/* FALLTHROUGH */
case IPSP_IPSEC_USE:
return ipsp_spd_inp(m, inp, ipo, tdbout);
return ipsp_spd_inp(m, seclevel, ipo, tdbout);
}
}
@ -905,23 +904,23 @@ ipsp_acquire_sa(struct ipsec_policy *ipo, union sockaddr_union *gw,
* Deal with PCB security requirements.
*/
int
ipsp_spd_inp(struct mbuf *m, struct inpcb *inp, struct ipsec_policy *ipo,
ipsp_spd_inp(struct mbuf *m, const u_char seclevel[], struct ipsec_policy *ipo,
struct tdb **tdbout)
{
/* Sanity check. */
if (inp == NULL)
if (seclevel == NULL)
goto justreturn;
/* We only support IPSEC_LEVEL_BYPASS or IPSEC_LEVEL_AVAIL */
if (inp->inp_seclevel[SL_ESP_TRANS] == IPSEC_LEVEL_BYPASS &&
inp->inp_seclevel[SL_ESP_NETWORK] == IPSEC_LEVEL_BYPASS &&
inp->inp_seclevel[SL_AUTH] == IPSEC_LEVEL_BYPASS)
if (seclevel[SL_ESP_TRANS] == IPSEC_LEVEL_BYPASS &&
seclevel[SL_ESP_NETWORK] == IPSEC_LEVEL_BYPASS &&
seclevel[SL_AUTH] == IPSEC_LEVEL_BYPASS)
goto justreturn;
if (inp->inp_seclevel[SL_ESP_TRANS] == IPSEC_LEVEL_AVAIL &&
inp->inp_seclevel[SL_ESP_NETWORK] == IPSEC_LEVEL_AVAIL &&
inp->inp_seclevel[SL_AUTH] == IPSEC_LEVEL_AVAIL)
if (seclevel[SL_ESP_TRANS] == IPSEC_LEVEL_AVAIL &&
seclevel[SL_ESP_NETWORK] == IPSEC_LEVEL_AVAIL &&
seclevel[SL_AUTH] == IPSEC_LEVEL_AVAIL)
goto justreturn;
return -EINVAL; /* Silently drop packet. */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip_var.h,v 1.109 2023/04/05 21:51:47 bluhm Exp $ */
/* $OpenBSD: ip_var.h,v 1.110 2023/11/26 22:08:10 bluhm Exp $ */
/* $NetBSD: ip_var.h,v 1.16 1996/02/13 23:43:20 christos Exp $ */
/*
@ -236,7 +236,7 @@ struct mbuf*
int ip_mforward(struct mbuf *, struct ifnet *);
int ip_optcopy(struct ip *, struct ip *);
int ip_output(struct mbuf *, struct mbuf *, struct route *, int,
struct ip_moptions *, struct inpcb *, u_int32_t);
struct ip_moptions *, const u_char[], u_int32_t);
u_int16_t
ip_randomid(void);
void ip_send(struct mbuf *);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: raw_ip.c,v 1.151 2023/01/22 12:05:44 mvs Exp $ */
/* $OpenBSD: raw_ip.c,v 1.152 2023/11/26 22:08:10 bluhm Exp $ */
/* $NetBSD: raw_ip.c,v 1.25 1996/02/18 18:58:33 christos Exp $ */
/*
@ -326,7 +326,7 @@ rip_output(struct mbuf *m, struct socket *so, struct sockaddr *dstaddr,
#endif
error = ip_output(m, inp->inp_options, &inp->inp_route, flags,
inp->inp_moptions, inp, 0);
inp->inp_moptions, inp->inp_seclevel, 0);
return (error);
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: tcp_input.c,v 1.392 2023/11/16 18:27:48 bluhm Exp $ */
/* $OpenBSD: tcp_input.c,v 1.393 2023/11/26 22:08:10 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, NULL, NULL);
tdb, inp->inp_seclevel, NULL, NULL);
tdb_unref(tdb);
if (error) {
tcpstat_inc(tcps_rcvnosec);
@ -4162,7 +4162,7 @@ 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, 0);
(ip_mtudisc ? IP_MTUDISC : 0), NULL, inp->inp_seclevel, 0);
break;
#ifdef INET6
case AF_INET6:

View file

@ -1,4 +1,4 @@
/* $OpenBSD: tcp_output.c,v 1.140 2023/07/06 09:15:24 bluhm Exp $ */
/* $OpenBSD: tcp_output.c,v 1.141 2023/11/26 22:08:10 bluhm Exp $ */
/* $NetBSD: tcp_output.c,v 1.16 1997/06/03 16:17:09 kml Exp $ */
/*
@ -1087,8 +1087,9 @@ send:
SET(m->m_pkthdr.csum_flags, M_FLOWID);
#endif
error = ip_output(m, tp->t_inpcb->inp_options,
&tp->t_inpcb->inp_route,
(ip_mtudisc ? IP_MTUDISC : 0), NULL, tp->t_inpcb, 0);
&tp->t_inpcb->inp_route,
(ip_mtudisc ? IP_MTUDISC : 0), NULL,
tp->t_inpcb->inp_seclevel, 0);
break;
#ifdef INET6
case AF_INET6:
@ -1107,7 +1108,8 @@ send:
#endif
}
error = ip6_output(m, tp->t_inpcb->inp_outputopts6,
&tp->t_inpcb->inp_route6, 0, NULL, tp->t_inpcb);
&tp->t_inpcb->inp_route6, 0, NULL,
tp->t_inpcb->inp_seclevel);
break;
#endif /* INET6 */
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: tcp_subr.c,v 1.192 2023/07/06 09:15:24 bluhm Exp $ */
/* $OpenBSD: tcp_subr.c,v 1.193 2023/11/26 22:08:10 bluhm Exp $ */
/* $NetBSD: tcp_subr.c,v 1.22 1996/02/13 23:44:00 christos Exp $ */
/*
@ -402,7 +402,7 @@ tcp_respond(struct tcpcb *tp, caddr_t template, struct tcphdr *th0,
ip6_output(m, tp ? tp->t_inpcb->inp_outputopts6 : NULL,
tp ? &tp->t_inpcb->inp_route6 : NULL,
0, NULL,
tp ? tp->t_inpcb : NULL);
tp ? tp->t_inpcb->inp_seclevel : NULL);
break;
#endif /* INET6 */
case AF_INET:
@ -412,7 +412,7 @@ tcp_respond(struct tcpcb *tp, caddr_t template, struct tcphdr *th0,
ip_output(m, NULL,
tp ? &tp->t_inpcb->inp_route : NULL,
ip_mtudisc ? IP_MTUDISC : 0, NULL,
tp ? tp->t_inpcb : NULL, 0);
tp ? tp->t_inpcb->inp_seclevel : NULL, 0);
break;
}
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: udp_usrreq.c,v 1.306 2023/09/16 09:33:27 mpi Exp $ */
/* $OpenBSD: udp_usrreq.c,v 1.307 2023/11/26 22:08:10 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, NULL, NULL);
tdb, inp->inp_seclevel, NULL, NULL);
if (error) {
udpstat_inc(udps_nosec);
tdb_unref(tdb);
@ -1065,7 +1065,7 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct mbuf *addr,
error = ip_output(m, inp->inp_options, &inp->inp_route,
(inp->inp_socket->so_options & SO_BROADCAST), inp->inp_moptions,
inp, ipsecflowinfo);
inp->inp_seclevel, ipsecflowinfo);
bail:
m_freem(control);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip6_output.c,v 1.279 2023/07/07 08:05:02 bluhm Exp $ */
/* $OpenBSD: ip6_output.c,v 1.280 2023/11/26 22:08:10 bluhm Exp $ */
/* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */
/*
@ -161,7 +161,7 @@ struct idgen32_ctx ip6_id_ctx;
*/
int
ip6_output(struct mbuf *m, struct ip6_pktopts *opt, struct route_in6 *ro,
int flags, struct ip6_moptions *im6o, struct inpcb *inp)
int flags, struct ip6_moptions *im6o, const u_char seclevel[])
{
struct ip6_hdr *ip6;
struct ifnet *ifp = NULL;
@ -185,11 +185,6 @@ ip6_output(struct mbuf *m, struct ip6_pktopts *opt, struct route_in6 *ro,
struct tdb *tdb = NULL;
#endif /* IPSEC */
#ifdef IPSEC
if (inp && (inp->inp_flags & INP_IPV6) == 0)
panic("%s: IPv4 pcb is passed", __func__);
#endif /* IPSEC */
ip6 = mtod(m, struct ip6_hdr *);
finaldst = ip6->ip6_dst;
@ -218,8 +213,8 @@ ip6_output(struct mbuf *m, struct ip6_pktopts *opt, struct route_in6 *ro,
}
#ifdef IPSEC
if (ipsec_in_use || inp != NULL) {
error = ip6_output_ipsec_lookup(m, inp, &tdb);
if (ipsec_in_use || seclevel != NULL) {
error = ip6_output_ipsec_lookup(m, seclevel, &tdb);
if (error) {
/*
* -EINVAL is used to indicate that the packet should
@ -2751,7 +2746,8 @@ in6_proto_cksum_out(struct mbuf *m, struct ifnet *ifp)
#ifdef IPSEC
int
ip6_output_ipsec_lookup(struct mbuf *m, struct inpcb *inp, struct tdb **tdbout)
ip6_output_ipsec_lookup(struct mbuf *m, const u_char seclevel[],
struct tdb **tdbout)
{
struct tdb *tdb;
struct m_tag *mtag;
@ -2765,7 +2761,7 @@ ip6_output_ipsec_lookup(struct mbuf *m, struct inpcb *inp, struct tdb **tdbout)
/* Do we have any pending SAs to apply ? */
error = ipsp_spd_lookup(m, AF_INET6, sizeof(struct ip6_hdr),
IPSP_DIRECTION_OUT, NULL, inp, &tdb, NULL);
IPSP_DIRECTION_OUT, NULL, seclevel, &tdb, NULL);
if (error || tdb == NULL) {
*tdbout = NULL;
return error;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip6_var.h,v 1.106 2022/11/12 02:49:34 kn Exp $ */
/* $OpenBSD: ip6_var.h,v 1.107 2023/11/26 22:08:10 bluhm Exp $ */
/* $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $ */
/*
@ -325,7 +325,7 @@ void ip6_forward(struct mbuf *, struct rtentry *, int);
void ip6_mloopback(struct ifnet *, struct mbuf *, struct sockaddr_in6 *);
int ip6_output(struct mbuf *, struct ip6_pktopts *, struct route_in6 *, int,
struct ip6_moptions *, struct inpcb *);
struct ip6_moptions *, const u_char[]);
int ip6_fragment(struct mbuf *, struct mbuf_list *, int, u_char, u_long);
int ip6_ctloutput(int, struct socket *, int, int, struct mbuf *);
int ip6_raw_ctloutput(int, struct socket *, int, int, struct mbuf *);
@ -376,7 +376,7 @@ u_int32_t ip6_randomflowlabel(void);
#ifdef IPSEC
struct tdb;
int ip6_output_ipsec_lookup(struct mbuf *, struct inpcb *, struct tdb **);
int ip6_output_ipsec_lookup(struct mbuf *, const u_char[], struct tdb **);
int ip6_output_ipsec_send(struct tdb *, struct mbuf *, struct route_in6 *,
int, int);
#endif /* IPSEC */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: raw_ip6.c,v 1.173 2023/09/16 09:33:27 mpi Exp $ */
/* $OpenBSD: raw_ip6.c,v 1.174 2023/11/26 22:08:10 bluhm Exp $ */
/* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */
/*
@ -514,7 +514,7 @@ rip6_output(struct mbuf *m, struct socket *so, struct sockaddr *dstaddr,
#endif
error = ip6_output(m, optp, &in6p->inp_route6, flags,
in6p->inp_moptions6, in6p);
in6p->inp_moptions6, in6p->inp_seclevel);
if (so->so_proto->pr_protocol == IPPROTO_ICMPV6) {
icmp6stat_inc(icp6s_outhist + type);
} else

View file

@ -1,4 +1,4 @@
/* $OpenBSD: udp6_output.c,v 1.59 2022/02/22 01:35:41 guenther Exp $ */
/* $OpenBSD: udp6_output.c,v 1.60 2023/11/26 22:08:10 bluhm Exp $ */
/* $KAME: udp6_output.c,v 1.21 2001/02/07 11:51:54 itojun Exp $ */
/*
@ -232,7 +232,7 @@ udp6_output(struct inpcb *in6p, struct mbuf *m, struct mbuf *addr6,
#endif
error = ip6_output(m, optp, &in6p->inp_route6,
flags, in6p->inp_moptions6, in6p);
flags, in6p->inp_moptions6, in6p->inp_seclevel);
goto releaseopt;
release: