sync with OpenBSD -current

This commit is contained in:
purplerain 2024-01-24 01:29:50 +00:00
parent 18e54d401d
commit 9394581c89
Signed by: purplerain
GPG Key ID: F42C07F07E2E35B7
58 changed files with 711 additions and 763 deletions

View File

@ -1,9 +1,19 @@
ChangeLog file for zlib
Changes in 1.3.0.1 (xx Aug 2023)
Changes in 1.3.1.1 (xx Jan 2024)
-
Changes in 1.3.1 (22 Jan 2024)
- Reject overflows of zip header fields in minizip
- Fix bug in inflateSync() for data held in bit buffer
- Add LIT_MEM define to use more memory for a small deflate speedup
- Fix decision on the emission of Zip64 end records in minizip
- Add bounds checking to ERR_MSG() macro, used by zError()
- Neutralize zip file traversal attacks in miniunz
- Fix a bug in ZLIB_DEBUG compiles in check_match()
- Various portability and appearance improvements
Changes in 1.3 (18 Aug 2023)
- Remove K&R function definitions and zlib2ansi
- Fix bug in deflateBound() for level 0 and memLevel 9

View File

@ -1,6 +1,6 @@
ZLIB DATA COMPRESSION LIBRARY
zlib 1.3.0.1 is a general purpose data compression library. All the code is
zlib 1.3.1.1 is a general purpose data compression library. All the code is
thread safe. The data format used by the zlib library is described by RFCs
(Request for Comments) 1950 to 1952 in the files
http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
@ -31,7 +31,7 @@ Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
issue of Dr. Dobb's Journal; a copy of the article is available at
https://marknelson.us/posts/1997/01/01/zlib-engine.html .
The changes made in version 1.3.0.1 are documented in the file ChangeLog.
The changes made in version 1.3.1.1 are documented in the file ChangeLog.
Unsupported third party contributions are provided in directory contrib/ .
@ -83,7 +83,7 @@ Acknowledgments:
Copyright notice:
(C) 1995-2023 Jean-loup Gailly and Mark Adler
(C) 1995-2024 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View File

@ -1,5 +1,5 @@
/* deflate.c -- compress data using the deflation algorithm
* Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler
* Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/

View File

@ -1,5 +1,5 @@
/* deflate.h -- internal compression state
* Copyright (C) 1995-2018 Jean-loup Gailly
* Copyright (C) 1995-2024 Jean-loup Gailly
* For conditions of distribution and use, see copyright notice in zlib.h
*/

View File

@ -1,5 +1,5 @@
/* gzguts.h -- zlib internal header definitions for gz* operations
* Copyright (C) 2004-2019 Mark Adler
* Copyright (C) 2004-2024 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/

View File

@ -1,5 +1,5 @@
/* gzlib.c -- zlib functions common to reading and writing gzip files
* Copyright (C) 2004-2019 Mark Adler
* Copyright (C) 2004-2024 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/

View File

@ -1,5 +1,5 @@
/* inftrees.c -- generate Huffman trees for efficient decoding
* Copyright (C) 1995-2023 Mark Adler
* Copyright (C) 1995-2024 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@ -55,7 +55,7 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 70, 200};
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 73, 200};
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,

View File

@ -1,5 +1,5 @@
/* trees.c -- output deflated data using Huffman coding
* Copyright (C) 1995-2021 Jean-loup Gailly
* Copyright (C) 1995-2024 Jean-loup Gailly
* detect_data_type() function provided freely by Cosmin Truta, 2006
* For conditions of distribution and use, see copyright notice in zlib.h
*/

View File

