sync with OpenBSD -current

This commit is contained in:
purplerain 2024-06-09 07:57:03 +00:00
parent 2d0895064a
commit 0d235ae71d
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
70 changed files with 1715 additions and 502 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: cpu.c,v 1.189 2024/05/29 12:21:33 kettenis Exp $ */
/* $OpenBSD: cpu.c,v 1.190 2024/06/07 16:53:35 kettenis Exp $ */
/* $NetBSD: cpu.c,v 1.1 2003/04/26 18:39:26 fvdl Exp $ */
/*-
@ -1469,7 +1469,10 @@ int cpu_suspended;
void
cpu_suspend_cycle(void)
{
cpu_idle_cycle_fcn();
if (cpu_suspend_cycle_fcn)
cpu_suspend_cycle_fcn();
else
cpu_idle_cycle_fcn();
}
int

View file

@ -1,4 +1,4 @@
/* $OpenBSD: intr.c,v 1.58 2024/05/29 12:21:33 kettenis Exp $ */
/* $OpenBSD: intr.c,v 1.59 2024/06/07 06:26:23 jsg Exp $ */
/* $NetBSD: intr.c,v 1.3 2003/03/03 22:16:20 fvdl Exp $ */
/*
@ -559,8 +559,6 @@ intr_handler(struct intrframe *frame, struct intrhand *ih)
return rc;
}
#define CONCAT(x,y) __CONCAT(x,y)
/*
* Fake interrupt handler structures for the benefit of symmetry with
* other interrupt sources, and the benefit of intr_calculatemasks()

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ipifuncs.c,v 1.38 2023/10/30 12:50:59 mvs Exp $ */
/* $OpenBSD: ipifuncs.c,v 1.39 2024/06/07 16:53:35 kettenis Exp $ */
/* $NetBSD: ipifuncs.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */
/*-
@ -128,7 +128,10 @@ x86_64_ipi_halt(struct cpu_info *ci)
wbinvd();
for(;;) {
__asm volatile("hlt");
if (cpu_suspend_cycle_fcn)
cpu_suspend_cycle_fcn();
else
__asm volatile("hlt");
}
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: machdep.c,v 1.293 2024/04/29 00:29:48 jsg Exp $ */
/* $OpenBSD: machdep.c,v 1.294 2024/06/07 16:53:35 kettenis Exp $ */
/* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */
/*-
@ -162,6 +162,7 @@ char machine[] = MACHINE;
*/
void cpu_idle_cycle_hlt(void);
void (*cpu_idle_cycle_fcn)(void) = &cpu_idle_cycle_hlt;
void (*cpu_suspend_cycle_fcn)(void);
/* the following is used externally for concurrent handlers */
int setperf_prio = 0;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: mpbios.c,v 1.31 2022/02/21 11:03:39 mpi Exp $ */
/* $OpenBSD: mpbios.c,v 1.32 2024/06/07 23:19:18 jsg Exp $ */
/* $NetBSD: mpbios.c,v 1.7 2003/05/15 16:32:50 fvdl Exp $ */
/*-
@ -856,14 +856,6 @@ mp_print_eisa_intr(int intr)
}
#endif
#define TAB_UNIT 4
#define TAB_ROUND(a) _TAB_ROUND(a, TAB_UNIT)
#define _TAB_ROUND(a,u) (((a) + (u - 1)) & ~(u - 1))
#define EXTEND_TAB(a,u) (!(_TAB_ROUND(a, u) == _TAB_ROUND((a + 1), u)))
void
mpbios_bus(const u_int8_t *ent, struct device *self)
{

View file

@ -1,4 +1,4 @@
# $OpenBSD: Makefile.amd64,v 1.136 2024/06/05 20:19:26 deraadt Exp $
# $OpenBSD: Makefile.amd64,v 1.137 2024/06/07 05:17:34 deraadt Exp $
# For instructions on building kernels consult the config(8) and options(4)
# manual pages.
@ -73,7 +73,7 @@ CMACHFLAGS+= -mno-retpoline -fcf-protection=none
.endif
.else
CMACHFLAGS+= -mretpoline-external-thunk -fcf-protection=branch
#CMACHFLAGS+= -fret-clean
CMACHFLAGS+= -fret-clean
.endif
.if ${COMPILER_VERSION:Mclang}
NO_INTEGR_AS= -no-integrated-as

View file

@ -1,4 +1,4 @@
/* $OpenBSD: cpu.h,v 1.171 2024/05/29 12:21:33 kettenis Exp $ */
/* $OpenBSD: cpu.h,v 1.172 2024/06/07 16:53:35 kettenis Exp $ */
/* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */
/*-
@ -420,6 +420,7 @@ void cpu_proc_fork(struct proc *, struct proc *);
int amd64_pa_used(paddr_t);
#define cpu_idle_enter() do { /* nothing */ } while (0)
extern void (*cpu_idle_cycle_fcn)(void);
extern void (*cpu_suspend_cycle_fcn)(void);
#define cpu_idle_cycle() (*cpu_idle_cycle_fcn)()
#define cpu_idle_leave() do { /* nothing */ } while (0)
extern void (*initclock_func)(void);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: i82489var.h,v 1.18 2018/10/04 05:00:40 guenther Exp $ */
/* $OpenBSD: i82489var.h,v 1.19 2024/06/09 03:12:59 jsg Exp $ */
/* $NetBSD: i82489var.h,v 1.1 2003/02/26 21:26:10 fvdl Exp $ */
/*-
@ -87,21 +87,6 @@ extern void Xresume_lapic_ltimer(void);
extern void Xrecurse_lapic_ltimer(void);
#define LAPIC_TIMER_VECTOR 0xc0
/*
* 'pin numbers' for local APIC
*/
#define LAPIC_PIN_TIMER 0
#define LAPIC_PIN_PCINT 2
#define LAPIC_PIN_LVINT0 3
#define LAPIC_PIN_LVINT1 4
#define LAPIC_PIN_LVERR 5
extern void Xintr_lapic0(void);
extern void Xintr_lapic2(void);
extern void Xintr_lapic3(void);
extern void Xintr_lapic4(void);
extern void Xintr_lapic5(void);
/*
* Vector used for Xen HVM Event Channel Interrupts.
*/

View file

