From 1abf3d5d6ce4d05115c6c1b12b8c8b892c2c4de0 Mon Sep 17 00:00:00 2001 From: purplerain Date: Tue, 21 Nov 2023 08:46:51 +0000 Subject: [PATCH] sync with OpenBSD -current --- etc/skel/dot.version | 2 +- .../clang/lib/Driver/ToolChains/Clang.cpp | 4 +- gnu/llvm/lld/ELF/Arch/RISCV.cpp | 2 +- gnu/llvm/lld/ELF/LinkerScript.cpp | 2 +- gnu/llvm/lld/ELF/Relocations.cpp | 7 + lib/libc/asr/asr_private.h | 3 +- lib/libc/asr/asr_utils.c | 34 +++- lib/libc/asr/getaddrinfo_async.c | 28 +++- lib/libc/asr/gethostnamadr_async.c | 33 +++- regress/lib/libcrypto/free/freenull.c.head | 3 +- regress/usr.sbin/snmpd/Makefile | 12 +- regress/usr.sbin/snmpd/regress.h | 21 +++ regress/usr.sbin/snmpd/snmp.c | 39 ++--- regress/usr.sbin/snmpd/snmpd_regress.c | 5 +- regress/usr.sbin/snmpd/transport.c | 150 ++++++++++++++++++ sys/dev/fdt/if_dwge.c | 20 ++- sys/dev/pci/drm/amd/amdgpu/amdgpu_devlist.h | 10 +- sys/dev/pci/drm/amd/amdkfd/kfd_svm.c | 8 +- .../pci/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 70 ++++++-- sys/dev/pci/drm/drm_syncobj.c | 3 +- sys/dev/pci/drm/radeon/evergreen.c | 7 +- usr.bin/kdump/Makefile | 16 +- usr.bin/kdump/mkioctls | 15 +- usr.bin/ssh/sshconnect.c | 4 +- usr.sbin/bgpctl/bgpctl.c | 130 +++++++-------- usr.sbin/bgpctl/mrtparser.c | 2 +- usr.sbin/bgpctl/output.c | 8 +- usr.sbin/bgpctl/output_json.c | 2 +- usr.sbin/bgpctl/output_ometric.c | 2 +- usr.sbin/bgpctl/parser.c | 6 +- usr.sbin/snmpd/snmpe.c | 3 +- 31 files changed, 490 insertions(+), 161 deletions(-) create mode 100644 regress/usr.sbin/snmpd/transport.c diff --git a/etc/skel/dot.version b/etc/skel/dot.version index 5f599ba13..5abf50e3b 100644 --- a/etc/skel/dot.version +++ b/etc/skel/dot.version @@ -1 +1 @@ -# SecBSD 1.4-731e06f: Mon Nov 20 02:17:28 UTC 2023 (Mictlantecuhtli) +# SecBSD 1.4-4ca0067: Tue Nov 21 07:49:44 UTC 2023 (Mictlantecuhtli) diff --git a/gnu/llvm/clang/lib/Driver/ToolChains/Clang.cpp b/gnu/llvm/clang/lib/Driver/ToolChains/Clang.cpp index 28feeed46..1d073428f 100644 --- a/gnu/llvm/clang/lib/Driver/ToolChains/Clang.cpp +++ b/gnu/llvm/clang/lib/Driver/ToolChains/Clang.cpp @@ -1572,7 +1572,7 @@ static void CollectARMPACBTIOptions(const ToolChain &TC, const ArgList &Args, options::OPT_mbranch_protection_EQ) : Args.getLastArg(options::OPT_mbranch_protection_EQ); if (!A) { - if (Triple.isOSOpenBSD()) { + if (Triple.isOSOpenBSD() && isAArch64) { CmdArgs.push_back("-msign-return-address=non-leaf"); CmdArgs.push_back("-msign-return-address-key=a_key"); CmdArgs.push_back("-mbranch-target-enforce"); @@ -1594,7 +1594,7 @@ static void CollectARMPACBTIOptions(const ToolChain &TC, const ArgList &Args, D.Diag(diag::err_drv_unsupported_option_argument) << A->getSpelling() << Scope; Key = "a_key"; - if (Triple.isOSOpenBSD()) + if (Triple.isOSOpenBSD() && isAArch64) IndirectBranches = true; else IndirectBranches = false; diff --git a/gnu/llvm/lld/ELF/Arch/RISCV.cpp b/gnu/llvm/lld/ELF/Arch/RISCV.cpp index 87887b314..b0864b517 100644 --- a/gnu/llvm/lld/ELF/Arch/RISCV.cpp +++ b/gnu/llvm/lld/ELF/Arch/RISCV.cpp @@ -144,7 +144,7 @@ uint32_t RISCV::calcEFlags() const { target |= EF_RISCV_RVC; if ((eflags & EF_RISCV_FLOAT_ABI) != (target & EF_RISCV_FLOAT_ABI)) - error( + warn( toString(f) + ": cannot link object files with different floating-point ABI from " + toString(ctx.objectFiles[0])); diff --git a/gnu/llvm/lld/ELF/LinkerScript.cpp b/gnu/llvm/lld/ELF/LinkerScript.cpp index 24e4ae68f..0fe9433b6 100644 --- a/gnu/llvm/lld/ELF/LinkerScript.cpp +++ b/gnu/llvm/lld/ELF/LinkerScript.cpp @@ -104,7 +104,7 @@ static StringRef getOutputSectionName(const InputSectionBase *s) { {".data.rel.ro", ".data", ".rodata", ".bss.rel.ro", ".bss", ".gcc_except_table", ".init_array", ".fini_array", ".tbss", ".tdata", ".ARM.exidx", ".ARM.extab", ".ctors", ".dtors", - ".openbsd.randomdata.", ".openbsd.mutable."}) + ".openbsd.randomdata", ".openbsd.mutable"}) if (isSectionPrefix(v, s->name)) return v; diff --git a/gnu/llvm/lld/ELF/Relocations.cpp b/gnu/llvm/lld/ELF/Relocations.cpp index 80b3615f1..3c9e7e450 100644 --- a/gnu/llvm/lld/ELF/Relocations.cpp +++ b/gnu/llvm/lld/ELF/Relocations.cpp @@ -832,6 +832,13 @@ static bool maybeReportUndefined(Undefined &sym, InputSectionBase &sec, if (sym.discardedSecIdx != 0 && (sec.name == ".got2" || sec.name == ".toc")) return false; +#ifdef __OpenBSD__ + // GCC (at least 8 and 11) can produce a ".gcc_except_table" with relocations + // to discarded sections on riscv64 + if (sym.discardedSecIdx != 0 && sec.name == ".gcc_except_table") + return false; +#endif + bool isWarning = (config->unresolvedSymbols == UnresolvedPolicy::Warn && canBeExternal) || config->noinhibitExec; diff --git a/lib/libc/asr/asr_private.h b/lib/libc/asr/asr_private.h index 64f044f12..27f5421a9 100644 --- a/lib/libc/asr/asr_private.h +++ b/lib/libc/asr/asr_private.h @@ -1,4 +1,4 @@ -/* $OpenBSD: asr_private.h,v 1.48 2022/11/17 17:39:41 florian Exp $ */ +/* $OpenBSD: asr_private.h,v 1.49 2023/11/20 12:15:16 florian Exp $ */ /* * Copyright (c) 2012 Eric Faurot * @@ -299,6 +299,7 @@ int _asr_sockaddr_from_str(struct sockaddr *, int, const char *); ssize_t _asr_dname_from_fqdn(const char *, char *, size_t); ssize_t _asr_addr_as_fqdn(const char *, int, char *, size_t); int hnok_lenient(const char *); +int _asr_is_localhost(const char*); /* asr.c */ void _asr_resolver_done(void *); diff --git a/lib/libc/asr/asr_utils.c b/lib/libc/asr/asr_utils.c index 9ae9bfa86..ab8603ab1 100644 --- a/lib/libc/asr/asr_utils.c +++ b/lib/libc/asr/asr_utils.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asr_utils.c,v 1.21 2023/03/15 22:12:00 millert Exp $ */ +/* $OpenBSD: asr_utils.c,v 1.22 2023/11/20 12:15:16 florian Exp $ */ /* * Copyright (c) 2009-2012 Eric Faurot * @@ -582,3 +582,35 @@ hnok_lenient(const char *dn) } return 1; } + +/* Check if the hostname is localhost or if it's in the localhost domain */ +int +_asr_is_localhost(const char *hn) +{ + size_t hnlen, localhostlen; + + if (hn == NULL) + return 0; + + if (strcasecmp(hn, "localhost") == 0 || + strcasecmp(hn, "localhost.") == 0) + return 1; + + hnlen = strlen(hn); + localhostlen = strlen(".localhost"); + + if (hnlen < localhostlen) + return 0; + + if (strcasecmp(hn + hnlen - localhostlen, ".localhost") == 0) + return 1; + + localhostlen++; + if (hnlen < localhostlen) + return 0; + + if (strcasecmp(hn + hnlen - localhostlen, ".localhost.") == 0) + return 1; + + return 0; +} diff --git a/lib/libc/asr/getaddrinfo_async.c b/lib/libc/asr/getaddrinfo_async.c index 5e0d186f3..d5a9561fa 100644 --- a/lib/libc/asr/getaddrinfo_async.c +++ b/lib/libc/asr/getaddrinfo_async.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getaddrinfo_async.c,v 1.59 2022/12/27 17:10:06 jmc Exp $ */ +/* $OpenBSD: getaddrinfo_async.c,v 1.60 2023/11/20 12:15:16 florian Exp $ */ /* * Copyright (c) 2012 Eric Faurot * @@ -115,7 +115,7 @@ getaddrinfo_async_run(struct asr_query *as, struct asr_result *ar) char fqdn[MAXDNAME]; const char *str; struct addrinfo *ai; - int i, family, r; + int i, family, r, is_localhost; FILE *f; union { struct sockaddr sa; @@ -228,8 +228,19 @@ getaddrinfo_async_run(struct asr_query *as, struct asr_result *ar) ar->ar_gai_errno = 0; - /* If hostname is NULL, use local address */ - if (as->as.ai.hostname == NULL) { + is_localhost = _asr_is_localhost(as->as.ai.hostname); + /* + * If hostname is NULL, "localhost" or falls within the + * ".localhost." domain, use local address. + * RFC 6761, 6.3: + * 3. Name resolution APIs and libraries SHOULD recognize + * localhost names as special and SHOULD always return the IP + * loopback address for address queries and negative responses + * for all other query types. Name resolution APIs SHOULD NOT + * send queries for localhost names to their configured caching + * DNS server(s). + */ + if (as->as.ai.hostname == NULL || is_localhost) { for (family = iter_family(as, 1); family != -1; family = iter_family(as, 0)) { @@ -238,11 +249,12 @@ getaddrinfo_async_run(struct asr_query *as, struct asr_result *ar) * those, rather than parsing over and over. */ if (family == PF_INET) - str = (ai->ai_flags & AI_PASSIVE) ? \ - "0.0.0.0" : "127.0.0.1"; + str = (ai->ai_flags & AI_PASSIVE && + !is_localhost) ? "0.0.0.0" : + "127.0.0.1"; else /* PF_INET6 */ - str = (ai->ai_flags & AI_PASSIVE) ? \ - "::" : "::1"; + str = (ai->ai_flags & AI_PASSIVE && + !is_localhost) ? "::" : "::1"; /* This can't fail */ _asr_sockaddr_from_str(&sa.sa, family, str); if ((r = addrinfo_add(as, &sa.sa, NULL))) { diff --git a/lib/libc/asr/gethostnamadr_async.c b/lib/libc/asr/gethostnamadr_async.c index bdc00cbdd..ed998cfde 100644 --- a/lib/libc/asr/gethostnamadr_async.c +++ b/lib/libc/asr/gethostnamadr_async.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gethostnamadr_async.c,v 1.47 2023/11/14 08:27:33 florian Exp $ */ +/* $OpenBSD: gethostnamadr_async.c,v 1.48 2023/11/20 12:15:16 florian Exp $ */ /* * Copyright (c) 2012 Eric Faurot * @@ -209,6 +209,37 @@ gethostnamadr_async_run(struct asr_query *as, struct asr_result *ar) async_set_state(as, ASR_STATE_HALT); break; } + + /* + * If hostname is "localhost" or falls within the + * ".localhost." domain, use local address. + * RFC 6761, 6.3: + * 3. Name resolution APIs and libraries SHOULD + * recognize localhost names as special and SHOULD + * always return the IP loopback address for address + * queries and negative responses for all other query + * types. Name resolution APIs SHOULD NOT send queries + * for localhost names to their configured caching DNS + * server(s). + */ + + if (_asr_is_localhost(as->as.hostnamadr.name)) { + inet_pton(as->as.hostnamadr.family, + as->as.hostnamadr.family == AF_INET ? + "127.0.0.1" : "::1", addr); + h = hostent_from_addr(as->as.hostnamadr.family, + as->as.hostnamadr.name, addr); + if (h == NULL) { + ar->ar_errno = errno; + ar->ar_h_errno = NETDB_INTERNAL; + } + else { + ar->ar_hostent = &h->h; + ar->ar_h_errno = NETDB_SUCCESS; + } + async_set_state(as, ASR_STATE_HALT); + break; + } } async_set_state(as, ASR_STATE_NEXT_DB); break; diff --git a/regress/lib/libcrypto/free/freenull.c.head b/regress/lib/libcrypto/free/freenull.c.head index 43b87598e..3c4e542fa 100644 --- a/regress/lib/libcrypto/free/freenull.c.head +++ b/regress/lib/libcrypto/free/freenull.c.head @@ -1,4 +1,4 @@ -/* $OpenBSD: freenull.c.head,v 1.7 2023/11/19 13:11:06 tb Exp $ */ +/* $OpenBSD: freenull.c.head,v 1.8 2023/11/20 01:20:19 tb Exp $ */ #include #include @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include diff --git a/regress/usr.sbin/snmpd/Makefile b/regress/usr.sbin/snmpd/Makefile index 9f3403736..63b0fc017 100644 --- a/regress/usr.sbin/snmpd/Makefile +++ b/regress/usr.sbin/snmpd/Makefile @@ -1,8 +1,9 @@ -# $OpenBSD: Makefile,v 1.11 2023/11/16 13:26:45 martijn Exp $ +# $OpenBSD: Makefile,v 1.12 2023/11/20 10:34:21 martijn Exp $ # Regress tests for snmpd PROG = snmpd_regress SRCS = snmpd_regress.c agentx.c backend.c snmp.c +SRCS+= transport.c LDADD= -lutil DPADD= ${LIBUTIL} @@ -249,7 +250,14 @@ SNMP_TARGETS+= snmp_v3_usm_noauthpriv REGRESS_TARGETS+= ${SNMP_TARGETS} snmp: ${SNMP_TARGETS} -.PHONY: agentx backend +TRANSPORT_TARGETS+= transport_tcp_get +TRANSPORT_TARGETS+= transport_tcp_disconnect +TRANSPORT_TARGETS+= transport_tcp_double_get_disconnect + +REGRESS_TARGETS+= ${TRANSPORT_TARGETS} +transport: ${TRANSPORT_TARGETS} + +.PHONY: agentx backend snmp transport ${REGRESS_TARGETS}: snmpd_regress # Always start snmpd if it's not running diff --git a/regress/usr.sbin/snmpd/regress.h b/regress/usr.sbin/snmpd/regress.h index cd05eb51b..b63a58723 100644 --- a/regress/usr.sbin/snmpd/regress.h +++ b/regress/usr.sbin/snmpd/regress.h @@ -98,6 +98,19 @@ struct varbind { } data; }; +enum snmp_request { + REQUEST_GET = 0, + REQUEST_GETNEXT = 1, + REQUEST_RESPONSE = 2, + REQUEST_SET = 3, + REQUEST_TRAP = 4, + REQUEST_GETBULK = 5, + REQUEST_INFORM = 6, + REQUEST_TRAPV2 = 7, + REQUEST_REPORT = 8 +}; + + extern int verbose; extern char *axsocket; extern char *hostname; @@ -128,11 +141,13 @@ char *oid_print(struct oid *, char *, size_t); #define MIB_SUBAGENT_UNREGISTER MIB_SUBAGENTS, 4 #define MIB_SUBAGENT_BACKEND MIB_SUBAGENTS, 5 #define MIB_SUBAGENT_SNMP MIB_SUBAGENTS, 6 +#define MIB_SUBAGENT_TRANSPORT MIB_SUBAGENTS, 7 /* Region used for registration testing */ #define MIB_REGISTER MIB_OPENBSD_REGRESS, 2 #define MIB_UNREGISTER MIB_OPENBSD_REGRESS, 3 #define MIB_BACKEND MIB_OPENBSD_REGRESS, 4 #define MIB_SNMP MIB_OPENBSD_REGRESS, 5 +#define MIB_TRANSPORT MIB_OPENBSD_REGRESS, 6 #define SYSORTABLE 1, 3, 6, 1, 2, 1, 1, 9 @@ -234,9 +249,12 @@ int32_t snmpv2_get(int, const char *, int32_t, struct varbind *, size_t); int32_t snmpv2_getnext(int, const char *, int32_t, struct varbind *, size_t); int32_t snmpv2_getbulk(int, const char *, int32_t, int32_t, int32_t, struct varbind *, size_t); +struct ber_element *snmpv2_build(const char *, enum snmp_request, int32_t, + int32_t, int32_t, struct varbind *, size_t); void snmpv2_response_validate(int, int, const char *, int32_t, int32_t, int32_t, struct varbind *, size_t); void snmp_timeout(int, int); +void smi_debug_elements(struct ber_element *); void backend_get_integer(void); void backend_get_octetstring(void); @@ -370,3 +388,6 @@ void backend_error_getnext_nonstandard(void); void backend_error_getbulk_firstrepetition(void); void backend_error_getbulk_secondrepetition(void); void snmp_v3_usm_noauthpriv(void); +void transport_tcp_get(void); +void transport_tcp_disconnect(void); +void transport_tcp_double_get_disconnect(void); diff --git a/regress/usr.sbin/snmpd/snmp.c b/regress/usr.sbin/snmpd/snmp.c index 333909531..d2e105edf 100644 --- a/regress/usr.sbin/snmpd/snmp.c +++ b/regress/usr.sbin/snmpd/snmp.c @@ -54,18 +54,6 @@ enum snmp_exception { EXCEPTION_ENDOFMIBVIEW = 2 }; -enum snmp_request { - REQUEST_GET = 0, - REQUEST_GETNEXT = 1, - REQUEST_RESPONSE = 2, - REQUEST_SET = 3, - REQUEST_TRAP = 4, - REQUEST_GETBULK = 5, - REQUEST_INFORM = 6, - REQUEST_TRAPV2 = 7, - REQUEST_REPORT = 8 -}; - enum security_model { SM_USM = 3, SM_TSM = 4 @@ -127,7 +115,6 @@ struct ber_element *snmp_data2ber_element(enum type, union data *); unsigned int smi_application(struct ber_element *); char *smi_oid2string(struct ber_oid *, char *, size_t); char *smi_print_element(struct ber_element *); -void smi_debug_elements(struct ber_element *); struct ber_element *v2cmps(struct ber_element *, const char *); void snmp_pdu_validate(struct ber_element *, enum snmp_request, int32_t, int32_t, int32_t, struct varbind *, size_t); @@ -243,6 +230,23 @@ snmpv2_getbulk(int s, const char *community, int32_t requestid, int32_t nonrep, maxrep, varbindlist, nvarbind); } +struct ber_element * +snmpv2_build(const char *community, enum snmp_request request, + int32_t requestid, int32_t error, int32_t index, + struct varbind *varbindlist, size_t nvarbind) +{ + struct ber_element *message; + + if (community == NULL) + community = SNMP_R_COMMUNITY; + message = ober_printf_elements(NULL, "{dse}", 1, community, + snmp_pdu(request, requestid, error, index, varbindlist, nvarbind)); + if (message == NULL) + err(1, NULL); + + return message; +} + int32_t snmpv2_send(int s, const char *community, enum snmp_request request, int32_t requestid, int32_t error, int32_t index, @@ -253,14 +257,11 @@ snmpv2_send(int s, const char *community, enum snmp_request request, void *buf; ssize_t buflen, writelen; - if (community == NULL) - community = SNMP_R_COMMUNITY; while (requestid == 0) requestid = arc4random(); - message = ober_printf_elements(NULL, "{dse}", 1, community, - snmp_pdu(request, requestid, error, index, varbindlist, nvarbind)); - if (message == NULL) - err(1, NULL); + + message = snmpv2_build(community, request, requestid, error, index, + varbindlist,nvarbind); if (ober_write_elements(&ber, message) == -1) err(1, "ober_write_elements"); diff --git a/regress/usr.sbin/snmpd/snmpd_regress.c b/regress/usr.sbin/snmpd/snmpd_regress.c index 36714ce37..044f843e4 100644 --- a/regress/usr.sbin/snmpd/snmpd_regress.c +++ b/regress/usr.sbin/snmpd/snmpd_regress.c @@ -213,7 +213,10 @@ const struct { { "backend_error_getnext_nonstandard", backend_error_getnext_nonstandard }, { "backend_error_getbulk_firstrepetition", backend_error_getbulk_firstrepetition }, { "backend_error_getbulk_secondrepetition", backend_error_getbulk_secondrepetition }, - { "snmp_v3_usm_noauthpriv", snmp_v3_usm_noauthpriv}, + { "snmp_v3_usm_noauthpriv", snmp_v3_usm_noauthpriv }, + { "transport_tcp_get", transport_tcp_get }, + { "transport_tcp_disconnect", transport_tcp_disconnect }, + { "transport_tcp_double_get_disconnect", transport_tcp_double_get_disconnect }, { NULL, NULL } }; diff --git a/regress/usr.sbin/snmpd/transport.c b/regress/usr.sbin/snmpd/transport.c new file mode 100644 index 000000000..cfda5ba4f --- /dev/null +++ b/regress/usr.sbin/snmpd/transport.c @@ -0,0 +1,150 @@ +#include + +#include +#include +#include +#include +#include +#include + +#include "regress.h" + +#define MIB_SUBAGENT_TRANSPORT_TCP MIB_SUBAGENT_TRANSPORT, 1 +#define MIB_TRANSPORT_TCP MIB_TRANSPORT, 1 + +void +transport_tcp_get(void) +{ + struct sockaddr_storage ss; + struct sockaddr *sa = (struct sockaddr *)&ss; + socklen_t salen; + int snmp_s, ax_s; + uint32_t sessionid; + struct varbind varbind = { + .type = TYPE_NULL, + .name = OID_STRUCT(MIB_TRANSPORT_TCP, 1, 0), + .data.int32 = 1 + }; + int32_t requestid; + char buf[1024]; + size_t n; + + ax_s = agentx_connect(axsocket); + sessionid = agentx_open(ax_s, 0, 0, + OID_ARG(MIB_SUBAGENT_TRANSPORT_TCP, 1), __func__); + agentx_register(ax_s, sessionid, 0, 0, 127, 0, + OID_ARG(MIB_TRANSPORT_TCP, 1), 0); + + salen = snmp_resolve(SOCK_STREAM, hostname, servname, sa); + snmp_s = snmp_connect(SOCK_STREAM, sa, salen); + requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1); + + n = agentx_read(ax_s, buf, sizeof(buf), 1000); + agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1); + + varbind.type = TYPE_INTEGER; + agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1); + + snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0, + &varbind, 1); +} + +void +transport_tcp_disconnect(void) +{ + struct sockaddr_storage ss; + struct sockaddr *sa = (struct sockaddr *)&ss; + socklen_t salen; + int snmp_s, ax_s; + uint32_t sessionid; + struct varbind varbind = { + .type = TYPE_NULL, + .name = OID_STRUCT(MIB_TRANSPORT_TCP, 2, 0), + .data.int32 = 1 + }; + int32_t requestid; + char buf[1024]; + size_t n; + + ax_s = agentx_connect(axsocket); + sessionid = agentx_open(ax_s, 0, 0, + OID_ARG(MIB_SUBAGENT_TRANSPORT_TCP, 2), __func__); + agentx_register(ax_s, sessionid, 0, 0, 127, 0, + OID_ARG(MIB_TRANSPORT_TCP, 2), 0); + + salen = snmp_resolve(SOCK_STREAM, hostname, servname, sa); + snmp_s = snmp_connect(SOCK_STREAM, sa, salen); + requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1); + + close(snmp_s); + + n = agentx_read(ax_s, buf, sizeof(buf), 1000); + agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1); + + varbind.type = TYPE_INTEGER; + agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1); +} + +void +transport_tcp_double_get_disconnect(void) +{ + struct sockaddr_storage ss; + struct sockaddr *sa = (struct sockaddr *)&ss; + socklen_t salen; + int snmp_s, ax_s; + uint32_t sessionid; + struct varbind varbind = { + .type = TYPE_NULL, + .name = OID_STRUCT(MIB_TRANSPORT_TCP, 2, 0), + .data.int32 = 1 + }; + struct ber_element *message; + struct ber ber = {}; + char buf[1024]; + ssize_t buflen, writelen; + void *ptr; + size_t n; + + ax_s = agentx_connect(axsocket); + sessionid = agentx_open(ax_s, 0, 0, + OID_ARG(MIB_SUBAGENT_TRANSPORT_TCP, 2), __func__); + agentx_register(ax_s, sessionid, 0, 0, 127, 0, + OID_ARG(MIB_TRANSPORT_TCP, 2), 0); + + salen = snmp_resolve(SOCK_STREAM, hostname, servname, sa); + snmp_s = snmp_connect(SOCK_STREAM, sa, salen); + + message = snmpv2_build(community, REQUEST_GET, 0, 0, 0, &varbind, 1); + + if (ober_write_elements(&ber, message) == -1) + err(1, "ober_write_elements"); + + buflen = ober_get_writebuf(&ber, &ptr); + /* send two copies in a single window */ + memcpy(buf, ptr, buflen); + memcpy(buf + buflen, ptr, buflen); + + if ((writelen = write(snmp_s, buf, buflen * 2)) == -1) + err(1, "write"); + if (writelen != buflen * 2) + errx(1, "write: short write"); + + if (verbose) { + printf("SNMP send(%d):\n", snmp_s); + smi_debug_elements(message); + } + ober_free_elements(message); + ober_free(&ber); + + close(snmp_s); + + n = agentx_read(ax_s, buf, sizeof(buf), 1000); + agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1); + + varbind.type = TYPE_INTEGER; + agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1); + + n = agentx_read(ax_s, buf, sizeof(buf), 1000); + agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1); + agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1); +} diff --git a/sys/dev/fdt/if_dwge.c b/sys/dev/fdt/if_dwge.c index c2154a508..f0fe26676 100644 --- a/sys/dev/fdt/if_dwge.c +++ b/sys/dev/fdt/if_dwge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_dwge.c,v 1.20 2023/11/10 15:51:19 bluhm Exp $ */ +/* $OpenBSD: if_dwge.c,v 1.21 2023/11/20 20:41:18 kettenis Exp $ */ /* * Copyright (c) 2008, 2019 Mark Kettenis * Copyright (c) 2017 Patrick Wildt @@ -214,6 +214,7 @@ struct dwge_desc { #define RDES0_OE (1 << 11) #define RDES0_SAF (1 << 13) #define RDES0_DE (1 << 14) +#define RDES0_ES (1 << 15) #define RDES0_FL_MASK 0x3fff #define RDES0_FL_SHIFT 16 #define RDES0_AFM (1 << 30) @@ -1097,15 +1098,20 @@ dwge_rx_proc(struct dwge_softc *sc) len, BUS_DMASYNC_POSTREAD); bus_dmamap_unload(sc->sc_dmat, rxb->tb_map); - /* Strip off CRC. */ - len -= ETHER_CRC_LEN; - KASSERT(len > 0); - m = rxb->tb_m; rxb->tb_m = NULL; - m->m_pkthdr.len = m->m_len = len; + if (rxd->sd_status & RDES0_ES) { + ifp->if_ierrors++; + m_freem(m); + } else { + /* Strip off CRC. */ + len -= ETHER_CRC_LEN; + KASSERT(len > 0); - ml_enqueue(&ml, m); + m->m_pkthdr.len = m->m_len = len; + + ml_enqueue(&ml, m); + } put++; if (sc->sc_rx_cons == (DWGE_NRXDESC - 1)) diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_devlist.h b/sys/dev/pci/drm/amd/amdgpu/amdgpu_devlist.h index 674e56199..6ee14c0ac 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_devlist.h +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_devlist.h @@ -197,18 +197,18 @@ static const struct pci_matchid amdgpu_devices[] = { */ /* GC 10.3.6, DCN 3.1.5, APU, Ryzen 7000 "Raphael" */ - {0x1002, 0x164e }, + {0x1002, 0x164e }, /* Radeon 610M */ /* GC 10.3.7, DCN 3.1.6, APU, Ryzen 7020 "Mendocino" */ - {0x1002, 0x1506 }, + {0x1002, 0x1506 }, /* Radeon 610M */ /* GC 11.0.0, DCN 3.2.0, dGPU, "Navi 31" */ {0x1002, 0x7448 }, /* Radeon Pro W7900 */ - {0x1002, 0x744c }, /* Radeon RX 7900 XT/XTX/GRE */ + {0x1002, 0x744c }, /* Radeon RX 7900 XT/XTX/GRE, 7900M */ {0x1002, 0x745e }, /* Radeon Pro W7800 */ /* GC 11.0.1, DCN 3.1.4, APU, Ryzen 7040 "Phoenix" */ - {0x1002, 0x15bf }, + {0x1002, 0x15bf }, /* Radeon 740M / 760M / 780M */ /* GC 11.0.2, DCN 3.2.1, dGPU, "Navi 33" */ {0x1002, 0x7480 }, /* Radeon RX 7600S, 7700S, 7600M XT, @@ -221,7 +221,7 @@ static const struct pci_matchid amdgpu_devices[] = { {0x1002, 0x747e }, /* Radeon RX 7700 XT, 7800 XT */ /* GC 11.0.4, DCN 3.1.4, APU, "Phoenix 2" */ - {0x1002, 0x15c8 }, + {0x1002, 0x15c8 }, /* Radeon 740M */ /* GC 11.5.0, DCN 3.5.0, APU, linux >= 6.7 */ }; diff --git a/sys/dev/pci/drm/amd/amdkfd/kfd_svm.c b/sys/dev/pci/drm/amd/amdkfd/kfd_svm.c index 63feea089..d7e758c86 100644 --- a/sys/dev/pci/drm/amd/amdkfd/kfd_svm.c +++ b/sys/dev/pci/drm/amd/amdkfd/kfd_svm.c @@ -487,11 +487,11 @@ svm_range_validate_svm_bo(struct amdgpu_device *adev, struct svm_range *prange) /* We need a new svm_bo. Spin-loop to wait for concurrent * svm_range_bo_release to finish removing this range from - * its range list. After this, it is safe to reuse the - * svm_bo pointer and svm_bo_list head. + * its range list and set prange->svm_bo to null. After this, + * it is safe to reuse the svm_bo pointer and svm_bo_list head. */ - while (!list_empty_careful(&prange->svm_bo_list)) - ; + while (!list_empty_careful(&prange->svm_bo_list) || prange->svm_bo) + cond_resched(); return false; } diff --git a/sys/dev/pci/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/sys/dev/pci/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 3abbd09a1..64a9b954d 100644 --- a/sys/dev/pci/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/sys/dev/pci/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -9630,16 +9630,27 @@ static void dm_get_oriented_plane_size(struct drm_plane_state *plane_state, } } +static void +dm_get_plane_scale(struct drm_plane_state *plane_state, + int *out_plane_scale_w, int *out_plane_scale_h) +{ + int plane_src_w, plane_src_h; + + dm_get_oriented_plane_size(plane_state, &plane_src_w, &plane_src_h); + *out_plane_scale_w = plane_state->crtc_w * 1000 / plane_src_w; + *out_plane_scale_h = plane_state->crtc_h * 1000 / plane_src_h; +} + static int dm_check_crtc_cursor(struct drm_atomic_state *state, struct drm_crtc *crtc, struct drm_crtc_state *new_crtc_state) { - struct drm_plane *cursor = crtc->cursor, *underlying; + struct drm_plane *cursor = crtc->cursor, *plane, *underlying; + struct drm_plane_state *old_plane_state, *new_plane_state; struct drm_plane_state *new_cursor_state, *new_underlying_state; int i; int cursor_scale_w, cursor_scale_h, underlying_scale_w, underlying_scale_h; - int cursor_src_w, cursor_src_h; - int underlying_src_w, underlying_src_h; + bool any_relevant_change = false; /* On DCE and DCN there is no dedicated hardware cursor plane. We get a * cursor per pipe but it's going to inherit the scaling and @@ -9647,13 +9658,50 @@ static int dm_check_crtc_cursor(struct drm_atomic_state *state, * blending properties match the underlying planes'. */ - new_cursor_state = drm_atomic_get_new_plane_state(state, cursor); - if (!new_cursor_state || !new_cursor_state->fb) + /* If no plane was enabled or changed scaling, no need to check again */ + for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) { + int new_scale_w, new_scale_h, old_scale_w, old_scale_h; + + if (!new_plane_state || !new_plane_state->fb || new_plane_state->crtc != crtc) + continue; + + if (!old_plane_state || !old_plane_state->fb || old_plane_state->crtc != crtc) { + any_relevant_change = true; + break; + } + + if (new_plane_state->fb == old_plane_state->fb && + new_plane_state->crtc_w == old_plane_state->crtc_w && + new_plane_state->crtc_h == old_plane_state->crtc_h) + continue; + + dm_get_plane_scale(new_plane_state, &new_scale_w, &new_scale_h); + dm_get_plane_scale(old_plane_state, &old_scale_w, &old_scale_h); + + if (new_scale_w != old_scale_w || new_scale_h != old_scale_h) { + any_relevant_change = true; + break; + } + } + + if (!any_relevant_change) return 0; - dm_get_oriented_plane_size(new_cursor_state, &cursor_src_w, &cursor_src_h); - cursor_scale_w = new_cursor_state->crtc_w * 1000 / cursor_src_w; - cursor_scale_h = new_cursor_state->crtc_h * 1000 / cursor_src_h; + new_cursor_state = drm_atomic_get_plane_state(state, cursor); + if (IS_ERR(new_cursor_state)) + return PTR_ERR(new_cursor_state); + + if (!new_cursor_state->fb) + return 0; + + dm_get_plane_scale(new_cursor_state, &cursor_scale_w, &cursor_scale_h); + + /* Need to check all enabled planes, even if this commit doesn't change + * their state + */ + i = drm_atomic_add_affected_planes(state, crtc); + if (i) + return i; for_each_new_plane_in_state_reverse(state, underlying, new_underlying_state, i) { /* Narrow down to non-cursor planes on the same CRTC as the cursor */ @@ -9664,10 +9712,8 @@ static int dm_check_crtc_cursor(struct drm_atomic_state *state, if (!new_underlying_state->fb) continue; - dm_get_oriented_plane_size(new_underlying_state, - &underlying_src_w, &underlying_src_h); - underlying_scale_w = new_underlying_state->crtc_w * 1000 / underlying_src_w; - underlying_scale_h = new_underlying_state->crtc_h * 1000 / underlying_src_h; + dm_get_plane_scale(new_underlying_state, + &underlying_scale_w, &underlying_scale_h); if (cursor_scale_w != underlying_scale_w || cursor_scale_h != underlying_scale_h) { diff --git a/sys/dev/pci/drm/drm_syncobj.c b/sys/dev/pci/drm/drm_syncobj.c index 922fe5ddf..9a28ae54b 100644 --- a/sys/dev/pci/drm/drm_syncobj.c +++ b/sys/dev/pci/drm/drm_syncobj.c @@ -1078,7 +1078,8 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs, fence = drm_syncobj_fence_get(syncobjs[i]); if (!fence || dma_fence_chain_find_seqno(&fence, points[i])) { dma_fence_put(fence); - if (flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT) { + if (flags & (DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT | + DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE)) { continue; } else { timeout = -EINVAL; diff --git a/sys/dev/pci/drm/radeon/evergreen.c b/sys/dev/pci/drm/radeon/evergreen.c index 452569764..230015330 100644 --- a/sys/dev/pci/drm/radeon/evergreen.c +++ b/sys/dev/pci/drm/radeon/evergreen.c @@ -4823,14 +4823,15 @@ restart_ih: break; case 44: /* hdmi */ afmt_idx = src_data; - if (!(afmt_status[afmt_idx] & AFMT_AZ_FORMAT_WTRIG)) - DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); - if (afmt_idx > 5) { DRM_ERROR("Unhandled interrupt: %d %d\n", src_id, src_data); break; } + + if (!(afmt_status[afmt_idx] & AFMT_AZ_FORMAT_WTRIG)) + DRM_DEBUG("IH: IH event w/o asserted irq bit?\n"); + afmt_status[afmt_idx] &= ~AFMT_AZ_FORMAT_WTRIG; queue_hdmi = true; DRM_DEBUG("IH: HDMI%d\n", afmt_idx + 1); diff --git a/usr.bin/kdump/Makefile b/usr.bin/kdump/Makefile index bac23a2d9..6cae73b66 100644 --- a/usr.bin/kdump/Makefile +++ b/usr.bin/kdump/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.37 2020/06/22 01:02:30 dlg Exp $ +# $OpenBSD: Makefile,v 1.39 2023/11/20 17:48:27 kn Exp $ LDSTATIC=${STATIC} PROG= kdump @@ -10,16 +10,17 @@ CLEANFILES+=ioctl.c kdump_subr.c ioctl.c: ${.CURDIR}/Makefile ${.CURDIR}/mkioctls CC="${CC}" \ - /bin/sh ${.CURDIR}/mkioctls ${SYS_DIR}/sys/ioctl.h \ + /bin/sh ${.CURDIR}/mkioctls \ ${SYS_DIR}/dev/biovar.h \ + ${SYS_DIR}/dev/efi/efiio.h \ ${SYS_DIR}/dev/ipmi.h \ - ${SYS_DIR}/dev/wscons/wsconsio.h \ - ${SYS_DIR}/dev/vndioctl.h \ - ${SYS_DIR}/dev/vscsivar.h \ ${SYS_DIR}/dev/pci/drm/include/uapi/drm/i915_drm.h \ ${SYS_DIR}/dev/pv/pvvar.h \ ${SYS_DIR}/dev/usb/udlio.h \ ${SYS_DIR}/dev/usb/usb.h \ + ${SYS_DIR}/dev/vndioctl.h \ + ${SYS_DIR}/dev/vscsivar.h \ + ${SYS_DIR}/dev/wscons/wsconsio.h \ ${SYS_DIR}/miscfs/fuse/fusefs.h \ ${SYS_DIR}/net/bpf.h \ ${SYS_DIR}/net/if_ppp.h \ @@ -31,8 +32,6 @@ ioctl.c: ${.CURDIR}/Makefile ${.CURDIR}/mkioctls ${SYS_DIR}/net/pipex.h \ ${SYS_DIR}/net80211/ieee80211_ioctl.h \ ${SYS_DIR}/netinet6/in6_var.h \ - ${SYS_DIR}/sys/tty.h \ - ${SYS_DIR}/sys/syslog.h \ ${SYS_DIR}/sys/ataio.h \ ${SYS_DIR}/sys/audioio.h \ ${SYS_DIR}/sys/cdio.h \ @@ -40,6 +39,7 @@ ioctl.c: ${.CURDIR}/Makefile ${.CURDIR}/mkioctls ${SYS_DIR}/sys/dkio.h \ ${SYS_DIR}/sys/filio.h \ ${SYS_DIR}/sys/gpio.h \ + ${SYS_DIR}/sys/ioctl.h \ ${SYS_DIR}/sys/kcov.h \ ${SYS_DIR}/sys/memrange.h \ ${SYS_DIR}/sys/mtio.h \ @@ -47,6 +47,8 @@ ioctl.c: ${.CURDIR}/Makefile ${.CURDIR}/mkioctls ${SYS_DIR}/sys/radioio.h \ ${SYS_DIR}/sys/scsiio.h \ ${SYS_DIR}/sys/sockio.h \ + ${SYS_DIR}/sys/syslog.h \ + ${SYS_DIR}/sys/tty.h \ ${SYS_DIR}/sys/videoio.h \ > ioctl.c diff --git a/usr.bin/kdump/mkioctls b/usr.bin/kdump/mkioctls index 549289426..3f22ae4f6 100644 --- a/usr.bin/kdump/mkioctls +++ b/usr.bin/kdump/mkioctls @@ -1,5 +1,5 @@ #!/bin/sh - -# $OpenBSD: mkioctls,v 1.43 2021/09/17 15:13:04 deraadt Exp $ +# $OpenBSD: mkioctls,v 1.45 2023/11/20 17:48:27 kn Exp $ # # Copyright (c) 1994 @@ -79,16 +79,17 @@ BEGIN { print "#include " print "#include " print "#include " - print "#include " - print "#include " - print "#include " - print "#include " print "#include " - print "#include " + print "#include " + print "#include " + print "#include " print "#include " print "#include " print "#include " print "#include " + print "#include " + print "#include " + print "#include " print "#include " print "#include \"kdump.h\"" print "" @@ -99,7 +100,7 @@ BEGIN { print "" } -/^[ ]*#[ ]*define[ ]+(ATAIO|AUDIO_|BIOC|CDIO|CHIO|DIOC|DRM|GPIO|IPMICTL|TIO|FIO|KIO|MEMRANGE|MTIOC|LIOC|SIO|OSIO|SESIOC_|SIOC|PCIOC|PIPEX|PPPIOC|PPPOE|PVBUSIOC|RIOC|RND|STRIOC|SCIOC|OSCIOC|TUN|UDLIO|USB|VIDIOC|VNDIOC|VSCSI|WSKBD|WSMOUSE|WSDISPLAY|WSMUX|PTM)[A-Z_0-9]*[ ]+(DRM)?_IO/ { +/^[ ]*#[ ]*define[ ]+(ATAIO|AUDIO_|BIOC|CDIO|CHIO|DIOC|DRM|EFI|GPIO|IPMICTL|TIO|FIO|KIO|MEMRANGE|MTIOC|LIOC|SIO|OSIO|SESIOC_|SIOC|PCIOC|PIPEX|PPPIOC|PPPOE|PVBUSIOC|RIOC|RND|STRIOC|SCIOC|OSCIOC|TUN|UDLIO|USB|VIDIOC|VNDIOC|VSCSI|WSKBD|WSMOUSE|WSDISPLAY|WSMUX|PTM)[A-Z_0-9]*[ ]+(DRM)?_IO/ { # find where the name starts for (i = 1; i <= NF; i++) diff --git a/usr.bin/ssh/sshconnect.c b/usr.bin/ssh/sshconnect.c index a47c8f76b..c8ee995b3 100644 --- a/usr.bin/ssh/sshconnect.c +++ b/usr.bin/ssh/sshconnect.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshconnect.c,v 1.364 2023/11/15 23:03:38 djm Exp $ */ +/* $OpenBSD: sshconnect.c,v 1.365 2023/11/20 02:50:00 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -463,7 +463,7 @@ ssh_connect_direct(struct ssh *ssh, const char *host, struct addrinfo *aitop, ai->ai_family != options.address_family) { debug2_f("skipping address [%s]:%s: " "wrong address family", ntop, strport); - errno = 0; + errno = EAFNOSUPPORT; continue; } diff --git a/usr.sbin/bgpctl/bgpctl.c b/usr.sbin/bgpctl/bgpctl.c index ebfa0b4a6..bd3a89861 100644 --- a/usr.sbin/bgpctl/bgpctl.c +++ b/usr.sbin/bgpctl/bgpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpctl.c,v 1.296 2023/09/06 09:52:26 claudio Exp $ */ +/* $OpenBSD: bgpctl.c,v 1.298 2023/11/20 14:41:55 claudio Exp $ */ /* * Copyright (c) 2003 Henning Brauer @@ -60,7 +60,7 @@ void network_bulk(struct parse_result *); int match_aspath(void *, uint16_t, struct filter_as *); struct flowspec *res_to_flowspec(struct parse_result *); -struct imsgbuf *ibuf; +struct imsgbuf *imsgbuf; struct mrt_parser show_mrt = { show_mrt_dump, show_mrt_state, show_mrt_msg }; struct mrt_parser net_mrt = { network_mrt_dump, NULL, NULL }; const struct output *output = &show_output; @@ -174,9 +174,9 @@ main(int argc, char *argv[]) if (pledge("stdio", NULL) == -1) err(1, "pledge"); - if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) + if ((imsgbuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, NULL); - imsg_init(ibuf, fd); + imsg_init(imsgbuf, fd); done = 0; switch (res->action) { @@ -186,10 +186,11 @@ main(int argc, char *argv[]) /* NOTREACHED */ case SHOW: case SHOW_SUMMARY: - imsg_compose(ibuf, IMSG_CTL_SHOW_NEIGHBOR, 0, 0, -1, NULL, 0); + imsg_compose(imsgbuf, IMSG_CTL_SHOW_NEIGHBOR, 0, 0, -1, + NULL, 0); break; case SHOW_SUMMARY_TERSE: - imsg_compose(ibuf, IMSG_CTL_SHOW_TERSE, 0, 0, -1, NULL, 0); + imsg_compose(imsgbuf, IMSG_CTL_SHOW_TERSE, 0, 0, -1, NULL, 0); break; case SHOW_FIB: if (!res->addr.aid) { @@ -197,7 +198,7 @@ main(int argc, char *argv[]) sa_family_t af; af = aid2af(res->aid); - if ((msg = imsg_create(ibuf, IMSG_CTL_KROUTE, + if ((msg = imsg_create(imsgbuf, IMSG_CTL_KROUTE, res->rtableid, 0, sizeof(res->flags) + sizeof(af))) == NULL) errx(1, "imsg_create failure"); @@ -205,36 +206,39 @@ main(int argc, char *argv[]) -1 || imsg_add(msg, &af, sizeof(af)) == -1) errx(1, "imsg_add failure"); - imsg_close(ibuf, msg); + imsg_close(imsgbuf, msg); } else - imsg_compose(ibuf, IMSG_CTL_KROUTE_ADDR, res->rtableid, - 0, -1, &res->addr, sizeof(res->addr)); + imsg_compose(imsgbuf, IMSG_CTL_KROUTE_ADDR, + res->rtableid, 0, -1, + &res->addr, sizeof(res->addr)); break; case SHOW_FIB_TABLES: - imsg_compose(ibuf, IMSG_CTL_SHOW_FIB_TABLES, 0, 0, -1, NULL, 0); - break; - case SHOW_NEXTHOP: - imsg_compose(ibuf, IMSG_CTL_SHOW_NEXTHOP, res->rtableid, 0, -1, + imsg_compose(imsgbuf, IMSG_CTL_SHOW_FIB_TABLES, 0, 0, -1, NULL, 0); break; + case SHOW_NEXTHOP: + imsg_compose(imsgbuf, IMSG_CTL_SHOW_NEXTHOP, res->rtableid, + 0, -1, NULL, 0); + break; case SHOW_INTERFACE: - imsg_compose(ibuf, IMSG_CTL_SHOW_INTERFACE, 0, 0, -1, NULL, 0); + imsg_compose(imsgbuf, IMSG_CTL_SHOW_INTERFACE, 0, 0, -1, + NULL, 0); break; case SHOW_SET: - imsg_compose(ibuf, IMSG_CTL_SHOW_SET, 0, 0, -1, NULL, 0); + imsg_compose(imsgbuf, IMSG_CTL_SHOW_SET, 0, 0, -1, NULL, 0); break; case SHOW_RTR: - imsg_compose(ibuf, IMSG_CTL_SHOW_RTR, 0, 0, -1, NULL, 0); + imsg_compose(imsgbuf, IMSG_CTL_SHOW_RTR, 0, 0, -1, NULL, 0); break; case SHOW_NEIGHBOR: case SHOW_NEIGHBOR_TIMERS: case SHOW_NEIGHBOR_TERSE: neighbor.show_timers = (res->action == SHOW_NEIGHBOR_TIMERS); if (res->peeraddr.aid || res->peerdesc[0]) - imsg_compose(ibuf, IMSG_CTL_SHOW_NEIGHBOR, 0, 0, -1, + imsg_compose(imsgbuf, IMSG_CTL_SHOW_NEIGHBOR, 0, 0, -1, &neighbor, sizeof(neighbor)); else - imsg_compose(ibuf, IMSG_CTL_SHOW_NEIGHBOR, 0, 0, -1, + imsg_compose(imsgbuf, IMSG_CTL_SHOW_NEIGHBOR, 0, 0, -1, NULL, 0); break; case SHOW_RIB: @@ -254,19 +258,20 @@ main(int argc, char *argv[]) ribreq.aid = res->aid; ribreq.path_id = res->pathid; ribreq.flags = res->flags; - imsg_compose(ibuf, type, 0, 0, -1, &ribreq, sizeof(ribreq)); + imsg_compose(imsgbuf, type, 0, 0, -1, &ribreq, sizeof(ribreq)); break; case SHOW_RIB_MEM: - imsg_compose(ibuf, IMSG_CTL_SHOW_RIB_MEM, 0, 0, -1, NULL, 0); + imsg_compose(imsgbuf, IMSG_CTL_SHOW_RIB_MEM, 0, 0, -1, NULL, 0); break; case SHOW_METRICS: output = &ometric_output; numdone = 2; - imsg_compose(ibuf, IMSG_CTL_SHOW_NEIGHBOR, 0, 0, -1, NULL, 0); - imsg_compose(ibuf, IMSG_CTL_SHOW_RIB_MEM, 0, 0, -1, NULL, 0); + imsg_compose(imsgbuf, IMSG_CTL_SHOW_NEIGHBOR, 0, 0, -1, + NULL, 0); + imsg_compose(imsgbuf, IMSG_CTL_SHOW_RIB_MEM, 0, 0, -1, NULL, 0); break; case RELOAD: - imsg_compose(ibuf, IMSG_CTL_RELOAD, 0, 0, -1, + imsg_compose(imsgbuf, IMSG_CTL_RELOAD, 0, 0, -1, res->reason, sizeof(res->reason)); if (res->reason[0]) printf("reload request sent: %s\n", res->reason); @@ -277,14 +282,14 @@ main(int argc, char *argv[]) errx(1, "action==FIB"); break; case FIB_COUPLE: - imsg_compose(ibuf, IMSG_CTL_FIB_COUPLE, res->rtableid, 0, -1, + imsg_compose(imsgbuf, IMSG_CTL_FIB_COUPLE, res->rtableid, 0, -1, NULL, 0); printf("couple request sent.\n"); done = 1; break; case FIB_DECOUPLE: - imsg_compose(ibuf, IMSG_CTL_FIB_DECOUPLE, res->rtableid, 0, -1, - NULL, 0); + imsg_compose(imsgbuf, IMSG_CTL_FIB_DECOUPLE, res->rtableid, + 0, -1, NULL, 0); printf("decouple request sent.\n"); done = 1; break; @@ -292,23 +297,23 @@ main(int argc, char *argv[]) errx(1, "action==NEIGHBOR"); break; case NEIGHBOR_UP: - imsg_compose(ibuf, IMSG_CTL_NEIGHBOR_UP, 0, 0, -1, + imsg_compose(imsgbuf, IMSG_CTL_NEIGHBOR_UP, 0, 0, -1, &neighbor, sizeof(neighbor)); break; case NEIGHBOR_DOWN: - imsg_compose(ibuf, IMSG_CTL_NEIGHBOR_DOWN, 0, 0, -1, + imsg_compose(imsgbuf, IMSG_CTL_NEIGHBOR_DOWN, 0, 0, -1, &neighbor, sizeof(neighbor)); break; case NEIGHBOR_CLEAR: - imsg_compose(ibuf, IMSG_CTL_NEIGHBOR_CLEAR, 0, 0, -1, + imsg_compose(imsgbuf, IMSG_CTL_NEIGHBOR_CLEAR, 0, 0, -1, &neighbor, sizeof(neighbor)); break; case NEIGHBOR_RREFRESH: - imsg_compose(ibuf, IMSG_CTL_NEIGHBOR_RREFRESH, 0, 0, -1, + imsg_compose(imsgbuf, IMSG_CTL_NEIGHBOR_RREFRESH, 0, 0, -1, &neighbor, sizeof(neighbor)); break; case NEIGHBOR_DESTROY: - imsg_compose(ibuf, IMSG_CTL_NEIGHBOR_DESTROY, 0, 0, -1, + imsg_compose(imsgbuf, IMSG_CTL_NEIGHBOR_DESTROY, 0, 0, -1, &neighbor, sizeof(neighbor)); break; case NETWORK_BULK_ADD: @@ -325,19 +330,19 @@ main(int argc, char *argv[]) net.rd = res->rd; /* attribute sets are not supported */ if (res->action == NETWORK_ADD) { - imsg_compose(ibuf, IMSG_NETWORK_ADD, 0, 0, -1, + imsg_compose(imsgbuf, IMSG_NETWORK_ADD, 0, 0, -1, &net, sizeof(net)); - send_filterset(ibuf, &res->set); - imsg_compose(ibuf, IMSG_NETWORK_DONE, 0, 0, -1, + send_filterset(imsgbuf, &res->set); + imsg_compose(imsgbuf, IMSG_NETWORK_DONE, 0, 0, -1, NULL, 0); } else - imsg_compose(ibuf, IMSG_NETWORK_REMOVE, 0, 0, -1, + imsg_compose(imsgbuf, IMSG_NETWORK_REMOVE, 0, 0, -1, &net, sizeof(net)); printf("request sent.\n"); done = 1; break; case NETWORK_FLUSH: - imsg_compose(ibuf, IMSG_NETWORK_FLUSH, 0, 0, -1, NULL, 0); + imsg_compose(imsgbuf, IMSG_NETWORK_FLUSH, 0, 0, -1, NULL, 0); printf("request sent.\n"); done = 1; break; @@ -345,7 +350,7 @@ main(int argc, char *argv[]) memset(&ribreq, 0, sizeof(ribreq)); ribreq.aid = res->aid; strlcpy(ribreq.rib, res->rib, sizeof(ribreq.rib)); - imsg_compose(ibuf, IMSG_CTL_SHOW_NETWORK, 0, 0, -1, + imsg_compose(imsgbuf, IMSG_CTL_SHOW_NETWORK, 0, 0, -1, &ribreq, sizeof(ribreq)); break; case NETWORK_MRT: @@ -369,19 +374,19 @@ main(int argc, char *argv[]) f = res_to_flowspec(res); /* attribute sets are not supported */ if (res->action == FLOWSPEC_ADD) { - imsg_compose(ibuf, IMSG_FLOWSPEC_ADD, 0, 0, -1, + imsg_compose(imsgbuf, IMSG_FLOWSPEC_ADD, 0, 0, -1, f, FLOWSPEC_SIZE + f->len); - send_filterset(ibuf, &res->set); - imsg_compose(ibuf, IMSG_FLOWSPEC_DONE, 0, 0, -1, + send_filterset(imsgbuf, &res->set); + imsg_compose(imsgbuf, IMSG_FLOWSPEC_DONE, 0, 0, -1, NULL, 0); } else - imsg_compose(ibuf, IMSG_FLOWSPEC_REMOVE, 0, 0, -1, + imsg_compose(imsgbuf, IMSG_FLOWSPEC_REMOVE, 0, 0, -1, f, FLOWSPEC_SIZE + f->len); printf("request sent.\n"); done = 1; break; case FLOWSPEC_FLUSH: - imsg_compose(ibuf, IMSG_FLOWSPEC_FLUSH, 0, 0, -1, NULL, 0); + imsg_compose(imsgbuf, IMSG_FLOWSPEC_FLUSH, 0, 0, -1, NULL, 0); printf("request sent.\n"); done = 1; break; @@ -402,14 +407,14 @@ main(int argc, char *argv[]) aid2str(res->aid)); } strlcpy(ribreq.rib, res->rib, sizeof(ribreq.rib)); - imsg_compose(ibuf, IMSG_CTL_SHOW_FLOWSPEC, 0, 0, -1, + imsg_compose(imsgbuf, IMSG_CTL_SHOW_FLOWSPEC, 0, 0, -1, &ribreq, sizeof(ribreq)); break; case LOG_VERBOSE: verbose = 1; /* FALLTHROUGH */ case LOG_BRIEF: - imsg_compose(ibuf, IMSG_CTL_LOG_VERBOSE, 0, 0, -1, + imsg_compose(imsgbuf, IMSG_CTL_LOG_VERBOSE, 0, 0, -1, &verbose, sizeof(verbose)); printf("logging request sent.\n"); done = 1; @@ -419,13 +424,13 @@ main(int argc, char *argv[]) output->head(res); again: - while (ibuf->w.queued) - if (msgbuf_write(&ibuf->w) <= 0) + while (imsgbuf->w.queued) + if (msgbuf_write(&imsgbuf->w) <= 0) err(1, "write error"); while (!done) { while (!done) { - if ((n = imsg_get(ibuf, &imsg)) == -1) + if ((n = imsg_get(imsgbuf, &imsg)) == -1) err(1, "imsg_get error"); if (n == 0) break; @@ -437,7 +442,7 @@ main(int argc, char *argv[]) if (done) break; - if ((n = imsg_read(ibuf)) == -1) + if ((n = imsg_read(imsgbuf)) == -1) err(1, "imsg_read error"); if (n == 0) errx(1, "pipe closed"); @@ -452,7 +457,7 @@ main(int argc, char *argv[]) output->tail(); close(fd); - free(ibuf); + free(imsgbuf); exit(0); } @@ -1197,21 +1202,21 @@ network_bulk(struct parse_result *res) net.rd = res->rd; if (res->action == NETWORK_BULK_ADD) { - imsg_compose(ibuf, IMSG_NETWORK_ADD, + imsg_compose(imsgbuf, IMSG_NETWORK_ADD, 0, 0, -1, &net, sizeof(net)); /* * can't use send_filterset since that * would free the set. */ TAILQ_FOREACH(s, &res->set, entry) { - imsg_compose(ibuf, + imsg_compose(imsgbuf, IMSG_FILTER_SET, 0, 0, -1, s, sizeof(*s)); } - imsg_compose(ibuf, IMSG_NETWORK_DONE, + imsg_compose(imsgbuf, IMSG_NETWORK_DONE, 0, 0, -1, NULL, 0); } else - imsg_compose(ibuf, IMSG_NETWORK_REMOVE, + imsg_compose(imsgbuf, IMSG_NETWORK_REMOVE, 0, 0, -1, &net, sizeof(net)); } } @@ -1388,22 +1393,22 @@ network_mrt_dump(struct mrt_rib *mr, struct mrt_peer *mp, void *arg) net.type = NETWORK_MRTCLONE; /* XXX rd can't be set and will be 0 */ - imsg_compose(ibuf, IMSG_NETWORK_ADD, 0, 0, -1, + imsg_compose(imsgbuf, IMSG_NETWORK_ADD, 0, 0, -1, &net, sizeof(net)); - if ((msg = imsg_create(ibuf, IMSG_NETWORK_ASPATH, + if ((msg = imsg_create(imsgbuf, IMSG_NETWORK_ASPATH, 0, 0, sizeof(ctl) + mre->aspath_len)) == NULL) errx(1, "imsg_create failure"); if (imsg_add(msg, &ctl, sizeof(ctl)) == -1 || imsg_add(msg, mre->aspath, mre->aspath_len) == -1) errx(1, "imsg_add failure"); - imsg_close(ibuf, msg); + imsg_close(imsgbuf, msg); for (j = 0; j < mre->nattrs; j++) - imsg_compose(ibuf, IMSG_NETWORK_ATTR, 0, 0, -1, + imsg_compose(imsgbuf, IMSG_NETWORK_ATTR, 0, 0, -1, mre->attrs[j].attr, mre->attrs[j].attr_len); - imsg_compose(ibuf, IMSG_NETWORK_DONE, 0, 0, -1, NULL, 0); + imsg_compose(imsgbuf, IMSG_NETWORK_DONE, 0, 0, -1, NULL, 0); - while (ibuf->w.queued) { - if (msgbuf_write(&ibuf->w) <= 0 && errno != EAGAIN) + while (imsgbuf->w.queued) { + if (msgbuf_write(&imsgbuf->w) <= 0 && errno != EAGAIN) err(1, "write error"); } } @@ -1807,7 +1812,8 @@ show_mrt_update(u_char *p, uint16_t len, int reqflags, int addpath) while (len > 0) { if (addpath) { if (len <= sizeof(pathid)) { - printf(" bad nlri prefix: pathid, len %d", len); + printf(" bad nlri prefix: pathid, " + "len %d", len); return; } memcpy(&pathid, p, sizeof(pathid)); diff --git a/usr.sbin/bgpctl/mrtparser.c b/usr.sbin/bgpctl/mrtparser.c index a231f3d0d..39b101c14 100644 --- a/usr.sbin/bgpctl/mrtparser.c +++ b/usr.sbin/bgpctl/mrtparser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mrtparser.c,v 1.19 2022/10/18 09:30:29 job Exp $ */ +/* $OpenBSD: mrtparser.c,v 1.20 2023/11/20 14:18:21 claudio Exp $ */ /* * Copyright (c) 2011 Claudio Jeker * diff --git a/usr.sbin/bgpctl/output.c b/usr.sbin/bgpctl/output.c index d50a62c7d..d9a5e5279 100644 --- a/usr.sbin/bgpctl/output.c +++ b/usr.sbin/bgpctl/output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output.c,v 1.41 2023/04/28 13:24:25 claudio Exp $ */ +/* $OpenBSD: output.c,v 1.42 2023/11/20 14:18:21 claudio Exp $ */ /* * Copyright (c) 2003 Henning Brauer @@ -1176,21 +1176,21 @@ show_rtr(struct ctl_show_rtr *rtr) if (rtr->local_addr.aid != AID_UNSPEC) printf(" Local Address: %s\n", log_addr(&rtr->local_addr)); if (rtr->session_id != -1) - printf (" Session ID: %d Serial #: %u\n", + printf(" Session ID: %d Serial #: %u\n", rtr->session_id, rtr->serial); printf(" Refresh: %u, Retry: %u, Expire: %u\n", rtr->refresh, rtr->retry, rtr->expire); if (rtr->last_sent_error != NO_ERROR) { printf(" Last sent error: %s\n", - log_rtr_error(rtr->last_sent_error)); + log_rtr_error(rtr->last_sent_error)); if (rtr->last_sent_msg[0]) printf(" with reason \"%s\"", log_reason(rtr->last_sent_msg)); } if (rtr->last_recv_error != NO_ERROR) { printf(" Last received error: %s\n", - log_rtr_error(rtr->last_recv_error)); + log_rtr_error(rtr->last_recv_error)); if (rtr->last_recv_msg[0]) printf(" with reason \"%s\"", log_reason(rtr->last_recv_msg)); diff --git a/usr.sbin/bgpctl/output_json.c b/usr.sbin/bgpctl/output_json.c index f1617a88a..cf0a476fe 100644 --- a/usr.sbin/bgpctl/output_json.c +++ b/usr.sbin/bgpctl/output_json.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output_json.c,v 1.35 2023/06/05 16:24:05 claudio Exp $ */ +/* $OpenBSD: output_json.c,v 1.36 2023/11/20 14:18:21 claudio Exp $ */ /* * Copyright (c) 2020 Claudio Jeker diff --git a/usr.sbin/bgpctl/output_ometric.c b/usr.sbin/bgpctl/output_ometric.c index 3648da22b..69f9494e6 100644 --- a/usr.sbin/bgpctl/output_ometric.c +++ b/usr.sbin/bgpctl/output_ometric.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output_ometric.c,v 1.11 2023/03/28 12:07:09 claudio Exp $ */ +/* $OpenBSD: output_ometric.c,v 1.12 2023/11/20 14:18:21 claudio Exp $ */ /* * Copyright (c) 2022 Claudio Jeker diff --git a/usr.sbin/bgpctl/parser.c b/usr.sbin/bgpctl/parser.c index ae9003fd7..56be82df7 100644 --- a/usr.sbin/bgpctl/parser.c +++ b/usr.sbin/bgpctl/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.133 2023/05/09 13:26:27 claudio Exp $ */ +/* $OpenBSD: parser.c,v 1.134 2023/11/20 14:18:21 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -329,8 +329,8 @@ static const struct token t_show_mrt_as[] = { static const struct token t_show_prefix[] = { { FLAG, "all", F_LONGER, t_show_rib}, { FLAG, "longer-prefixes", F_LONGER, t_show_rib}, - { FLAG, "or-longer", F_LONGER, t_show_rib}, - { FLAG, "or-shorter", F_SHORTER, t_show_rib}, + { FLAG, "or-longer", F_LONGER, t_show_rib}, + { FLAG, "or-shorter", F_SHORTER, t_show_rib}, { ANYTOKEN, "", NONE, t_show_rib}, { ENDTOKEN, "", NONE, NULL} }; diff --git a/usr.sbin/snmpd/snmpe.c b/usr.sbin/snmpd/snmpe.c index da12181df..121692985 100644 --- a/usr.sbin/snmpd/snmpe.c +++ b/usr.sbin/snmpd/snmpe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: snmpe.c,v 1.91 2023/11/12 19:59:56 martijn Exp $ */ +/* $OpenBSD: snmpe.c,v 1.92 2023/11/20 10:32:45 martijn Exp $ */ /* * Copyright (c) 2007, 2008, 2012 Reyk Floeter @@ -648,7 +648,6 @@ snmpe_writecb(int fd, short type, void *arg) msg->sm_datalen - reqlen); nmsg->sm_datalen = msg->sm_datalen - reqlen; snmp_msgfree(msg); - snmpe_prepare_read(nmsg, fd); snmpe_tryparse(fd, nmsg); } else { snmp_msgfree(msg);