sync with OpenBSD -current

This commit is contained in:
purplerain 2024-02-13 19:37:16 +00:00
parent c151d49b7a
commit be76e7e421
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
96 changed files with 2153 additions and 617 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: mvacc.c,v 1.5 2022/07/11 10:44:08 jmatthew Exp $ */
/* $OpenBSD: mvacc.c,v 1.6 2024/02/13 02:14:25 jsg Exp $ */
/*
* Copyright (c) 2016 Patrick Wildt <patrick@blueri.se>
*
@ -133,7 +133,7 @@ mvacc_get_frequency(void *cookie, uint32_t *cells)
cpu = (sar >> SAR_CPU_DDR_FREQ_OPT) & SAR_CPU_DDR_FREQ_OPT_MASK;
tclk = (sar >> SAR_TCLK_FREQ_OPT) & SAR_TCLK_FREQ_OPT_MASK;
if (cpu > nitems(mvacc_cpu_freqs)) {
if (cpu >= nitems(mvacc_cpu_freqs)) {
printf("%s: invalid cpu frequency", sc->sc_dev.dv_xname);
return 0;
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ehci_fdt.c,v 1.11 2024/01/26 17:11:50 kettenis Exp $ */
/* $OpenBSD: ehci_fdt.c,v 1.12 2024/02/12 21:37:25 uaa Exp $ */
/*
* Copyright (c) 2005 David Gwynne <dlg@openbsd.org>
@ -207,6 +207,7 @@ struct ehci_phy ehci_phys[] = {
{ "allwinner,sun8i-v3s-usb-phy", sun4i_phy_init },
{ "allwinner,sun20i-d1-usb-phy", sun4i_phy_init },
{ "allwinner,sun50i-h6-usb-phy", sun4i_phy_init },
{ "allwinner,sun50i-h616-usb-phy", sun4i_phy_init },
{ "allwinner,sun50i-a64-usb-phy", sun4i_phy_init },
{ "allwinner,sun9i-a80-usb-phy", sun9i_phy_init },
};
@ -286,6 +287,62 @@ ehci_init_phys(struct ehci_fdt_softc *sc)
#define SUNXI_AHB_INCR8 (1 << 10)
#define SUNXI_AHB_INCR16 (1 << 11)
void
sun50i_h616_phy2_init(struct ehci_fdt_softc *sc, int node)
{
int len, idx;
uint32_t *reg, val;
bus_size_t size;
bus_space_handle_t ioh;
/*
* to access USB2-PHY register, get address from "reg" property of
* current "allwinner,...-usb-phy" node
*/
len = OF_getproplen(node, "reg");
if (len <= 0)
goto out;
reg = malloc(len, M_TEMP, M_WAITOK);
OF_getpropintarray(node, "reg", reg, len);
idx = OF_getindex(node, "pmu2", "reg-names");
if (idx < 0 || (idx + 1) > (len / (sizeof(uint32_t) * 2))) {
printf(": no phy2 register\n");
goto free;
}
/* convert "reg-names" index to "reg" (address-size pair) index */
idx *= 2;
size = reg[idx + 1];
if (bus_space_map(sc->sc.iot, reg[idx], size, 0, &ioh)) {
printf(": can't map phy2 registers\n");
goto free;
}
clock_enable(node, "usb2_phy");
reset_deassert(node, "usb2_reset");
clock_enable(node, "pmu2_clk");
/*
* address is offset from "pmu2", not EHCI2 base address
* (normally it points EHCI2 base address + 0x810)
*/
val = bus_space_read_4(sc->sc.iot, ioh, 0x10);
val &= ~(1 << 3); /* clear SIDDQ */
bus_space_write_4(sc->sc.iot, ioh, 0x10, val);
clock_disable(node, "pmu2_clk");
/* "usb2_reset" and "usb2_phy" unchanged */
bus_space_unmap(sc->sc.iot, ioh, size);
free:
free(reg, M_TEMP, len);
out:
return;
}
void
sun4i_phy_init(struct ehci_fdt_softc *sc, uint32_t *cells)
{
@ -298,6 +355,11 @@ sun4i_phy_init(struct ehci_fdt_softc *sc, uint32_t *cells)
if (node == -1)
return;
/* Allwinner H616 needs to clear PHY2's SIDDQ flag */
if (OF_is_compatible(node, "allwinner,sun50i-h616-usb-phy") &&
cells[1] != 2)
sun50i_h616_phy2_init(sc, node);
val = bus_space_read_4(sc->sc.iot, sc->sc.ioh, SUNXI_HCI_ICR);
val |= SUNXI_AHB_INCR8 | SUNXI_AHB_INCR4;
val |= SUNXI_AHB_INCRX_ALIGN;
@ -315,11 +377,19 @@ sun4i_phy_init(struct ehci_fdt_softc *sc, uint32_t *cells)
val = bus_space_read_4(sc->sc.iot, sc->sc.ioh, 0x810);
val &= ~(1 << 1);
bus_space_write_4(sc->sc.iot, sc->sc.ioh, 0x810, val);
} else if (OF_is_compatible(node, "allwinner,sun20i-d1-usb-phy")) {
} else if (OF_is_compatible(node, "allwinner,sun8i-a83t-usb-phy") ||
OF_is_compatible(node, "allwinner,sun20i-d1-usb-phy") ||
OF_is_compatible(node, "allwinner,sun50i-h616-usb-phy")) {
val = bus_space_read_4(sc->sc.iot, sc->sc.ioh, 0x810);
val &= ~(1 << 3);
bus_space_write_4(sc->sc.iot, sc->sc.ioh, 0x810, val);
}
if (OF_is_compatible(node, "allwinner,sun8i-a83t-usb-phy") ||
OF_is_compatible(node, "allwinner,sun50i-h616-usb-phy")) {
val = bus_space_read_4(sc->sc.iot, sc->sc.ioh, 0x810);
val |= 1 << 5;
bus_space_write_4(sc->sc.iot, sc->sc.ioh, 0x810, val);
}
pinctrl_byname(node, "default");

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if_bnxt.c,v 1.45 2024/01/19 03:25:13 jmatthew Exp $ */
/* $OpenBSD: if_bnxt.c,v 1.46 2024/02/13 13:58:19 bluhm Exp $ */
/*-
* Broadcom NetXtreme-C/E network driver.
*
@ -1433,13 +1433,13 @@ bnxt_start(struct ifqueue *ifq)
lflags |= TX_BD_LONG_LFLAGS_LSO;
hdrsize = sizeof(*ext.eh);
if (ext.ip4)
hdrsize += ext.ip4->ip_hl << 2;
hdrsize += ext.ip4hlen;
else if (ext.ip6)
hdrsize += sizeof(*ext.ip6);
else
tcpstat_inc(tcps_outbadtso);
hdrsize += ext.tcp->th_off << 2;
hdrsize += ext.tcphlen;
txhi->hdr_size = htole16(hdrsize / 2);
outlen = m->m_pkthdr.ph_mss;

View file

@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE.
***************************************************************************/
/* $OpenBSD: if_em.c,v 1.371 2024/01/28 18:42:58 mglocker Exp $ */
/* $OpenBSD: if_em.c,v 1.372 2024/02/13 13:58:19 bluhm Exp $ */
/* $FreeBSD: if_em.c,v 1.46 2004/09/29 18:28:28 mlaier Exp $ */
#include <dev/pci/if_em.h>
@ -2433,7 +2433,7 @@ em_tx_ctx_setup(struct em_queue *que, struct mbuf *mp, u_int head,
vlan_macip_lens |= (sizeof(*ext.eh) << E1000_ADVTXD_MACLEN_SHIFT);
if (ext.ip4) {
iphlen = ext.ip4->ip_hl << 2;
iphlen = ext.ip4hlen;
type_tucmd_mlhl |= E1000_ADVTXD_TUCMD_IPV4;
if (ISSET(mp->m_pkthdr.csum_flags, M_IPV4_CSUM_OUT)) {

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if_igc.c,v 1.15 2024/01/23 08:48:12 kevlo Exp $ */
/* $OpenBSD: if_igc.c,v 1.16 2024/02/13 13:58:19 bluhm Exp $ */
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
@ -2028,7 +2028,7 @@ igc_tx_ctx_setup(struct tx_ring *txr, struct mbuf *mp, int prod,
ether_extract_headers(mp, &ext);
if (ext.ip4) {
iphlen = ext.ip4->ip_hl << 2;
iphlen = ext.ip4hlen;
type_tucmd_mlhl |= IGC_ADVTXD_TUCMD_IPV4;
if (ISSET(mp->m_pkthdr.csum_flags, M_IPV4_CSUM_OUT)) {

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if_ix.c,v 1.206 2023/11/10 15:51:20 bluhm Exp $ */
/* $OpenBSD: if_ix.c,v 1.207 2024/02/13 13:58:19 bluhm Exp $ */
/******************************************************************************
@ -2502,7 +2502,7 @@ ixgbe_tx_offload(struct mbuf *mp, uint32_t *vlan_macip_lens,
*vlan_macip_lens |= (ethlen << IXGBE_ADVTXD_MACLEN_SHIFT);
if (ext.ip4) {
iphlen = ext.ip4->ip_hl << 2;
iphlen = ext.ip4hlen;
if (ISSET(mp->m_pkthdr.csum_flags, M_IPV4_CSUM_OUT)) {
*olinfo_status |= IXGBE_TXD_POPTS_IXSM << 8;
@ -2542,7 +2542,7 @@ ixgbe_tx_offload(struct mbuf *mp, uint32_t *vlan_macip_lens,
if (ext.tcp) {
uint32_t hdrlen, thlen, paylen, outlen;
thlen = ext.tcp->th_off << 2;
thlen = ext.tcphlen;
outlen = mp->m_pkthdr.ph_mss;
*mss_l4len_idx |= outlen << IXGBE_ADVTXD_MSS_SHIFT;
@ -3277,11 +3277,11 @@ ixgbe_rxeof(struct rx_ring *rxr)
hdrlen += ETHER_VLAN_ENCAP_LEN;
#endif
if (ext.ip4)
hdrlen += ext.ip4->ip_hl << 2;
hdrlen += ext.ip4hlen;
if (ext.ip6)
hdrlen += sizeof(*ext.ip6);
if (ext.tcp) {
hdrlen += ext.tcp->th_off << 2;
hdrlen += ext.tcphlen;
tcpstat_inc(tcps_inhwlro);
tcpstat_add(tcps_inpktlro, pkts);
} else {

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if_vio.c,v 1.29 2023/12/20 09:51:06 jan Exp $ */
/* $OpenBSD: if_vio.c,v 1.30 2024/02/13 13:58:19 bluhm Exp $ */
/*
* Copyright (c) 2012 Stefan Fritsch, Alexander Fiveg.
@ -765,7 +765,7 @@ again:
hdr->csum_offset = offsetof(struct udphdr, uh_sum);
if (ext.ip4)
hdr->csum_start += ext.ip4->ip_hl << 2;
hdr->csum_start += ext.ip4hlen;
#ifdef INET6
else if (ext.ip6)
hdr->csum_start += sizeof(*ext.ip6);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: kern_clock.c,v 1.122 2024/02/09 17:42:18 cheloha Exp $ */
/* $OpenBSD: kern_clock.c,v 1.123 2024/02/12 22:07:33 cheloha Exp $ */
/* $NetBSD: kern_clock.c,v 1.34 1996/06/09 04:51:03 briggs Exp $ */
/*-
@ -140,13 +140,6 @@ initclocks(void)
void
hardclock(struct clockframe *frame)
{
/*
* If we are not the primary CPU, we're not allowed to do
* any more work.
*/
if (CPU_IS_PRIMARY(curcpu()) == 0)
return;
tc_ticktock();
ticks++;
jiffies++;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: kern_clockintr.c,v 1.66 2024/02/09 16:52:58 cheloha Exp $ */
/* $OpenBSD: kern_clockintr.c,v 1.67 2024/02/12 22:07:33 cheloha Exp $ */
/*
* Copyright (c) 2003 Dale Rahn <drahn@openbsd.org>
* Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org>
@ -63,7 +63,7 @@ clockintr_cpu_init(const struct intrclock *ic)
clockqueue_intrclock_install(cq, ic);
/* TODO: Remove this from struct clockintr_queue. */
if (cq->cq_hardclock.cl_expiration == 0) {
if (CPU_IS_PRIMARY(ci) && cq->cq_hardclock.cl_expiration == 0) {
clockintr_bind(&cq->cq_hardclock, ci, clockintr_hardclock,
NULL);
}
@ -99,12 +99,6 @@ clockintr_cpu_init(const struct intrclock *ic)
clockintr_schedule(&cq->cq_hardclock, 0);
else
clockintr_advance(&cq->cq_hardclock, hardclock_period);
} else {
if (cq->cq_hardclock.cl_expiration == 0) {
clockintr_stagger(&cq->cq_hardclock, hardclock_period,
multiplier, MAXCPUS);
}
clockintr_advance(&cq->cq_hardclock, hardclock_period);
}
/*

View file

@ -1,4 +1,4 @@
/* $OpenBSD: uipc_socket.c,v 1.319 2024/02/11 21:36:49 mvs Exp $ */
/* $OpenBSD: uipc_socket.c,v 1.320 2024/02/12 22:48:27 mvs Exp $ */
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/*
@ -132,8 +132,9 @@ soinit(void)
}
struct socket *
soalloc(const struct domain *dp, int wait)
soalloc(const struct protosw *prp, int wait)
{
const struct domain *dp = prp->pr_domain;
struct socket *so;
so = pool_get(&socket_pool, (wait == M_WAIT ? PR_WAITOK : PR_NOWAIT) |
@ -153,7 +154,7 @@ soalloc(const struct domain *dp, int wait)
switch (dp->dom_family) {
case AF_INET:
case AF_INET6:
switch (dp->dom_protosw->pr_type) {
switch (prp->pr_type) {
case SOCK_DGRAM:
case SOCK_RAW:
so->so_rcv.sb_flags |= SB_MTXLOCK;
@ -188,7 +189,7 @@ socreate(int dom, struct socket **aso, int type, int proto)
return (EPROTONOSUPPORT);
if (prp->pr_type != type)
return (EPROTOTYPE);
so = soalloc(pffinddomain(dom), M_WAIT);
so = soalloc(prp, M_WAIT);
so->so_type = type;
if (suser(p) == 0)
so->so_state = SS_PRIV;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: uipc_socket2.c,v 1.143 2024/02/11 18:14:26 mvs Exp $ */
/* $OpenBSD: uipc_socket2.c,v 1.144 2024/02/12 22:48:27 mvs Exp $ */
/* $NetBSD: uipc_socket2.c,v 1.11 1996/02/04 02:17:55 christos Exp $ */
/*
@ -188,7 +188,7 @@ sonewconn(struct socket *head, int connstatus, int wait)
return (NULL);
if (head->so_qlen + head->so_q0len > head->so_qlimit * 3)
return (NULL);
so = soalloc(head->so_proto->pr_domain, wait);
so = soalloc(head->so_proto, wait);
if (so == NULL)
return (NULL);
so->so_type = head->so_type;

View file

@ -513,12 +513,12 @@ typedef uLong FAR uLongf;
#if !defined(_WIN32) && defined(Z_LARGE64)
# define z_off64_t off64_t
#elif defined(_WIN32) && !defined(__GNUC__)
# define z_off64_t __int64
#elif defined(__GO32__)
# define z_off64_t offset_t
#else
# if defined(_WIN32) && !defined(__GNUC__)
# define z_off64_t __int64
# else
# define z_off64_t z_off_t
# endif
# define z_off64_t z_off_t
#endif
/* MVS linker does not support external names larger than 8 bytes */

View file

@ -1891,9 +1891,9 @@ ZEXTERN int ZEXPORT gzgetc_(gzFile file); /* backward compatibility */
ZEXTERN z_off_t ZEXPORT gzseek64(gzFile, z_off_t, int);
ZEXTERN z_off_t ZEXPORT gztell64(gzFile);
ZEXTERN z_off_t ZEXPORT gzoffset64(gzFile);
ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t);
ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t);
ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t);
ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off64_t);
ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off64_t);
ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off64_t);
# endif
#else
ZEXTERN gzFile ZEXPORT gzopen(const char *, const char *);