@ -1,4 +1,4 @@
/* $OpenBSD: db_trace.c,v 1.44 2023/04/26 16:53:58 claudio Exp $ */
/* $OpenBSD: db_trace.c,v 1.45 2024/06/07 10:14:29 jsg Exp $ */
/* $NetBSD: db_trace.c,v 1.18 1996/05/03 19:42:01 christos Exp $ */
/*
@ -68,12 +68,6 @@ struct db_variable *db_eregs = db_regs + nitems(db_regs);
*/
#define INKERNEL(va) (((vaddr_t)(va)) >= VM_MIN_KERNEL_ADDRESS)
#define NONE 0
#define TRAP 1
#define SYSCALL 2
#define INTERRUPT 3
#define AST 4
int db_i386_numargs(struct callframe *);
/*

View file

@ -1,4 +1,4 @@
/* $OpenBSD: machdep.c,v 1.671 2024/05/26 13:37:32 kettenis Exp $ */
/* $OpenBSD: machdep.c,v 1.672 2024/06/07 16:53:35 kettenis Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
@ -167,6 +167,7 @@ char machine[] = MACHINE;
void (*cpu_idle_leave_fcn)(void) = NULL;
void (*cpu_idle_cycle_fcn)(void) = NULL;
void (*cpu_idle_enter_fcn)(void) = NULL;
void (*cpu_suspend_cycle_fcn)(void);
struct uvm_constraint_range isa_constraint = { 0x0, 0x00ffffffUL };

View file

@ -1,4 +1,4 @@
/* $OpenBSD: mpbios.c,v 1.46 2024/05/13 01:15:50 jsg Exp $ */
/* $OpenBSD: mpbios.c,v 1.47 2024/06/07 23:19:18 jsg Exp $ */
/* $NetBSD: mpbios.c,v 1.2 2002/10/01 12:56:57 fvdl Exp $ */
/*-
@ -925,14 +925,6 @@ mp_print_eisa_intr(int intr)
printf(" EISA irq %d", intr);
}
#define TAB_UNIT 4
#define TAB_ROUND(a) _TAB_ROUND(a, TAB_UNIT)
#define _TAB_ROUND(a,u) (((a) + (u - 1)) & ~(u - 1))
#define EXTEND_TAB(a,u) (!(_TAB_ROUND(a, u) == _TAB_ROUND((a + 1), u)))
void
mpbios_bus(const u_int8_t *ent, struct device *self)
{

View file

@ -1,4 +1,4 @@
/* $OpenBSD: cpu.h,v 1.189 2024/05/21 23:16:06 jsg Exp $ */
/* $OpenBSD: cpu.h,v 1.190 2024/06/07 16:53:35 kettenis Exp $ */
/* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */
/*-
@ -375,6 +375,7 @@ extern const struct cpu_cpuid_nameclass i386_cpuid_cpus[];
extern void (*cpu_idle_enter_fcn)(void);
extern void (*cpu_idle_cycle_fcn)(void);
extern void (*cpu_idle_leave_fcn)(void);
extern void (*cpu_suspend_cycle_fcn)(void);
extern int cpuspeed;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: clock.c,v 1.69 2024/05/13 01:15:50 jsg Exp $ */
/* $OpenBSD: clock.c,v 1.70 2024/06/08 00:24:00 jsg Exp $ */
/* $NetBSD: clock.c,v 1.39 1996/05/12 23:11:54 mycroft Exp $ */
/*-
@ -138,9 +138,6 @@ static struct timecounter i8254_timecounter = {
struct mutex timer_mutex = MUTEX_INITIALIZER(IPL_HIGH);
u_long rtclock_tval;
#define SECMIN ((unsigned)60) /* seconds per minute */
#define SECHOUR ((unsigned)(60*SECMIN)) /* seconds per hour */
u_int
mc146818_read(void *sc, u_int reg)
{

View file

@ -1,4 +1,4 @@
/* $OpenBSD: acpicpu.c,v 1.92 2022/04/06 18:59:27 naddy Exp $ */
/* $OpenBSD: acpicpu.c,v 1.93 2024/06/07 16:53:35 kettenis Exp $ */
/*
* Copyright (c) 2005 Marco Peereboom <marco@openbsd.org>
* Copyright (c) 2015 Philip Guenther <guenther@openbsd.org>
@ -172,6 +172,7 @@ void acpicpu_add_cstate(struct acpicpu_softc *_sc, int _state, int _method,
int _flags, int _latency, int _power, uint64_t _address);
void acpicpu_set_pdc(struct acpicpu_softc *);
void acpicpu_idle(void);
void acpicpu_suspend(void);
#if 0
void acpicpu_set_throttle(struct acpicpu_softc *, int);
@ -747,6 +748,7 @@ acpicpu_attach(struct device *parent, struct device *self, void *aux)
extern uint32_t acpi_force_bm;
cpu_idle_cycle_fcn = &acpicpu_idle;
cpu_suspend_cycle_fcn = &acpicpu_suspend;
/*
* C3 (and maybe C2?) needs BM_RLD to be set to
@ -1277,3 +1279,66 @@ acpicpu_idle(void)
sc->sc_prev_sleep = (sc->sc_prev_sleep + (sc->sc_prev_sleep >> 1)
+ itime) >> 1;
}
void
acpicpu_suspend(void)
{
extern int cpu_suspended;
struct cpu_info *ci = curcpu();
struct acpicpu_softc *sc = (struct acpicpu_softc *)ci->ci_acpicpudev;
struct acpi_cstate *best, *cx;
if (sc == NULL) {
__asm volatile("sti");
panic("null acpicpu");
}
/*
* Find the lowest usable state.
*/
best = cx = SLIST_FIRST(&sc->sc_cstates);
while ((cx->flags & CST_FLAG_SKIP)) {
if ((cx = SLIST_NEXT(cx, link)) == NULL)
break;
best = cx;
}
switch (best->method) {
default:
case CST_METH_HALT:
__asm volatile("sti; hlt");
break;
case CST_METH_IO_HALT:
inb((u_short)best->address);
__asm volatile("sti; hlt");
break;
case CST_METH_MWAIT:
{
unsigned int hints;
hints = (unsigned)best->address;
/* intel errata AAI65: cflush before monitor */
if (ci->ci_cflushsz != 0 &&
strcmp(cpu_vendor, "GenuineIntel") == 0) {
membar_sync();
clflush((unsigned long)&cpu_suspended);
membar_sync();
}
monitor(&cpu_suspended, 0, 0);
if (cpu_suspended || !CPU_IS_PRIMARY(ci))
mwait(0, hints);
break;
}
case CST_METH_GAS_IO:
inb((u_short)best->address);
/* something harmless to give system time to change state */
acpi_read_pmreg(acpi_softc, ACPIREG_PM1_STS, 0);
break;
}
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: audio.c,v 1.206 2023/02/10 14:34:16 visa Exp $ */
/* $OpenBSD: audio.c,v 1.207 2024/06/07 08:48:10 jsg Exp $ */
/*
* Copyright (c) 2015 Alexandre Ratchov <alex@caoua.org>
*
@ -48,8 +48,6 @@
#define DPRINTFN(n, ...) do {} while(0)
#endif
#define IPL_SOFTAUDIO IPL_SOFTNET
#define DEVNAME(sc) ((sc)->dev.dv_xname)
#define AUDIO_UNIT(n) (minor(n) & 0x0f)
#define AUDIO_DEV(n) (minor(n) & 0xf0)

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ufshci.c,v 1.34 2024/06/05 04:58:05 mglocker Exp $ */
/* $OpenBSD: ufshci.c,v 1.35 2024/06/09 03:21:54 jsg Exp $ */
/*
* Copyright (c) 2022 Marcus Glocker <mglocker@openbsd.org>
@ -89,8 +89,6 @@ int ufshci_utr_cmd_sync(struct ufshci_softc *,
struct ufshci_ccb *, struct scsi_xfer *,
uint32_t, uint16_t);
int ufshci_xfer_complete(struct ufshci_softc *);
int ufshci_powerdown(struct ufshci_softc *);
int ufshci_resume(struct ufshci_softc *);
/* SCSI */
int ufshci_ccb_alloc(struct ufshci_softc *, int);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: fms.c,v 1.38 2024/05/24 06:02:53 jsg Exp $ */
/* $OpenBSD: fms.c,v 1.39 2024/06/09 05:18:12 jsg Exp $ */
/* $NetBSD: fms.c,v 1.5.4.1 2000/06/30 16:27:50 simonb Exp $ */
/*-
@ -118,9 +118,6 @@ int fms_read_codec(void *, u_int8_t, u_int16_t *);
int fms_write_codec(void *, u_int8_t, u_int16_t);
void fms_reset_codec(void *);
int fms_allocmem(struct fms_softc *, size_t, size_t,
struct fms_dma *);
int
fms_match(struct device *parent, void *match, void *aux)
{

View file

@ -31,7 +31,7 @@
*******************************************************************************/
/* $OpenBSD: if_em_hw.h,v 1.94 2024/05/13 01:15:51 jsg Exp $ */
/* $OpenBSD: if_em_hw.h,v 1.95 2024/06/09 05:18:12 jsg Exp $ */
/* $FreeBSD: if_em_hw.h,v 1.15 2005/05/26 23:32:02 tackerman Exp $ */
/* if_em_hw.h
@ -408,8 +408,6 @@ struct em_host_mng_dhcp_cookie{
};
int32_t em_read_part_num(struct em_hw *hw, uint32_t *part_num);
int32_t em_mng_write_dhcp_info(struct em_hw *hw, uint8_t *buffer,
uint16_t length);
boolean_t em_check_mng_mode(struct em_hw *hw);
boolean_t em_enable_tx_pkt_filtering(struct em_hw *hw);
int32_t em_read_eeprom(struct em_hw *hw, uint16_t reg, uint16_t words, uint16_t *data);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if_vmx.c,v 1.86 2024/05/21 19:49:06 jan Exp $ */
/* $OpenBSD: if_vmx.c,v 1.87 2024/06/07 08:44:25 jan Exp $ */
/*
* Copyright (c) 2013 Tsubai Masanari
@ -114,6 +114,8 @@ struct vmxnet3_comp_ring {
};
u_int next;
u_int32_t gen;
struct mbuf *sendmp;
struct mbuf *lastmp;
};
struct vmxnet3_txqueue {
@ -160,6 +162,7 @@ struct vmxnet3_softc {
struct vmxnet3_queue *sc_q;
struct intrmap *sc_intrmap;
u_int sc_vrrs;
struct vmxnet3_driver_shared *sc_ds;
u_int8_t *sc_mcast;
struct vmxnet3_upt1_rss_conf *sc_rss;
@ -170,7 +173,7 @@ struct vmxnet3_softc {
#endif
};
#define JUMBO_LEN (1024 * 9)
#define JUMBO_LEN ((16 * 1024) - 1)
#define DMAADDR(map) ((map)->dm_segs[0].ds_addr)
#define READ_BAR0(sc, reg) bus_space_read_4((sc)->sc_iot0, (sc)->sc_ioh0, reg)
@ -273,15 +276,21 @@ vmxnet3_attach(struct device *parent, struct device *self, void *aux)
return;
}
/* Vmxnet3 Revision Report and Selection */
ver = READ_BAR1(sc, VMXNET3_BAR1_VRRS);
if ((ver & 0x1) == 0) {
if (ISSET(ver, 0x2)) {
sc->sc_vrrs = 2;
} else if (ISSET(ver, 0x1)) {
sc->sc_vrrs = 1;
} else {
printf(": unsupported hardware version 0x%x\n", ver);
return;
}
WRITE_BAR1(sc, VMXNET3_BAR1_VRRS, 1);
WRITE_BAR1(sc, VMXNET3_BAR1_VRRS, sc->sc_vrrs);
/* UPT Version Report and Selection */
ver = READ_BAR1(sc, VMXNET3_BAR1_UVRS);
if ((ver & 0x1) == 0) {
if (!ISSET(ver, 0x1)) {
printf(": incompatible UPT version 0x%x\n", ver);
return;
}
@ -410,6 +419,11 @@ vmxnet3_attach(struct device *parent, struct device *self, void *aux)
ifp->if_capabilities |= IFCAP_TSOv4 | IFCAP_TSOv6;
if (sc->sc_vrrs == 2) {
ifp->if_xflags |= IFXF_LRO;
ifp->if_capabilities |= IFCAP_LRO;
}
#if NVLAN > 0
if (sc->sc_ds->upt_features & UPT1_F_VLAN)
ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING;
@ -704,6 +718,10 @@ vmxnet3_rxfill(struct vmxnet3_rxring *ring)
uint32_t rgen;
uint32_t type = htole32(VMXNET3_BTYPE_HEAD << VMXNET3_RX_BTYPE_S);
/* Second ring just contains packet bodies. */
if (ring->rid == 1)
type = htole32(VMXNET3_BTYPE_BODY << VMXNET3_RX_BTYPE_S);
MUTEX_ASSERT_LOCKED(&ring->mtx);
slots = if_rxr_get(&ring->rxr, NRXDESC);
@ -781,17 +799,17 @@ vmxnet3_rxinit(struct vmxnet3_softc *sc, struct vmxnet3_rxqueue *rq)
VMX_DMA_LEN(&ring->dmamem));
bus_dmamap_sync(sc->sc_dmat, VMX_DMA_MAP(&ring->dmamem),
0, VMX_DMA_LEN(&ring->dmamem), BUS_DMASYNC_PREWRITE);
}
/* XXX only fill ring 0 */
ring = &rq->cmd_ring[0];
mtx_enter(&ring->mtx);
vmxnet3_rxfill(ring);
mtx_leave(&ring->mtx);
mtx_enter(&ring->mtx);
vmxnet3_rxfill(ring);
mtx_leave(&ring->mtx);
}
comp_ring = &rq->comp_ring;
comp_ring->next = 0;
comp_ring->gen = VMX_RXC_GEN;
comp_ring->sendmp = NULL;
comp_ring->lastmp = NULL;
memset(VMX_DMA_KVA(&comp_ring->dmamem), 0,
VMX_DMA_LEN(&comp_ring->dmamem));
@ -1074,9 +1092,9 @@ vmxnet3_rxintr(struct vmxnet3_softc *sc, struct vmxnet3_rxqueue *rq)
struct mbuf_list ml = MBUF_LIST_INITIALIZER();
struct mbuf *m;
bus_dmamap_t map;
unsigned int idx, len;
unsigned int idx;
unsigned int next, rgen;
unsigned int done = 0;
unsigned int rid, done[2] = {0, 0};
next = comp_ring->next;
rgen = comp_ring->gen;
@ -1096,11 +1114,14 @@ vmxnet3_rxintr(struct vmxnet3_softc *sc, struct vmxnet3_rxqueue *rq)
idx = letoh32((rxcd->rxc_word0 >> VMXNET3_RXC_IDX_S) &
VMXNET3_RXC_IDX_M);
if (letoh32((rxcd->rxc_word0 >> VMXNET3_RXC_QID_S) &
VMXNET3_RXC_QID_M) < sc->sc_nqueues)
ring = &rq->cmd_ring[0];
rid = 0;
else
ring = &rq->cmd_ring[1];
rid = 1;
ring = &rq->cmd_ring[rid];
m = ring->m[idx];
KASSERT(m != NULL);
@ -1111,31 +1132,62 @@ vmxnet3_rxintr(struct vmxnet3_softc *sc, struct vmxnet3_rxqueue *rq)
BUS_DMASYNC_POSTREAD);
bus_dmamap_unload(sc->sc_dmat, map);
done++;
done[rid]++;
/*
* A receive descriptor of type 4 which is flaged as start of
* packet, contains the number of TCP segment of an LRO packet.
*/
if (letoh32((rxcd->rxc_word3 & VMXNET3_RXC_TYPE_M) >>
VMXNET3_RXC_TYPE_S) == 4 &&
ISSET(rxcd->rxc_word0, VMXNET3_RXC_SOP)) {
m->m_pkthdr.ph_mss = letoh32(rxcd->rxc_word1 &
VMXNET3_RXC_SEG_CNT_M);
}
m->m_len = letoh32((rxcd->rxc_word2 >> VMXNET3_RXC_LEN_S) &
VMXNET3_RXC_LEN_M);
if (comp_ring->sendmp == NULL) {
comp_ring->sendmp = comp_ring->lastmp = m;
comp_ring->sendmp->m_pkthdr.len = 0;
} else {
CLR(m->m_flags, M_PKTHDR);
comp_ring->lastmp->m_next = m;
comp_ring->lastmp = m;
}
comp_ring->sendmp->m_pkthdr.len += m->m_len;
if (!ISSET(rxcd->rxc_word0, VMXNET3_RXC_EOP))
continue;
/*
* End of Packet
*/
if (letoh32(rxcd->rxc_word2 & VMXNET3_RXC_ERROR)) {
ifp->if_ierrors++;
m_freem(m);
m_freem(comp_ring->sendmp);
comp_ring->sendmp = comp_ring->lastmp = NULL;
continue;
}
len = letoh32((rxcd->rxc_word2 >> VMXNET3_RXC_LEN_S) &
VMXNET3_RXC_LEN_M);
if (len < VMXNET3_MIN_MTU) {
m_freem(m);
if (comp_ring->sendmp->m_pkthdr.len < VMXNET3_MIN_MTU) {
m_freem(comp_ring->sendmp);
comp_ring->sendmp = comp_ring->lastmp = NULL;
continue;
}
m->m_pkthdr.len = m->m_len = len;
vmxnet3_rx_offload(rxcd, m);
if (((letoh32(rxcd->rxc_word0) >> VMXNET3_RXC_RSSTYPE_S) &
VMXNET3_RXC_RSSTYPE_M) != VMXNET3_RXC_RSSTYPE_NONE) {
m->m_pkthdr.ph_flowid = letoh32(rxcd->rxc_word1);
SET(m->m_pkthdr.csum_flags, M_FLOWID);
comp_ring->sendmp->m_pkthdr.ph_flowid =
letoh32(rxcd->rxc_word1);
SET(comp_ring->sendmp->m_pkthdr.csum_flags, M_FLOWID);
}
ml_enqueue(&ml, m);
vmxnet3_rx_offload(rxcd, comp_ring->sendmp);
ml_enqueue(&ml, comp_ring->sendmp);
comp_ring->sendmp = comp_ring->lastmp = NULL;
}
bus_dmamap_sync(sc->sc_dmat, VMX_DMA_MAP(&comp_ring->dmamem),
@ -1144,19 +1196,20 @@ vmxnet3_rxintr(struct vmxnet3_softc *sc, struct vmxnet3_rxqueue *rq)
comp_ring->next = next;
comp_ring->gen = rgen;
if (done == 0)
return;
for (int i = 0; i < 2; i++) {
if (done[i] == 0)
continue;
ring = &rq->cmd_ring[0];
ring = &rq->cmd_ring[i];
if (ifiq_input(rq->ifiq, &ml))
if_rxr_livelocked(&ring->rxr);
if (ifiq_input(rq->ifiq, &ml))
if_rxr_livelocked(&ring->rxr);
/* XXX Should we (try to) allocate buffers for ring 2 too? */
mtx_enter(&ring->mtx);
if_rxr_put(&ring->rxr, done);
vmxnet3_rxfill(ring);
mtx_leave(&ring->mtx);
mtx_enter(&ring->mtx);
if_rxr_put(&ring->rxr, done[i]);
vmxnet3_rxfill(ring);
mtx_leave(&ring->mtx);
}
}
void
@ -1211,6 +1264,8 @@ vmxnet3_iff(struct vmxnet3_softc *sc)
void
vmxnet3_rx_offload(struct vmxnet3_rxcompdesc *rxcd, struct mbuf *m)
{
uint32_t pkts;
/*
* VLAN Offload
*/
@ -1243,6 +1298,45 @@ vmxnet3_rx_offload(struct vmxnet3_rxcompdesc *rxcd, struct mbuf *m)
else if (ISSET(rxcd->rxc_word3, VMXNET3_RXC_UDP))
SET(m->m_pkthdr.csum_flags, M_UDP_CSUM_IN_OK);
}
/*
* TCP Large Receive Offload
*/
pkts = m->m_pkthdr.ph_mss;
m->m_pkthdr.ph_mss = 0;
if (pkts > 1) {
struct ether_extracted ext;
uint32_t paylen;
ether_extract_headers(m, &ext);
paylen = ext.iplen;
if (ext.ip4 || ext.ip6)
paylen -= ext.iphlen;
if (ext.tcp) {
paylen -= ext.tcphlen;
tcpstat_inc(tcps_inhwlro);
tcpstat_add(tcps_inpktlro, pkts);
} else {
tcpstat_inc(tcps_inbadlro);
}
/*
* If we gonna forward this packet, we have to mark it as TSO,
* set a correct mss, and recalculate the TCP checksum.
*/
if (ext.tcp && paylen >= pkts) {
SET(m->m_pkthdr.csum_flags, M_TCP_TSO);
m->m_pkthdr.ph_mss = paylen / pkts;
}
if (ext.tcp &&
ISSET(m->m_pkthdr.csum_flags, M_TCP_CSUM_IN_OK)) {
SET(m->m_pkthdr.csum_flags, M_TCP_CSUM_OUT);
}
}
}
void
@ -1309,6 +1403,13 @@ vmxnet3_init(struct vmxnet3_softc *sc)
return EIO;
}
/* TCP Large Receive Offload */
if (ISSET(ifp->if_xflags, IFXF_LRO))
SET(sc->sc_ds->upt_features, UPT1_F_LRO);
else
CLR(sc->sc_ds->upt_features, UPT1_F_LRO);
WRITE_CMD(sc, VMXNET3_CMD_SET_FEATURE);
/* Program promiscuous mode and multicast filters. */
vmxnet3_iff(sc);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if_vmxreg.h,v 1.9 2020/07/07 01:36:49 dlg Exp $ */
/* $OpenBSD: if_vmxreg.h,v 1.10 2024/06/07 08:44:25 jan Exp $ */
/*
* Copyright (c) 2013 Tsubai Masanari
@ -76,6 +76,7 @@ enum UPT1_RxStats {
#define VMXNET3_CMD_RESET 0xcafe0002 /* reset device */
#define VMXNET3_CMD_SET_RXMODE 0xcafe0003 /* set interface flags */
#define VMXNET3_CMD_SET_FILTER 0xcafe0004 /* set address filter */
#define VMXNET3_CMD_SET_FEATURE 0xcafe0009 /* set features */
#define VMXNET3_CMD_GET_STATUS 0xf00d0000 /* get queue errors */
#define VMXNET3_CMD_GET_STATS 0xf00d0001
#define VMXNET3_CMD_GET_LINK 0xf00d0002 /* get link status */
@ -189,6 +190,7 @@ struct vmxnet3_rxcompdesc {
u_int32_t rxc_word1;
#define VMXNET3_RXC_RSSHASH_M 0xffffffff /* RSS hash value */
#define VMXNET3_RXC_RSSHASH_S 0
#define VMXNET3_RXC_SEG_CNT_M 0x000000ff /* No. of seg. in LRO pkt */
u_int32_t rxc_word2;
#define VMXNET3_RXC_LEN_M 0x00003fff
@ -210,6 +212,7 @@ struct vmxnet3_rxcompdesc {
#define VMXNET3_RXC_FRAGMENT 0x00400000 /* IP fragment */
#define VMXNET3_RXC_FCS 0x00800000 /* frame CRC correct */
#define VMXNET3_RXC_TYPE_M 0x7f000000
#define VMXNET3_RXC_TYPE_S 24
#define VMXNET3_RXC_GEN_M 0x00000001U
#define VMXNET3_RXC_GEN_S 31
} __packed;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: igc_api.h,v 1.2 2022/05/11 06:14:15 kevlo Exp $ */
/* $OpenBSD: igc_api.h,v 1.3 2024/06/09 05:18:12 jsg Exp $ */
/*-
* Copyright 2021 Intel Corp
* Copyright 2021 Rubicon Communications, LLC (Netgate)
@ -20,35 +20,17 @@ int igc_setup_init_funcs(struct igc_hw *, bool);
int igc_init_mac_params(struct igc_hw *);
int igc_init_nvm_params(struct igc_hw *);
int igc_init_phy_params(struct igc_hw *);
int igc_get_bus_info(struct igc_hw *);
void igc_clear_vfta(struct igc_hw *);
void igc_write_vfta(struct igc_hw *, uint32_t, uint32_t);
int igc_force_mac_fc(struct igc_hw *);
int igc_check_for_link(struct igc_hw *);
int igc_reset_hw(struct igc_hw *);
int igc_init_hw(struct igc_hw *);
int igc_setup_link(struct igc_hw *);
int igc_get_speed_and_duplex(struct igc_hw *, uint16_t *,
uint16_t *);
int igc_disable_pcie_master(struct igc_hw *);
void igc_config_collision_dist(struct igc_hw *);
int igc_rar_set(struct igc_hw *, uint8_t *, uint32_t);
uint32_t igc_hash_mc_addr(struct igc_hw *, uint8_t *);
void igc_update_mc_addr_list(struct igc_hw *, uint8_t *, uint32_t);
int igc_check_reset_block(struct igc_hw *);
int igc_get_cable_length(struct igc_hw *);
int igc_validate_mdi_setting(struct igc_hw *);
int igc_get_phy_info(struct igc_hw *);
int igc_phy_hw_reset(struct igc_hw *);
void igc_power_up_phy(struct igc_hw *);
void igc_power_down_phy(struct igc_hw *);
int igc_read_mac_addr(struct igc_hw *);
int igc_read_pba_string(struct igc_hw *, uint8_t *, uint32_t);
void igc_reload_nvm(struct igc_hw *);
int igc_validate_nvm_checksum(struct igc_hw *);
int igc_read_nvm(struct igc_hw *, uint16_t, uint16_t, uint16_t *);
int igc_write_nvm(struct igc_hw *, uint16_t, uint16_t, uint16_t *);
int igc_set_d3_lplu_state(struct igc_hw *, bool);
int igc_set_d0_lplu_state(struct igc_hw *, bool);
#endif /* _IGC_API_H_ */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: igc_mac.h,v 1.1 2021/10/31 14:52:57 patrick Exp $ */
/* $OpenBSD: igc_mac.h,v 1.2 2024/06/09 05:18:12 jsg Exp $ */
/*-
* Copyright 2021 Intel Corp
* Copyright 2021 Rubicon Communications, LLC (Netgate)
@ -12,34 +12,23 @@
void igc_init_mac_ops_generic(struct igc_hw *);
int igc_null_ops_generic(struct igc_hw *);
int igc_null_link_info(struct igc_hw *, uint16_t *, uint16_t *);
bool igc_null_mng_mode(struct igc_hw *);
void igc_null_update_mc(struct igc_hw *, uint8_t *h, uint32_t);
void igc_null_write_vfta(struct igc_hw *, uint32_t a, uint32_t);
int igc_check_for_copper_link_generic(struct igc_hw *);
int igc_config_fc_after_link_up_generic(struct igc_hw *);
int igc_disable_pcie_master_generic(struct igc_hw *);
int igc_force_mac_fc_generic(struct igc_hw *);
int igc_get_auto_rd_done_generic(struct igc_hw *);
int igc_get_bus_info_pcie_generic(struct igc_hw *);
void igc_set_lan_id_single_port(struct igc_hw *);
int igc_get_speed_and_duplex_copper_generic(struct igc_hw *, uint16_t *,
uint16_t *);
void igc_update_mc_addr_list_generic(struct igc_hw *, uint8_t *, uint32_t);
int igc_rar_set_generic(struct igc_hw *, uint8_t *, uint32_t);
int igc_set_fc_watermarks_generic(struct igc_hw *);
int igc_setup_link_generic(struct igc_hw *);
int igc_validate_mdi_setting_crossover_generic(struct igc_hw *);
int igc_hash_mc_addr_generic(struct igc_hw *, uint8_t *);
void igc_clear_hw_cntrs_base_generic(struct igc_hw *);
void igc_clear_vfta_generic(struct igc_hw *);
void igc_init_rx_addrs_generic(struct igc_hw *, uint16_t);
void igc_pcix_mmrbc_workaround_generic(struct igc_hw *);
void igc_put_hw_semaphore_generic(struct igc_hw *);
int igc_check_alt_mac_addr_generic(struct igc_hw *);
void igc_set_pcie_no_snoop_generic(struct igc_hw *, uint32_t);
void igc_write_vfta_generic(struct igc_hw *, uint32_t, uint32_t);
void igc_config_collision_dist_generic(struct igc_hw *);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: igc_nvm.h,v 1.1 2021/10/31 14:52:57 patrick Exp $ */
/* $OpenBSD: igc_nvm.h,v 1.2 2024/06/09 05:18:12 jsg Exp $ */
/*-
* Copyright 2021 Intel Corp
* Copyright 2021 Rubicon Communications, LLC (Netgate)
@ -13,17 +13,11 @@
void igc_init_nvm_ops_generic(struct igc_hw *);
int igc_null_read_nvm(struct igc_hw *, uint16_t, uint16_t, uint16_t *);
void igc_null_nvm_generic(struct igc_hw *);
int igc_null_led_default(struct igc_hw *, uint16_t *);
int igc_null_write_nvm(struct igc_hw *, uint16_t, uint16_t, uint16_t *);
int igc_poll_eerd_eewr_done(struct igc_hw *, int);
int igc_read_mac_addr_generic(struct igc_hw *);
int igc_read_pba_string_generic(struct igc_hw *, uint8_t *, uint32_t);
int igc_read_nvm_eerd(struct igc_hw *, uint16_t, uint16_t, uint16_t *);
int igc_valid_led_default_generic(struct igc_hw *, uint16_t *);
int igc_validate_nvm_checksum_generic(struct igc_hw *);
int igc_write_nvm_spi(struct igc_hw *, uint16_t, uint16_t, uint16_t *);
int igc_update_nvm_checksum_generic(struct igc_hw *);
void igc_release_nvm_generic(struct igc_hw *);
void igc_reload_nvm_generic(struct igc_hw *);
#endif /* _IGC_NVM_H_ */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: igc_phy.h,v 1.2 2022/05/11 06:14:15 kevlo Exp $ */
/* $OpenBSD: igc_phy.h,v 1.3 2024/06/09 05:18:12 jsg Exp $ */
/*-
* Copyright 2021 Intel Corp
* Copyright 2021 Rubicon Communications, LLC (Netgate)
@ -20,13 +20,8 @@ int igc_check_downshift_generic(struct igc_hw *);
int igc_check_reset_block_generic(struct igc_hw *);
int igc_get_phy_id(struct igc_hw *);
int igc_phy_hw_reset_generic(struct igc_hw *);
int igc_phy_reset_dsp_generic(struct igc_hw *);
int igc_set_d3_lplu_state_generic(struct igc_hw *, bool);
int igc_setup_copper_link_generic(struct igc_hw *);
int igc_phy_has_link_generic(struct igc_hw *, uint32_t, uint32_t, bool *);
int igc_determine_phy_address(struct igc_hw *);
int igc_enable_phy_wakeup_reg_access_bm(struct igc_hw *, uint16_t *);
int igc_disable_phy_wakeup_reg_access_bm(struct igc_hw *, uint16_t *);
void igc_power_up_phy_copper(struct igc_hw *);
void igc_power_down_phy_copper(struct igc_hw *);
int igc_read_phy_reg_mdic(struct igc_hw *, uint32_t offset, uint16_t *);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ixgbe.h,v 1.35 2024/04/12 19:27:43 jan Exp $ */
/* $OpenBSD: ixgbe.h,v 1.36 2024/06/09 05:18:12 jsg Exp $ */
/******************************************************************************
@ -268,10 +268,6 @@ int32_t ixgbe_init_hw(struct ixgbe_hw *hw);
enum ixgbe_media_type ixgbe_get_media_type(struct ixgbe_hw *hw);
int32_t ixgbe_identify_phy(struct ixgbe_hw *hw);
void ixgbe_flap_tx_laser(struct ixgbe_hw *hw);
int32_t ixgbe_setup_link(struct ixgbe_hw *hw, ixgbe_link_speed speed,
bool autoneg_wait_to_complete);
int32_t ixgbe_setup_mac_link(struct ixgbe_hw *hw, ixgbe_link_speed speed,
bool autoneg_wait_to_complete);
int32_t ixgbe_check_link(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
bool *link_up, bool link_up_wait_to_complete);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: pf.c,v 1.1196 2024/05/14 08:26:13 jsg Exp $ */
/* $OpenBSD: pf.c,v 1.1197 2024/06/07 18:24:16 bluhm Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@ -7958,12 +7958,17 @@ done:
switch (pd.naf) {
case AF_INET:
if (pd.dir == PF_IN) {
if (ipforwarding == 0) {
int flags;
if (ip_forwarding == 0) {
ipstat_inc(ips_cantforward);
action = PF_DROP;
break;
}
ip_forward(pd.m, ifp, NULL, 1);
flags = IP_FORWARDING | IP_REDIRECT;
if (ip_directedbcast)
SET(flags, IP_ALLOWBROADCAST);
ip_forward(pd.m, ifp, NULL, flags);
} else
ip_output(pd.m, NULL, NULL, 0, NULL, NULL, 0);
break;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: pipex.c,v 1.153 2024/01/23 17:57:21 mvs Exp $ */
/* $OpenBSD: pipex.c,v 1.154 2024/06/07 13:43:21 jsg Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
@ -104,9 +104,6 @@ int pipex_prune = 1; /* [I] walk list every seconds */
struct mbuf_queue pipexoutq = MBUF_QUEUE_INITIALIZER(
IFQ_MAXLEN, IPL_SOFTNET);
/* borrow an mbuf pkthdr field */
#define ph_ppp_proto ether_vtag
#ifdef PIPEX_DEBUG
int pipex_debug = 0; /* [A] systcl net.inet.ip.pipex_debug */
#endif

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip_esp.c,v 1.195 2022/05/03 09:18:11 claudio Exp $ */
/* $OpenBSD: ip_esp.c,v 1.196 2024/06/07 13:15:25 jsg Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
@ -334,8 +334,6 @@ esp_zeroize(struct tdb *tdbp)
return error;
}
#define MAXBUFSIZ (AH_ALEN_MAX > ESP_MAX_IVS ? AH_ALEN_MAX : ESP_MAX_IVS)
/*
* ESP input processing, called (eventually) through the protocol switch.
*/

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip_icmp.c,v 1.192 2023/09/16 09:33:27 mpi Exp $ */
/* $OpenBSD: ip_icmp.c,v 1.193 2024/06/07 18:24:16 bluhm Exp $ */
/* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */
/*
@ -589,7 +589,7 @@ reflect:
struct sockaddr_in ssrc;
struct rtentry *newrt = NULL;
if (icmp_rediraccept == 0 || ipforwarding == 1)
if (icmp_rediraccept == 0 || ip_forwarding == 1)
goto freeit;
if (code > 3)
goto badcode;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip_input.c,v 1.394 2024/05/08 13:01:30 bluhm Exp $ */
/* $OpenBSD: ip_input.c,v 1.395 2024/06/07 18:24:16 bluhm Exp $ */
/* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */
/*
@ -84,10 +84,10 @@
#endif
/* values controllable via sysctl */
int ipforwarding = 0;
int ip_forwarding = 0;
int ipmforwarding = 0;
int ipmultipath = 0;
int ipsendredirects = 1;
int ip_sendredirects = 1;
int ip_dosourceroute = 0;
int ip_defttl = IPDEFTTL;
int ip_mtudisc = 1;
@ -108,8 +108,8 @@ const struct sysctl_bounded_args ipctl_vars[] = {
#ifdef MROUTING
{ IPCTL_MRTPROTO, &ip_mrtproto, SYSCTL_INT_READONLY },
#endif
{ IPCTL_FORWARDING, &ipforwarding, 0, 2 },
{ IPCTL_SENDREDIRECTS, &ipsendredirects, 0, 1 },
{ IPCTL_FORWARDING, &ip_forwarding, 0, 2 },
{ IPCTL_SENDREDIRECTS, &ip_sendredirects, 0, 1 },
{ IPCTL_DEFTTL, &ip_defttl, 0, 255 },
{ IPCTL_DIRECTEDBCAST, &ip_directedbcast, 0, 1 },
{ IPCTL_IPPORT_FIRSTAUTO, &ipport_firstauto, 0, 65535 },
@ -137,8 +137,8 @@ static struct mbuf_queue ipsendraw_mq;
extern struct niqueue arpinq;
int ip_ours(struct mbuf **, int *, int, int);
int ip_dooptions(struct mbuf *, struct ifnet *);
int in_ouraddr(struct mbuf *, struct ifnet *, struct route *);
int ip_dooptions(struct mbuf *, struct ifnet *, int);
int in_ouraddr(struct mbuf *, struct ifnet *, struct route *, int);
int ip_fragcheck(struct mbuf **, int *);
struct mbuf * ip_reass(struct ipqent *, struct ipq *);
@ -431,7 +431,7 @@ ip_input_if(struct mbuf **mp, int *offp, int nxt, int af, struct ifnet *ifp)
#if NPF > 0
struct in_addr odst;
#endif
int pfrdr = 0;
int flags = 0;
KASSERT(*offp == 0);
@ -461,9 +461,15 @@ ip_input_if(struct mbuf **mp, int *offp, int nxt, int af, struct ifnet *ifp)
goto bad;
ip = mtod(m, struct ip *);
pfrdr = odst.s_addr != ip->ip_dst.s_addr;
if (odst.s_addr != ip->ip_dst.s_addr)
SET(flags, IP_REDIRECT);
#endif
if (ip_forwarding != 0)
SET(flags, IP_FORWARDING);
if (ip_directedbcast)
SET(flags, IP_ALLOWBROADCAST);
hlen = ip->ip_hl << 2;
/*
@ -472,7 +478,7 @@ ip_input_if(struct mbuf **mp, int *offp, int nxt, int af, struct ifnet *ifp)
* error was detected (causing an icmp message
* to be sent and the original packet to be freed).
*/
if (hlen > sizeof (struct ip) && ip_dooptions(m, ifp)) {
if (hlen > sizeof (struct ip) && ip_dooptions(m, ifp, flags)) {
m = *mp = NULL;
goto bad;
}
@ -483,7 +489,7 @@ ip_input_if(struct mbuf **mp, int *offp, int nxt, int af, struct ifnet *ifp)
goto out;
}
switch(in_ouraddr(m, ifp, &ro)) {
switch(in_ouraddr(m, ifp, &ro, flags)) {
case 2:
goto bad;
case 1:
@ -565,7 +571,7 @@ ip_input_if(struct mbuf **mp, int *offp, int nxt, int af, struct ifnet *ifp)
/*
* Not for us; forward if possible and desirable.
*/
if (ipforwarding == 0) {
if (!ISSET(flags, IP_FORWARDING)) {
ipstat_inc(ips_cantforward);
goto bad;
}
@ -585,7 +591,7 @@ ip_input_if(struct mbuf **mp, int *offp, int nxt, int af, struct ifnet *ifp)
}
#endif /* IPSEC */
ip_forward(m, ifp, &ro, pfrdr);
ip_forward(m, ifp, &ro, flags);
*mp = NULL;
rtfree(ro.ro_rt);
return IPPROTO_DONE;
@ -807,7 +813,7 @@ ip_deliver(struct mbuf **mp, int *offp, int nxt, int af, int shared)
#undef IPSTAT_INC
int
in_ouraddr(struct mbuf *m, struct ifnet *ifp, struct route *ro)
in_ouraddr(struct mbuf *m, struct ifnet *ifp, struct route *ro, int flags)
{
struct rtentry *rt;
struct ip *ip;
@ -837,7 +843,8 @@ in_ouraddr(struct mbuf *m, struct ifnet *ifp, struct route *ro)
* if it is received on the interface with that address.
*/
if (ISSET(rt->rt_flags, RTF_BROADCAST) &&
(!ip_directedbcast || rt->rt_ifidx == ifp->if_index)) {
(!ISSET(flags, IP_ALLOWBROADCAST) ||
rt->rt_ifidx == ifp->if_index)) {
match = 1;
/* Make sure M_BCAST is set */
@ -876,7 +883,8 @@ in_ouraddr(struct mbuf *m, struct ifnet *ifp, struct route *ro)
break;
}
}
} else if (ipforwarding == 0 && rt->rt_ifidx != ifp->if_index &&
} else if (!ISSET(flags, IP_FORWARDING) &&
rt->rt_ifidx != ifp->if_index &&
!((ifp->if_flags & IFF_LOOPBACK) || (ifp->if_type == IFT_ENC) ||
(m->m_pkthdr.pf.flags & PF_TAG_TRANSLATE_LOCALHOST))) {
/* received on wrong interface. */
@ -1150,7 +1158,7 @@ ip_flush(void)
* 0 if the packet should be processed further.
*/
int
ip_dooptions(struct mbuf *m, struct ifnet *ifp)
ip_dooptions(struct mbuf *m, struct ifnet *ifp, int flags)
{
struct ip *ip = mtod(m, struct ip *);
unsigned int rtableid = m->m_pkthdr.ph_rtableid;
@ -1371,8 +1379,8 @@ ip_dooptions(struct mbuf *m, struct ifnet *ifp)
}
}
KERNEL_UNLOCK();
if (forward && ipforwarding > 0) {
ip_forward(m, ifp, NULL, 1);
if (forward && ISSET(flags, IP_FORWARDING)) {
ip_forward(m, ifp, NULL, flags | IP_REDIRECT);
return (1);
}
return (0);
@ -1514,7 +1522,7 @@ const u_char inetctlerrmap[PRC_NCMDS] = {
* of codes and types.
*
* If not forwarding, just drop the packet. This could be confusing
* if ipforwarding was zero but some routing protocol was advancing
* if ip_forwarding was zero but some routing protocol was advancing
* us as a gateway to somewhere. However, we must let the routing
* protocol deal with that.
*
@ -1522,7 +1530,7 @@ const u_char inetctlerrmap[PRC_NCMDS] = {
* via a source route.
*/
void
ip_forward(struct mbuf *m, struct ifnet *ifp, struct route *ro, int srcrt)
ip_forward(struct mbuf *m, struct ifnet *ifp, struct route *ro, int flags)
{
struct mbuf mfake, *mcopy;
struct ip *ip = mtod(m, struct ip *);
@ -1588,7 +1596,7 @@ ip_forward(struct mbuf *m, struct ifnet *ifp, struct route *ro, int srcrt)
if ((rt->rt_ifidx == ifp->if_index) &&
(rt->rt_flags & (RTF_DYNAMIC|RTF_MODIFIED)) == 0 &&
satosin(rt_key(rt))->sin_addr.s_addr != 0 &&
ipsendredirects && !srcrt &&
ip_sendredirects && !ISSET(flags, IP_REDIRECT) &&
!arpproxy(satosin(rt_key(rt))->sin_addr, m->m_pkthdr.ph_rtableid)) {
if ((ip->ip_src.s_addr & ifatoia(rt->rt_ifa)->ia_netmask) ==
ifatoia(rt->rt_ifa)->ia_net) {
@ -1602,9 +1610,7 @@ ip_forward(struct mbuf *m, struct ifnet *ifp, struct route *ro, int srcrt)
}
}
error = ip_output(m, NULL, ro,
(IP_FORWARDING | (ip_directedbcast ? IP_ALLOWBROADCAST : 0)),
NULL, NULL, 0);
error = ip_output(m, NULL, ro, flags | IP_FORWARDING, NULL, NULL, 0);
rt = ro->ro_rt;
if (error)
ipstat_inc(ips_cantforward);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip_output.c,v 1.399 2024/05/16 13:01:04 bluhm Exp $ */
/* $OpenBSD: ip_output.c,v 1.400 2024/06/07 18:24:16 bluhm Exp $ */
/* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */
/*
@ -428,7 +428,7 @@ sendit:
#endif
#ifdef IPSEC
if ((flags & IP_FORWARDING) && ipforwarding == 2 &&
if ((flags & IP_FORWARDING) && ip_forwarding == 2 &&
(!ipsec_in_use ||
m_tag_find(m, PACKET_TAG_IPSEC_IN_DONE, NULL) == NULL)) {
error = EHOSTUNREACH;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip_var.h,v 1.117 2024/04/17 20:48:51 bluhm Exp $ */
/* $OpenBSD: ip_var.h,v 1.118 2024/06/07 18:24:16 bluhm Exp $ */
/* $NetBSD: ip_var.h,v 1.16 1996/02/13 23:43:20 christos Exp $ */
/*
@ -204,10 +204,11 @@ struct ipoffnxt {
};
/* flags passed to ip_output */
#define IP_FORWARDING 0x1 /* most of ip header exists */
#define IP_RAWOUTPUT 0x2 /* raw ip header exists */
#define IP_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */
#define IP_MTUDISC 0x0800 /* pmtu discovery, set DF */
#define IP_FORWARDING 0x0001 /* most of ip header exists */
#define IP_RAWOUTPUT 0x0002 /* raw ip header exists */
#define IP_REDIRECT 0x0004 /* redirected by pf or source route */
#define IP_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */
#define IP_MTUDISC 0x0800 /* pmtu discovery, set DF */
extern struct ipstat ipstat;
extern int ip_defttl; /* default IP ttl */
@ -221,11 +222,12 @@ extern int ipport_firstauto; /* min port for port allocation */
extern int ipport_lastauto; /* max port for port allocation */
extern int ipport_hifirstauto; /* min dynamic/private port number */
extern int ipport_hilastauto; /* max dynamic/private port number */
extern int ipforwarding; /* enable IP forwarding */
extern int ip_forwarding; /* enable IP forwarding */
#ifdef MROUTING
extern int ipmforwarding; /* enable multicast forwarding */
#endif
extern int ipmultipath; /* enable multipath routing */
extern int ip_directedbcast; /* accept all broadcast packets */
extern unsigned int la_hold_total;
extern const struct pr_usrreqs rip_usrreqs;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: tcp_input.c,v 1.405 2024/04/17 20:48:51 bluhm Exp $ */
/* $OpenBSD: tcp_input.c,v 1.406 2024/06/07 08:02:17 jsg Exp $ */
/* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */
/*
@ -106,11 +106,6 @@ int tcp_flush_queue(struct tcpcb *);
#ifdef INET6
#include <netinet6/in6_var.h>
#include <netinet6/nd6.h>
/* for the packet header length in the mbuf */
#define M_PH_LEN(m) (((struct mbuf *)(m))->m_pkthdr.len)
#define M_V6_LEN(m) (M_PH_LEN(m) - sizeof(struct ip6_hdr))
#define M_V4_LEN(m) (M_PH_LEN(m) - sizeof(struct ip))
#endif /* INET6 */
int tcprexmtthresh = 3;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: in6.c,v 1.266 2024/05/21 15:12:25 florian Exp $ */
/* $OpenBSD: in6.c,v 1.267 2024/06/07 09:48:19 florian Exp $ */
/* $KAME: in6.c,v 1.372 2004/06/14 08:14:21 itojun Exp $ */
/*
@ -549,7 +549,7 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
struct in6_ifaddr *ia6)
{
int error = 0, hostIsNew = 0, plen = -1;
struct sockaddr_in6 dst6;
struct sockaddr_in6 dst6, gw6;
struct in6_addrlifetime *lt;
struct in6_multi_mship *imm;
struct rtentry *rt;
@ -604,7 +604,13 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
plen = in6_mask2len(&ia6->ia_prefixmask.sin6_addr, NULL);
}
dst6 = ifra->ifra_dstaddr;
if (ifra->ifra_flags & IN6_IFF_AUTOCONF) {
gw6 = ifra->ifra_dstaddr;
memset(&dst6, 0, sizeof(dst6));
} else {
dst6 = ifra->ifra_dstaddr;
memset(&gw6, 0, sizeof(gw6));
}
if (dst6.sin6_family == AF_INET6) {
error = in6_check_embed_scope(&dst6, ifp->if_index);
if (error)
@ -614,6 +620,11 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
(ifp->if_flags & IFF_LOOPBACK)) && plen != 128)
return (EINVAL);
}
if (gw6.sin6_family == AF_INET6) {
error = in6_check_embed_scope(&gw6, ifp->if_index);
if (error)
return error;
}
/* lifetime consistency check */
lt = &ifra->ifra_lifetime;
if (lt->ia6t_pltime > lt->ia6t_vltime)
@ -702,10 +713,10 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
}
if ((ifra->ifra_flags & IN6_IFF_AUTOCONF) &&
dst6.sin6_family == AF_INET6 &&
gw6.sin6_family == AF_INET6 &&
!IN6_ARE_ADDR_EQUAL(&dst6.sin6_addr, &ia6->ia_gwaddr.sin6_addr)) {
/* Set or update announcing router */
ia6->ia_gwaddr = dst6;
ia6->ia_gwaddr = gw6;
}
/*

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip6_forward.c,v 1.117 2024/04/16 12:56:39 bluhm Exp $ */
/* $OpenBSD: ip6_forward.c,v 1.118 2024/06/07 18:24:16 bluhm Exp $ */
/* $KAME: ip6_forward.c,v 1.75 2001/06/29 12:42:13 jinmei Exp $ */
/*
@ -75,7 +75,7 @@
* of codes and types.
*
* If not forwarding, just drop the packet. This could be confusing
* if ipforwarding was zero but some routing protocol was advancing
* if ip6_forwarding was zero but some routing protocol was advancing
* us as a gateway to somewhere. However, we must let the routing
* protocol deal with that.
*

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip6_mroute.c,v 1.141 2024/04/06 14:23:27 bluhm Exp $ */
/* $OpenBSD: ip6_mroute.c,v 1.142 2024/06/07 08:37:59 jsg Exp $ */
/* $NetBSD: ip6_mroute.c,v 1.59 2003/12/10 09:28:38 itojun Exp $ */
/* $KAME: ip6_mroute.c,v 1.45 2001/03/25 08:38:51 itojun Exp $ */
@ -135,34 +135,6 @@ int ip6_mrouter_ver = 0;
int ip6_mrtproto; /* for netstat only */
struct mrt6stat mrt6stat;
#define NO_RTE_FOUND 0x1
#define RTE_FOUND 0x2
/*
* Macros to compute elapsed time efficiently
* Borrowed from Van Jacobson's scheduling code
*/
#define TV_DELTA(a, b, delta) do { \
int xxs; \
\
delta = (a).tv_usec - (b).tv_usec; \
if ((xxs = (a).tv_sec - (b).tv_sec)) { \
switch (xxs) { \
case 2: \
delta += 1000000; \
/* FALLTHROUGH */ \
case 1: \
delta += 1000000; \
break; \
default: \
delta += (1000000 * xxs); \
} \
} \
} while (0)
#define TV_LT(a, b) (((a).tv_usec < (b).tv_usec && \
(a).tv_sec <= (b).tv_sec) || (a).tv_sec < (b).tv_sec)
int get_sg6_cnt(struct sioc_sg_req6 *, unsigned int);
int get_mif6_cnt(struct sioc_mif_req6 *, unsigned int);
int ip6_mrouter_init(struct socket *, int, int);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ext2fs_vfsops.c,v 1.119 2024/05/12 09:19:54 jsg Exp $ */
/* $OpenBSD: ext2fs_vfsops.c,v 1.120 2024/06/07 09:26:37 jsg Exp $ */
/* $NetBSD: ext2fs_vfsops.c,v 1.1 1997/06/11 09:34:07 bouyer Exp $ */
/*
@ -101,10 +101,7 @@ ext2fs_init(struct vfsconf *vfsp)
/*
* Called by main() when ext2fs is going to be mounted as root.
*
* Name is updated by mount(8) after booting.
*/
#define ROOTNAME "root_device"
int
ext2fs_mountroot(void)

View file

@ -1,4 +1,4 @@
/* $OpenBSD: uvm_addr.c,v 1.34 2024/05/13 01:15:53 jsg Exp $ */
/* $OpenBSD: uvm_addr.c,v 1.35 2024/06/07 06:04:43 jsg Exp $ */
/*
* Copyright (c) 2011 Ariane van der Steldt <ariane@stack.nl>
@ -24,8 +24,6 @@
#include <uvm/uvm_addr.h>
#include <sys/pool.h>
/* Max gap between hint allocations. */
#define UADDR_HINT_MAXGAP (4 * PAGE_SIZE)
/* Number of pivots in pivot allocator. */
#define NUM_PIVOTS 16
/*