@ -1,5 +1,5 @@
/* zconf.h -- configuration of the zlib compression library
* Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
* Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/

View File

@ -1,7 +1,7 @@
/* zlib.h -- interface of the 'zlib' general purpose compression library
version 1.3.0.1, August xxth, 2023
version 1.3.1.1, January xxth, 2024
Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler
Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -37,11 +37,11 @@
extern "C" {
#endif
#define ZLIB_VERSION "1.3.0.1-motley"
#define ZLIB_VERNUM 0x1301
#define ZLIB_VERSION "1.3.1.1-motley"
#define ZLIB_VERNUM 0x1311
#define ZLIB_VER_MAJOR 1
#define ZLIB_VER_MINOR 3
#define ZLIB_VER_REVISION 0
#define ZLIB_VER_REVISION 1
#define ZLIB_VER_SUBREVISION 1
/*

View File

@ -1,5 +1,5 @@
/* zutil.h -- internal interface and configuration of the compression library
* Copyright (C) 1995-2022 Jean-loup Gailly, Mark Adler
* Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/

View File

@ -1,4 +1,4 @@
/* $OpenBSD: exec_self.c,v 1.2 2016/03/17 19:40:43 krw Exp $ */
/* $OpenBSD: exec_self.c,v 1.3 2024/01/23 10:27:12 anton Exp $ */
/*
* Written by Artur Grabowski <art@openbsd.org> 2002 Public Domain.
*/
@ -13,7 +13,7 @@ struct {
const char pad1[256*1024]; /* avoid read-ahead. */
const char string[256*1024]; /* at least one page */
const char pad2[256*1024]; /* avoid read-behind. */
} const blob = {
} const blob __attribute__((section(".openbsd.mutable"))) = {
"padding1",
"the_test",
"padding2"

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: apldrm.4,v 1.1 2024/01/22 18:56:18 kettenis Exp $
.\" $OpenBSD: apldrm.4,v 1.2 2024/01/23 05:48:47 jsg Exp $
.\"
.\" Copyright (c) 2024 Mark Kettenis <kettenis@openbsd.org>
.\"
@ -14,14 +14,14 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: January 22 2024 $
.Dd $Mdocdate: January 23 2024 $
.Dt APLDRM 4 arm64
.Os
.Sh NAME
.Nm apldrm
.Nd Apple DRM subsystem
.Sh SYNOPSIS
.Cd "aplrm* at fdt?"
.Cd "apldrm* at fdt?"
.Cd "drm* at apldrm?"
.Cd "wsdisplay* at apldrm?"
.Sh DESCRIPTION

View File

@ -24,10 +24,10 @@
.\" DEALINGS IN THE SOFTWARE.
.\"
.\" $FreeBSD: src/share/man/man4/multicast.4,v 1.4 2004/07/09 09:22:36 ru Exp $
.\" $OpenBSD: multicast.4,v 1.16 2022/02/18 10:24:32 jsg Exp $
.\" $OpenBSD: multicast.4,v 1.17 2024/01/23 08:20:30 jmc Exp $
.\" $NetBSD: multicast.4,v 1.3 2004/09/12 13:12:26 wiz Exp $
.\"
.Dd $Mdocdate: February 18 2022 $
.Dd $Mdocdate: January 23 2024 $
.Dt MULTICAST 4
.Os
.\"
@ -74,7 +74,7 @@ the user must enable multicast forwarding via the
variables
.Va net.inet.ip.mforwarding
and/or
.Va net.inet.ip6.mforwarding ,
.Va net.inet6.ip6.mforwarding ,
and set
.Va multicast
to

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: termcap.5,v 1.31 2022/03/31 17:27:23 naddy Exp $
.\" $OpenBSD: termcap.5,v 1.32 2024/01/23 22:28:20 millert Exp $
.\"
.\" Copyright (c) 1985, 1991 The Regents of the University of California.
.\" All rights reserved.
@ -29,7 +29,7 @@
.\"
.\" from: @(#)termcap.5 6.11 (Berkeley) 3/6/93
.\"
.Dd $Mdocdate: March 31 2022 $
.Dd $Mdocdate: January 23 2024 $
.Dt TERMCAP 5
.Os
.Sh NAME
@ -1827,12 +1827,9 @@ entry.
Most programs now use the kernel information primarily; the information
in this file is used only if the kernel does not have any information.
.Pp
.Xr vi 1
allows only 256 characters for string capabilities, and the routines
in
.Xr termcap 3
do not check for overflow of this buffer.
The total length of a single entry (excluding only escaped newlines)
may not exceed 1024.
Historically, the total length of a single entry (excluding only
escaped newlines) was limited to 1023 bytes, not including the NUL
terminator.
Larger entries may lead to a buffer overflow on some systems.
.Pp
Not all programs support all entries.

View File

@ -1,4 +1,4 @@
/* $OpenBSD: eephy.c,v 1.63 2023/12/28 14:03:21 uwe Exp $ */
/* $OpenBSD: eephy.c,v 1.64 2024/01/23 11:51:53 uwe Exp $ */
/*
* Principal Author: Parag Patel
* Copyright (c) 2001
@ -270,6 +270,7 @@ eephy_reset(struct mii_softc *sc)
case MII_MODEL_MARVELL_E1011:
case MII_MODEL_MARVELL_E1111:
case MII_MODEL_MARVELL_E1112:
case MII_MODEL_MARVELL_E1512:
case MII_MODEL_MARVELL_PHYG65G:
reg &= ~E1000_SCR_EN_DETECT_MASK;
break;

View File

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only OR MIT
/* Copyright 2022 Sven Peter <sven@svenpeter.dev> */
#include <linux/bitfield.h>
#include <linux/dma-mapping.h>
#include <linux/slab.h>
#include <linux/workqueue.h>
@ -136,7 +137,7 @@ static void afk_init_rxtx(struct apple_dcp_afkep *ep, u64 message,
u32 bufsz, end;
if (tag != ep->bfr_tag) {
dev_err(ep->dcp->dev, "AFK[ep:%02x]: expected tag 0x%x but got 0x%x",
dev_err(ep->dcp->dev, "AFK[ep:%02x]: expected tag 0x%x but got 0x%x\n",
ep->endpoint, ep->bfr_tag, tag);
return;
}
@ -149,7 +150,7 @@ static void afk_init_rxtx(struct apple_dcp_afkep *ep, u64 message,
if (base >= ep->bfr_size) {
dev_err(ep->dcp->dev,
"AFK[ep:%02x]: requested base 0x%x >= max size 0x%lx",
"AFK[ep:%02x]: requested base 0x%x >= max size 0x%lx\n",
ep->endpoint, base, ep->bfr_size);
return;
}
@ -157,7 +158,7 @@ static void afk_init_rxtx(struct apple_dcp_afkep *ep, u64 message,
end = base + size;
if (end > ep->bfr_size) {
dev_err(ep->dcp->dev,
"AFK[ep:%02x]: requested end 0x%x > max size 0x%lx",
"AFK[ep:%02x]: requested end 0x%x > max size 0x%lx\n",
ep->endpoint, end, ep->bfr_size);
return;
}
@ -166,7 +167,7 @@ static void afk_init_rxtx(struct apple_dcp_afkep *ep, u64 message,
bufsz = le32_to_cpu(bfr->hdr->bufsz);
if (bufsz + sizeof(*bfr->hdr) != size) {
dev_err(ep->dcp->dev,
"AFK[ep:%02x]: ring buffer size 0x%x != expected 0x%lx",
"AFK[ep:%02x]: ring buffer size 0x%x != expected 0x%lx\n",
ep->endpoint, bufsz, sizeof(*bfr->hdr));
return;
}
@ -236,7 +237,7 @@ static void afk_recv_handle_init(struct apple_dcp_afkep *ep, u32 channel,
return;
}
strlcpy(name, payload, sizeof(name));
strscpy(name, payload, sizeof(name));
/*
* in DCP firmware 13.2 DCP reports interface-name as name which starts

View File

@ -195,9 +195,7 @@ static void apple_crtc_atomic_enable(struct drm_crtc *crtc,
if (crtc_state->active_changed && crtc_state->active) {
struct apple_crtc *apple_crtc = to_apple_crtc(crtc);
dev_dbg(&apple_crtc->dcp->dev, "%s", __func__);
dcp_poweron(apple_crtc->dcp);
dev_dbg(&apple_crtc->dcp->dev, "%s finished", __func__);
}
if (crtc_state->active)
@ -212,9 +210,7 @@ static void apple_crtc_atomic_disable(struct drm_crtc *crtc,
if (crtc_state->active_changed && !crtc_state->active) {
struct apple_crtc *apple_crtc = to_apple_crtc(crtc);
dev_dbg(&apple_crtc->dcp->dev, "%s", __func__);
dcp_poweroff(apple_crtc->dcp);
dev_dbg(&apple_crtc->dcp->dev, "%s finished", __func__);
}
if (crtc->state->event && !crtc->state->active) {
@ -459,7 +455,7 @@ static int apple_drm_init_dcp(struct device *dev)
ret = dcp_wait_ready(dcp[i], wait);
/* There is nothing we can do if a dcp/dcpext does not boot
* (successfully). Ignoring it should not do any harm now.
* Needs to reevaluated whenn adding dcpext support.
* Needs to reevaluated when adding dcpext support.
*/
if (ret)
dev_warn(dev, "DCP[%d] not ready: %d\n", i, ret);

View File

@ -95,7 +95,7 @@ struct dcp_panel {
int width_mm;
/// panel height in millimeter
int height_mm;
/// panel has a mini-LED backllight
/// panel has a mini-LED backlight
bool has_mini_led;
};
@ -212,6 +212,8 @@ struct apple_dcp {
/* Workqueue for updating the initial initial brightness */
struct work_struct bl_register_wq;
struct rwlock bl_register_mutex;
/* Workqueue for updating the brightness */
struct work_struct bl_update_wq;
/* integrated panel if present */
struct dcp_panel panel;
@ -241,6 +243,7 @@ struct apple_dcp {
};
int dcp_backlight_register(struct apple_dcp *dcp);
int dcp_backlight_update(struct apple_dcp *dcp);
bool dcp_has_panel(struct apple_dcp *dcp);
#define DCP_AUDIO_MAX_CHANS 15

View File

@ -129,7 +129,7 @@ static void dcp_recv_msg(void *cookie, u8 endpoint, u64 message)
afk_receive_message(dcp->dptxep, message);
return;
default:
WARN(endpoint, "unknown DCP endpoint %hhu", endpoint);
WARN(endpoint, "unknown DCP endpoint %hhu\n", endpoint);
}
}
@ -138,7 +138,7 @@ static void dcp_rtk_crashed(void *cookie)
struct apple_dcp *dcp = cookie;
dcp->crashed = true;
dev_err(dcp->dev, "DCP has crashed");
dev_err(dcp->dev, "DCP has crashed\n");
if (dcp->connector) {
dcp->connector->connected = 0;
schedule_work(&dcp->connector->hotplug_wq);
@ -170,7 +170,7 @@ static int dcp_rtk_shmem_setup(void *cookie, struct apple_rtkit_shmem *bfr)
bfr->is_mapped = true;
dev_info(dcp->dev,
"shmem_setup: iova: %lx -> pa: %lx -> iomem: %lx",
"shmem_setup: iova: %lx -> pa: %lx -> iomem: %lx\n",
(uintptr_t)bfr->iova, (uintptr_t)phy_addr,
(uintptr_t)bfr->buffer);
} else {
@ -179,7 +179,7 @@ static int dcp_rtk_shmem_setup(void *cookie, struct apple_rtkit_shmem *bfr)
if (!bfr->buffer)
return -ENOMEM;
dev_info(dcp->dev, "shmem_setup: iova: %lx, buffer: %lx",
dev_info(dcp->dev, "shmem_setup: iova: %lx, buffer: %lx\n",
(uintptr_t)bfr->iova, (uintptr_t)bfr->buffer);
}
@ -227,7 +227,7 @@ int dcp_crtc_atomic_check(struct drm_crtc *crtc, struct drm_atomic_state *state)
needs_modeset = drm_atomic_crtc_needs_modeset(crtc_state) || !dcp->valid_mode;
if (!needs_modeset && !dcp->connector->connected) {
dev_err(dcp->dev, "crtc_atomic_check: disconnected but no modeset");
dev_err(dcp->dev, "crtc_atomic_check: disconnected but no modeset\n");
return -EINVAL;
}
@ -240,7 +240,7 @@ int dcp_crtc_atomic_check(struct drm_crtc *crtc, struct drm_atomic_state *state)
}
if (plane_count > DCP_MAX_PLANES) {
dev_err(dcp->dev, "crtc_atomic_check: Blend supports only 2 layers!");
dev_err(dcp->dev, "crtc_atomic_check: Blend supports only 2 layers!\n");
return -EINVAL;
}
@ -356,17 +356,17 @@ int dcp_start(struct platform_device *pdev)
/* start RTKit endpoints */
ret = systemep_init(dcp);
if (ret)
dev_warn(dcp->dev, "Failed to start system endpoint: %d", ret);
dev_warn(dcp->dev, "Failed to start system endpoint: %d\n", ret);
if (dcp->phy && dcp->fw_compat >= DCP_FIRMWARE_V_13_5) {
ret = ibootep_init(dcp);
if (ret)
dev_warn(dcp->dev, "Failed to start IBOOT endpoint: %d",
dev_warn(dcp->dev, "Failed to start IBOOT endpoint: %d\n",
ret);
ret = dptxep_init(dcp);
if (ret)
dev_warn(dcp->dev, "Failed to start DPTX endpoint: %d",
dev_warn(dcp->dev, "Failed to start DPTX endpoint: %d\n",
ret);
else if (dcp->dptxport[0].enabled) {
bool connected;
@ -389,7 +389,7 @@ int dcp_start(struct platform_device *pdev)
ret = iomfb_start_rtkit(dcp);
if (ret)
dev_err(dcp->dev, "Failed to start IOMFB endpoint: %d", ret);
dev_err(dcp->dev, "Failed to start IOMFB endpoint: %d\n", ret);
return ret;
}
@ -516,6 +516,15 @@ out_unlock:
mutex_unlock(&dcp->bl_register_mutex);
}
static void dcp_work_update_backlight(struct work_struct *work)
{
struct apple_dcp *dcp;
dcp = container_of(work, struct apple_dcp, bl_update_wq);
dcp_backlight_update(dcp);
}
static int dcp_create_piodma_iommu_dev(struct apple_dcp *dcp)
{
int ret;
@ -809,7 +818,7 @@ static int dcp_comp_bind(struct device *dev, struct device *main, void *data)
if (dcp->notch_height > 0)
dev_info(dev, "Detected display with notch of %u pixel\n", dcp->notch_height);
/* intialize brightness scale to a sensible default to avoid divide by 0*/
/* initialize brightness scale to a sensible default to avoid divide by 0*/
dcp->brightness.scale = 65536;
panel_np = of_get_compatible_child(dev->of_node, "apple,panel-mini-led");
if (panel_np)
@ -836,6 +845,7 @@ static int dcp_comp_bind(struct device *dev, struct device *main, void *data)
dcp->connector_type = DRM_MODE_CONNECTOR_eDP;
INIT_WORK(&dcp->bl_register_wq, dcp_work_register_backlight);
rw_init(&dcp->bl_register_mutex, "dcpbl");
INIT_WORK(&dcp->bl_update_wq, dcp_work_update_backlight);
} else if (of_property_match_string(dev->of_node, "apple,connector-type", "HDMI-A") >= 0)
dcp->connector_type = DRM_MODE_CONNECTOR_HDMIA;
else if (of_property_match_string(dev->of_node, "apple,connector-type", "DP") >= 0)
@ -878,12 +888,12 @@ static int dcp_comp_bind(struct device *dev, struct device *main, void *data)
dcp->rtk = devm_apple_rtkit_init(dev, dcp, "mbox", 0, &rtkit_ops);
if (IS_ERR(dcp->rtk))
return dev_err_probe(dev, PTR_ERR(dcp->rtk),
"Failed to intialize RTKit");
"Failed to initialize RTKit\n");
ret = apple_rtkit_wake(dcp->rtk);
if (ret)
return dev_err_probe(dev, ret,
"Failed to boot RTKit: %d", ret);
"Failed to boot RTKit: %d\n", ret);
return ret;
}
@ -951,7 +961,7 @@ static int dcp_platform_probe(struct platform_device *pdev)
dcp->phy = devm_phy_optional_get(dev, "dp-phy");
if (IS_ERR(dcp->phy)) {
dev_err(dev, "Failed to get dp-phy: %ld", PTR_ERR(dcp->phy));
dev_err(dev, "Failed to get dp-phy: %ld\n", PTR_ERR(dcp->phy));
return PTR_ERR(dcp->phy);
}
if (dcp->phy) {
@ -978,7 +988,7 @@ static int dcp_platform_probe(struct platform_device *pdev)
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
"dp2hdmi-hpd-irq", dcp);
if (ret < 0) {
dev_err(dev, "failed to request HDMI hpd irq %d: %d",
dev_err(dev, "failed to request HDMI hpd irq %d: %d\n",
irq, ret);
return ret;
}
@ -1001,7 +1011,7 @@ static int dcp_platform_probe(struct platform_device *pdev)
if (!ret) {
dcp->xbar = devm_mux_control_get(dev, "dp-xbar");
if (IS_ERR(dcp->xbar)) {
dev_err(dev, "Failed to get dp-xbar: %ld", PTR_ERR(dcp->xbar));
dev_err(dev, "Failed to get dp-xbar: %ld\n", PTR_ERR(dcp->xbar));
return PTR_ERR(dcp->xbar);
}
ret = mux_control_select(dcp->xbar, mux_index);

View File

@ -99,7 +99,7 @@ static u32 interpolate(int val, int min, int max, u32 *tbl, size_t tbl_size)
size_t index = interpolated / SCALE_FACTOR;
if (WARN(index + 1 >= tbl_size, "invalid index %zu for brightness %u", index, val))
if (WARN(index + 1 >= tbl_size, "invalid index %zu for brightness %u\n", index, val))
return tbl[tbl_size / 2];
frac = interpolated & (SCALE_FACTOR - 1);
@ -172,20 +172,8 @@ done:
return ret;
}
static int dcp_set_brightness(struct backlight_device *bd)
int dcp_backlight_update(struct apple_dcp *dcp)
{
int ret = 0;
struct apple_dcp *dcp = bl_get_data(bd);
struct drm_modeset_acquire_ctx ctx;
int brightness = backlight_get_brightness(bd);
DRM_MODESET_LOCK_ALL_BEGIN(dcp->crtc->base.dev, ctx, 0, ret);
dcp->brightness.dac = calculate_dac(dcp, brightness);
dcp->brightness.update = true;
DRM_MODESET_LOCK_ALL_END(dcp->crtc->base.dev, ctx, ret);
/*
* Do not actively try to change brightness if no mode is set.
* TODO: should this be reflected the in backlight's power property?
@ -202,6 +190,23 @@ static int dcp_set_brightness(struct backlight_device *bd)
return drm_crtc_set_brightness(dcp);
}
static int dcp_set_brightness(struct backlight_device *bd)
{
int ret = 0;
struct apple_dcp *dcp = bl_get_data(bd);
struct drm_modeset_acquire_ctx ctx;
int brightness = backlight_get_brightness(bd);
DRM_MODESET_LOCK_ALL_BEGIN(dcp->crtc->base.dev, ctx, 0, ret);
dcp->brightness.dac = calculate_dac(dcp, brightness);
dcp->brightness.update = true;
DRM_MODESET_LOCK_ALL_END(dcp->crtc->base.dev, ctx, ret);
return dcp_backlight_update(dcp);
}
static const struct backlight_ops dcp_backlight_ops = {
.options = BL_CORE_SUSPENDRESUME,
.get_brightness = dcp_get_brightness,

View File

@ -2,6 +2,7 @@
/* Copyright 2021 Alyssa Rosenzweig <alyssa@rosenzweig.io> */
#include <linux/align.h>
#include <linux/bitfield.h>
#include <linux/bitmap.h>
#include <linux/clk.h>
#include <linux/completion.h>
@ -273,7 +274,7 @@ static void dcpep_handle_cb(struct apple_dcp *dcp, enum dcp_context_id context,
out = in + hdr->in_len;
// TODO: verify that in_len and out_len match our prototypes
// for now just clear the out data to have at least consistant results
// for now just clear the out data to have at least consistent results
if (hdr->out_len)
memset(out, 0, hdr->out_len);
@ -325,7 +326,7 @@ static void dcpep_got_msg(struct apple_dcp *dcp, u64 message)
channel_offset = dcp_channel_offset(ctx_id);
if (channel_offset < 0) {
dev_warn(dcp->dev, "invalid context received %u", ctx_id);
dev_warn(dcp->dev, "invalid context received %u\n", ctx_id);
return;
}
@ -481,7 +482,7 @@ void dcp_flush(struct drm_crtc *crtc, struct drm_atomic_state *state)
if (dcp_channel_busy(&dcp->ch_cmd))
{
dev_err(dcp->dev, "unexpected busy command channel");
dev_err(dcp->dev, "unexpected busy command channel\n");
/* HACK: issue a delayed vblank event to avoid timeouts in
* drm_atomic_helper_wait_for_vblanks().
*/

View File

@ -299,7 +299,7 @@ static void dcpep_cb_unmap_piodma(struct apple_dcp *dcp,
struct dcp_mem_descriptor *memdesc;
if (resp->buffer >= ARRAY_SIZE(dcp->memdesc)) {
dev_warn(dcp->dev, "unmap request for out of range buffer %llu",
dev_warn(dcp->dev, "unmap request for out of range buffer %llu\n",
resp->buffer);
return;
}
@ -308,14 +308,14 @@ static void dcpep_cb_unmap_piodma(struct apple_dcp *dcp,
if (!memdesc->buf) {
dev_warn(dcp->dev,
"unmap for non-mapped buffer %llu iova:0x%08llx",
"unmap for non-mapped buffer %llu iova:0x%08llx\n",
resp->buffer, resp->dva);
return;
}
if (memdesc->dva != resp->dva) {
dev_warn(dcp->dev, "unmap buffer %llu address mismatch "
"memdesc.dva:%llx dva:%llx", resp->buffer,
"memdesc.dva:%llx dva:%llx\n", resp->buffer,
memdesc->dva, resp->dva);
return;
}
@ -326,7 +326,7 @@ static void dcpep_cb_unmap_piodma(struct apple_dcp *dcp,
/*
* Allocate an IOVA contiguous buffer mapped to the DCP. The buffer need not be
* physically contigiuous, however we should save the sgtable in case the
* physically contiguous, however we should save the sgtable in case the
* buffer needs to be later mapped for PIODMA.
*/
static struct dcp_allocate_buffer_resp
@ -343,7 +343,7 @@ dcpep_cb_allocate_buffer(struct apple_dcp *dcp,
find_first_zero_bit(dcp->memdesc_map, DCP_MAX_MAPPINGS);
if (resp.mem_desc_id >= DCP_MAX_MAPPINGS) {
dev_warn(dcp->dev, "DCP overflowed mapping table, ignoring");
dev_warn(dcp->dev, "DCP overflowed mapping table, ignoring\n");
resp.dva_size = 0;
resp.mem_desc_id = 0;
return resp;
@ -378,7 +378,7 @@ static u8 dcpep_cb_release_mem_desc(struct apple_dcp *dcp, u32 *mem_desc_id)
}
if (!test_and_clear_bit(id, dcp->memdesc_map)) {
dev_warn(dcp->dev, "unmap request for unused mem_desc_id %u",
dev_warn(dcp->dev, "unmap request for unused mem_desc_id %u\n",
id);
return 0;
}
@ -428,7 +428,7 @@ dcpep_cb_map_physical(struct apple_dcp *dcp, struct dcp_map_physical_req *req)
u32 id;
if (!is_disp_register(dcp, req->paddr, req->paddr + size - 1)) {
dev_err(dcp->dev, "refusing to map phys address %llx size %llx",
dev_err(dcp->dev, "refusing to map phys address %llx size %llx\n",
req->paddr, req->size);
return (struct dcp_map_physical_resp){};
}
@ -457,7 +457,7 @@ static struct DCP_FW_NAME(dcp_map_reg_resp) dcpep_cb_map_reg(struct apple_dcp *d
struct DCP_FW_NAME(dcp_map_reg_req) *req)
{
if (req->index >= dcp->nr_disp_registers) {
dev_warn(dcp->dev, "attempted to read invalid reg index %u",
dev_warn(dcp->dev, "attempted to read invalid reg index %u\n",
req->index);
return (struct DCP_FW_NAME(dcp_map_reg_resp)){ .ret = 1 };
@ -497,6 +497,7 @@ static void iomfbep_cb_enable_backlight_message_ap_gated(struct apple_dcp *dcp,
* syslog: "[BrightnessLCD.cpp:743][AFK]nitsToDBV: iDAC out of range"
*/
dcp->brightness.update = true;
schedule_work(&dcp->bl_update_wq);
}
/* Chunked data transfer for property dictionaries */
@ -601,7 +602,7 @@ static void boot_done(struct apple_dcp *dcp, void *out, void *cookie)
{
struct dcp_channel *ch = &dcp->ch_cb;
u8 *succ = ch->output[ch->depth - 1];
dev_dbg(dcp->dev, "boot done");
dev_dbg(dcp->dev, "boot done\n");
*succ = true;
dcp_ack(dcp, DCP_CONTEXT_CB);
@ -716,7 +717,6 @@ static void release_swap_cookie(struct kref *ref)
static void dcp_swap_cleared(struct apple_dcp *dcp, void *data, void *cookie)
{
struct DCP_FW_NAME(dcp_swap_submit_resp) *resp = data;
dev_dbg(dcp->dev, "%s", __func__);
if (cookie) {
struct dcp_swap_cookie *info = cookie;
@ -747,7 +747,6 @@ static void dcp_swap_clear_started(struct apple_dcp *dcp, void *data,
void *cookie)
{
struct dcp_swap_start_resp *resp = data;
dev_dbg(dcp->dev, "%s swap_id: %u", __func__, resp->swap_id);
DCP_FW_UNION(dcp->swap).swap.swap_id = resp->swap_id;
if (cookie) {
@ -761,7 +760,6 @@ static void dcp_swap_clear_started(struct apple_dcp *dcp, void *data,
static void dcp_on_final(struct apple_dcp *dcp, void *out, void *cookie)
{
struct dcp_wait_cookie *wait = cookie;
dev_dbg(dcp->dev, "%s", __func__);
if (wait) {
complete(&wait->done);
@ -774,7 +772,6 @@ static void dcp_on_set_power_state(struct apple_dcp *dcp, void *out, void *cooki
struct dcp_set_power_state_req req = {
.unklong = 1,
};
dev_dbg(dcp->dev, "%s", __func__);
dcp_set_power_state(dcp, false, &req, dcp_on_final, cookie);
}
@ -790,7 +787,6 @@ static void dcp_on_set_parameter(struct apple_dcp *dcp, void *out, void *cookie)
.count = 1,
#endif
};
dev_dbg(dcp->dev, "%s", __func__);
dcp_set_parameter_dcp(dcp, false, &param, dcp_on_set_power_state, cookie);
}
@ -802,8 +798,6 @@ void DCP_FW_NAME(iomfb_poweron)(struct apple_dcp *dcp)
u32 handle;
dev_err(dcp->dev, "dcp_poweron() starting\n");
dev_dbg(dcp->dev, "%s", __func__);
cookie = kzalloc(sizeof(*cookie), GFP_KERNEL);
if (!cookie)
return;
@ -825,7 +819,7 @@ void DCP_FW_NAME(iomfb_poweron)(struct apple_dcp *dcp)
ret = wait_for_completion_timeout(&cookie->done, msecs_to_jiffies(500));
if (ret == 0)
dev_warn(dcp->dev, "wait for power timed out");
dev_warn(dcp->dev, "wait for power timed out\n");
kref_put(&cookie->refcount, release_wait_cookie);;
@ -873,8 +867,6 @@ void DCP_FW_NAME(iomfb_poweroff)(struct apple_dcp *dcp)
struct dcp_swap_start_req swap_req = { 0 };
struct DCP_FW_NAME(dcp_swap_submit_req) *swap = &DCP_FW_UNION(dcp->swap);
dev_dbg(dcp->dev, "%s", __func__);
cookie = kzalloc(sizeof(*cookie), GFP_KERNEL);
if (!cookie)
return;
@ -922,7 +914,7 @@ void DCP_FW_NAME(iomfb_poweroff)(struct apple_dcp *dcp)
return;
}
dev_dbg(dcp->dev, "%s: clear swap submitted: %u", __func__, swap_id);
dev_dbg(dcp->dev, "%s: clear swap submitted: %u\n", __func__, swap_id);
poff_cookie = kzalloc(sizeof(*poff_cookie), GFP_KERNEL);
if (!poff_cookie)
@ -938,14 +930,13 @@ void DCP_FW_NAME(iomfb_poweroff)(struct apple_dcp *dcp)
msecs_to_jiffies(1000));
if (ret == 0)
dev_warn(dcp->dev, "setPowerState(0) timeout %u ms", 1000);
dev_warn(dcp->dev, "setPowerState(0) timeout %u ms\n", 1000);
else if (ret > 0)
dev_dbg(dcp->dev,
"setPowerState(0) finished with %d ms to spare",
jiffies_to_msecs(ret));
kref_put(&poff_cookie->refcount, release_wait_cookie);
dev_dbg(dcp->dev, "%s: setPowerState(0) done", __func__);
dev_err(dcp->dev, "dcp_poweroff() done\n");
}
@ -989,11 +980,9 @@ void DCP_FW_NAME(iomfb_sleep)(struct apple_dcp *dcp)
msecs_to_jiffies(1000));
if (ret == 0)
dev_warn(dcp->dev, "setDCPPower(0) timeout %u ms", 1000);
dev_warn(dcp->dev, "setDCPPower(0) timeout %u ms\n", 1000);
kref_put(&cookie->refcount, release_wait_cookie);
dev_dbg(dcp->dev, "%s: setDCPPower(0) done", __func__);
dev_err(dcp->dev, "dcp_sleep() done\n");
}
@ -1162,7 +1151,6 @@ static void dcp_swap_started(struct apple_dcp *dcp, void *data, void *cookie)
static void do_swap(struct apple_dcp *dcp, void *data, void *cookie)
{
struct dcp_swap_start_req start_req = { 0 };
dev_dbg(dcp->dev, "%s", __func__);
if (dcp->connector && dcp->connector->connected)
dcp_swap_start(dcp, false, &start_req, dcp_swap_started, NULL);
@ -1174,7 +1162,6 @@ static void complete_set_digital_out_mode(struct apple_dcp *dcp, void *data,
void *cookie)
{
struct dcp_wait_cookie *wait = cookie;
dev_dbg(dcp->dev, "%s", __func__);
if (wait) {
complete(&wait->done);
@ -1241,7 +1228,6 @@ int DCP_FW_NAME(iomfb_modeset)(struct apple_dcp *dcp,
* modesets. Add an extra 500ms to safe side that the modeset
* call has returned.
*/
dev_dbg(dcp->dev, "%s - wait for modeset", __func__);
ret = wait_for_completion_timeout(&cookie->done,
msecs_to_jiffies(8500));
@ -1275,7 +1261,6 @@ void DCP_FW_NAME(iomfb_flush)(struct apple_dcp *dcp, struct drm_crtc *crtc, stru
struct DCP_FW_NAME(dcp_swap_submit_req) *req = &DCP_FW_UNION(dcp->swap);
int plane_idx, l;
int has_surface = 0;
dev_dbg(dcp->dev, "%s", __func__);
crtc_state = drm_atomic_get_new_crtc_state(state, crtc);

View File

@ -53,7 +53,7 @@ static const iomfb_cb_handler cb_handlers[IOMFB_MAX_CB] = {
[110] = trampoline_true, /* create_pmu_service */
[111] = trampoline_true, /* create_iomfb_service */
[112] = trampoline_create_backlight_service,
[113] = trampoline_true, /* create_nvram_servce? */
[113] = trampoline_true, /* create_nvram_service? */
[114] = trampoline_get_tiling_state,
[115] = trampoline_false, /* set_tiling_state */
[120] = dcpep_cb_boot_1,

View File

@ -694,7 +694,7 @@ int parse_epic_service_init(struct dcp_parse_ctx *handle, const char **name,
return ret;
}
int parse_sample_rate_bit(struct dcp_parse_ctx *handle, unsigned int *ratebit)
static int parse_sample_rate_bit(struct dcp_parse_ctx *handle, unsigned int *ratebit)
{
s64 rate;
int ret = parse_int(handle, &rate);
@ -715,7 +715,7 @@ int parse_sample_rate_bit(struct dcp_parse_ctx *handle, unsigned int *ratebit)
return 0;
}
int parse_sample_fmtbit(struct dcp_parse_ctx *handle, u64 *fmtbit)
static int parse_sample_fmtbit(struct dcp_parse_ctx *handle, u64 *fmtbit)
{
s64 sample_size;
int ret = parse_int(handle, &sample_size);

View File

@ -5,7 +5,14 @@
#include <sys/param.h>
#define roundup2(x, y) (((x) + ((y) - 1)) & (~((__typeof(x))(y) - 1)))
#define rounddown2(x, y) ((x) & ~((__typeof(x))(y) - 1))
#undef ALIGN
#define ALIGN(x, y) roundup2((x), (y))
#define IS_ALIGNED(x, y) (((x) & ((y) - 1)) == 0)
#define PTR_ALIGN(x, y) ((__typeof(x))roundup2((unsigned long)(x), (y)))
#define ALIGN_DOWN(x, y) ((__typeof(x))rounddown2((unsigned long)(x), (y)))
#endif

View File

@ -0,0 +1,8 @@
/* Public domain. */
#ifndef _LINUX_ARGS_H
#define _LINUX_ARGS_H
#define CONCATENATE(x, y) __CONCAT(x, y)
#endif

View File

@ -3,7 +3,6 @@
#ifndef _LINUX_KERNEL_H
#define _LINUX_KERNEL_H
#include <sys/stdint.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/stdarg.h>
@ -19,24 +18,13 @@
#include <linux/container_of.h>
#include <linux/stddef.h>
#include <linux/align.h>
#include <linux/math.h>
#include <linux/limits.h>
#include <asm/byteorder.h>
#define swap(a, b) \
do { __typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define offsetofend(s, e) (offsetof(s, e) + sizeof((((s *)0)->e)))
#define S8_MAX INT8_MAX
#define S16_MAX INT16_MAX
#define S32_MAX INT32_MAX
#define S64_MAX INT64_MAX
#define U8_MAX UINT8_MAX
#define U16_MAX UINT16_MAX
#define U32_MAX UINT32_MAX
#define U64_C(x) UINT64_C(x)
#define U64_MAX UINT64_MAX
#define ARRAY_SIZE nitems
#define lower_32_bits(n) ((u32)(n))
@ -65,24 +53,6 @@
#define min_not_zero(a, b) (a == 0) ? b : ((b == 0) ? a : min(a, b))
#define mult_frac(x, n, d) (((x) * (n)) / (d))
#define roundup2(x, y) (((x) + ((y) - 1)) & (~((__typeof(x))(y) - 1)))
#define rounddown2(x, y) ((x) & ~((__typeof(x))(y) - 1))
#define round_up(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
#define round_down(x, y) (((x) / (y)) * (y)) /* y is power of two */
#define rounddown(x, y) (((x) / (y)) * (y)) /* arbitrary y */
#define DIV_ROUND_UP(x, y) (((x) + ((y) - 1)) / (y))
#define DIV_ROUND_UP_ULL(x, y) DIV_ROUND_UP(x, y)
#define DIV_ROUND_DOWN(x, y) ((x) / (y))
#define DIV_ROUND_DOWN_ULL(x, y) DIV_ROUND_DOWN(x, y)
#define DIV_ROUND_CLOSEST(x, y) (((x) + ((y) / 2)) / (y))
#define DIV_ROUND_CLOSEST_ULL(x, y) DIV_ROUND_CLOSEST(x, y)
#define IS_ALIGNED(x, y) (((x) & ((y) - 1)) == 0)
#define PTR_ALIGN(x, y) ((__typeof(x))roundup2((unsigned long)(x), (y)))
#define ALIGN_DOWN(x, y) ((__typeof(x))rounddown2((unsigned long)(x), (y)))
static inline char *
kvasprintf(int flags, const char *fmt, va_list ap)
{
@ -127,17 +97,6 @@ vscnprintf(char *buf, size_t size, const char *fmt, va_list ap)
return nc;
}
static inline int
_in_dbg_master(void)
{
#ifdef DDB
return (db_active);
#endif
return (0);
}
#define oops_in_progress _in_dbg_master()
#define might_sleep() assertwaitok()
#define might_sleep_if(x) do { \
if (x) \
@ -155,8 +114,6 @@ _in_dbg_master(void)
#define STUB() do { printf("%s: stub\n", __func__); } while(0)
#define CONCATENATE(x, y) __CONCAT(x, y)
#define PTR_IF(c, p) ((c) ? (p) : NULL)
#endif

View File

@ -0,0 +1,19 @@
/* Public domain. */
#ifndef _LINUX_LIMITS_H
#define _LINUX_LIMITS_H
#include <sys/stdint.h>
#define S8_MAX INT8_MAX
#define S16_MAX INT16_MAX
#define S32_MAX INT32_MAX
#define S64_MAX INT64_MAX
#define U8_MAX UINT8_MAX
#define U16_MAX UINT16_MAX
#define U32_MAX UINT32_MAX
#define U64_C(x) UINT64_C(x)
#define U64_MAX UINT64_MAX
#endif

View File

@ -3,4 +3,16 @@
#ifndef _LINUX_MATH_H
#define _LINUX_MATH_H
#define mult_frac(x, n, d) (((x) * (n)) / (d))
#define round_up(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
#define round_down(x, y) (((x) / (y)) * (y)) /* y is power of two */
#define rounddown(x, y) (((x) / (y)) * (y)) /* arbitrary y */
#define DIV_ROUND_UP(x, y) (((x) + ((y) - 1)) / (y))
#define DIV_ROUND_UP_ULL(x, y) DIV_ROUND_UP(x, y)
#define DIV_ROUND_DOWN(x, y) ((x) / (y))
#define DIV_ROUND_DOWN_ULL(x, y) DIV_ROUND_DOWN(x, y)
#define DIV_ROUND_CLOSEST(x, y) (((x) + ((y) / 2)) / (y))
#define DIV_ROUND_CLOSEST_ULL(x, y) DIV_ROUND_CLOSEST(x, y)
#endif

View File

@ -69,4 +69,15 @@ struct va_format {
va_list *va;
};
static inline int
_in_dbg_master(void)
{
#ifdef DDB
return (db_active);
#endif
return (0);
}
#define oops_in_progress _in_dbg_master()
#endif

View File

@ -6,4 +6,6 @@
#define DECLARE_FLEX_ARRAY(t, n) \
struct { struct{} n ## __unused; t n[]; }
#define offsetofend(s, e) (offsetof(s, e) + sizeof((((s *)0)->e)))
#endif

View File

@ -1,4 +1,4 @@
/* $OpenBSD: if_igc.c,v 1.14 2023/11/10 15:51:20 bluhm Exp $ */
/* $OpenBSD: if_igc.c,v 1.15 2024/01/23 08:48:12 kevlo Exp $ */
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
@ -1523,16 +1523,16 @@ igc_media_change(struct ifnet *ifp)
sc->hw.phy.autoneg_advertised = ADVERTISE_1000_FULL;
break;
case IFM_100_TX:
if ((ifm->ifm_media & IFM_GMASK) == IFM_HDX)
sc->hw.phy.autoneg_advertised = ADVERTISE_100_HALF;
else
if ((ifm->ifm_media & IFM_GMASK) == IFM_FDX)
sc->hw.phy.autoneg_advertised = ADVERTISE_100_FULL;
else
sc->hw.phy.autoneg_advertised = ADVERTISE_100_HALF;
break;
case IFM_10_T:
if ((ifm->ifm_media & IFM_GMASK) == IFM_HDX)
sc->hw.phy.autoneg_advertised = ADVERTISE_10_HALF;
else
if ((ifm->ifm_media & IFM_GMASK) == IFM_FDX)
sc->hw.phy.autoneg_advertised = ADVERTISE_10_FULL;
else
sc->hw.phy.autoneg_advertised = ADVERTISE_10_HALF;
break;
default:
return EINVAL;
@ -2179,6 +2179,8 @@ igc_setup_receive_ring(struct rx_ring *rxr)
* Enable receive unit.
*
**********************************************************************/
#define BSIZEPKT_ROUNDUP ((1 << IGC_SRRCTL_BSIZEPKT_SHIFT) - 1)
void
igc_initialize_receive_unit(struct igc_softc *sc)
{
@ -2226,12 +2228,10 @@ igc_initialize_receive_unit(struct igc_softc *sc)
if (sc->sc_nqueues > 1)
igc_initialize_rss_mapping(sc);
#if 0
srrctl |= 4096 >> IGC_SRRCTL_BSIZEPKT_SHIFT;
rctl |= IGC_RCTL_SZ_4096 | IGC_RCTL_BSEX;
#endif
srrctl |= 2048 >> IGC_SRRCTL_BSIZEPKT_SHIFT;
/* Set maximum packet buffer len */
srrctl |= (sc->rx_mbuf_sz + BSIZEPKT_ROUNDUP) >>
IGC_SRRCTL_BSIZEPKT_SHIFT;
/* srrctl above overrides this but set the register to a sane value */
rctl |= IGC_RCTL_SZ_2048;
/*

View File

@ -1,5 +1,5 @@
/* deflate.c -- compress data using the deflation algorithm
* Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler
* Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/

View File

@ -1,5 +1,5 @@
/* deflate.h -- internal compression state
* Copyright (C) 1995-2018 Jean-loup Gailly
* Copyright (C) 1995-2024 Jean-loup Gailly
* For conditions of distribution and use, see copyright notice in zlib.h
*/

View File

@ -1,5 +1,5 @@
/* inftrees.c -- generate Huffman trees for efficient decoding
* Copyright (C) 1995-2023 Mark Adler
* Copyright (C) 1995-2024 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@ -55,7 +55,7 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 70, 200};
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 73, 200};
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,

View File

@ -1,5 +1,5 @@
/* trees.c -- output deflated data using Huffman coding
* Copyright (C) 1995-2021 Jean-loup Gailly
* Copyright (C) 1995-2024 Jean-loup Gailly
* detect_data_type() function provided freely by Cosmin Truta, 2006
* For conditions of distribution and use, see copyright notice in zlib.h
*/

View File

@ -1,5 +1,5 @@
/* zconf.h -- configuration of the zlib compression library
* Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
* Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/

View File

@ -1,7 +1,7 @@
/* zlib.h -- interface of the 'zlib' general purpose compression library
version 1.3.0.1, August xxth, 2023
version 1.3.1.1, January xxth, 2024
Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler
Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -37,11 +37,11 @@
extern "C" {
#endif
#define ZLIB_VERSION "1.3.0.1-motley"
#define ZLIB_VERNUM 0x1301
#define ZLIB_VERSION "1.3.1.1-motley"
#define ZLIB_VERNUM 0x1311
#define ZLIB_VER_MAJOR 1
#define ZLIB_VER_MINOR 3
#define ZLIB_VER_REVISION 0
#define ZLIB_VER_REVISION 1
#define ZLIB_VER_SUBREVISION 1
/*

View File

@ -1,5 +1,5 @@
/* zutil.h -- internal interface and configuration of the compression library
* Copyright (C) 1995-2022 Jean-loup Gailly, Mark Adler
* Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/

View File

@ -1,4 +1,4 @@
/* $OpenBSD: if_sec.c,v 1.9 2023/12/23 10:52:54 bluhm Exp $ */
/* $OpenBSD: if_sec.c,v 1.10 2024/01/24 00:17:01 dlg Exp $ */
/*
* Copyright (c) 2022 The University of Queensland
@ -315,6 +315,14 @@ sec_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
}
}
mtag = m_tag_get(PACKET_TAG_GRE, sizeof(ifp->if_index), M_NOWAIT);
if (mtag == NULL) {
error = ENOBUFS;
goto drop;
}
*(int *)(mtag + 1) = ifp->if_index;
m_tag_prepend(m, mtag);
m->m_pkthdr.ph_family = dst->sa_family;
error = if_enqueue(ifp, m);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pipex.c,v 1.151 2023/12/01 20:30:22 mvs Exp $ */
/* $OpenBSD: pipex.c,v 1.153 2024/01/23 17:57:21 mvs Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
@ -98,7 +98,6 @@ struct pipex_hash_head
pipex_id_hashtable[PIPEX_HASH_SIZE]; /* [L] peer id hash */
struct radix_node_head *pipex_rd_head4 = NULL; /* [L] */
struct radix_node_head *pipex_rd_head6 = NULL; /* [L] */
struct timeout pipex_timer_ch; /* callout timer context */
int pipex_prune = 1; /* [I] walk list every seconds */
@ -152,6 +151,8 @@ pipex_destroy_all_sessions(void *ownersc)
LIST_FOREACH_SAFE(session, &pipex_session_list, session_list,
session_tmp) {
if (session->flags & PIPEX_SFLAGS_ITERATOR)
continue;
if (session->ownersc == ownersc) {
KASSERT((session->flags & PIPEX_SFLAGS_PPPX) == 0);
pipex_unlink_session_locked(session);
@ -437,11 +438,6 @@ pipex_link_session(struct pipex_session *session, struct ifnet *ifp,
offsetof(struct sockaddr_in, sin_addr)))
panic("rn_inithead() failed on pipex_link_session()");
}
if (pipex_rd_head6 == NULL) {
if (!rn_inithead((void **)&pipex_rd_head6,
offsetof(struct sockaddr_in6, sin6_addr)))
panic("rn_inithead() failed on pipex_link_session()");
}
if (pipex_lookup_by_session_id_locked(session->protocol,
session->session_id)) {
error = EEXIST;
@ -600,6 +596,8 @@ pipex_get_closed(struct pipex_session_list_req *req, void *ownersc)
LIST_FOREACH_SAFE(session, &pipex_close_wait_list, state_list,
session_tmp) {
if (session->flags & PIPEX_SFLAGS_ITERATOR)
continue;
if (session->ownersc != ownersc)
continue;
req->plr_ppp_id[req->plr_ppp_id_count++] = session->ppp_id;
@ -736,6 +734,8 @@ pipex_timer(void *ignored_arg)
/* walk through */
LIST_FOREACH_SAFE(session, &pipex_session_list, session_list,
session_tmp) {
if (session->flags & PIPEX_SFLAGS_ITERATOR)
continue;
switch (session->state) {
case PIPEX_STATE_OPENED:
if (session->timeout_sec == 0)
@ -775,6 +775,47 @@ pipex_timer(void *ignored_arg)
/***********************************************************************
* Common network I/O functions. (tunnel protocol independent)
***********************************************************************/
struct pipex_session *
pipex_iterator(struct pipex_session *session,
struct pipex_session_iterator *iter, void *ownersc)
{
struct pipex_session *session_tmp;
mtx_enter(&pipex_list_mtx);
if (session)
session_tmp = LIST_NEXT(session, session_list);
else
session_tmp = LIST_FIRST(&pipex_session_list);
while (session_tmp) {
if (session_tmp->flags & PIPEX_SFLAGS_ITERATOR)
goto next;
if (session_tmp->ownersc != ownersc)
goto next;
break;
next:
session_tmp = LIST_NEXT(session_tmp, session_list);
}
if (session)
LIST_REMOVE(iter, session_list);
if (session_tmp) {
LIST_INSERT_AFTER(session_tmp,
(struct pipex_session *)&iter, session_list);
refcnt_take(&session_tmp->pxs_refcnt);
}
mtx_leave(&pipex_list_mtx);
if (session)
pipex_rele_session(session);
return (session_tmp);
}
void
pipex_ip_output(struct mbuf *m0, struct pipex_session *session)
{
@ -809,23 +850,17 @@ pipex_ip_output(struct mbuf *m0, struct pipex_session *session)
pipex_ppp_output(m0, session, PPP_IP);
} else {
struct pipex_session_iterator iter = {
.flags = PIPEX_SFLAGS_ITERATOR,
};
struct pipex_session *session_tmp;
struct mbuf *m;
m0->m_flags &= ~(M_BCAST|M_MCAST);
mtx_enter(&pipex_list_mtx);
session_tmp = LIST_FIRST(&pipex_session_list);
while (session_tmp != NULL) {
struct pipex_session *session_save = NULL;
if (session_tmp->ownersc != session->ownersc)
goto next;
refcnt_take(&session_tmp->pxs_refcnt);
mtx_leave(&pipex_list_mtx);
session_tmp = pipex_iterator(NULL, &iter, session->ownersc);
while (session_tmp) {
m = m_copym(m0, 0, M_COPYALL, M_NOWAIT);
if (m != NULL)
pipex_ppp_output(m, session_tmp, PPP_IP);
@ -833,16 +868,10 @@ pipex_ip_output(struct mbuf *m0, struct pipex_session *session)
counters_inc(session_tmp->stat_counters,
pxc_oerrors);
mtx_enter(&pipex_list_mtx);
session_save = session_tmp;
next:
session_tmp = LIST_NEXT(session_tmp, session_list);
if (session_save != NULL)
pipex_rele_session(session_save);
session_tmp = pipex_iterator(session_tmp,
&iter, session->ownersc);
}
mtx_leave(&pipex_list_mtx);
m_freem(m0);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pipex_local.h,v 1.49 2022/07/15 22:56:13 mvs Exp $ */
/* $OpenBSD: pipex_local.h,v 1.51 2024/01/23 17:57:21 mvs Exp $ */
/*
* Copyright (c) 2009 Internet Initiative Japan Inc.
@ -156,21 +156,32 @@ struct pipex_l2tp_session {
struct cpumem;
/* special iterator session */
struct pipex_session_iterator {
/* Fields below should be in sync with pipex_session structure */
struct radix_node ps4_rn[2];
u_int flags; /* [I] flags, see below */
LIST_ENTRY(pipex_session) session_list; /* [L] all session chain */
};
/* pppac ip-extension session table */
struct pipex_session {
struct radix_node ps4_rn[2];
/* [L] tree glue, and other values */
struct radix_node ps6_rn[2];
/* [L] tree glue, and other values */
struct refcnt pxs_refcnt;
struct mutex pxs_mtx;
u_int flags; /* [I] flags, see below */
#define PIPEX_SFLAGS_MULTICAST 0x01 /* virtual entry for multicast */
#define PIPEX_SFLAGS_PPPX 0x02 /* interface is
point2point(pppx) */
#define PIPEX_SFLAGS_ITERATOR 0x04 /* iterator session */
LIST_ENTRY(pipex_session) session_list; /* [L] all session chain */
LIST_ENTRY(pipex_session) state_list; /* [L] state list chain */
LIST_ENTRY(pipex_session) id_chain; /* [L] id hash chain */
LIST_ENTRY(pipex_session) peer_addr_chain;
/* [L] peer's address hash chain */
struct refcnt pxs_refcnt;
struct mutex pxs_mtx;
u_int state; /* [L] pipex session state */
#define PIPEX_STATE_INITIAL 0x0000
#define PIPEX_STATE_OPENED 0x0001
@ -180,11 +191,6 @@ struct pipex_session {
uint32_t idle_time; /* [L] idle time in seconds */
u_int flags; /* [I] flags, see below */
#define PIPEX_SFLAGS_MULTICAST 0x01 /* virtual entry for multicast */
#define PIPEX_SFLAGS_PPPX 0x02 /* interface is
point2point(pppx) */
uint16_t protocol; /* [I] tunnel protocol (PK) */
uint16_t session_id; /* [I] session-id (PK) */
uint16_t peer_session_id; /* [I] peer's session-id */
@ -466,3 +472,5 @@ int pipex_ppp_enqueue (struct mbuf *, struct pipex_session *,
void pipex_timer_start (void);
void pipex_timer_stop (void);
void pipex_timer (void *);
struct pipex_session *pipex_iterator(struct pipex_session *,
struct pipex_session_iterator *, void *);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: bgpctl.c,v 1.300 2024/01/18 14:46:21 claudio Exp $ */
/* $OpenBSD: bgpctl.c,v 1.301 2024/01/23 16:16:15 claudio Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@ -1709,118 +1709,85 @@ static void
show_mrt_update(u_char *p, uint16_t len, int reqflags, int addpath)
{
struct bgpd_addr prefix;
int pos;
struct ibuf *b, buf, wbuf, abuf;
uint32_t pathid;
uint16_t wlen, alen;
uint8_t prefixlen;
if (len < sizeof(wlen)) {
printf("bad length");
return;
}
memcpy(&wlen, p, sizeof(wlen));
wlen = ntohs(wlen);
p += sizeof(wlen);
len -= sizeof(wlen);
if (len < wlen) {
printf("bad withdraw length");
return;
}
ibuf_from_buffer(&buf, p, len);
b = &buf;
if (ibuf_get_n16(b, &wlen) == -1 ||
ibuf_get_ibuf(b, wlen, &wbuf) == -1)
goto trunc;
if (wlen > 0) {
printf("\n Withdrawn prefixes:");
while (wlen > 0) {
if (addpath) {
if (wlen <= sizeof(pathid)) {
printf("bad withdraw prefix");
return;
}
memcpy(&pathid, p, sizeof(pathid));
pathid = ntohl(pathid);
p += sizeof(pathid);
len -= sizeof(pathid);
wlen -= sizeof(pathid);
}
if ((pos = nlri_get_prefix(p, wlen, &prefix,
&prefixlen)) == -1) {
printf("bad withdraw prefix");
return;
}
while (ibuf_size(&wbuf) > 0) {
if (addpath)
if (ibuf_get_n32(&wbuf, &pathid) == -1)
goto trunc;
if (nlri_get_prefix(&wbuf, &prefix, &prefixlen) == -1)
goto trunc;
printf(" %s/%u", log_addr(&prefix), prefixlen);
if (addpath)
printf(" path-id %u", pathid);
p += pos;
len -= pos;
wlen -= pos;
}
}
if (len < sizeof(alen)) {
printf("bad length");
return;
}
memcpy(&alen, p, sizeof(alen));
alen = ntohs(alen);
p += sizeof(alen);
len -= sizeof(alen);
if (ibuf_get_n16(b, &alen) == -1 ||
ibuf_get_ibuf(b, alen, &abuf) == -1)
goto trunc;
if (len < alen) {
printf("bad attribute length");
return;
}
printf("\n");
/* alen attributes here */
while (alen > 3) {
uint8_t flags;
while (ibuf_size(&abuf) > 0) {
struct ibuf attrbuf;
uint16_t attrlen;
uint8_t flags;
flags = p[0];
/* type = p[1]; */
ibuf_from_ibuf(&abuf, &attrbuf);
if (ibuf_get_n8(&attrbuf, &flags) == -1 ||
ibuf_skip(&attrbuf, 1) == -1)
goto trunc;
/* get the attribute length */
if (flags & ATTR_EXTLEN) {
if (len < sizeof(attrlen) + 2)
printf("bad attribute length");
memcpy(&attrlen, &p[2], sizeof(attrlen));
attrlen = ntohs(attrlen);
attrlen += sizeof(attrlen) + 2;
if (ibuf_get_n16(&attrbuf, &attrlen) == -1)
goto trunc;
} else {
attrlen = p[2];
attrlen += 1 + 2;
uint8_t tmp;
if (ibuf_get_n8(&attrbuf, &tmp) == -1)
goto trunc;
attrlen = tmp;
}
if (ibuf_truncate(&attrbuf, attrlen) == -1)
goto trunc;
ibuf_rewind(&attrbuf);
if (ibuf_skip(&abuf, ibuf_size(&attrbuf)) == -1)
goto trunc;
output->attr(p, attrlen, reqflags, addpath);
p += attrlen;
alen -= attrlen;
len -= attrlen;
output->attr(ibuf_data(&attrbuf), ibuf_size(&attrbuf),
reqflags, addpath);
}
if (len > 0) {
if (ibuf_size(b) > 0) {
printf(" NLRI prefixes:");
while (len > 0) {
if (addpath) {
if (len <= sizeof(pathid)) {
printf(" bad nlri prefix: pathid, "
"len %d", len);
return;
}
memcpy(&pathid, p, sizeof(pathid));
pathid = ntohl(pathid);
p += sizeof(pathid);
len -= sizeof(pathid);
}
if ((pos = nlri_get_prefix(p, len, &prefix,
&prefixlen)) == -1) {
printf(" bad nlri prefix");
return;
}
while (ibuf_size(b) > 0) {
if (addpath)
if (ibuf_get_n32(b, &pathid) == -1)
goto trunc;
if (nlri_get_prefix(b, &prefix, &prefixlen) == -1)
goto trunc;
printf(" %s/%u", log_addr(&prefix), prefixlen);
if (addpath)
printf(" path-id %u", pathid);
p += pos;
len -= pos;
}
}
return;
trunc:
printf("truncated message");
}
void

View File

@ -1,4 +1,4 @@
/* $OpenBSD: mrtparser.c,v 1.20 2023/11/20 14:18:21 claudio Exp $ */
/* $OpenBSD: mrtparser.c,v 1.21 2024/01/23 16:16:15 claudio Exp $ */
/*
* Copyright (c) 2011 Claudio Jeker <claudio@openbsd.org>
*
@ -398,7 +398,7 @@ mrt_parse_v2_rib(struct mrt_hdr *hdr, void *msg, int verbose)
/* prefix */
ret = mrt_extract_prefix(b, len, AID_INET, &r->prefix,
&r->prefixlen, verbose);
if (ret == 1)
if (ret == -1)
goto fail;
break;
case MRT_DUMP_V2_RIB_IPV6_UNICAST_ADDPATH:
@ -410,7 +410,7 @@ mrt_parse_v2_rib(struct mrt_hdr *hdr, void *msg, int verbose)
/* prefix */
ret = mrt_extract_prefix(b, len, AID_INET6, &r->prefix,
&r->prefixlen, verbose);
if (ret == 1)
if (ret == -1)
goto fail;
break;
case MRT_DUMP_V2_RIB_GENERIC_ADDPATH:
@ -439,7 +439,7 @@ mrt_parse_v2_rib(struct mrt_hdr *hdr, void *msg, int verbose)
/* prefix */
ret = mrt_extract_prefix(b, len, aid, &r->prefix,
&r->prefixlen, verbose);
if (ret == 1)
if (ret == -1)
goto fail;
break;
default:
@ -744,7 +744,7 @@ mrt_parse_dump_mp(struct mrt_hdr *hdr, void *msg, struct mrt_peer **pp,
/* prefix */
ret = mrt_extract_prefix(b, len, aid, &r->prefix, &r->prefixlen,
verbose);
if (ret == 1)
if (ret == -1)
goto fail;
b += ret;
len -= ret;
@ -1032,23 +1032,25 @@ mrt_extract_addr(void *msg, u_int len, struct bgpd_addr *addr, uint8_t aid)
}
int
mrt_extract_prefix(void *msg, u_int len, uint8_t aid,
mrt_extract_prefix(void *m, u_int len, uint8_t aid,
struct bgpd_addr *prefix, uint8_t *prefixlen, int verbose)
{
struct ibuf buf, *msg = &buf;
int r;
ibuf_from_buffer(msg, m, len); /* XXX */
switch (aid) {
case AID_INET:
r = nlri_get_prefix(msg, len, prefix, prefixlen);
r = nlri_get_prefix(msg, prefix, prefixlen);
break;
case AID_INET6:
r = nlri_get_prefix6(msg, len, prefix, prefixlen);
r = nlri_get_prefix6(msg, prefix, prefixlen);
break;
case AID_VPN_IPv4:
r = nlri_get_vpn4(msg, len, prefix, prefixlen, 0);
r = nlri_get_vpn4(msg, prefix, prefixlen, 0);
break;
case AID_VPN_IPv6:
r = nlri_get_vpn6(msg, len, prefix, prefixlen, 0);
r = nlri_get_vpn6(msg, prefix, prefixlen, 0);
break;
default:
if (verbose)
@ -1057,6 +1059,8 @@ mrt_extract_prefix(void *msg, u_int len, uint8_t aid,
}
if (r == -1 && verbose)
printf("failed to parse prefix of AID %d\n", aid);
if (r != -1)
r = len - ibuf_size(msg); /* XXX */
return r;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: mrtparser.h,v 1.5 2022/02/06 09:52:32 claudio Exp $ */
/* $OpenBSD: mrtparser.h,v 1.6 2024/01/23 15:56:48 claudio Exp $ */
/*
* Copyright (c) 2011 Claudio Jeker <claudio@openbsd.org>
*
@ -56,7 +56,7 @@ struct mrt_rib {
uint32_t seqnum;
uint16_t nentries;
uint8_t prefixlen;
uint8_t add_path;
uint8_t add_path;
};
/* data structures for the BGP4MP MESSAGE and STATE types */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: output.c,v 1.46 2024/01/11 14:34:49 claudio Exp $ */
/* $OpenBSD: output.c,v 1.47 2024/01/23 16:16:15 claudio Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@ -772,11 +772,12 @@ show_attr(u_char *data, size_t len, int reqflags, int addpath)
u_char *path;
struct in_addr id;
struct bgpd_addr prefix;
struct ibuf ibuf, *buf = &ibuf;
char *aspath;
uint32_t as, pathid;
uint16_t alen, ioff, short_as, afi;
uint8_t flags, type, safi, aid, prefixlen;
int i, pos, e2, e4;
int i, e2, e4;
if (len < 3) {
warnx("Too short BGP attribute");
@ -951,43 +952,35 @@ show_attr(u_char *data, size_t len, int reqflags, int addpath)
printf(" nexthop: %s", log_addr(&nexthop));
}
while (alen > 0) {
if (addpath) {
if (alen <= sizeof(pathid)) {
printf("bad nlri prefix");
return;
}
memcpy(&pathid, data, sizeof(pathid));
pathid = ntohl(pathid);
data += sizeof(pathid);
alen -= sizeof(pathid);
}
ibuf_from_buffer(buf, data, alen);
while (ibuf_size(buf) > 0) {
if (addpath)
if (ibuf_get_n32(buf, &pathid) == -1)
goto bad_len;
switch (aid) {
case AID_INET6:
pos = nlri_get_prefix6(data, alen, &prefix,
&prefixlen);
if (nlri_get_prefix6(buf, &prefix,
&prefixlen) == -1)
goto bad_len;
break;
case AID_VPN_IPv4:
pos = nlri_get_vpn4(data, alen, &prefix,
&prefixlen, 1);
if (nlri_get_vpn4(buf, &prefix,
&prefixlen, 1) == -1)
goto bad_len;
break;
case AID_VPN_IPv6:
pos = nlri_get_vpn6(data, alen, &prefix,
&prefixlen, 1);
if (nlri_get_vpn6(buf, &prefix,
&prefixlen, 1) == -1)
goto bad_len;
break;
default:
printf("unhandled AID #%u", aid);
goto done;
}
if (pos == -1) {
printf("bad %s prefix", aid2str(aid));
break;
}
printf(" %s/%u", log_addr(&prefix), prefixlen);
if (addpath)
printf(" path-id %u", pathid);
data += pos;
alen -= pos;
}
break;
case ATTR_EXT_COMMUNITIES:

View File

@ -1,4 +1,4 @@
/* $OpenBSD: output_json.c,v 1.38 2024/01/11 13:09:41 claudio Exp $ */
/* $OpenBSD: output_json.c,v 1.39 2024/01/23 16:16:15 claudio Exp $ */
/*
* Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
@ -589,12 +589,13 @@ json_attr(u_char *data, size_t len, int reqflags, int addpath)
{
struct bgpd_addr prefix;
struct in_addr id;
struct ibuf ibuf, *buf = &ibuf;
char *aspath;
u_char *path;
uint32_t as, pathid;
uint16_t alen, afi, off, short_as;
uint8_t flags, type, safi, aid, prefixlen;
int e4, e2, pos;
int e4, e2;
if (len < 3) {
warnx("Too short BGP attribute");
@ -780,48 +781,39 @@ bad_len:
json_do_string("nexthop", log_addr(&nexthop));
}
ibuf_from_buffer(buf, data, alen);
json_do_array("NLRI");
while (alen > 0) {
while (ibuf_size(buf) > 0) {
json_do_object("prefix", 1);
if (addpath) {
if (alen <= sizeof(pathid)) {
json_do_string("error", "bad path-id");
break;
}
memcpy(&pathid, data, sizeof(pathid));
pathid = ntohl(pathid);
data += sizeof(pathid);
alen -= sizeof(pathid);
}
if (addpath)
if (ibuf_get_n32(buf, &pathid) == -1)
goto bad_len;
switch (aid) {
case AID_INET6:
pos = nlri_get_prefix6(data, alen, &prefix,
&prefixlen);
if (nlri_get_prefix6(buf, &prefix,
&prefixlen) == -1)
goto bad_len;
break;
case AID_VPN_IPv4:
pos = nlri_get_vpn4(data, alen, &prefix,
&prefixlen, 1);
break;
if (nlri_get_vpn4(buf, &prefix,
&prefixlen, 1) == -1)
goto bad_len;
break;
case AID_VPN_IPv6:
pos = nlri_get_vpn6(data, alen, &prefix,
&prefixlen, 1);
break;
if (nlri_get_vpn6(buf, &prefix,
&prefixlen, 1) == -1)
goto bad_len;
break;
default:
json_do_printf("error", "unhandled AID: %d",
aid);
return;
}
if (pos == -1) {
json_do_printf("error", "bad %s prefix",
aid2str(aid));
break;
}
json_do_printf("prefix", "%s/%u", log_addr(&prefix),
prefixlen);
if (addpath)
json_do_uint("path_id", pathid);
data += pos;
alen -= pos;
json_do_end();
}
json_do_end();

View File

@ -1,4 +1,4 @@
/* $OpenBSD: output_ometric.c,v 1.12 2023/11/20 14:18:21 claudio Exp $ */
/* $OpenBSD: output_ometric.c,v 1.13 2024/01/23 15:55:20 claudio Exp $ */
/*
* Copyright (c) 2022 Claudio Jeker <claudio@openbsd.org>
@ -41,9 +41,9 @@ struct ometric *peer_info, *peer_state, *peer_state_raw, *peer_last_change,
struct ometric *peer_prefixes_transmit, *peer_prefixes_receive;
struct ometric *peer_message_transmit, *peer_message_receive;
struct ometric *peer_update_transmit, *peer_update_pending,
*peer_update_receive;
*peer_update_receive;
struct ometric *peer_withdraw_transmit, *peer_withdraw_pending,
*peer_withdraw_receive;
*peer_withdraw_receive;
struct ometric *peer_rr_req_transmit, *peer_rr_req_receive;
struct ometric *peer_rr_borr_transmit, *peer_rr_borr_receive;
struct ometric *peer_rr_eorr_transmit, *peer_rr_eorr_receive;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: bgpd.h,v 1.481 2024/01/11 13:08:39 claudio Exp $ */
/* $OpenBSD: bgpd.h,v 1.483 2024/01/23 16:13:35 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -1153,9 +1153,9 @@ extern const struct ext_comm_pairs iana_ext_comms[];
#define FLOWSPEC_TYPE_FLOW 13
#define FLOWSPEC_TYPE_MAX 14
#define FLOWSPEC_TCP_FLAG_STRING "FSRPAUEW"
#define FLOWSPEC_FRAG_STRING4 "DIFL"
#define FLOWSPEC_FRAG_STRING6 " IFL"
#define FLOWSPEC_TCP_FLAG_STRING "FSRPAUEW"
#define FLOWSPEC_FRAG_STRING4 "DIFL"
#define FLOWSPEC_FRAG_STRING6 " IFL"
struct filter_prefix {
struct bgpd_addr addr;
@ -1557,14 +1557,12 @@ int aspath_verify(void *, uint16_t, int, int);
#define AS_ERR_SOFT -4
u_char *aspath_inflate(void *, uint16_t, uint16_t *);
int extract_prefix(const u_char *, int, void *, uint8_t, uint8_t);
int nlri_get_prefix(u_char *, uint16_t, struct bgpd_addr *,
uint8_t *);
int nlri_get_prefix6(u_char *, uint16_t, struct bgpd_addr *,
uint8_t *);
int nlri_get_vpn4(u_char *, uint16_t, struct bgpd_addr *,
uint8_t *, int);
int nlri_get_vpn6(u_char *, uint16_t, struct bgpd_addr *,
uint8_t *, int);
int nlri_get_prefix(struct ibuf *, struct bgpd_addr *, uint8_t *);
int nlri_get_prefix6(struct ibuf *, struct bgpd_addr *, uint8_t *);
int nlri_get_vpn4(struct ibuf *, struct bgpd_addr *, uint8_t *,
int);
int nlri_get_vpn6(struct ibuf *, struct bgpd_addr *, uint8_t *,
int);
int prefix_compare(const struct bgpd_addr *,
const struct bgpd_addr *, int);
void inet4applymask(struct in_addr *, const struct in_addr *, int);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: rde.c,v 1.614 2024/01/15 15:44:50 claudio Exp $ */
/* $OpenBSD: rde.c,v 1.616 2024/01/23 16:13:35 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -49,16 +49,16 @@ void rde_dispatch_imsg_session(struct imsgbuf *);
void rde_dispatch_imsg_parent(struct imsgbuf *);
void rde_dispatch_imsg_rtr(struct imsgbuf *);
void rde_dispatch_imsg_peer(struct rde_peer *, void *);
void rde_update_dispatch(struct rde_peer *, struct imsg *);
void rde_update_dispatch(struct rde_peer *, struct ibuf *);
int rde_update_update(struct rde_peer *, uint32_t,
struct filterstate *, struct bgpd_addr *, uint8_t);
void rde_update_withdraw(struct rde_peer *, uint32_t,
struct bgpd_addr *, uint8_t);
int rde_attr_parse(u_char *, uint16_t, struct rde_peer *,
struct filterstate *, struct mpattr *);
int rde_attr_parse(struct ibuf *, struct rde_peer *,
struct filterstate *, struct ibuf *, struct ibuf *);
int rde_attr_add(struct filterstate *, struct ibuf *);
uint8_t rde_attr_missing(struct rde_aspath *, int, uint16_t);
int rde_get_mp_nexthop(u_char *, uint16_t, uint8_t,
int rde_get_mp_nexthop(struct ibuf *, uint8_t,
struct rde_peer *, struct filterstate *);
void rde_as4byte_fixup(struct rde_peer *, struct rde_aspath *);
uint8_t rde_aspa_validity(struct rde_peer *, struct rde_aspath *,
@ -449,9 +449,10 @@ rde_dispatch_imsg_session(struct imsgbuf *imsgbuf)
switch (imsg_get_type(&imsg)) {
case IMSG_SESSION_STALE:
peer_stale(peer, aid, 0);
break;
case IMSG_SESSION_NOGRACE:
peer_stale(peer, aid,
imsg_get_type(&imsg) == IMSG_SESSION_NOGRACE);
peer_stale(peer, aid, 1);
break;
case IMSG_SESSION_FLUSH:
peer_flush(peer, aid, peer->staletime[aid]);
@ -1301,6 +1302,7 @@ rde_dispatch_imsg_peer(struct rde_peer *peer, void *bula)
{
struct route_refresh rr;
struct imsg imsg;
struct ibuf ibuf;
if (!peer_imsg_pop(peer, &imsg))
return;
@ -1309,7 +1311,10 @@ rde_dispatch_imsg_peer(struct rde_peer *peer, void *bula)
case IMSG_UPDATE:
if (peer->state != PEER_UP)
break;
rde_update_dispatch(peer, &imsg);
if (imsg_get_ibuf(&imsg, &ibuf) == -1)
log_warn("update: bad imsg");
else
rde_update_dispatch(peer, &ibuf);
break;
case IMSG_REFRESH:
if (imsg_get_data(&imsg, &rr, sizeof(rr)) == -1) {
@ -1368,80 +1373,57 @@ rde_dispatch_imsg_peer(struct rde_peer *peer, void *bula)
/* handle routing updates from the session engine. */
void
rde_update_dispatch(struct rde_peer *peer, struct imsg *imsg)
rde_update_dispatch(struct rde_peer *peer, struct ibuf *buf)
{
struct filterstate state;
struct bgpd_addr prefix;
struct mpattr mpa;
u_char *p, *mpp = NULL;
int pos = 0;
uint16_t afi, len, mplen;
uint16_t withdrawn_len;
uint16_t attrpath_len;
uint16_t nlri_len;
struct ibuf wdbuf, attrbuf, nlribuf, reachbuf, unreachbuf;
uint16_t afi, len;
uint8_t aid, prefixlen, safi, subtype;
uint32_t fas, pathid;
p = imsg->data;
if (imsg->hdr.len < IMSG_HEADER_SIZE + 2) {
rde_update_err(peer, ERR_UPDATE, ERR_UPD_ATTRLIST, NULL, 0);
if (ibuf_get_n16(buf, &len) == -1 ||
ibuf_get_ibuf(buf, len, &wdbuf) == -1 ||
ibuf_get_n16(buf, &len) == -1 ||
ibuf_get_ibuf(buf, len, &attrbuf) == -1 ||
ibuf_get_ibuf(buf, ibuf_size(buf), &nlribuf) == -1) {
rde_update_err(peer, ERR_UPDATE, ERR_UPD_ATTRLIST, NULL);
return;
}
memcpy(&len, p, 2);
withdrawn_len = ntohs(len);
p += 2;
if (imsg->hdr.len < IMSG_HEADER_SIZE + 2 + withdrawn_len + 2) {
rde_update_err(peer, ERR_UPDATE, ERR_UPD_ATTRLIST, NULL, 0);
return;
}
p += withdrawn_len;
memcpy(&len, p, 2);
attrpath_len = len = ntohs(len);
p += 2;
if (imsg->hdr.len <
IMSG_HEADER_SIZE + 2 + withdrawn_len + 2 + attrpath_len) {
rde_update_err(peer, ERR_UPDATE, ERR_UPD_ATTRLIST, NULL, 0);
return;
}
nlri_len =
imsg->hdr.len - IMSG_HEADER_SIZE - 4 - withdrawn_len - attrpath_len;
if (attrpath_len == 0) {
if (ibuf_size(&attrbuf) == 0) {
/* 0 = no NLRI information in this message */
if (nlri_len != 0) {
if (ibuf_size(&nlribuf) != 0) {
/* crap at end of update which should not be there */
rde_update_err(peer, ERR_UPDATE,
ERR_UPD_ATTRLIST, NULL, 0);
rde_update_err(peer, ERR_UPDATE, ERR_UPD_ATTRLIST,
NULL);
return;
}
if (withdrawn_len == 0) {
if (ibuf_size(&wdbuf) == 0) {
/* EoR marker */
rde_peer_recv_eor(peer, AID_INET);
return;
}
}
memset(&mpa, 0, sizeof(mpa));
ibuf_from_buffer(&reachbuf, NULL, 0);
ibuf_from_buffer(&unreachbuf, NULL, 0);
rde_filterstate_init(&state);
if (attrpath_len != 0) { /* 0 = no NLRI information in this message */
if (ibuf_size(&attrbuf) != 0) {
/* parse path attributes */
while (len > 0) {
if ((pos = rde_attr_parse(p, len, peer, &state,
&mpa)) < 0)
while (ibuf_size(&attrbuf) > 0) {
if (rde_attr_parse(&attrbuf, peer, &state, &reachbuf,
&unreachbuf) == -1)
goto done;
p += pos;
len -= pos;
}
/* check for missing but necessary attributes */
if ((subtype = rde_attr_missing(&state.aspath, peer->conf.ebgp,
nlri_len))) {
ibuf_size(&nlribuf)))) {
struct ibuf sbuf;
ibuf_from_buffer(&sbuf, &subtype, sizeof(subtype));
rde_update_err(peer, ERR_UPDATE, ERR_UPD_MISSNG_WK_ATTR,
&subtype, sizeof(uint8_t));
&sbuf);
goto done;
}
@ -1452,12 +1434,13 @@ rde_update_dispatch(struct rde_peer *peer, struct imsg *imsg)
peer->conf.enforce_as == ENFORCE_AS_ON) {
fas = aspath_neighbor(state.aspath.aspath);
if (peer->conf.remote_as != fas) {
log_peer_warnx(&peer->conf, "bad path, "
"starting with %s, "
"enforce neighbor-as enabled", log_as(fas));
rde_update_err(peer, ERR_UPDATE, ERR_UPD_ASPATH,
NULL, 0);
goto done;
log_peer_warnx(&peer->conf, "bad path, "
"starting with %s expected %u, "
"enforce neighbor-as enabled",
log_as(fas), peer->conf.remote_as);
rde_update_err(peer, ERR_UPDATE, ERR_UPD_ASPATH,
NULL);
goto done;
}
}
@ -1478,69 +1461,51 @@ rde_update_dispatch(struct rde_peer *peer, struct imsg *imsg)
}
}
p = imsg->data;
len = withdrawn_len;
p += 2;
/* withdraw prefix */
if (len > 0) {
if (ibuf_size(&wdbuf) > 0) {
if (peer->capa.mp[AID_INET] == 0) {
log_peer_warnx(&peer->conf,
"bad withdraw, %s disabled", aid2str(AID_INET));
rde_update_err(peer, ERR_UPDATE, ERR_UPD_OPTATTR,
NULL, 0);
rde_update_err(peer, ERR_UPDATE, ERR_UPD_NETWORK,
NULL);
goto done;
}
}
while (len > 0) {
while (ibuf_size(&wdbuf) > 0) {
if (peer_has_add_path(peer, AID_INET, CAPA_AP_RECV)) {
if (len <= sizeof(pathid)) {
if (ibuf_get_n32(&wdbuf, &pathid) == -1) {
log_peer_warnx(&peer->conf,
"bad withdraw prefix");
rde_update_err(peer, ERR_UPDATE,
ERR_UPD_NETWORK, NULL, 0);
ERR_UPD_NETWORK, NULL);
goto done;
}
memcpy(&pathid, p, sizeof(pathid));
pathid = ntohl(pathid);
p += sizeof(pathid);
len -= sizeof(pathid);
} else
pathid = 0;
if ((pos = nlri_get_prefix(p, len, &prefix,
&prefixlen)) == -1) {
if (nlri_get_prefix(&wdbuf, &prefix, &prefixlen) == -1) {
/*
* the RFC does not mention what we should do in
* this case. Let's do the same as in the NLRI case.
*/
log_peer_warnx(&peer->conf, "bad withdraw prefix");
rde_update_err(peer, ERR_UPDATE, ERR_UPD_NETWORK,
NULL, 0);
NULL);
goto done;
}
p += pos;
len -= pos;
rde_update_withdraw(peer, pathid, &prefix, prefixlen);
}
/* withdraw MP_UNREACH_NLRI if available */
if (mpa.unreach_len != 0) {
mpp = mpa.unreach;
mplen = mpa.unreach_len;
memcpy(&afi, mpp, 2);
mpp += 2;
mplen -= 2;
afi = ntohs(afi);
safi = *mpp++;
mplen--;
if (afi2aid(afi, safi, &aid) == -1) {
if (ibuf_size(&unreachbuf) != 0) {
if (ibuf_get_n16(&unreachbuf, &afi) == -1 ||
ibuf_get_n8(&unreachbuf, &safi) == -1 ||
afi2aid(afi, safi, &aid) == -1) {
log_peer_warnx(&peer->conf,
"bad AFI/SAFI pair in withdraw");
rde_update_err(peer, ERR_UPDATE, ERR_UPD_OPTATTR,
NULL, 0);
&unreachbuf);
goto done;
}
@ -1548,65 +1513,58 @@ rde_update_dispatch(struct rde_peer *peer, struct imsg *imsg)
log_peer_warnx(&peer->conf,
"bad withdraw, %s disabled", aid2str(aid));
rde_update_err(peer, ERR_UPDATE, ERR_UPD_OPTATTR,
NULL, 0);
&unreachbuf);
goto done;
}
if ((state.aspath.flags & ~F_ATTR_MP_UNREACH) == 0 &&
mplen == 0) {
ibuf_size(&unreachbuf) == 0) {
/* EoR marker */
rde_peer_recv_eor(peer, aid);
}
while (mplen > 0) {
while (ibuf_size(&unreachbuf) > 0) {
if (peer_has_add_path(peer, aid, CAPA_AP_RECV)) {
if (mplen <= sizeof(pathid)) {
if (ibuf_get_n32(&unreachbuf,
&pathid) == -1) {
log_peer_warnx(&peer->conf,
"bad %s withdraw prefix",
aid2str(aid));
rde_update_err(peer, ERR_UPDATE,
ERR_UPD_OPTATTR,
mpa.unreach, mpa.unreach_len);
ERR_UPD_OPTATTR, &unreachbuf);
goto done;
}
memcpy(&pathid, mpp, sizeof(pathid));
pathid = ntohl(pathid);
mpp += sizeof(pathid);
mplen -= sizeof(pathid);
} else
pathid = 0;
switch (aid) {
case AID_INET6:
if ((pos = nlri_get_prefix6(mpp, mplen,
&prefix, &prefixlen)) == -1) {
if (nlri_get_prefix6(&unreachbuf,
&prefix, &prefixlen) == -1) {
log_peer_warnx(&peer->conf,
"bad IPv6 withdraw prefix");
rde_update_err(peer, ERR_UPDATE,
ERR_UPD_OPTATTR,
mpa.unreach, mpa.unreach_len);
ERR_UPD_OPTATTR, &unreachbuf);
goto done;
}
break;
case AID_VPN_IPv4:
if ((pos = nlri_get_vpn4(mpp, mplen,
&prefix, &prefixlen, 1)) == -1) {
if (nlri_get_vpn4(&unreachbuf,
&prefix, &prefixlen, 1) == -1) {
log_peer_warnx(&peer->conf,
"bad VPNv4 withdraw prefix");
rde_update_err(peer, ERR_UPDATE,
ERR_UPD_OPTATTR,
mpa.unreach, mpa.unreach_len);
ERR_UPD_OPTATTR, &unreachbuf);
goto done;
}
break;
case AID_VPN_IPv6:
if ((pos = nlri_get_vpn6(mpp, mplen,
&prefix, &prefixlen, 1)) == -1) {
if (nlri_get_vpn6(&unreachbuf,
&prefix, &prefixlen, 1) == -1) {
log_peer_warnx(&peer->conf,
"bad VPNv6 withdraw prefix");
rde_update_err(peer, ERR_UPDATE,
ERR_UPD_OPTATTR, mpa.unreach,
mpa.unreach_len);
ERR_UPD_OPTATTR, &unreachbuf);
goto done;
}
break;
@ -1615,14 +1573,17 @@ rde_update_dispatch(struct rde_peer *peer, struct imsg *imsg)
/* ignore flowspec for now */
default:
/* ignore unsupported multiprotocol AF */
mpp += mplen;
mplen = 0;
if (ibuf_skip(&unreachbuf,
ibuf_size(&unreachbuf)) == -1) {
log_peer_warnx(&peer->conf,
"bad VPNv6 withdraw prefix");
rde_update_err(peer, ERR_UPDATE,
ERR_UPD_OPTATTR, &unreachbuf);
goto done;
}
continue;
}
mpp += pos;
mplen -= pos;
rde_update_withdraw(peer, pathid, &prefix, prefixlen);
}
@ -1630,16 +1591,13 @@ rde_update_dispatch(struct rde_peer *peer, struct imsg *imsg)
goto done;
}
/* shift to NLRI information */
p += 2 + attrpath_len;
/* parse nlri prefix */
if (nlri_len > 0) {
if (ibuf_size(&nlribuf) > 0) {
if (peer->capa.mp[AID_INET] == 0) {
log_peer_warnx(&peer->conf,
"bad update, %s disabled", aid2str(AID_INET));
rde_update_err(peer, ERR_UPDATE, ERR_UPD_OPTATTR,
NULL, 0);
rde_update_err(peer, ERR_UPDATE, ERR_UPD_NETWORK,
NULL);
goto done;
}
@ -1655,7 +1613,7 @@ rde_update_dispatch(struct rde_peer *peer, struct imsg *imsg)
ATTR_OPTIONAL|ATTR_TRANSITIVE, ATTR_OTC,
&tmp, sizeof(tmp)) == -1) {
rde_update_err(peer, ERR_UPDATE,
ERR_UPD_ATTRLIST, NULL, 0);
ERR_UPD_ATTRLIST, NULL);
goto done;
}
state.aspath.flags |= F_ATTR_OTC;
@ -1665,54 +1623,39 @@ rde_update_dispatch(struct rde_peer *peer, struct imsg *imsg)
}
}
}
while (nlri_len > 0) {
while (ibuf_size(&nlribuf) > 0) {
if (peer_has_add_path(peer, AID_INET, CAPA_AP_RECV)) {
if (nlri_len <= sizeof(pathid)) {
if (ibuf_get_n32(&nlribuf, &pathid) == -1) {
log_peer_warnx(&peer->conf,
"bad nlri prefix");
rde_update_err(peer, ERR_UPDATE,
ERR_UPD_NETWORK, NULL, 0);
ERR_UPD_NETWORK, NULL);
goto done;
}
memcpy(&pathid, p, sizeof(pathid));
pathid = ntohl(pathid);
p += sizeof(pathid);
nlri_len -= sizeof(pathid);
} else
pathid = 0;
if ((pos = nlri_get_prefix(p, nlri_len, &prefix,
&prefixlen)) == -1) {
if (nlri_get_prefix(&nlribuf, &prefix, &prefixlen) == -1) {
log_peer_warnx(&peer->conf, "bad nlri prefix");
rde_update_err(peer, ERR_UPDATE, ERR_UPD_NETWORK,
NULL, 0);
NULL);
goto done;
}
p += pos;
nlri_len -= pos;
if (rde_update_update(peer, pathid, &state,
&prefix, prefixlen) == -1)
goto done;
}
/* add MP_REACH_NLRI if available */
if (mpa.reach_len != 0) {
mpp = mpa.reach;
mplen = mpa.reach_len;
memcpy(&afi, mpp, 2);
mpp += 2;
mplen -= 2;
afi = ntohs(afi);
safi = *mpp++;
mplen--;
if (afi2aid(afi, safi, &aid) == -1) {
if (ibuf_size(&reachbuf) != 0) {
if (ibuf_get_n16(&reachbuf, &afi) == -1 ||
ibuf_get_n8(&reachbuf, &safi) == -1 ||
afi2aid(afi, safi, &aid) == -1) {
log_peer_warnx(&peer->conf,
"bad AFI/SAFI pair in update");
rde_update_err(peer, ERR_UPDATE, ERR_UPD_OPTATTR,
NULL, 0);
&reachbuf);
goto done;
}
@ -1720,7 +1663,7 @@ rde_update_dispatch(struct rde_peer *peer, struct imsg *imsg)
log_peer_warnx(&peer->conf,
"bad update, %s disabled", aid2str(aid));
rde_update_err(peer, ERR_UPDATE, ERR_UPD_OPTATTR,
NULL, 0);
&reachbuf);
goto done;
}
@ -1738,7 +1681,7 @@ rde_update_dispatch(struct rde_peer *peer, struct imsg *imsg)
ATTR_OTC, &tmp,
sizeof(tmp)) == -1) {
rde_update_err(peer, ERR_UPDATE,
ERR_UPD_ATTRLIST, NULL, 0);
ERR_UPD_ATTRLIST, NULL);
goto done;
}
state.aspath.flags |= F_ATTR_OTC;
@ -1755,64 +1698,53 @@ rde_update_dispatch(struct rde_peer *peer, struct imsg *imsg)
/* unlock the previously locked nexthop, it is no longer used */
nexthop_unref(state.nexthop);
state.nexthop = NULL;
if ((pos = rde_get_mp_nexthop(mpp, mplen, aid, peer,
&state)) == -1) {
if (rde_get_mp_nexthop(&reachbuf, aid, peer, &state) == -1) {
log_peer_warnx(&peer->conf, "bad nlri nexthop");
rde_update_err(peer, ERR_UPDATE, ERR_UPD_OPTATTR,
mpa.reach, mpa.reach_len);
&reachbuf);
goto done;
}
mpp += pos;
mplen -= pos;
while (mplen > 0) {
while (ibuf_size(&reachbuf) > 0) {
if (peer_has_add_path(peer, aid, CAPA_AP_RECV)) {
if (mplen <= sizeof(pathid)) {
if (ibuf_get_n32(&reachbuf, &pathid) == -1) {
log_peer_warnx(&peer->conf,
"bad %s nlri prefix", aid2str(aid));
rde_update_err(peer, ERR_UPDATE,
ERR_UPD_OPTATTR,
mpa.reach, mpa.reach_len);
ERR_UPD_OPTATTR, &reachbuf);
goto done;
}
memcpy(&pathid, mpp, sizeof(pathid));
pathid = ntohl(pathid);
mpp += sizeof(pathid);
mplen -= sizeof(pathid);
} else
pathid = 0;
switch (aid) {
case AID_INET6:
if ((pos = nlri_get_prefix6(mpp, mplen,
&prefix, &prefixlen)) == -1) {
if (nlri_get_prefix6(&reachbuf,
&prefix, &prefixlen) == -1) {
log_peer_warnx(&peer->conf,
"bad IPv6 nlri prefix");
rde_update_err(peer, ERR_UPDATE,
ERR_UPD_OPTATTR,
mpa.reach, mpa.reach_len);
ERR_UPD_OPTATTR, &reachbuf);
goto done;
}
break;
case AID_VPN_IPv4:
if ((pos = nlri_get_vpn4(mpp, mplen,
&prefix, &prefixlen, 0)) == -1) {
if (nlri_get_vpn4(&reachbuf,
&prefix, &prefixlen, 0) == -1) {
log_peer_warnx(&peer->conf,
"bad VPNv4 nlri prefix");
rde_update_err(peer, ERR_UPDATE,
ERR_UPD_OPTATTR,
mpa.reach, mpa.reach_len);
ERR_UPD_OPTATTR, &reachbuf);
goto done;
}
break;
case AID_VPN_IPv6:
if ((pos = nlri_get_vpn6(mpp, mplen,
&prefix, &prefixlen, 0)) == -1) {
if (nlri_get_vpn6(&reachbuf,
&prefix, &prefixlen, 0) == -1) {
log_peer_warnx(&peer->conf,
"bad VPNv6 nlri prefix");
rde_update_err(peer, ERR_UPDATE,
ERR_UPD_OPTATTR,
mpa.reach, mpa.reach_len);
ERR_UPD_OPTATTR, &reachbuf);
goto done;
}
break;
@ -1821,14 +1753,17 @@ rde_update_dispatch(struct rde_peer *peer, struct imsg *imsg)
/* ignore flowspec for now */
default:
/* ignore unsupported multiprotocol AF */
mpp += mplen;
mplen = 0;
if (ibuf_skip(&reachbuf,
ibuf_size(&reachbuf)) == -1) {
log_peer_warnx(&peer->conf,
"bad VPNv6 withdraw prefix");
rde_update_err(peer, ERR_UPDATE,
ERR_UPD_OPTATTR, &reachbuf);
goto done;
}
continue;
}
mpp += pos;
mplen -= pos;
if (rde_update_update(peer, pathid, &state,
&prefix, prefixlen) == -1)
goto done;
@ -1920,7 +1855,7 @@ rde_update_update(struct rde_peer *peer, uint32_t path_id,
peer->stats.prefix_cnt > peer->conf.max_prefix) {
log_peer_warnx(&peer->conf, "prefix limit reached (>%u/%u)",
peer->stats.prefix_cnt, peer->conf.max_prefix);
rde_update_err(peer, ERR_CEASE, ERR_CEASE_MAX_PREFIX, NULL, 0);
rde_update_err(peer, ERR_CEASE, ERR_CEASE_MAX_PREFIX, NULL);
return (-1);
}
@ -1992,63 +1927,63 @@ rde_update_withdraw(struct rde_peer *peer, uint32_t path_id,
(((s) & ~(ATTR_DEFMASK | (m))) == (t))
int
rde_attr_parse(u_char *p, uint16_t len, struct rde_peer *peer,
struct filterstate *state, struct mpattr *mpa)
rde_attr_parse(struct ibuf *buf, struct rde_peer *peer,
struct filterstate *state, struct ibuf *reach, struct ibuf *unreach)
{
struct bgpd_addr nexthop;
struct rde_aspath *a = &state->aspath;
u_char *op = p, *npath;
struct ibuf attrbuf;
u_char *p, *npath;
uint32_t tmp32, zero = 0;
int error;
uint16_t attr_len, nlen;
uint16_t plen = 0;
uint8_t flags, type, tmp8;
uint16_t nlen;
size_t attr_len, hlen, plen;
uint8_t flags, type;
if (len < 3) {
bad_len:
rde_update_err(peer, ERR_UPDATE, ERR_UPD_ATTRLEN, op, len);
return (-1);
}
ibuf_from_ibuf(&attrbuf, buf);
if (ibuf_get_n8(&attrbuf, &flags) == -1 ||
ibuf_get_n8(&attrbuf, &type) == -1)
goto bad_list;
UPD_READ(&flags, p, plen, 1);
UPD_READ(&type, p, plen, 1);
if (flags & ATTR_EXTLEN) {
if (len - plen < 2)
goto bad_len;
UPD_READ(&attr_len, p, plen, 2);
attr_len = ntohs(attr_len);
uint16_t alen;
if (ibuf_get_n16(&attrbuf, &alen) == -1)
goto bad_list;
attr_len = alen;
hlen = 4;
} else {
UPD_READ(&tmp8, p, plen, 1);
attr_len = tmp8;
uint8_t alen;
if (ibuf_get_n8(&attrbuf, &alen) == -1)
goto bad_list;
attr_len = alen;
hlen = 3;
}
if (len - plen < attr_len)
goto bad_len;
if (ibuf_truncate(&attrbuf, attr_len) == -1)
goto bad_list;
/* consume the attribute in buf before moving forward */
if (ibuf_skip(buf, hlen + attr_len) == -1)
goto bad_list;
/* adjust len to the actual attribute size including header */
len = plen + attr_len;
p = ibuf_data(&attrbuf);
plen = ibuf_size(&attrbuf);
switch (type) {
case ATTR_UNDEF:
/* ignore and drop path attributes with a type code of 0 */
plen += attr_len;
break;
case ATTR_ORIGIN:
if (attr_len != 1)
goto bad_len;
if (!CHECK_FLAGS(flags, ATTR_WELL_KNOWN, 0)) {
bad_flags:
rde_update_err(peer, ERR_UPDATE, ERR_UPD_ATTRFLAGS,
op, len);
return (-1);
}
if (!CHECK_FLAGS(flags, ATTR_WELL_KNOWN, 0))
goto bad_flags;
UPD_READ(&a->origin, p, plen, 1);
if (a->origin > ORIGIN_INCOMPLETE) {
rde_update_err(peer, ERR_UPDATE, ERR_UPD_ORIGIN,
op, len);
&attrbuf);
return (-1);
}
if (a->flags & F_ATTR_ORIGIN)
@ -2069,7 +2004,7 @@ bad_flags:
a->flags |= F_ATTR_PARSE_ERR;
} else if (error != 0) {
rde_update_err(peer, ERR_UPDATE, ERR_UPD_ASPATH,
NULL, 0);
NULL);
return (-1);
}
if (a->flags & F_ATTR_ASPATH)
@ -2116,7 +2051,7 @@ bad_flags:
tmp32 = ntohl(nexthop.v4.s_addr);
if (IN_MULTICAST(tmp32)) {
rde_update_err(peer, ERR_UPDATE, ERR_UPD_NEXTHOP,
op, len);
&attrbuf);
return (-1);
}
nexthop_unref(state->nexthop); /* just to be sure */
@ -2270,9 +2205,7 @@ bad_flags:
goto bad_list;
a->flags |= F_ATTR_MP_REACH;
mpa->reach = p;
mpa->reach_len = attr_len;
plen += attr_len;
*reach = attrbuf;
break;
case ATTR_MP_UNREACH_NLRI:
if (attr_len < 3)
@ -2284,9 +2217,7 @@ bad_flags:
goto bad_list;
a->flags |= F_ATTR_MP_UNREACH;
mpa->unreach = p;
mpa->unreach_len = attr_len;
plen += attr_len;
*unreach = attrbuf;
break;
case ATTR_AS4_AGGREGATOR:
if (attr_len != 8) {
@ -2353,22 +2284,29 @@ bad_flags:
default:
if ((flags & ATTR_OPTIONAL) == 0) {
rde_update_err(peer, ERR_UPDATE, ERR_UPD_UNKNWN_WK_ATTR,
op, len);
return (-1);
}
optattr:
if (attr_optadd(a, flags, type, p, attr_len) == -1) {
bad_list:
rde_update_err(peer, ERR_UPDATE, ERR_UPD_ATTRLIST,
NULL, 0);
&attrbuf);
return (-1);
}
optattr:
if (attr_optadd(a, flags, type, p, attr_len) == -1)
goto bad_list;
plen += attr_len;
break;
}
return (plen);
(void)plen; /* XXX make compiler happy for now */
return (0);
bad_len:
rde_update_err(peer, ERR_UPDATE, ERR_UPD_ATTRLEN, &attrbuf);
return (-1);
bad_flags:
rde_update_err(peer, ERR_UPDATE, ERR_UPD_ATTRFLAGS, &attrbuf);
return (-1);
bad_list:
rde_update_err(peer, ERR_UPDATE, ERR_UPD_ATTRLIST, NULL);
return (-1);
}
#undef UPD_READ
@ -2438,20 +2376,19 @@ rde_attr_missing(struct rde_aspath *a, int ebgp, uint16_t nlrilen)
}
int
rde_get_mp_nexthop(u_char *data, uint16_t len, uint8_t aid,
rde_get_mp_nexthop(struct ibuf *buf, uint8_t aid,
struct rde_peer *peer, struct filterstate *state)
{
struct bgpd_addr nexthop;
uint8_t totlen, nhlen;
struct ibuf nhbuf;
uint8_t nhlen;
if (len == 0)
if (ibuf_get_n8(buf, &nhlen) == -1)
return (-1);
nhlen = *data++;
totlen = 1;
len--;
if (nhlen + 1 > len)
if (ibuf_get_ibuf(buf, nhlen, &nhbuf) == -1)
return (-1);
/* ignore reserved (old SNPA) field as per RFC4760 */
if (ibuf_skip(buf, 1) == -1)
return (-1);
memset(&nexthop, 0, sizeof(nexthop));
@ -2470,7 +2407,8 @@ rde_get_mp_nexthop(u_char *data, uint16_t len, uint8_t aid,
"bad size %d", aid2str(aid), nhlen);
return (-1);
}
memcpy(&nexthop.v6.s6_addr, data, 16);
if (ibuf_get(&nhbuf, &nexthop.v6, sizeof(nexthop.v6)) == -1)
return (-1);
nexthop.aid = AID_INET6;
if (IN6_IS_ADDR_LINKLOCAL(&nexthop.v6)) {
if (peer->local_if_scope != 0) {
@ -2502,9 +2440,10 @@ rde_get_mp_nexthop(u_char *data, uint16_t len, uint8_t aid,
"bad size %d", aid2str(aid), nhlen);
return (-1);
}
if (ibuf_skip(&nhbuf, sizeof(uint64_t)) == -1 ||
ibuf_get(&nhbuf, &nexthop.v4, sizeof(nexthop.v4)) == -1)
return (-1);
nexthop.aid = AID_INET;
memcpy(&nexthop.v4, data + sizeof(uint64_t),
sizeof(nexthop.v4));
break;
case AID_VPN_IPv6:
if (nhlen != 24) {
@ -2512,8 +2451,9 @@ rde_get_mp_nexthop(u_char *data, uint16_t len, uint8_t aid,
"bad size %d", aid2str(aid), nhlen);
return (-1);
}
memcpy(&nexthop.v6, data + sizeof(uint64_t),
sizeof(nexthop.v6));
if (ibuf_skip(&nhbuf, sizeof(uint64_t)) == -1 ||
ibuf_get(&nhbuf, &nexthop.v6, sizeof(nexthop.v6)) == -1)
return (-1);
nexthop.aid = AID_INET6;
if (IN6_IS_ADDR_LINKLOCAL(&nexthop.v6)) {
if (peer->local_if_scope != 0) {
@ -2534,8 +2474,7 @@ rde_get_mp_nexthop(u_char *data, uint16_t len, uint8_t aid,
"bad size %d", aid2str(aid), nhlen);
return (-1);
}
/* also ignore reserved (old SNPA) field as per RFC4760 */
return (totlen + 1);
return (0);
default:
log_peer_warnx(&peer->conf, "bad multiprotocol nexthop, "
"bad AID");
@ -2544,25 +2483,29 @@ rde_get_mp_nexthop(u_char *data, uint16_t len, uint8_t aid,
state->nexthop = nexthop_get(&nexthop);
/* ignore reserved (old SNPA) field as per RFC4760 */
totlen += nhlen + 1;
return (totlen);
return (0);
}
void
rde_update_err(struct rde_peer *peer, uint8_t error, uint8_t suberr,
void *data, uint16_t size)
struct ibuf *opt)
{
struct ibuf *wbuf;
struct ibuf *wbuf;
size_t size = 0;
if (opt != NULL) {
ibuf_rewind(opt);
size = ibuf_size(opt);
}
if ((wbuf = imsg_create(ibuf_se, IMSG_UPDATE_ERR, peer->conf.id, 0,
size + sizeof(error) + sizeof(suberr))) == NULL)
fatal("%s %d imsg_create error", __func__, __LINE__);
if (imsg_add(wbuf, &error, sizeof(error)) == -1 ||
imsg_add(wbuf, &suberr, sizeof(suberr)) == -1 ||
imsg_add(wbuf, data, size) == -1)
imsg_add(wbuf, &suberr, sizeof(suberr)) == -1)
fatal("%s %d imsg_add error", __func__, __LINE__);
if (opt != NULL)
if (ibuf_add_ibuf(wbuf, opt) == -1)
fatal("%s %d imsg_add error", __func__, __LINE__);
imsg_close(ibuf_se, wbuf);
peer->state = PEER_ERR;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: rde.h,v 1.297 2023/10/16 10:25:46 claudio Exp $ */
/* $OpenBSD: rde.h,v 1.298 2024/01/23 16:13:35 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and
@ -169,13 +169,6 @@ struct attr {
uint8_t type;
};
struct mpattr {
void *reach;
void *unreach;
uint16_t reach_len;
uint16_t unreach_len;
};
struct rde_community {
RB_ENTRY(rde_community) entry;
int size;
@ -341,7 +334,7 @@ void mrt_dump_upcall(struct rib_entry *, void *);
/* rde.c */
void rde_update_err(struct rde_peer *, uint8_t , uint8_t,
void *, uint16_t);
struct ibuf *);
void rde_update_log(const char *, uint16_t,
const struct rde_peer *, const struct bgpd_addr *,
const struct bgpd_addr *, uint8_t);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: rde_update.c,v 1.164 2023/10/12 14:16:28 claudio Exp $ */
/* $OpenBSD: rde_update.c,v 1.166 2024/01/23 16:13:35 claudio Exp $ */
/*
* Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
@ -199,7 +199,7 @@ up_process_prefix(struct rde_peer *peer, struct prefix *new, struct prefix *p)
"outbound prefix limit reached (>%u/%u)",
peer->stats.prefix_out_cnt, peer->conf.max_out_prefix);
rde_update_err(peer, ERR_CEASE,
ERR_CEASE_MAX_SENT_PREFIX, NULL, 0);
ERR_CEASE_MAX_SENT_PREFIX, NULL);
return UP_ERR_LIMIT;
}
@ -447,7 +447,7 @@ up_generate_default(struct rde_peer *peer, uint8_t aid)
"outbound prefix limit reached (>%u/%u)",
peer->stats.prefix_out_cnt, peer->conf.max_out_prefix);
rde_update_err(peer, ERR_CEASE,
ERR_CEASE_MAX_SENT_PREFIX, NULL, 0);
ERR_CEASE_MAX_SENT_PREFIX, NULL);
}
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: rtr_proto.c,v 1.32 2024/01/15 11:55:26 claudio Exp $ */
/* $OpenBSD: rtr_proto.c,v 1.33 2024/01/23 15:59:56 claudio Exp $ */
/*
* Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
@ -323,7 +323,7 @@ rtr_send_error(struct rtr_session *rs, struct ibuf *pdu, enum rtr_error err,
}
log_warnx("rtr %s: sending error: %s%s%s", log_rtr(rs),
log_rtr_error(err), mlen > 0 ? ": " : "", rs->last_sent_msg);
log_rtr_error(err), mlen > 0 ? ": " : "", rs->last_sent_msg);
if (pdu != NULL) {
ibuf_rewind(pdu);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: util.c,v 1.78 2024/01/10 13:31:09 claudio Exp $ */
/* $OpenBSD: util.c,v 1.79 2024/01/23 16:13:35 claudio Exp $ */
/*
* Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org>
@ -563,12 +563,13 @@ aspath_inflate(void *data, uint16_t len, uint16_t *newlen)
return (ndata);
}
static const u_char addrmask[] = { 0x00, 0x80, 0xc0, 0xe0, 0xf0,
0xf8, 0xfc, 0xfe, 0xff };
/* NLRI functions to extract prefixes from the NLRI blobs */
int
extract_prefix(const u_char *p, int len, void *va, uint8_t pfxlen, uint8_t max)
{
static u_char addrmask[] = {
0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff };
u_char *a = va;
int plen;
@ -588,187 +589,177 @@ extract_prefix(const u_char *p, int len, void *va, uint8_t pfxlen, uint8_t max)
return (plen);
}
int
nlri_get_prefix(u_char *p, uint16_t len, struct bgpd_addr *prefix,
uint8_t *prefixlen)
static int
extract_prefix_buf(struct ibuf *buf, void *va, uint8_t pfxlen, uint8_t max)
{
u_char *a = va;
unsigned int plen;
uint8_t tmp;
plen = PREFIX_SIZE(pfxlen) - 1;
if (ibuf_size(buf) < plen || max < plen)
return -1;
while (pfxlen > 0) {
if (ibuf_get_n8(buf, &tmp) == -1)
return -1;
if (pfxlen < 8) {
*a++ = tmp & addrmask[pfxlen];
break;
} else {
*a++ = tmp;
pfxlen -= 8;
}
}
return (0);
}
int
nlri_get_prefix(struct ibuf *buf, struct bgpd_addr *prefix, uint8_t *prefixlen)
{
int plen;
uint8_t pfxlen;
if (len < 1)
if (ibuf_get_n8(buf, &pfxlen) == -1)
return (-1);
if (pfxlen > 32)
return (-1);
pfxlen = *p++;
len--;
memset(prefix, 0, sizeof(struct bgpd_addr));
prefix->aid = AID_INET;
if (extract_prefix_buf(buf, &prefix->v4, pfxlen,
sizeof(prefix->v4)) == -1)
return (-1);
*prefixlen = pfxlen;
if (pfxlen > 32)
return (-1);
if ((plen = extract_prefix(p, len, &prefix->v4, pfxlen,
sizeof(prefix->v4))) == -1)
return (-1);
return (plen + 1); /* pfxlen needs to be added */
return (0);
}
int
nlri_get_prefix6(u_char *p, uint16_t len, struct bgpd_addr *prefix,
uint8_t *prefixlen)
nlri_get_prefix6(struct ibuf *buf, struct bgpd_addr *prefix, uint8_t *prefixlen)
{
int plen;
uint8_t pfxlen;
if (len < 1)
if (ibuf_get_n8(buf, &pfxlen) == -1)
return (-1);
if (pfxlen > 128)
return (-1);
pfxlen = *p++;
len--;
memset(prefix, 0, sizeof(struct bgpd_addr));
prefix->aid = AID_INET6;
if (extract_prefix_buf(buf, &prefix->v6, pfxlen,
sizeof(prefix->v6)) == -1)
return (-1);
*prefixlen = pfxlen;
if (pfxlen > 128)
return (-1);
if ((plen = extract_prefix(p, len, &prefix->v6, pfxlen,
sizeof(prefix->v6))) == -1)
return (-1);
return (plen + 1); /* pfxlen needs to be added */
return (0);
}
int
nlri_get_vpn4(u_char *p, uint16_t len, struct bgpd_addr *prefix,
nlri_get_vpn4(struct ibuf *buf, struct bgpd_addr *prefix,
uint8_t *prefixlen, int withdraw)
{
int rv, done = 0;
uint16_t plen;
int done = 0;
uint8_t pfxlen;
if (len < 1)
if (ibuf_get_n8(buf, &pfxlen) == -1)
return (-1);
memcpy(&pfxlen, p, 1);
p += 1;
plen = 1;
memset(prefix, 0, sizeof(struct bgpd_addr));
prefix->aid = AID_VPN_IPv4;
/* label stack */
do {
if (len - plen < 3 || pfxlen < 3 * 8)
return (-1);
if (prefix->labellen + 3U >
sizeof(prefix->labelstack))
if (prefix->labellen + 3U > sizeof(prefix->labelstack) ||
pfxlen < 3 * 8)
return (-1);
if (withdraw) {
/* on withdraw ignore the labelstack all together */
p += 3;
plen += 3;
if (ibuf_skip(buf, 3) == -1)
return (-1);
pfxlen -= 3 * 8;
break;
}
prefix->labelstack[prefix->labellen++] = *p++;
prefix->labelstack[prefix->labellen++] = *p++;
prefix->labelstack[prefix->labellen] = *p++;
if (prefix->labelstack[prefix->labellen] &
if (ibuf_get(buf, &prefix->labelstack[prefix->labellen], 3) ==
-1)
return -1;
if (prefix->labelstack[prefix->labellen + 2] &
BGP_MPLS_BOS)
done = 1;
prefix->labellen++;
plen += 3;
prefix->labellen += 3;
pfxlen -= 3 * 8;
} while (!done);
/* RD */
if (len - plen < (int)sizeof(uint64_t) ||
pfxlen < sizeof(uint64_t) * 8)
if (pfxlen < sizeof(uint64_t) * 8 ||
ibuf_get_h64(buf, &prefix->rd) == -1)
return (-1);
memcpy(&prefix->rd, p, sizeof(uint64_t));
pfxlen -= sizeof(uint64_t) * 8;
p += sizeof(uint64_t);
plen += sizeof(uint64_t);
/* prefix */
prefix->aid = AID_VPN_IPv4;
*prefixlen = pfxlen;
if (pfxlen > 32)
return (-1);
if ((rv = extract_prefix(p, len, &prefix->v4,
pfxlen, sizeof(prefix->v4))) == -1)
if (extract_prefix_buf(buf, &prefix->v4, pfxlen,
sizeof(prefix->v4)) == -1)
return (-1);
return (plen + rv);
*prefixlen = pfxlen;
return (0);
}
int
nlri_get_vpn6(u_char *p, uint16_t len, struct bgpd_addr *prefix,
nlri_get_vpn6(struct ibuf *buf, struct bgpd_addr *prefix,
uint8_t *prefixlen, int withdraw)
{
int rv, done = 0;
uint16_t plen;
int done = 0;
uint8_t pfxlen;
if (len < 1)
if (ibuf_get_n8(buf, &pfxlen) == -1)
return (-1);
memcpy(&pfxlen, p, 1);
p += 1;
plen = 1;
memset(prefix, 0, sizeof(struct bgpd_addr));
prefix->aid = AID_VPN_IPv6;
/* label stack */
do {
if (len - plen < 3 || pfxlen < 3 * 8)
return (-1);
if (prefix->labellen + 3U >
sizeof(prefix->labelstack))
if (prefix->labellen + 3U > sizeof(prefix->labelstack) ||
pfxlen < 3 * 8)
return (-1);
if (withdraw) {
/* on withdraw ignore the labelstack all together */
p += 3;
plen += 3;
if (ibuf_skip(buf, 3) == -1)
return (-1);
pfxlen -= 3 * 8;
break;
}
prefix->labelstack[prefix->labellen++] = *p++;
prefix->labelstack[prefix->labellen++] = *p++;
prefix->labelstack[prefix->labellen] = *p++;
if (prefix->labelstack[prefix->labellen] &
if (ibuf_get(buf, &prefix->labelstack[prefix->labellen], 3) ==
-1)
return (-1);
if (prefix->labelstack[prefix->labellen + 2] &
BGP_MPLS_BOS)
done = 1;
prefix->labellen++;
plen += 3;
prefix->labellen += 3;
pfxlen -= 3 * 8;
} while (!done);
/* RD */
if (len - plen < (int)sizeof(uint64_t) ||
pfxlen < sizeof(uint64_t) * 8)
if (pfxlen < sizeof(uint64_t) * 8 ||
ibuf_get_h64(buf, &prefix->rd) == -1)
return (-1);
memcpy(&prefix->rd, p, sizeof(uint64_t));
pfxlen -= sizeof(uint64_t) * 8;
p += sizeof(uint64_t);
plen += sizeof(uint64_t);
/* prefix */
prefix->aid = AID_VPN_IPv6;
*prefixlen = pfxlen;
if (pfxlen > 128)
return (-1);
if ((rv = extract_prefix(p, len, &prefix->v6,
pfxlen, sizeof(prefix->v6))) == -1)
if (extract_prefix_buf(buf, &prefix->v6, pfxlen,
sizeof(prefix->v6)) == -1)
return (-1);
return (plen + rv);
*prefixlen = pfxlen;
return (0);
}
static in_addr_t

View File

@ -1,4 +1,4 @@
/* $OpenBSD: btrace.c,v 1.81 2023/11/10 18:56:21 jasper Exp $ */
/* $OpenBSD: btrace.c,v 1.82 2024/01/23 22:04:15 mpi Exp $ */
/*
* Copyright (c) 2019 - 2023 Martin Pieuchot <mpi@openbsd.org>
@ -1631,7 +1631,7 @@ ba2long(struct bt_arg *ba, struct dt_evt *dtev)
if (bv->bv_value == NULL)
return 0;
val = ba2long(map_get((struct map *)bv->bv_value,
ba2str(ba->ba_key, dtev)), dtev);
ba2hash(ba->ba_key, dtev)), dtev);
break;
case B_AT_NIL:
val = 0L;
@ -1767,7 +1767,7 @@ ba2str(struct bt_arg *ba, struct dt_evt *dtev)
break;
}
str = ba2str(map_get((struct map *)bv->bv_value,
ba2str(ba->ba_key, dtev)), dtev);
ba2hash(ba->ba_key, dtev)), dtev);
break;
case B_AT_VAR:
str = ba2str(ba_read(ba), dtev);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: filemode.c,v 1.36 2023/10/13 12:06:49 job Exp $ */
/* $OpenBSD: filemode.c,v 1.37 2024/01/23 09:32:57 job Exp $ */
/*
* Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
@ -477,7 +477,7 @@ proc_parser_file(char *file, unsigned char *buf, size_t len)
cert_free(eecert);
} else if (status) {
cert->talid = a->cert->talid;
status = constraints_validate(file, cert);
constraints_validate(file, cert);
}
} else if (is_ta) {
if ((tal = find_tal(cert)) != NULL) {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ypbind.c,v 1.79 2023/11/27 18:37:53 tb Exp $ */
/* $OpenBSD: ypbind.c,v 1.80 2024/01/23 14:13:55 deraadt Exp $ */
/*
* Copyright (c) 1992, 1993, 1996, 1997, 1998 Theo de Raadt <deraadt@openbsd.org>
@ -156,8 +156,7 @@ ypbindproc_domain_2x(SVCXPRT *transp, domainname *argp, CLIENT *clnt)
if (ypdb == NULL)
return NULL;
memset(ypdb, 0, sizeof *ypdb);
strncpy(ypdb->dom_domain, *argp, sizeof ypdb->dom_domain-1);
ypdb->dom_domain[sizeof ypdb->dom_domain-1] = '\0';
strlcpy(ypdb->dom_domain, *argp, sizeof ypdb->dom_domain);
ypdb->dom_vers = YPVERS;
ypdb->dom_alive = 0;
ypdb->dom_lockfd = -1;
@ -487,8 +486,7 @@ main(int argc, char *argv[])
if (ypbindlist == NULL)
errx(1, "no memory");
memset(ypbindlist, 0, sizeof *ypbindlist);
strncpy(ypbindlist->dom_domain, domain, sizeof ypbindlist->dom_domain-1);
ypbindlist->dom_domain[sizeof (ypbindlist->dom_domain)-1] = '\0';
strlcpy(ypbindlist->dom_domain, domain, sizeof ypbindlist->dom_domain);
ypbindlist->dom_vers = YPVERS;
snprintf(ypbindlist->dom_servlist, sizeof ypbindlist->dom_servlist,
"%s/%s", SERVERSDIR, ypbindlist->dom_domain);
@ -960,8 +958,7 @@ rpc_received(char *dom, struct sockaddr_in *raddrp, int force)
if (ypdb == NULL)
return;
memset(ypdb, 0, sizeof *ypdb);
strncpy(ypdb->dom_domain, dom, sizeof ypdb->dom_domain-1);
ypdb->dom_domain[sizeof (ypdb->dom_domain)-1] = '\0';
strlcpy(ypdb->dom_domain, dom, sizeof ypdb->dom_domain);
ypdb->dom_lockfd = -1;
ypdb->dom_xid = unique_xid(ypdb);
ypdb->dom_pnext = ypbindlist;