View file

@ -184,11 +184,10 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#endif
/* provide prototypes for these when building zlib without LFS */
#if !defined(_WIN32) && \
(!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t);
ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t);
ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t);
#ifndef Z_LARGE64
ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off64_t);
ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off64_t);
ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off64_t);
#endif
/* common defaults */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if_bridge.c,v 1.368 2023/05/16 14:32:54 jan Exp $ */
/* $OpenBSD: if_bridge.c,v 1.369 2024/02/13 12:22:09 bluhm Exp $ */
/*
* Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net)
@ -48,6 +48,7 @@
#include <net/if_types.h>
#include <net/if_llc.h>
#include <net/netisr.h>
#include <net/route.h>
#include <netinet/in.h>
#include <netinet/ip.h>

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if_etherip.c,v 1.54 2023/12/23 10:52:54 bluhm Exp $ */
/* $OpenBSD: if_etherip.c,v 1.55 2024/02/13 12:22:09 bluhm Exp $ */
/*
* Copyright (c) 2015 Kazuya GODA <goda@openbsd.org>
*
@ -31,6 +31,7 @@
#include <net/if_var.h>
#include <net/if_dl.h>
#include <net/if_media.h>
#include <net/route.h>
#include <net/rtable.h>
#include <netinet/in.h>

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if_ethersubr.c,v 1.291 2023/07/27 20:21:25 jan Exp $ */
/* $OpenBSD: if_ethersubr.c,v 1.292 2024/02/13 13:58:19 bluhm Exp $ */
/* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */
/*
@ -140,6 +140,20 @@ didn't get a copy, you may request one from <license@ipv6.nrl.navy.mil>.
#include <netmpls/mpls.h>
#endif /* MPLS */
/* #define ETHERDEBUG 1 */
#ifdef ETHERDEBUG
int etherdebug = ETHERDEBUG;
#define DNPRINTF(level, fmt, args...) \
do { \
if (etherdebug >= level) \
printf("%s: " fmt "\n", __func__, ## args); \
} while (0)
#else
#define DNPRINTF(level, fmt, args...) \
do { } while (0)
#endif
#define DPRINTF(fmt, args...) DNPRINTF(1, fmt, args)
u_int8_t etherbroadcastaddr[ETHER_ADDR_LEN] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
u_int8_t etheranyaddr[ETHER_ADDR_LEN] =
@ -1034,56 +1048,126 @@ ether_e64_to_addr(struct ether_addr *ea, uint64_t e64)
/* Parse different TCP/IP protocol headers for a quick view inside an mbuf. */
void
ether_extract_headers(struct mbuf *mp, struct ether_extracted *ext)
ether_extract_headers(struct mbuf *m0, struct ether_extracted *ext)
{
struct mbuf *m;
uint64_t hlen;
size_t hlen;
int hoff;
uint8_t ipproto;
uint16_t ether_type;
/* gcc 4.2.1 on sparc64 may create 32 bit loads on unaligned mbuf */
union {
u_char hc_data;
#if _BYTE_ORDER == _LITTLE_ENDIAN
struct {
u_int hl:4, /* header length */
v:4; /* version */
} hc_ip;
struct {
u_int x2:4, /* (unused) */
off:4; /* data offset */
} hc_th;
#endif
#if _BYTE_ORDER == _BIG_ENDIAN
struct {
u_int v:4, /* version */
hl:4; /* header length */
} hc_ip;
struct {
u_int off:4, /* data offset */
x2:4; /* (unused) */
} hc_th;
#endif
} hdrcpy;
/* Return NULL if header was not recognized. */
memset(ext, 0, sizeof(*ext));
if (mp->m_len < sizeof(*ext->eh))
return;
KASSERT(ISSET(m0->m_flags, M_PKTHDR));
ext->paylen = m0->m_pkthdr.len;
ext->eh = mtod(mp, struct ether_header *);
if (m0->m_len < sizeof(*ext->eh)) {
DPRINTF("m_len %d, eh %zu", m0->m_len, sizeof(*ext->eh));
return;
}
ext->eh = mtod(m0, struct ether_header *);
ether_type = ntohs(ext->eh->ether_type);
hlen = sizeof(*ext->eh);
if (ext->paylen < hlen) {
DPRINTF("paylen %u, ehlen %zu", ext->paylen, hlen);
ext->eh = NULL;
return;
}
ext->paylen -= hlen;
#if NVLAN > 0
if (ether_type == ETHERTYPE_VLAN) {
ext->evh = mtod(mp, struct ether_vlan_header *);
if (m0->m_len < sizeof(*ext->evh)) {
DPRINTF("m_len %d, evh %zu",
m0->m_len, sizeof(*ext->evh));
return;
}
ext->evh = mtod(m0, struct ether_vlan_header *);
ether_type = ntohs(ext->evh->evl_proto);
hlen = sizeof(*ext->evh);
if (sizeof(*ext->eh) + ext->paylen < hlen) {
DPRINTF("paylen %zu, evhlen %zu",
sizeof(*ext->eh) + ext->paylen, hlen);
ext->evh = NULL;
return;
}
ext->paylen = sizeof(*ext->eh) + ext->paylen - hlen;
}
#endif
switch (ether_type) {
case ETHERTYPE_IP:
m = m_getptr(mp, hlen, &hoff);
if (m == NULL || m->m_len - hoff < sizeof(*ext->ip4))
m = m_getptr(m0, hlen, &hoff);
if (m == NULL || m->m_len - hoff < sizeof(*ext->ip4)) {
DPRINTF("m_len %d, hoff %d, ip4 %zu",
m ? m->m_len : -1, hoff, sizeof(*ext->ip4));
return;
}
ext->ip4 = (struct ip *)(mtod(m, caddr_t) + hoff);
memcpy(&hdrcpy.hc_data, ext->ip4, 1);
hlen = hdrcpy.hc_ip.hl << 2;
if (m->m_len - hoff < hlen) {
DPRINTF("m_len %d, hoff %d, iphl %zu",
m ? m->m_len : -1, hoff, hlen);
ext->ip4 = NULL;
return;
}
if (ext->paylen < hlen) {
DPRINTF("paylen %u, ip4hlen %zu", ext->paylen, hlen);
ext->ip4 = NULL;
return;
}
ext->ip4hlen = hlen;
ext->paylen -= hlen;
ipproto = ext->ip4->ip_p;
if (ISSET(ntohs(ext->ip4->ip_off), IP_MF|IP_OFFMASK))
return;
hlen = ext->ip4->ip_hl << 2;
ipproto = ext->ip4->ip_p;
break;
#ifdef INET6
case ETHERTYPE_IPV6:
m = m_getptr(mp, hlen, &hoff);
if (m == NULL || m->m_len - hoff < sizeof(*ext->ip6))
m = m_getptr(m0, hlen, &hoff);
if (m == NULL || m->m_len - hoff < sizeof(*ext->ip6)) {
DPRINTF("m_len %d, hoff %d, ip6 %zu",
m ? m->m_len : -1, hoff, sizeof(*ext->ip6));
return;
}
ext->ip6 = (struct ip6_hdr *)(mtod(m, caddr_t) + hoff);
hlen = sizeof(*ext->ip6);
if (ext->paylen < hlen) {
DPRINTF("paylen %u, ip6hlen %zu", ext->paylen, hlen);
ext->ip6 = NULL;
return;
}
ext->paylen -= hlen;
ipproto = ext->ip6->ip6_nxt;
break;
#endif
default:
@ -1093,16 +1177,51 @@ ether_extract_headers(struct mbuf *mp, struct ether_extracted *ext)
switch (ipproto) {
case IPPROTO_TCP:
m = m_getptr(m, hoff + hlen, &hoff);
if (m == NULL || m->m_len - hoff < sizeof(*ext->tcp))
if (m == NULL || m->m_len - hoff < sizeof(*ext->tcp)) {
DPRINTF("m_len %d, hoff %d, tcp %zu",
m ? m->m_len : -1, hoff, sizeof(*ext->tcp));
return;
}
ext->tcp = (struct tcphdr *)(mtod(m, caddr_t) + hoff);
memcpy(&hdrcpy.hc_data, &ext->tcp->th_flags - 1, 1);
hlen = hdrcpy.hc_th.off << 2;
if (m->m_len - hoff < hlen) {
DPRINTF("m_len %d, hoff %d, thoff %zu",
m ? m->m_len : -1, hoff, hlen);
ext->tcp = NULL;
return;
}
if (ext->paylen < hlen) {
DPRINTF("paylen %u, tcphlen %zu", ext->paylen, hlen);
ext->tcp = NULL;
return;
}
ext->tcphlen = hlen;
ext->paylen -= hlen;
break;
case IPPROTO_UDP:
m = m_getptr(m, hoff + hlen, &hoff);
if (m == NULL || m->m_len - hoff < sizeof(*ext->udp))
if (m == NULL || m->m_len - hoff < sizeof(*ext->udp)) {
DPRINTF("m_len %d, hoff %d, tcp %zu",
m ? m->m_len : -1, hoff, sizeof(*ext->tcp));
return;
}
ext->udp = (struct udphdr *)(mtod(m, caddr_t) + hoff);
hlen = sizeof(*ext->udp);
if (ext->paylen < hlen) {
DPRINTF("paylen %u, udphlen %zu", ext->paylen, hlen);
ext->udp = NULL;
return;
}
break;
}
DNPRINTF(2, "%s%s%s%s%s%s ip4h %u, tcph %u, payl %u",
ext->eh ? "eh," : "", ext->evh ? "evh," : "",
ext->ip4 ? "ip4," : "", ext->ip6 ? "ip6," : "",
ext->tcp ? "tcp," : "", ext->udp ? "udp," : "",
ext->ip4hlen, ext->tcphlen, ext->paylen);
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if_pfsync.c,v 1.324 2023/12/23 10:52:54 bluhm Exp $ */
/* $OpenBSD: if_pfsync.c,v 1.325 2024/02/13 12:22:09 bluhm Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff
@ -69,6 +69,7 @@
#include <net/if_types.h>
#include <net/bpf.h>
#include <net/netisr.h>
#include <net/route.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if_veb.c,v 1.34 2023/12/23 10:52:54 bluhm Exp $ */
/* $OpenBSD: if_veb.c,v 1.35 2024/02/13 12:22:09 bluhm Exp $ */
/*
* Copyright (c) 2021 David Gwynne <dlg@openbsd.org>
@ -46,7 +46,6 @@
#ifdef INET6
#include <netinet6/in6_var.h>
#include <netinet/ip6.h>
#include <netinet6/ip6_var.h>
#endif
#if 0 && defined(IPSEC)

View file

@ -1,4 +1,4 @@
/* $OpenBSD: route.c,v 1.431 2024/02/09 14:02:11 bluhm Exp $ */
/* $OpenBSD: route.c,v 1.432 2024/02/13 12:22:09 bluhm Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
@ -212,8 +212,8 @@ route_cache(struct route *ro, struct in_addr addr, u_int rtableid)
if (rtisvalid(ro->ro_rt) &&
ro->ro_generation == gen &&
ro->ro_tableid == rtableid &&
ro->ro_dst.sa_family == AF_INET &&
satosin(&ro->ro_dst)->sin_addr.s_addr == addr.s_addr) {
ro->ro_dstsa.sa_family == AF_INET &&
ro->ro_dstsin.sin_addr.s_addr == addr.s_addr) {
ipstat_inc(ips_rtcachehit);
return (0);
}
@ -225,17 +225,16 @@ route_cache(struct route *ro, struct in_addr addr, u_int rtableid)
ro->ro_tableid = rtableid;
memset(&ro->ro_dst, 0, sizeof(ro->ro_dst));
satosin(&ro->ro_dst)->sin_family = AF_INET;
satosin(&ro->ro_dst)->sin_len = sizeof(struct sockaddr_in);
satosin(&ro->ro_dst)->sin_addr = addr;
ro->ro_dstsin.sin_family = AF_INET;
ro->ro_dstsin.sin_len = sizeof(struct sockaddr_in);
ro->ro_dstsin.sin_addr = addr;
return (ESRCH);
}
#ifdef INET6
int
route6_cache(struct route_in6 *ro, const struct in6_addr *addr,
u_int rtableid)
route6_cache(struct route *ro, const struct in6_addr *addr, u_int rtableid)
{
u_long gen;
@ -245,8 +244,8 @@ route6_cache(struct route_in6 *ro, const struct in6_addr *addr,
if (rtisvalid(ro->ro_rt) &&
ro->ro_generation == gen &&
ro->ro_tableid == rtableid &&
ro->ro_dst.sin6_family == AF_INET6 &&
IN6_ARE_ADDR_EQUAL(&ro->ro_dst.sin6_addr, addr)) {
ro->ro_dstsa.sa_family == AF_INET6 &&
IN6_ARE_ADDR_EQUAL(&ro->ro_dstsin6.sin6_addr, addr)) {
ip6stat_inc(ip6s_rtcachehit);
return (0);
}
@ -258,9 +257,9 @@ route6_cache(struct route_in6 *ro, const struct in6_addr *addr,
ro->ro_tableid = rtableid;
memset(&ro->ro_dst, 0, sizeof(ro->ro_dst));
ro->ro_dst.sin6_family = AF_INET6;
ro->ro_dst.sin6_len = sizeof(struct sockaddr_in6);
ro->ro_dst.sin6_addr = *addr;
ro->ro_dstsin6.sin6_family = AF_INET6;
ro->ro_dstsin6.sin6_len = sizeof(struct sockaddr_in6);
ro->ro_dstsin6.sin6_addr = *addr;
return (ESRCH);
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: route.h,v 1.205 2024/02/05 12:52:11 aoyama Exp $ */
/* $OpenBSD: route.h,v 1.206 2024/02/13 12:22:09 bluhm Exp $ */
/* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */
/*
@ -370,6 +370,19 @@ struct sockaddr_rtsearch {
char sr_search[RTSEARCH_LEN];
};
struct rt_addrinfo {
int rti_addrs;
const struct sockaddr *rti_info[RTAX_MAX];
int rti_flags;
struct ifaddr *rti_ifa;
struct rt_msghdr *rti_rtm;
u_char rti_mpls;
};
#ifdef __BSD_VISIBLE
#include <netinet/in.h>
/*
* A route consists of a destination address and a reference
* to a routing entry. These are often held by protocols
@ -379,17 +392,17 @@ struct route {
struct rtentry *ro_rt;
u_long ro_generation;
u_long ro_tableid; /* u_long because of alignment */
struct sockaddr ro_dst;
union {
struct sockaddr rod_sa;
struct sockaddr_in rod_sin;
struct sockaddr_in6 rod_sin6;
} ro_dst;
#define ro_dstsa ro_dst.rod_sa
#define ro_dstsin ro_dst.rod_sin
#define ro_dstsin6 ro_dst.rod_sin6
};
struct rt_addrinfo {
int rti_addrs;
const struct sockaddr *rti_info[RTAX_MAX];
int rti_flags;
struct ifaddr *rti_ifa;
struct rt_msghdr *rti_rtm;
u_char rti_mpls;
};
#endif /* __BSD_VISIBLE */
#ifdef _KERNEL
@ -449,6 +462,8 @@ struct if_ieee80211_data;
struct bfd_config;
void route_init(void);
int route_cache(struct route *, struct in_addr, u_int);
int route6_cache(struct route *, const struct in6_addr *, u_int);
void rtm_ifchg(struct ifnet *);
void rtm_ifannounce(struct ifnet *, int);
void rtm_bfd(struct bfd_config *);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if_ether.h,v 1.90 2023/07/27 20:21:25 jan Exp $ */
/* $OpenBSD: if_ether.h,v 1.91 2024/02/13 13:58:19 bluhm Exp $ */
/* $NetBSD: if_ether.h,v 1.22 1996/05/11 13:00:00 mycroft Exp $ */
/*
@ -307,6 +307,9 @@ struct ether_extracted {
struct ip6_hdr *ip6;
struct tcphdr *tcp;
struct udphdr *udp;
u_int ip4hlen;
u_int tcphlen;
u_int paylen;
};
void ether_extract_headers(struct mbuf *, struct ether_extracted *);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: in.h,v 1.147 2024/02/09 14:02:11 bluhm Exp $ */
/* $OpenBSD: in.h,v 1.148 2024/02/13 12:22:09 bluhm Exp $ */
/* $NetBSD: in.h,v 1.20 1996/02/13 23:41:47 christos Exp $ */
/*
@ -789,8 +789,6 @@ void in_len2mask(struct in_addr *, int);
int in_nam2sin(const struct mbuf *, struct sockaddr_in **);
int in_sa2sin(struct sockaddr *, struct sockaddr_in **);
int route_cache(struct route *, struct in_addr, u_int);
char *inet_ntoa(struct in_addr);
int inet_nat64(int, const void *, void *, const void *, u_int8_t);
int inet_nat46(int, const void *, void *, const void *, u_int8_t);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: in_pcb.c,v 1.292 2024/02/11 01:27:45 bluhm Exp $ */
/* $OpenBSD: in_pcb.c,v 1.293 2024/02/13 12:22:09 bluhm Exp $ */
/* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */
/*
@ -920,7 +920,7 @@ in_pcbrtentry(struct inpcb *inp)
if (inp->inp_faddr.s_addr == INADDR_ANY)
return (NULL);
if (route_cache(ro, inp->inp_faddr, inp->inp_rtableid)) {
ro->ro_rt = rtalloc_mpath(&ro->ro_dst,
ro->ro_rt = rtalloc_mpath(&ro->ro_dstsa,
&inp->inp_laddr.s_addr, ro->ro_tableid);
}
return (ro->ro_rt);
@ -984,7 +984,7 @@ in_pcbselsrc(struct in_addr *insrc, struct sockaddr_in *sin,
*/
if (route_cache(ro, sin->sin_addr, rtableid)) {
/* No route yet, so try to acquire one */
ro->ro_rt = rtalloc_mpath(&ro->ro_dst, NULL, ro->ro_tableid);
ro->ro_rt = rtalloc_mpath(&ro->ro_dstsa, NULL, ro->ro_tableid);
}
/*

View file

@ -1,4 +1,4 @@
/* $OpenBSD: in_pcb.h,v 1.151 2024/02/11 01:27:45 bluhm Exp $ */
/* $OpenBSD: in_pcb.h,v 1.152 2024/02/13 12:22:09 bluhm Exp $ */
/* $NetBSD: in_pcb.h,v 1.14 1996/02/13 23:42:00 christos Exp $ */
/*
@ -150,12 +150,7 @@ struct inpcb {
u_int16_t inp_lport; /* [t] local port */
struct socket *inp_socket; /* [I] back pointer to socket */
caddr_t inp_ppcb; /* pointer to per-protocol pcb */
union { /* Route (notice increased size). */
struct route ru_route;
struct route_in6 ru_route6;
} inp_ru;
#define inp_route inp_ru.ru_route
#define inp_route6 inp_ru.ru_route6
struct route inp_route; /* cached route */
struct refcnt inp_refcnt; /* refcount PCB, delay memory free */
struct mutex inp_mtx; /* protect PCB and socket members */
int inp_flags; /* generic IP/datagram flags */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip_carp.c,v 1.360 2023/12/23 10:52:54 bluhm Exp $ */
/* $OpenBSD: ip_carp.c,v 1.361 2024/02/13 12:22:09 bluhm Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff. All rights reserved.
@ -54,6 +54,7 @@
#include <net/if_var.h>
#include <net/if_types.h>
#include <net/netisr.h>
#include <net/route.h>
#include <crypto/sha1.h>

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip_input.c,v 1.388 2024/01/31 14:56:42 bluhm Exp $ */
/* $OpenBSD: ip_input.c,v 1.389 2024/02/13 12:22:09 bluhm Exp $ */
/* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */
/*
@ -1494,7 +1494,7 @@ ip_forward(struct mbuf *m, struct ifnet *ifp, struct rtentry *rt, int srcrt)
route_cache(&ro, ip->ip_dst, m->m_pkthdr.ph_rtableid);
if (!rtisvalid(rt)) {
rtfree(rt);
rt = rtalloc_mpath(&ro.ro_dst, &ip->ip_src.s_addr,
rt = rtalloc_mpath(&ro.ro_dstsa, &ip->ip_src.s_addr,
m->m_pkthdr.ph_rtableid);
if (rt == NULL) {
ipstat_inc(ips_noroute);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip_output.c,v 1.394 2024/01/31 14:56:43 bluhm Exp $ */
/* $OpenBSD: ip_output.c,v 1.395 2024/02/13 12:22:09 bluhm Exp $ */
/* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */
/*
@ -167,7 +167,7 @@ reroute:
* destination and is still up. If not, free it and try again.
*/
route_cache(ro, ip->ip_dst, m->m_pkthdr.ph_rtableid);
dst = satosin(&ro->ro_dst);
dst = &ro->ro_dstsin;
if ((IN_MULTICAST(ip->ip_dst.s_addr) ||
(ip->ip_dst.s_addr == INADDR_BROADCAST)) &&
@ -185,7 +185,7 @@ reroute:
struct in_ifaddr *ia;
if (ro->ro_rt == NULL)
ro->ro_rt = rtalloc_mpath(&ro->ro_dst,
ro->ro_rt = rtalloc_mpath(&ro->ro_dstsa,
&ip->ip_src.s_addr, ro->ro_tableid);
if (ro->ro_rt == NULL) {
@ -253,7 +253,7 @@ reroute:
* still points to the address in "ro". (It may have been
* changed to point to a gateway address, above.)
*/
dst = satosin(&ro->ro_dst);
dst = &ro->ro_dstsin;
/*
* See if the caller provided any multicast options
@ -455,7 +455,7 @@ sendit:
rtfree(ro->ro_rt);
ro->ro_tableid = orig_rtableid;
ro->ro_rt = icmp_mtudisc_clone(
satosin(&ro->ro_dst)->sin_addr, ro->ro_tableid, 0);
ro->ro_dstsin.sin_addr, ro->ro_tableid, 0);
}
#endif
/*
@ -558,7 +558,8 @@ ip_output_ipsec_pmtu_update(struct tdb *tdb, struct route *ro,
rt->rt_mtu = tdb->tdb_mtu;
if (ro != NULL && ro->ro_rt != NULL) {
rtfree(ro->ro_rt);
ro->ro_rt = rtalloc(&ro->ro_dst, RT_RESOLVE, rtableid);
ro->ro_rt = rtalloc(&ro->ro_dstsa, RT_RESOLVE,
rtableid);
}
if (rt_mtucloned)
rtfree(rt);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip_var.h,v 1.112 2024/02/05 23:16:39 bluhm Exp $ */
/* $OpenBSD: ip_var.h,v 1.113 2024/02/13 12:22:09 bluhm Exp $ */
/* $NetBSD: ip_var.h,v 1.16 1996/02/13 23:43:20 christos Exp $ */
/*
@ -227,6 +227,7 @@ extern const struct pr_usrreqs rip_usrreqs;
extern struct rttimer_queue ip_mtudisc_timeout_q;
extern struct pool ipqent_pool;
struct rtentry;
struct route;
struct inpcb;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: tcp_input.c,v 1.400 2024/02/11 01:27:45 bluhm Exp $ */
/* $OpenBSD: tcp_input.c,v 1.401 2024/02/13 12:22:09 bluhm Exp $ */
/* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */
/*
@ -145,8 +145,8 @@ struct timeval tcp_ackdrop_ppslim_last;
#define ND6_HINT(tp) \
do { \
if (tp && tp->t_inpcb && (tp->t_inpcb->inp_flags & INP_IPV6) && \
rtisvalid(tp->t_inpcb->inp_route6.ro_rt)) { \
nd6_nud_hint(tp->t_inpcb->inp_route6.ro_rt); \
rtisvalid(tp->t_inpcb->inp_route.ro_rt)) { \
nd6_nud_hint(tp->t_inpcb->inp_route.ro_rt); \
} \
} while (0)
#else
@ -3166,7 +3166,7 @@ syn_cache_put(struct syn_cache *sc)
/* Dealing with last reference, no lock needed. */
m_free(sc->sc_ipopts);
rtfree(sc->sc_route4.ro_rt);
rtfree(sc->sc_route.ro_rt);
pool_put(&syn_cache_pool, sc);
}
@ -3578,13 +3578,8 @@ syn_cache_get(struct sockaddr *src, struct sockaddr *dst, struct tcphdr *th,
/*
* Give the new socket our cached route reference.
*/
if (src->sa_family == AF_INET)
inp->inp_route = sc->sc_route4; /* struct assignment */
#ifdef INET6
else
inp->inp_route6 = sc->sc_route6;
#endif
sc->sc_route4.ro_rt = NULL;
inp->inp_route = sc->sc_route; /* struct assignment */
sc->sc_route.ro_rt = NULL;
am = m_get(M_DONTWAIT, MT_SONAME); /* XXX */
if (am == NULL)
@ -4152,7 +4147,7 @@ syn_cache_respond(struct syn_cache *sc, struct mbuf *m, uint64_t now)
if (inp != NULL)
ip->ip_tos = inp->inp_ip.ip_tos;
error = ip_output(m, sc->sc_ipopts, &sc->sc_route4,
error = ip_output(m, sc->sc_ipopts, &sc->sc_route,
(ip_mtudisc ? IP_MTUDISC : 0), NULL,
inp ? inp->inp_seclevel : NULL, 0);
break;
@ -4164,7 +4159,7 @@ syn_cache_respond(struct syn_cache *sc, struct mbuf *m, uint64_t now)
ip6->ip6_hlim = in6_selecthlim(inp);
/* leave flowlabel = 0, it is legal and require no state mgmt */
error = ip6_output(m, NULL /*XXX*/, &sc->sc_route6, 0,
error = ip6_output(m, NULL /*XXX*/, &sc->sc_route, 0,
NULL, inp ? inp->inp_seclevel : NULL);
break;
#endif

View file

@ -1,4 +1,4 @@
/* $OpenBSD: tcp_output.c,v 1.142 2024/02/11 01:27:45 bluhm Exp $ */
/* $OpenBSD: tcp_output.c,v 1.143 2024/02/13 12:22:09 bluhm Exp $ */
/* $NetBSD: tcp_output.c,v 1.16 1997/06/03 16:17:09 kml Exp $ */
/*
@ -1109,7 +1109,7 @@ send:
#endif
}
error = ip6_output(m, tp->t_inpcb->inp_outputopts6,
&tp->t_inpcb->inp_route6, 0, NULL,
&tp->t_inpcb->inp_route, 0, NULL,
tp->t_inpcb->inp_seclevel);
break;
#endif /* INET6 */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: tcp_subr.c,v 1.198 2024/02/11 01:27:45 bluhm Exp $ */
/* $OpenBSD: tcp_subr.c,v 1.199 2024/02/13 12:22:09 bluhm Exp $ */
/* $NetBSD: tcp_subr.c,v 1.22 1996/02/13 23:44:00 christos Exp $ */
/*
@ -401,7 +401,7 @@ tcp_respond(struct tcpcb *tp, caddr_t template, struct tcphdr *th0,
ip6->ip6_plen = tlen - sizeof(struct ip6_hdr);
ip6->ip6_plen = htons(ip6->ip6_plen);
ip6_output(m, tp ? tp->t_inpcb->inp_outputopts6 : NULL,
tp ? &tp->t_inpcb->inp_route6 : NULL,
tp ? &tp->t_inpcb->inp_route : NULL,
0, NULL,
tp ? tp->t_inpcb->inp_seclevel : NULL);
break;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: tcp_var.h,v 1.175 2024/01/27 21:13:46 bluhm Exp $ */
/* $OpenBSD: tcp_var.h,v 1.176 2024/02/13 12:22:09 bluhm Exp $ */
/* $NetBSD: tcp_var.h,v 1.17 1996/02/13 23:44:24 christos Exp $ */
/*
@ -247,16 +247,7 @@ struct syn_cache {
TAILQ_ENTRY(syn_cache) sc_bucketq; /* [S] link on bucket list */
struct refcnt sc_refcnt; /* ref count list and timer */
struct timeout sc_timer; /* rexmt timer */
union { /* cached route */
struct route route4;
#ifdef INET6
struct route_in6 route6;
#endif
} sc_route_u;
#define sc_route4 sc_route_u.route4 /* [N] */
#ifdef INET6
#define sc_route6 sc_route_u.route6 /* [N] */
#endif
struct route sc_route; /* [N] cached route */
long sc_win; /* [I] advertised window */
struct syn_cache_head *sc_buckethead; /* [S] our bucket index */
struct syn_cache_set *sc_set; /* [S] our syn cache set */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: dest6.c,v 1.19 2022/06/29 22:45:24 bluhm Exp $ */
/* $OpenBSD: dest6.c,v 1.20 2024/02/13 12:22:09 bluhm Exp $ */
/* $KAME: dest6.c,v 1.25 2001/02/22 01:39:16 itojun Exp $ */
/*
@ -38,6 +38,8 @@
#include <sys/time.h>
#include <sys/kernel.h>
#include <net/route.h>
#include <netinet/in.h>
#include <netinet/ip6.h>
#include <netinet6/ip6_var.h>

View file

@ -1,4 +1,4 @@
/* $OpenBSD: in6.h,v 1.115 2024/02/09 14:02:12 bluhm Exp $ */
/* $OpenBSD: in6.h,v 1.116 2024/02/13 12:22:09 bluhm Exp $ */
/* $KAME: in6.h,v 1.83 2001/03/29 02:55:07 jinmei Exp $ */
/*
@ -144,16 +144,6 @@ extern const struct in6_addr in6addr_linklocal_allnodes;
extern const struct in6_addr in6addr_linklocal_allrouters;
#if __BSD_VISIBLE
/*
* IPv6 route structure, keep fields in sync with struct route
*/
struct route_in6 {
struct rtentry *ro_rt;
u_long ro_generation;
u_long ro_tableid; /* padded to long for alignment */
struct sockaddr_in6 ro_dst;
};
/*
* Definition of some useful macros to handle IP6 addresses
*/
@ -428,8 +418,6 @@ 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 **);
int route6_cache(struct route_in6 *, const struct in6_addr *, u_int);
struct ip6_pktopts;
struct ip6_moptions;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: in6_pcb.c,v 1.137 2024/02/11 01:27:45 bluhm Exp $ */
/* $OpenBSD: in6_pcb.c,v 1.138 2024/02/13 12:22:09 bluhm Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -114,13 +114,12 @@
#include <net/pfvar.h>
#include <netinet/in.h>
#include <netinet6/in6_var.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet6/ip6_var.h>
#include <netinet/in_pcb.h>
#include <netinet6/in6_var.h>
#if NSTOEPLITZ > 0
#include <net/toeplitz.h>
#endif
@ -517,13 +516,10 @@ in6_pcbnotify(struct inpcbtable *table, const struct sockaddr_in6 *dst,
if ((PRC_IS_REDIRECT(cmd) || cmd == PRC_HOSTDEAD) &&
IN6_IS_ADDR_UNSPECIFIED(&inp->inp_laddr6) &&
inp->inp_route.ro_rt &&
!(inp->inp_route.ro_rt->rt_flags & RTF_HOST)) {
struct sockaddr_in6 *dst6;
dst6 = satosin6(&inp->inp_route.ro_dst);
if (IN6_ARE_ADDR_EQUAL(&dst6->sin6_addr,
&dst->sin6_addr))
goto do_notify;
!(inp->inp_route.ro_rt->rt_flags & RTF_HOST) &&
IN6_ARE_ADDR_EQUAL(&inp->inp_route.ro_dstsin6.sin6_addr,
&dst->sin6_addr)) {
goto do_notify;
}
/*
@ -565,12 +561,12 @@ in6_pcbnotify(struct inpcbtable *table, const struct sockaddr_in6 *dst,
struct rtentry *
in6_pcbrtentry(struct inpcb *inp)
{
struct route_in6 *ro = &inp->inp_route6;
struct route *ro = &inp->inp_route;
if (IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6))
return (NULL);
if (route6_cache(ro, &inp->inp_faddr6, inp->inp_rtableid)) {
ro->ro_rt = rtalloc_mpath(sin6tosa(&ro->ro_dst),
ro->ro_rt = rtalloc_mpath(&ro->ro_dstsa,
&inp->inp_laddr6.s6_addr32[0], ro->ro_tableid);
}
return (ro->ro_rt);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: in6_src.c,v 1.93 2024/02/09 14:02:12 bluhm Exp $ */
/* $OpenBSD: in6_src.c,v 1.94 2024/02/13 12:22:09 bluhm Exp $ */
/* $KAME: in6_src.c,v 1.36 2001/02/06 04:08:17 itojun Exp $ */
/*
@ -83,7 +83,7 @@
#include <netinet6/nd6.h>
int in6_selectif(const struct in6_addr *, struct ip6_pktopts *,
struct ip6_moptions *, struct route_in6 *, struct ifnet **, u_int);
struct ip6_moptions *, struct route *, struct ifnet **, u_int);
/*
* Return an IPv6 address, which is the most appropriate for a given
@ -95,7 +95,7 @@ in6_pcbselsrc(const struct in6_addr **in6src, struct sockaddr_in6 *dstsock,
struct inpcb *inp, struct ip6_pktopts *opts)
{
struct ip6_moptions *mopts = inp->inp_moptions6;
struct route_in6 *ro = &inp->inp_route6;
struct route *ro = &inp->inp_route;
const struct in6_addr *laddr = &inp->inp_laddr6;
u_int rtableid = inp->inp_rtableid;
struct ifnet *ifp = NULL;
@ -180,8 +180,7 @@ in6_pcbselsrc(const struct in6_addr **in6src, struct sockaddr_in6 *dstsock,
* our src addr is taken from the i/f, else punt.
*/
if (route6_cache(ro, dst, rtableid)) {
ro->ro_rt = rtalloc(sin6tosa(&ro->ro_dst),
RT_RESOLVE, ro->ro_tableid);
ro->ro_rt = rtalloc(&ro->ro_dstsa, RT_RESOLVE, ro->ro_tableid);
}
/*
@ -298,7 +297,7 @@ in6_selectsrc(const struct in6_addr **in6src, struct sockaddr_in6 *dstsock,
struct rtentry *
in6_selectroute(const struct in6_addr *dst, struct ip6_pktopts *opts,
struct route_in6 *ro, unsigned int rtableid)
struct route *ro, unsigned int rtableid)
{
/*
* Use a cached route if it exists and is valid, else try to allocate
@ -307,8 +306,8 @@ in6_selectroute(const struct in6_addr *dst, struct ip6_pktopts *opts,
if (ro) {
if (route6_cache(ro, dst, rtableid)) {
/* No route yet, so try to acquire one */
ro->ro_rt = rtalloc_mpath(sin6tosa(&ro->ro_dst),
NULL, ro->ro_tableid);
ro->ro_rt = rtalloc_mpath(&ro->ro_dstsa, NULL,
ro->ro_tableid);
}
/*
@ -336,7 +335,7 @@ in6_selectroute(const struct in6_addr *dst, struct ip6_pktopts *opts,
int
in6_selectif(const struct in6_addr *dst, struct ip6_pktopts *opts,
struct ip6_moptions *mopts, struct route_in6 *ro, struct ifnet **retifp,
struct ip6_moptions *mopts, struct route *ro, struct ifnet **retifp,
u_int rtableid)
{
struct rtentry *rt = NULL;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip6_divert.c,v 1.94 2024/02/11 18:14:27 mvs Exp $ */
/* $OpenBSD: ip6_divert.c,v 1.95 2024/02/13 12:22:09 bluhm Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@ -30,13 +30,13 @@
#include <net/netisr.h>
#include <netinet/in.h>
#include <netinet6/in6_var.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/in_pcb.h>
#include <netinet/ip_divert.h>
#include <netinet/ip6.h>
#include <netinet6/ip6_var.h>
#include <netinet6/in6_var.h>
#include <netinet/in_pcb.h>
#include <netinet/ip_divert.h>
#include <netinet6/ip6_divert.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
@ -180,7 +180,7 @@ divert6_output(struct inpcb *inp, struct mbuf *m, struct mbuf *nam,
} else {
m->m_pkthdr.ph_rtableid = inp->inp_rtableid;
error = ip6_output(m, NULL, &inp->inp_route6,
error = ip6_output(m, NULL, &inp->inp_route,
IP_ALLOWBROADCAST | IP_RAWOUTPUT, NULL, NULL);
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip6_forward.c,v 1.113 2024/02/07 23:40:40 bluhm Exp $ */
/* $OpenBSD: ip6_forward.c,v 1.114 2024/02/13 12:22:09 bluhm Exp $ */
/* $KAME: ip6_forward.c,v 1.75 2001/06/29 12:42:13 jinmei Exp $ */
/*
@ -86,7 +86,7 @@ ip6_forward(struct mbuf *m, struct rtentry *rt, int srcrt)
{
struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
struct sockaddr *dst;
struct route_in6 ro;
struct route ro;
struct ifnet *ifp = NULL;
int error = 0, type = 0, code = 0, destmtu = 0;
struct mbuf *mcopy = NULL;
@ -167,7 +167,7 @@ reroute:
ro.ro_rt = NULL;
route6_cache(&ro, &ip6->ip6_dst, m->m_pkthdr.ph_rtableid);
dst = sin6tosa(&ro.ro_dst);
dst = &ro.ro_dstsa;
if (!rtisvalid(rt)) {
rtfree(rt);
rt = rtalloc_mpath(dst, &ip6->ip6_src.s6_addr32[0],
@ -253,7 +253,7 @@ reroute:
ip6_sendredirects &&
(rt->rt_flags & (RTF_DYNAMIC|RTF_MODIFIED)) == 0) {
if ((ifp->if_flags & IFF_POINTOPOINT) &&
nd6_is_addr_neighbor(&ro.ro_dst, ifp)) {
nd6_is_addr_neighbor(&ro.ro_dstsin6, ifp)) {
/*
* If the incoming interface is equal to the outgoing
* one, the link attached to the interface is

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip6_id.c,v 1.16 2021/03/10 10:21:49 jsg Exp $ */
/* $OpenBSD: ip6_id.c,v 1.17 2024/02/13 12:22:09 bluhm Exp $ */
/* $NetBSD: ip6_id.c,v 1.7 2003/09/13 21:32:59 itojun Exp $ */
/* $KAME: ip6_id.c,v 1.8 2003/09/06 13:41:06 itojun Exp $ */
@ -89,7 +89,6 @@
#include <netinet/in.h>
#include <netinet/ip6.h>
#include <netinet6/ip6_var.h>
struct randomtab {
const int ru_bits; /* resulting bits */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip6_output.c,v 1.285 2024/02/07 23:40:40 bluhm Exp $ */
/* $OpenBSD: ip6_output.c,v 1.286 2024/02/13 12:22:09 bluhm Exp $ */
/* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */
/*
@ -143,7 +143,7 @@ static __inline u_int16_t __attribute__((__unused__))
u_int32_t, u_int32_t);
void in6_delayed_cksum(struct mbuf *, u_int8_t);
int ip6_output_ipsec_pmtu_update(struct tdb *, struct route_in6 *,
int ip6_output_ipsec_pmtu_update(struct tdb *, struct route *,
struct in6_addr *, int, int, int);
/* Context for non-repeating IDs */
@ -160,14 +160,14 @@ struct idgen32_ctx ip6_id_ctx;
* We use u_long to hold largest one, * which is rt_mtu.
*/
int
ip6_output(struct mbuf *m, struct ip6_pktopts *opt, struct route_in6 *ro,
ip6_output(struct mbuf *m, struct ip6_pktopts *opt, struct route *ro,
int flags, struct ip6_moptions *im6o, const u_char seclevel[])
{
struct ip6_hdr *ip6;
struct ifnet *ifp = NULL;
struct mbuf_list ml;
int hlen, tlen;
struct route_in6 ip6route;
struct route iproute;
struct rtentry *rt = NULL;
struct sockaddr_in6 *dst;
int error = 0;
@ -177,7 +177,7 @@ ip6_output(struct mbuf *m, struct ip6_pktopts *opt, struct route_in6 *ro,
u_int32_t optlen = 0, plen = 0, unfragpartlen = 0;
struct ip6_exthdrs exthdrs;
struct in6_addr finaldst;
struct route_in6 *ro_pmtu = NULL;
struct route *ro_pmtu = NULL;
int hdrsplit = 0;
u_int8_t sproto = 0;
u_char nextproto;
@ -390,13 +390,13 @@ reroute:
/* initialize cached route */
if (ro == NULL) {
ro = &ip6route;
ro = &iproute;
bzero((caddr_t)ro, sizeof(*ro));
}
ro_pmtu = ro;
if (opt && opt->ip6po_rthdr)
ro = &opt->ip6po_route;
dst = &ro->ro_dst;
dst = &ro->ro_dstsin6;
/*
* if specified, try to fill in the traffic class field.
@ -750,9 +750,9 @@ reroute:
ip6stat_inc(ip6s_fragmented);
done:
if (ro == &ip6route && ro->ro_rt) {
if (ro == &iproute && ro->ro_rt) {
rtfree(ro->ro_rt);
} else if (ro_pmtu == &ip6route && ro_pmtu->ro_rt) {
} else if (ro_pmtu == &iproute && ro_pmtu->ro_rt) {
rtfree(ro_pmtu->ro_rt);
}
if_put(ifp);
@ -2772,7 +2772,7 @@ ip6_output_ipsec_lookup(struct mbuf *m, const u_char seclevel[],
}
int
ip6_output_ipsec_pmtu_update(struct tdb *tdb, struct route_in6 *ro,
ip6_output_ipsec_pmtu_update(struct tdb *tdb, struct route *ro,
struct in6_addr *dst, int ifidx, int rtableid, int transportmode)
{
struct rtentry *rt = NULL;
@ -2807,7 +2807,7 @@ ip6_output_ipsec_pmtu_update(struct tdb *tdb, struct route_in6 *ro,
rt->rt_mtu = tdb->tdb_mtu;
if (ro != NULL && ro->ro_rt != NULL) {
rtfree(ro->ro_rt);
ro->ro_rt = rtalloc(sin6tosa(&ro->ro_dst), RT_RESOLVE,
ro->ro_rt = rtalloc(&ro->ro_dstsa, RT_RESOLVE,
rtableid);
}
if (rt_mtucloned)
@ -2817,7 +2817,7 @@ ip6_output_ipsec_pmtu_update(struct tdb *tdb, struct route_in6 *ro,
}
int
ip6_output_ipsec_send(struct tdb *tdb, struct mbuf *m, struct route_in6 *ro,
ip6_output_ipsec_send(struct tdb *tdb, struct mbuf *m, struct route *ro,
int tunalready, int fwd)
{
struct mbuf_list ml;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ip6_var.h,v 1.112 2024/02/07 23:40:40 bluhm Exp $ */
/* $OpenBSD: ip6_var.h,v 1.113 2024/02/13 12:22:09 bluhm Exp $ */
/* $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $ */
/*
@ -103,7 +103,7 @@ struct ip6_moptions {
/* Routing header related info */
struct ip6po_rhinfo {
struct ip6_rthdr *ip6po_rhi_rthdr; /* Routing header */
struct route_in6 ip6po_rhi_route; /* Route to the 1st hop */
struct route ip6po_rhi_route; /* Route to the 1st hop */
};
#define ip6po_rthdr ip6po_rhinfo.ip6po_rhi_rthdr
#define ip6po_route ip6po_rhinfo.ip6po_rhi_route
@ -323,7 +323,7 @@ int ip6_sysctl(int *, u_int, void *, size_t *, void *, size_t);
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,
int ip6_output(struct mbuf *, struct ip6_pktopts *, struct route *, int,
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 *);
@ -370,14 +370,14 @@ int in6_pcbselsrc(const struct in6_addr **, struct sockaddr_in6 *,
int in6_selectsrc(const struct in6_addr **, struct sockaddr_in6 *,
struct ip6_moptions *, unsigned int);
struct rtentry *in6_selectroute(const struct in6_addr *, struct ip6_pktopts *,
struct route_in6 *, unsigned int rtableid);
struct route *, unsigned int rtableid);
u_int32_t ip6_randomflowlabel(void);
#ifdef IPSEC
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 ip6_output_ipsec_send(struct tdb *, struct mbuf *, struct route *,
int, int);
#endif /* IPSEC */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: mld6.c,v 1.61 2022/09/08 10:22:07 kn Exp $ */
/* $OpenBSD: mld6.c,v 1.62 2024/02/13 12:22:09 bluhm Exp $ */
/* $KAME: mld6.c,v 1.26 2001/02/16 14:50:35 itojun Exp $ */
/*
@ -74,6 +74,7 @@
#include <net/if.h>
#include <net/if_var.h>
#include <net/route.h>
#include <netinet/in.h>
#include <netinet6/in6_var.h>

View file

@ -1,4 +1,4 @@
/* $OpenBSD: raw_ip6.c,v 1.181 2024/02/11 18:14:27 mvs Exp $ */
/* $OpenBSD: raw_ip6.c,v 1.182 2024/02/13 12:22:09 bluhm Exp $ */
/* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */
/*
@ -512,7 +512,7 @@ rip6_output(struct mbuf *m, struct socket *so, struct sockaddr *dstaddr,
pf_mbuf_link_inpcb(m, inp);
#endif
error = ip6_output(m, optp, &inp->inp_route6, flags,
error = ip6_output(m, optp, &inp->inp_route, flags,
inp->inp_moptions6, inp->inp_seclevel);
if (so->so_proto->pr_protocol == IPPROTO_ICMPV6) {
icmp6stat_inc(icp6s_outhist + type);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: route6.c,v 1.21 2017/04/14 20:46:31 bluhm Exp $ */
/* $OpenBSD: route6.c,v 1.22 2024/02/13 12:22:09 bluhm Exp $ */
/* $KAME: route6.c,v 1.22 2000/12/03 00:54:00 itojun Exp $ */
/*
@ -37,6 +37,7 @@
#include <net/if.h>
#include <net/if_var.h>
#include <net/route.h>
#include <netinet/in.h>
#include <netinet6/in6_var.h>

View file

@ -1,4 +1,4 @@
/* $OpenBSD: udp6_output.c,v 1.63 2023/12/03 20:36:24 bluhm Exp $ */
/* $OpenBSD: udp6_output.c,v 1.64 2024/02/13 12:22:09 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 *inp, struct mbuf *m, struct mbuf *addr6,
pf_mbuf_link_inpcb(m, inp);
#endif
error = ip6_output(m, optp, &inp->inp_route6,
error = ip6_output(m, optp, &inp->inp_route,
flags, inp->inp_moptions6, inp->inp_seclevel);
goto releaseopt;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: socketvar.h,v 1.123 2024/02/11 18:14:27 mvs Exp $ */
/* $OpenBSD: socketvar.h,v 1.124 2024/02/12 22:48:27 mvs Exp $ */
/* $NetBSD: socketvar.h,v 1.18 1996/02/09 18:25:38 christos Exp $ */
/*-
@ -375,7 +375,7 @@ int soconnect(struct socket *, struct mbuf *);
int soconnect2(struct socket *, struct socket *);
int socreate(int, struct socket **, int, int);
int sodisconnect(struct socket *);
struct socket *soalloc(const struct domain *, int);
struct socket *soalloc(const struct protosw *, int);
void sofree(struct socket *, int);
int sogetopt(struct socket *, int, int, struct mbuf *);
void sohasoutofband(struct socket *);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: uvm_page.c,v 1.173 2023/08/12 07:22:56 mpi Exp $ */
/* $OpenBSD: uvm_page.c,v 1.174 2024/02/13 10:16:28 miod Exp $ */
/* $NetBSD: uvm_page.c,v 1.44 2000/11/27 08:40:04 chs Exp $ */
/*
@ -1024,10 +1024,6 @@ uvm_pageclean(struct vm_page *pg)
void
uvm_pagefree(struct vm_page *pg)
{
if ((pg->pg_flags & (PG_TABLED|PQ_ACTIVE|PQ_INACTIVE)) &&
(pg->uobject == NULL || !UVM_OBJ_IS_PMAP(pg->uobject)))
MUTEX_ASSERT_LOCKED(&uvm.pageqlock);
uvm_pageclean(pg);
uvm_pmr_freepages(pg, 1);
}