sync code with last improvements from OpenBSD
This commit is contained in:
parent
e4e1b9f314
commit
e5a8beb33e
30 changed files with 156 additions and 154 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: pciecam.c,v 1.5 2021/10/24 17:52:28 mpi Exp $ */
|
||||
/* $OpenBSD: pciecam.c,v 1.6 2023/10/10 18:40:34 miod Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2013,2017 Patrick Wildt <patrick@blueri.se>
|
||||
*
|
||||
|
@ -28,6 +28,7 @@
|
|||
#include <dev/pci/pcivar.h>
|
||||
|
||||
#include <dev/ofw/fdt.h>
|
||||
#include <dev/ofw/ofw_pci.h>
|
||||
#include <dev/ofw/openfirm.h>
|
||||
|
||||
/* Assembling ECAM Configuration Address */
|
||||
|
@ -195,14 +196,21 @@ pciecam_attach(struct device *parent, struct device *self, void *aux)
|
|||
M_DEVBUF, NULL, 0, EX_NOWAIT | EX_FILLED);
|
||||
|
||||
for (i = 0; i < nranges; i++) {
|
||||
if (sc->sc_pciranges[i].flags >> 24 == 0)
|
||||
continue;
|
||||
if (sc->sc_pciranges[i].flags >> 24 == 1)
|
||||
switch (sc->sc_pciranges[i].flags & OFW_PCI_PHYS_HI_SPACEMASK) {
|
||||
case OFW_PCI_PHYS_HI_SPACE_IO:
|
||||
extent_free(sc->sc_ioex, sc->sc_pciranges[i].pci_base,
|
||||
sc->sc_pciranges[i].size, EX_NOWAIT);
|
||||
else
|
||||
break;
|
||||
case OFW_PCI_PHYS_HI_SPACE_MEM64:
|
||||
if (sc->sc_pciranges[i].pci_base +
|
||||
sc->sc_pciranges[i].size >= (1ULL << 32))
|
||||
break;
|
||||
/* FALLTHROUGH */
|
||||
case OFW_PCI_PHYS_HI_SPACE_MEM32:
|
||||
extent_free(sc->sc_memex, sc->sc_pciranges[i].pci_base,
|
||||
sc->sc_pciranges[i].size, EX_NOWAIT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(&sc->sc_bus, sc->sc_iot, sizeof(sc->sc_bus));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: if_dwqe_fdt.c,v 1.16 2023/10/09 14:25:00 stsp Exp $ */
|
||||
/* $OpenBSD: if_dwqe_fdt.c,v 1.17 2023/10/10 07:11:50 stsp Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2008, 2019 Mark Kettenis <kettenis@openbsd.org>
|
||||
* Copyright (c) 2017, 2022 Patrick Wildt <patrick@blueri.se>
|
||||
|
@ -193,18 +193,18 @@ dwqe_fdt_attach(struct device *parent, struct device *self, void *aux)
|
|||
LINK_STATE_FULL_DUPLEX : LINK_STATE_HALF_DUPLEX;
|
||||
}
|
||||
|
||||
sc->sc_clk = clock_get_frequency(faa->fa_node, "stmmaceth");
|
||||
if (sc->sc_clk > 500000000)
|
||||
sc->sc_clkrate = clock_get_frequency(faa->fa_node, "stmmaceth");
|
||||
if (sc->sc_clkrate > 500000000)
|
||||
sc->sc_clk = GMAC_MAC_MDIO_ADDR_CR_500_800;
|
||||
else if (sc->sc_clk > 300000000)
|
||||
else if (sc->sc_clkrate > 300000000)
|
||||
sc->sc_clk = GMAC_MAC_MDIO_ADDR_CR_300_500;
|
||||
else if (sc->sc_clk > 150000000)
|
||||
else if (sc->sc_clkrate > 150000000)
|
||||
sc->sc_clk = GMAC_MAC_MDIO_ADDR_CR_150_250;
|
||||
else if (sc->sc_clk > 100000000)
|
||||
else if (sc->sc_clkrate > 100000000)
|
||||
sc->sc_clk = GMAC_MAC_MDIO_ADDR_CR_100_150;
|
||||
else if (sc->sc_clk > 60000000)
|
||||
else if (sc->sc_clkrate > 60000000)
|
||||
sc->sc_clk = GMAC_MAC_MDIO_ADDR_CR_60_100;
|
||||
else if (sc->sc_clk > 35000000)
|
||||
else if (sc->sc_clkrate > 35000000)
|
||||
sc->sc_clk = GMAC_MAC_MDIO_ADDR_CR_35_60;
|
||||
else
|
||||
sc->sc_clk = GMAC_MAC_MDIO_ADDR_CR_20_35;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: dwqe.c,v 1.12 2023/10/09 14:25:00 stsp Exp $ */
|
||||
/* $OpenBSD: dwqe.c,v 1.13 2023/10/10 07:11:50 stsp Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2008, 2019 Mark Kettenis <kettenis@openbsd.org>
|
||||
* Copyright (c) 2017, 2022 Patrick Wildt <patrick@blueri.se>
|
||||
|
@ -772,7 +772,7 @@ dwqe_up(struct dwqe_softc *sc)
|
|||
ifp->if_flags |= IFF_RUNNING;
|
||||
ifq_clr_oactive(&ifp->if_snd);
|
||||
|
||||
dwqe_write(sc, GMAC_MAC_1US_TIC_CTR, (sc->sc_clk / 1000000) - 1);
|
||||
dwqe_write(sc, GMAC_MAC_1US_TIC_CTR, (sc->sc_clkrate / 1000000) - 1);
|
||||
|
||||
/* Start receive DMA */
|
||||
reg = dwqe_read(sc, GMAC_CHAN_RX_CONTROL(0));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: dwqereg.h,v 1.2 2023/02/16 14:43:53 kettenis Exp $ */
|
||||
/* $OpenBSD: dwqereg.h,v 1.3 2023/10/10 19:06:42 kettenis Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2008, 2019 Mark Kettenis <kettenis@openbsd.org>
|
||||
* Copyright (c) 2017, 2022 Patrick Wildt <patrick@blueri.se>
|
||||
|
@ -39,8 +39,6 @@
|
|||
#define GMAC_MAC_PACKET_FILTER_PR (1 << 0)
|
||||
#define GMAC_MAC_HASH_TAB_REG0 0x0010
|
||||
#define GMAC_MAC_HASH_TAB_REG1 0x0014
|
||||
#define GMAC_VERSION 0x0020
|
||||
#define GMAC_VERSION_SNPS_MASK 0xff
|
||||
#define GMAC_INT_MASK 0x003c
|
||||
#define GMAC_INT_MASK_LPIIM (1 << 10)
|
||||
#define GMAC_INT_MASK_PIM (1 << 3)
|
||||
|
@ -60,6 +58,8 @@
|
|||
#define GMAC_INT_STATUS 0x00b0
|
||||
#define GMAC_INT_EN 0x00b4
|
||||
#define GMAC_MAC_1US_TIC_CTR 0x00dc
|
||||
#define GMAC_VERSION 0x0110
|
||||
#define GMAC_VERSION_SNPS_MASK 0xff
|
||||
#define GMAC_MAC_HW_FEATURE(x) (0x011c + (x) * 0x4)
|
||||
#define GMAC_MAC_HW_FEATURE1_TXFIFOSIZE(x) (((x) >> 6) & 0x1f)
|
||||
#define GMAC_MAC_HW_FEATURE1_RXFIFOSIZE(x) (((x) >> 0) & 0x3f)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: dwqevar.h,v 1.7 2023/10/09 14:25:00 stsp Exp $ */
|
||||
/* $OpenBSD: dwqevar.h,v 1.8 2023/10/10 07:11:50 stsp Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2008, 2019 Mark Kettenis <kettenis@openbsd.org>
|
||||
* Copyright (c) 2017, 2022 Patrick Wildt <patrick@blueri.se>
|
||||
|
@ -80,6 +80,7 @@ struct dwqe_softc {
|
|||
struct task sc_statchg_task;
|
||||
|
||||
uint32_t sc_clk;
|
||||
uint32_t sc_clkrate;
|
||||
|
||||
bus_size_t sc_clk_sel;
|
||||
uint32_t sc_clk_sel_125;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: kern_clockintr.c,v 1.59 2023/10/08 21:08:00 cheloha Exp $ */
|
||||
/* $OpenBSD: kern_clockintr.c,v 1.60 2023/10/11 00:02:25 cheloha Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2003 Dale Rahn <drahn@openbsd.org>
|
||||
* Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org>
|
||||
|
@ -390,17 +390,17 @@ clockintr_schedule_locked(struct clockintr *cl, uint64_t expiration)
|
|||
}
|
||||
|
||||
void
|
||||
clockintr_stagger(struct clockintr *cl, uint64_t period, uint32_t n,
|
||||
uint32_t count)
|
||||
clockintr_stagger(struct clockintr *cl, uint64_t period, uint32_t numer,
|
||||
uint32_t denom)
|
||||
{
|
||||
struct clockintr_queue *cq = cl->cl_queue;
|
||||
|
||||
KASSERT(n < count);
|
||||
KASSERT(numer < denom);
|
||||
|
||||
mtx_enter(&cq->cq_mtx);
|
||||
if (ISSET(cl->cl_flags, CLST_PENDING))
|
||||
panic("%s: clock interrupt pending", __func__);
|
||||
cl->cl_expiration = period / count * n;
|
||||
cl->cl_expiration = period / denom * numer;
|
||||
mtx_leave(&cq->cq_mtx);
|
||||
}
|
||||
|
||||
|
|
62
sys/net/pf.c
62
sys/net/pf.c
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: pf.c,v 1.1186 2023/09/08 13:40:52 naddy Exp $ */
|
||||
/* $OpenBSD: pf.c,v 1.1188 2023/10/10 16:26:06 bluhm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 Daniel Hartmeier
|
||||
|
@ -3201,7 +3201,7 @@ pf_modulate_sack(struct pf_pdesc *pd, struct pf_state_peer *dst)
|
|||
optsoff = pd->off + sizeof(struct tcphdr);
|
||||
#define TCPOLEN_MINSACK (TCPOLEN_SACK + 2)
|
||||
if (olen < TCPOLEN_MINSACK ||
|
||||
!pf_pull_hdr(pd->m, optsoff, opts, olen, NULL, NULL, pd->af))
|
||||
!pf_pull_hdr(pd->m, optsoff, opts, olen, NULL, pd->af))
|
||||
return (0);
|
||||
|
||||
eoh = opts + olen;
|
||||
|
@ -3871,7 +3871,7 @@ pf_get_wscale(struct pf_pdesc *pd)
|
|||
|
||||
olen = (pd->hdr.tcp.th_off << 2) - sizeof(struct tcphdr);
|
||||
if (olen < TCPOLEN_WINDOW || !pf_pull_hdr(pd->m,
|
||||
pd->off + sizeof(struct tcphdr), opts, olen, NULL, NULL, pd->af))
|
||||
pd->off + sizeof(struct tcphdr), opts, olen, NULL, pd->af))
|
||||
return (0);
|
||||
|
||||
opt = opts;
|
||||
|
@ -3896,7 +3896,7 @@ pf_get_mss(struct pf_pdesc *pd)
|
|||
|
||||
olen = (pd->hdr.tcp.th_off << 2) - sizeof(struct tcphdr);
|
||||
if (olen < TCPOLEN_MAXSEG || !pf_pull_hdr(pd->m,
|
||||
pd->off + sizeof(struct tcphdr), opts, olen, NULL, NULL, pd->af))
|
||||
pd->off + sizeof(struct tcphdr), opts, olen, NULL, pd->af))
|
||||
return (0);
|
||||
|
||||
opt = opts;
|
||||
|
@ -4467,8 +4467,6 @@ pf_test_rule(struct pf_pdesc *pd, struct pf_rule **rm, struct pf_state **sm,
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
action = PF_PASS;
|
||||
|
||||
if (pd->virtual_proto != PF_VPROTO_FRAGMENT
|
||||
&& !ctx.state_icmp && r->keep_state) {
|
||||
|
||||
|
@ -4511,6 +4509,8 @@ pf_test_rule(struct pf_pdesc *pd, struct pf_rule **rm, struct pf_state **sm,
|
|||
#endif /* INET6 */
|
||||
|
||||
} else {
|
||||
action = PF_PASS;
|
||||
|
||||
while ((ctx.ri = SLIST_FIRST(&ctx.rules))) {
|
||||
SLIST_REMOVE_HEAD(&ctx.rules, entry);
|
||||
pool_put(&pf_rule_item_pl, ctx.ri);
|
||||
|
@ -5691,7 +5691,7 @@ pf_test_state_icmp(struct pf_pdesc *pd, struct pf_state **stp,
|
|||
ipoff2 = pd->off + ICMP_MINLEN;
|
||||
|
||||
if (!pf_pull_hdr(pd2.m, ipoff2, &h2, sizeof(h2),
|
||||
NULL, reason, pd2.af)) {
|
||||
reason, pd2.af)) {
|
||||
DPFPRINTF(LOG_NOTICE,
|
||||
"ICMP error message too short (ip)");
|
||||
return (PF_DROP);
|
||||
|
@ -5719,7 +5719,7 @@ pf_test_state_icmp(struct pf_pdesc *pd, struct pf_state **stp,
|
|||
ipoff2 = pd->off + sizeof(struct icmp6_hdr);
|
||||
|
||||
if (!pf_pull_hdr(pd2.m, ipoff2, &h2_6, sizeof(h2_6),
|
||||
NULL, reason, pd2.af)) {
|
||||
reason, pd2.af)) {
|
||||
DPFPRINTF(LOG_NOTICE,
|
||||
"ICMP error message too short (ip6)");
|
||||
return (PF_DROP);
|
||||
|
@ -5770,7 +5770,7 @@ pf_test_state_icmp(struct pf_pdesc *pd, struct pf_state **stp,
|
|||
* expected. Don't access any TCP header fields after
|
||||
* th_seq, an ackskew test is not possible.
|
||||
*/
|
||||
if (!pf_pull_hdr(pd2.m, pd2.off, th, 8, NULL, reason,
|
||||
if (!pf_pull_hdr(pd2.m, pd2.off, th, 8, reason,
|
||||
pd2.af)) {
|
||||
DPFPRINTF(LOG_NOTICE,
|
||||
"ICMP error message too short (tcp)");
|
||||
|
@ -5951,7 +5951,7 @@ pf_test_state_icmp(struct pf_pdesc *pd, struct pf_state **stp,
|
|||
int action;
|
||||
|
||||
if (!pf_pull_hdr(pd2.m, pd2.off, uh, sizeof(*uh),
|
||||
NULL, reason, pd2.af)) {
|
||||
reason, pd2.af)) {
|
||||
DPFPRINTF(LOG_NOTICE,
|
||||
"ICMP error message too short (udp)");
|
||||
return (PF_DROP);
|
||||
|
@ -6079,7 +6079,7 @@ pf_test_state_icmp(struct pf_pdesc *pd, struct pf_state **stp,
|
|||
}
|
||||
|
||||
if (!pf_pull_hdr(pd2.m, pd2.off, iih, ICMP_MINLEN,
|
||||
NULL, reason, pd2.af)) {
|
||||
reason, pd2.af)) {
|
||||
DPFPRINTF(LOG_NOTICE,
|
||||
"ICMP error message too short (icmp)");
|
||||
return (PF_DROP);
|
||||
|
@ -6185,7 +6185,7 @@ pf_test_state_icmp(struct pf_pdesc *pd, struct pf_state **stp,
|
|||
}
|
||||
|
||||
if (!pf_pull_hdr(pd2.m, pd2.off, iih,
|
||||
sizeof(struct icmp6_hdr), NULL, reason, pd2.af)) {
|
||||
sizeof(struct icmp6_hdr), reason, pd2.af)) {
|
||||
DPFPRINTF(LOG_NOTICE,
|
||||
"ICMP error message too short (icmp6)");
|
||||
return (PF_DROP);
|
||||
|
@ -6364,7 +6364,7 @@ pf_test_state_icmp(struct pf_pdesc *pd, struct pf_state **stp,
|
|||
*/
|
||||
void *
|
||||
pf_pull_hdr(struct mbuf *m, int off, void *p, int len,
|
||||
u_short *actionp, u_short *reasonp, sa_family_t af)
|
||||
u_short *reasonp, sa_family_t af)
|
||||
{
|
||||
int iplen = 0;
|
||||
|
||||
|
@ -6374,12 +6374,7 @@ pf_pull_hdr(struct mbuf *m, int off, void *p, int len,
|
|||
u_int16_t fragoff = (ntohs(h->ip_off) & IP_OFFMASK) << 3;
|
||||
|
||||
if (fragoff) {
|
||||
if (fragoff >= len)
|
||||
ACTION_SET(actionp, PF_PASS);
|
||||
else {
|
||||
ACTION_SET(actionp, PF_DROP);
|
||||
REASON_SET(reasonp, PFRES_FRAG);
|
||||
}
|
||||
REASON_SET(reasonp, PFRES_FRAG);
|
||||
return (NULL);
|
||||
}
|
||||
iplen = ntohs(h->ip_len);
|
||||
|
@ -6395,7 +6390,6 @@ pf_pull_hdr(struct mbuf *m, int off, void *p, int len,
|
|||
#endif /* INET6 */
|
||||
}
|
||||
if (m->m_pkthdr.len < off + len || iplen < off + len) {
|
||||
ACTION_SET(actionp, PF_DROP);
|
||||
REASON_SET(reasonp, PFRES_SHORT);
|
||||
return (NULL);
|
||||
}
|
||||
|
@ -6949,7 +6943,7 @@ pf_walk_header(struct pf_pdesc *pd, struct ip *h, u_short *reason)
|
|||
end < pd->off + sizeof(ext))
|
||||
return (PF_PASS);
|
||||
if (!pf_pull_hdr(pd->m, pd->off, &ext, sizeof(ext),
|
||||
NULL, reason, AF_INET)) {
|
||||
reason, AF_INET)) {
|
||||
DPFPRINTF(LOG_NOTICE, "IP short exthdr");
|
||||
return (PF_DROP);
|
||||
}
|
||||
|
@ -6975,7 +6969,7 @@ pf_walk_option6(struct pf_pdesc *pd, struct ip6_hdr *h, int off, int end,
|
|||
|
||||
while (off < end) {
|
||||
if (!pf_pull_hdr(pd->m, off, &opt.ip6o_type,
|
||||
sizeof(opt.ip6o_type), NULL, reason, AF_INET6)) {
|
||||
sizeof(opt.ip6o_type), reason, AF_INET6)) {
|
||||
DPFPRINTF(LOG_NOTICE, "IPv6 short opt type");
|
||||
return (PF_DROP);
|
||||
}
|
||||
|
@ -6984,7 +6978,7 @@ pf_walk_option6(struct pf_pdesc *pd, struct ip6_hdr *h, int off, int end,
|
|||
continue;
|
||||
}
|
||||
if (!pf_pull_hdr(pd->m, off, &opt, sizeof(opt),
|
||||
NULL, reason, AF_INET6)) {
|
||||
reason, AF_INET6)) {
|
||||
DPFPRINTF(LOG_NOTICE, "IPv6 short opt");
|
||||
return (PF_DROP);
|
||||
}
|
||||
|
@ -7009,7 +7003,7 @@ pf_walk_option6(struct pf_pdesc *pd, struct ip6_hdr *h, int off, int end,
|
|||
return (PF_DROP);
|
||||
}
|
||||
if (!pf_pull_hdr(pd->m, off, &jumbo, sizeof(jumbo),
|
||||
NULL, reason, AF_INET6)) {
|
||||
reason, AF_INET6)) {
|
||||
DPFPRINTF(LOG_NOTICE, "IPv6 short jumbo");
|
||||
return (PF_DROP);
|
||||
}
|
||||
|
@ -7058,7 +7052,7 @@ pf_walk_header6(struct pf_pdesc *pd, struct ip6_hdr *h, u_short *reason)
|
|||
break;
|
||||
case IPPROTO_HOPOPTS:
|
||||
if (!pf_pull_hdr(pd->m, pd->off, &ext, sizeof(ext),
|
||||
NULL, reason, AF_INET6)) {
|
||||
reason, AF_INET6)) {
|
||||
DPFPRINTF(LOG_NOTICE, "IPv6 short exthdr");
|
||||
return (PF_DROP);
|
||||
}
|
||||
|
@ -7085,7 +7079,7 @@ pf_walk_header6(struct pf_pdesc *pd, struct ip6_hdr *h, u_short *reason)
|
|||
return (PF_DROP);
|
||||
}
|
||||
if (!pf_pull_hdr(pd->m, pd->off, &frag, sizeof(frag),
|
||||
NULL, reason, AF_INET6)) {
|
||||
reason, AF_INET6)) {
|
||||
DPFPRINTF(LOG_NOTICE, "IPv6 short fragment");
|
||||
return (PF_DROP);
|
||||
}
|
||||
|
@ -7113,7 +7107,7 @@ pf_walk_header6(struct pf_pdesc *pd, struct ip6_hdr *h, u_short *reason)
|
|||
return (PF_PASS);
|
||||
}
|
||||
if (!pf_pull_hdr(pd->m, pd->off, &rthdr, sizeof(rthdr),
|
||||
NULL, reason, AF_INET6)) {
|
||||
reason, AF_INET6)) {
|
||||
DPFPRINTF(LOG_NOTICE, "IPv6 short rthdr");
|
||||
return (PF_DROP);
|
||||
}
|
||||
|
@ -7140,7 +7134,7 @@ pf_walk_header6(struct pf_pdesc *pd, struct ip6_hdr *h, u_short *reason)
|
|||
return (PF_PASS);
|
||||
}
|
||||
if (!pf_pull_hdr(pd->m, pd->off, &ext, sizeof(ext),
|
||||
NULL, reason, AF_INET6)) {
|
||||
reason, AF_INET6)) {
|
||||
DPFPRINTF(LOG_NOTICE, "IPv6 short exthdr");
|
||||
return (PF_DROP);
|
||||
}
|
||||
|
@ -7167,7 +7161,7 @@ pf_walk_header6(struct pf_pdesc *pd, struct ip6_hdr *h, u_short *reason)
|
|||
return (PF_PASS);
|
||||
}
|
||||
if (!pf_pull_hdr(pd->m, pd->off, &icmp6, sizeof(icmp6),
|
||||
NULL, reason, AF_INET6)) {
|
||||
reason, AF_INET6)) {
|
||||
DPFPRINTF(LOG_NOTICE, "IPv6 short icmp6hdr");
|
||||
return (PF_DROP);
|
||||
}
|
||||
|
@ -7338,7 +7332,7 @@ pf_setup_pdesc(struct pf_pdesc *pd, sa_family_t af, int dir,
|
|||
struct tcphdr *th = &pd->hdr.tcp;
|
||||
|
||||
if (!pf_pull_hdr(pd->m, pd->off, th, sizeof(*th),
|
||||
NULL, reason, pd->af))
|
||||
reason, pd->af))
|
||||
return (PF_DROP);
|
||||
pd->hdrlen = sizeof(*th);
|
||||
if (th->th_dport == 0 ||
|
||||
|
@ -7357,7 +7351,7 @@ pf_setup_pdesc(struct pf_pdesc *pd, sa_family_t af, int dir,
|
|||
struct udphdr *uh = &pd->hdr.udp;
|
||||
|
||||
if (!pf_pull_hdr(pd->m, pd->off, uh, sizeof(*uh),
|
||||
NULL, reason, pd->af))
|
||||
reason, pd->af))
|
||||
return (PF_DROP);
|
||||
pd->hdrlen = sizeof(*uh);
|
||||
if (uh->uh_dport == 0 ||
|
||||
|
@ -7373,7 +7367,7 @@ pf_setup_pdesc(struct pf_pdesc *pd, sa_family_t af, int dir,
|
|||
}
|
||||
case IPPROTO_ICMP: {
|
||||
if (!pf_pull_hdr(pd->m, pd->off, &pd->hdr.icmp, ICMP_MINLEN,
|
||||
NULL, reason, pd->af))
|
||||
reason, pd->af))
|
||||
return (PF_DROP);
|
||||
pd->hdrlen = ICMP_MINLEN;
|
||||
if (pd->off + pd->hdrlen > pd->tot_len) {
|
||||
|
@ -7388,7 +7382,7 @@ pf_setup_pdesc(struct pf_pdesc *pd, sa_family_t af, int dir,
|
|||
size_t icmp_hlen = sizeof(struct icmp6_hdr);
|
||||
|
||||
if (!pf_pull_hdr(pd->m, pd->off, &pd->hdr.icmp6, icmp_hlen,
|
||||
NULL, reason, pd->af))
|
||||
reason, pd->af))
|
||||
return (PF_DROP);
|
||||
/* ICMP headers we look further into to match state */
|
||||
switch (pd->hdr.icmp6.icmp6_type) {
|
||||
|
@ -7411,7 +7405,7 @@ pf_setup_pdesc(struct pf_pdesc *pd, sa_family_t af, int dir,
|
|||
}
|
||||
if (icmp_hlen > sizeof(struct icmp6_hdr) &&
|
||||
!pf_pull_hdr(pd->m, pd->off, &pd->hdr.icmp6, icmp_hlen,
|
||||
NULL, reason, pd->af))
|
||||
reason, pd->af))
|
||||
return (PF_DROP);
|
||||
pd->hdrlen = icmp_hlen;
|
||||
if (pd->off + pd->hdrlen > pd->tot_len) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: pf_norm.c,v 1.228 2023/07/06 04:55:05 dlg Exp $ */
|
||||
/* $OpenBSD: pf_norm.c,v 1.229 2023/10/10 11:25:31 bluhm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 2001 Niels Provos <provos@citi.umich.edu>
|
||||
|
@ -1075,7 +1075,7 @@ pf_normalize_ip6(struct pf_pdesc *pd, u_short *reason)
|
|||
if (pd->fragoff == 0)
|
||||
goto no_fragment;
|
||||
|
||||
if (!pf_pull_hdr(pd->m, pd->fragoff, &frag, sizeof(frag), NULL, reason,
|
||||
if (!pf_pull_hdr(pd->m, pd->fragoff, &frag, sizeof(frag), reason,
|
||||
AF_INET6))
|
||||
return (PF_DROP);
|
||||
|
||||
|
@ -1216,7 +1216,7 @@ pf_normalize_tcp_init(struct pf_pdesc *pd, struct pf_state_peer *src)
|
|||
|
||||
olen = (th->th_off << 2) - sizeof(*th);
|
||||
if (olen < TCPOLEN_TIMESTAMP || !pf_pull_hdr(pd->m,
|
||||
pd->off + sizeof(*th), opts, olen, NULL, NULL, pd->af))
|
||||
pd->off + sizeof(*th), opts, olen, NULL, pd->af))
|
||||
return (0);
|
||||
|
||||
opt = opts;
|
||||
|
@ -1299,7 +1299,7 @@ pf_normalize_tcp_stateful(struct pf_pdesc *pd, u_short *reason,
|
|||
if (olen >= TCPOLEN_TIMESTAMP &&
|
||||
((src->scrub && (src->scrub->pfss_flags & PFSS_TIMESTAMP)) ||
|
||||
(dst->scrub && (dst->scrub->pfss_flags & PFSS_TIMESTAMP))) &&
|
||||
pf_pull_hdr(pd->m, pd->off + sizeof(*th), opts, olen, NULL, NULL,
|
||||
pf_pull_hdr(pd->m, pd->off + sizeof(*th), opts, olen, NULL,
|
||||
pd->af)) {
|
||||
|
||||
/* Modulate the timestamps. Can be used for NAT detection, OS
|
||||
|
@ -1633,7 +1633,7 @@ pf_normalize_mss(struct pf_pdesc *pd, u_int16_t maxmss)
|
|||
olen = (pd->hdr.tcp.th_off << 2) - sizeof(struct tcphdr);
|
||||
optsoff = pd->off + sizeof(struct tcphdr);
|
||||
if (olen < TCPOLEN_MAXSEG ||
|
||||
!pf_pull_hdr(pd->m, optsoff, opts, olen, NULL, NULL, pd->af))
|
||||
!pf_pull_hdr(pd->m, optsoff, opts, olen, NULL, pd->af))
|
||||
return (0);
|
||||
|
||||
opt = opts;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: pf_osfp.c,v 1.46 2023/05/07 12:45:21 kn Exp $ */
|
||||
/* $OpenBSD: pf_osfp.c,v 1.47 2023/10/10 11:25:31 bluhm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003 Mike Frantzen <frantzen@w4g.org>
|
||||
|
@ -111,8 +111,7 @@ pf_osfp_fingerprint(struct pf_pdesc *pd)
|
|||
ip6 = mtod(pd->m, struct ip6_hdr *);
|
||||
break;
|
||||
}
|
||||
if (!pf_pull_hdr(pd->m, pd->off, hdr, th->th_off << 2, NULL, NULL,
|
||||
pd->af))
|
||||
if (!pf_pull_hdr(pd->m, pd->off, hdr, th->th_off << 2, NULL, pd->af))
|
||||
return (NULL);
|
||||
|
||||
return (pf_osfp_fingerprint_hdr(ip, ip6, (struct tcphdr *)hdr));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: pfvar.h,v 1.533 2023/07/06 04:55:05 dlg Exp $ */
|
||||
/* $OpenBSD: pfvar.h,v 1.534 2023/10/10 11:25:31 bluhm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 Daniel Hartmeier
|
||||
|
@ -1192,12 +1192,6 @@ enum pfi_kif_refs {
|
|||
#define SCNT_SRC_NODE_REMOVALS 2
|
||||
#define SCNT_MAX 3
|
||||
|
||||
#define ACTION_SET(a, x) \
|
||||
do { \
|
||||
if ((a) != NULL) \
|
||||
*(a) = (x); \
|
||||
} while (0)
|
||||
|
||||
#define REASON_SET(a, x) \
|
||||
do { \
|
||||
if ((void *)(a) != NULL) { \
|
||||
|
@ -1649,8 +1643,7 @@ void pf_poolmask(struct pf_addr *, struct pf_addr*,
|
|||
struct pf_addr *, struct pf_addr *, sa_family_t);
|
||||
void pf_addr_inc(struct pf_addr *, sa_family_t);
|
||||
|
||||
void *pf_pull_hdr(struct mbuf *, int, void *, int, u_short *, u_short *,
|
||||
sa_family_t);
|
||||
void *pf_pull_hdr(struct mbuf *, int, void *, int, u_short *, sa_family_t);
|
||||
#define PF_HI (true)
|
||||
#define PF_LO (!PF_HI)
|
||||
#define PF_ALGNMNT(off) (((off) % 2) == 0 ? PF_HI : PF_LO)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue