From nobody Thu May 09 17:04:05 2024 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VZyz92S6Sz5K5k5; Thu, 09 May 2024 17:04:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VZyz91qnTz4R20; Thu, 9 May 2024 17:04:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715274245; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=sOYbM8Pkp9ZXPYzWwOo/6kBUZBlxTlUKOlwhHHOfX28=; b=i8gbZfuf5UCraMw6CUJyK23K2c9urLt2Tgd+lgnBBabAnDBsgrfRRVRrP0kfUavImfjYxv 11Ev8ED6YhgomMTtoSYY+9pXhDU2AkmgtF0MisRwh4EG1L118z8sxqHnNAi50UVgVuhgYY dfvK855Zs/T7Ie3bPvkENXXuG5A5/8Dptjlrl+MmPHpyVKUoFhFVcDuVsQg6rXWvTlBGK1 uJIBtI6BFYyq73ZyBwIbRYX77kZFedRpCTGQeAlduwVsh8eagq6rw7eG9nEjEVGse8+XBY UiQ6W+/kYiJJpbmbAqeNwdVuYjkdxVBgTQex0eJhOG1gHxZr+0A3dPUCR8UPfg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1715274245; a=rsa-sha256; cv=none; b=njzFSvK1m3Bbo7YTKnyTnwtqlxIJF/wN1lmzdfTSE/0kaiHXIS7voS/yLRWJvDKrRGXm+J yS3ctMtXJbutYNzZeuiy4TFJstq1pbd7Mx6+lqqg2iwmDN/BAW/8YvvriZzuNb060gImUZ xflvNXEp5StwEIFEyxTPyFq2F0qUlsg3+g9HcoylJFYZpYJVsWZVJUCoC7xiwIguHMPM0T PvXIkU8e/fA280ditE1tej+6MsoNI9qcBlDBOZUzhh9+Mb/3GtvGUwvNEOGTI3HzIZ1OQe Eym0DEDgvJk/6UGODlTcOJZnGW8cWN4lIo3FIMnAczcHxrJQhJlPB9kd/mfwsA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715274245; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=sOYbM8Pkp9ZXPYzWwOo/6kBUZBlxTlUKOlwhHHOfX28=; b=rYWGebCNO0LWNq1FOfXqoHEhCjS84foKKyVCW7IrAILWM4Cki+jsxnAE5+rhBC6HW0NLBg 8WegfBrnWadgo9gN3m4q7Yx5lnPvS3V83v2uDJGl9eF2rr6ky18vhEPgclybj1ljJwBm7C xP+TPWrhJ6dEfcBO6ezF/+GGGt0Krtpovb/3wuHsUTN0bmMyz4fOTVhqe7TAeLAflSDZ9t +IpEno4mHjUpCNZYUkl6iPBQZ7qwhxcCoXh+EEOKM+Ep6BMl/o+mXkLjNHi7y44eX8qf9D qrq1imYSiIEUTrU4Ujc41Cx6H2WVB393LAaV8ichXteJijhQjT2rSeBhoh4cPw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VZyz91RFyz1Gsy; Thu, 9 May 2024 17:04:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 449H45gm020826; Thu, 9 May 2024 17:04:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 449H45f1020823; Thu, 9 May 2024 17:04:05 GMT (envelope-from git) Date: Thu, 9 May 2024 17:04:05 GMT Message-Id: <202405091704.449H45f1020823@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Mark Johnston Subject: git: 26406929ca14 - main - net-mgmt/net-snmp: Fix the IPV6 MIB implementation List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-ports-main@freebsd.org Sender: owner-dev-commits-ports-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 26406929ca14b616c3de4242d1a7cde0a57ee521 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/ports/commit/?id=26406929ca14b616c3de4242d1a7cde0a57ee521 commit 26406929ca14b616c3de4242d1a7cde0a57ee521 Author: Mark Johnston AuthorDate: 2024-04-30 16:25:11 +0000 Commit: Mark Johnston CommitDate: 2024-05-09 16:41:22 +0000 net-mgmt/net-snmp: Fix the IPV6 MIB implementation The implementations of var_tcp6() and var_udp6() on FreeBSD don't work and fail to compile. var_tcp6() also makes uses of kmem access, which I'm trying to disable in snmpd. Provide a patch to fix these problems. This has been committed to the 5.9 branch upstream. Readd mibII/ipv6 since it now compiles and works in my manual testing. Also, simply remove the IPV6 option. It has no effect, as --enable-ipv6 is the default. Approved by: zi Sponsored by: Klara, Inc. Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D45030 --- net-mgmt/net-snmp/Makefile | 16 +-- .../files/patch-agent_mibgroup_mibII_ipv6.c | 127 +++++++++++++++++++++ 2 files changed, 129 insertions(+), 14 deletions(-) diff --git a/net-mgmt/net-snmp/Makefile b/net-mgmt/net-snmp/Makefile index 9909de70e05f..71ad983bf18d 100644 --- a/net-mgmt/net-snmp/Makefile +++ b/net-mgmt/net-snmp/Makefile @@ -17,7 +17,7 @@ LICENSE_FILE= ${WRKSRC}/COPYING NOT_FOR_ARCHS= mips mips64 NOT_FOR_ARCHS_REASON= SSP is currently broken on MIPS -OPTIONS_DEFINE= IPV6 MFD_REWRITES PERL PERL_EMBEDDED PYTHON DUMMY TKMIB \ +OPTIONS_DEFINE= MFD_REWRITES PERL PERL_EMBEDDED PYTHON DUMMY TKMIB \ MYSQL AX_SOCKONLY UNPRIVILEGED SMUX DOCS JAIL AX_DISABLE_TRAP \ TLS NEWSYSLOG NOLIBPKG SCTP OPTIONS_DEFAULT=PERL PERL_EMBEDDED DUMMY SMUX NEWSYSLOG @@ -54,7 +54,7 @@ CONFIGURE_ARGS+=--enable-shared --enable-internal-md5 \ --with-sys-location="${NET_SNMP_SYS_LOCATION}" \ --with-logfile="${NET_SNMP_LOGFILE}" \ --with-persistent-directory="${NET_SNMP_PERSISTENTDIR}" \ - --with-gnu-ld --without-libwrap \ + --with-gnu-ld --without-libwrap --enable-ipv6 \ --with-ldflags="-lm -lkvm -ldevstat -L${PKG_PREFIX}/lib -L${LOCALBASE}/lib ${LCRYPTO}" SUB_FILES= pkg-message @@ -129,14 +129,6 @@ CONFIGURE_ARGS+=--disable-snmptrapd-subagent CONFIGURE_ARGS+=--enable-agentx-dom-sock-only .endif -.if ${PORT_OPTIONS:MIPV6} -CONFIGURE_ARGS+=--enable-ipv6 -# --with-transport="UDPIPv6 TCPIPv6" --with-modules=mibII/ipv6" -PLIST_SUB+= WITH_IPV6="" -.else -PLIST_SUB+= WITH_IPV6="@comment " -.endif - .if ${PORT_OPTIONS:MUNPRIVILEGED} CONFIGURE_ARGS+=--without-root-access .endif @@ -153,10 +145,6 @@ NET_SNMP_LOGFILE?= /var/log/snmpd.log NET_SNMP_PERSISTENTDIR?=/var/net-snmp NET_SNMP_WITH_MIB_MODULE_LIST+= host disman/event-mib mibII/mta_sendmail mibII/tcpTable ucd-snmp/diskio -.if ${OPSYS} == FreeBSD -NET_SNMP_WITHOUT_MIB_MODULE_LIST+= mibII/ipv6 -.endif - .if ${PORT_OPTIONS:MSCTP} NET_SNMP_WITH_MIB_MODULE_LIST+= sctp-mib .endif diff --git a/net-mgmt/net-snmp/files/patch-agent_mibgroup_mibII_ipv6.c b/net-mgmt/net-snmp/files/patch-agent_mibgroup_mibII_ipv6.c new file mode 100644 index 000000000000..ad4ea51fe56a --- /dev/null +++ b/net-mgmt/net-snmp/files/patch-agent_mibgroup_mibII_ipv6.c @@ -0,0 +1,127 @@ +--- agent/mibgroup/mibII/ipv6.c.orig 2023-08-15 20:32:01 UTC ++++ agent/mibgroup/mibII/ipv6.c +@@ -5,9 +5,6 @@ + + #include + #include +-/* For FreeBSD */ +-#define _WANT_INPCB 1 +-#define _WANT_TCPCB 1 + #include + #include + #ifdef HAVE_SYS_IOCTL_H +@@ -1513,8 +1510,10 @@ var_udp6(register struct variable * vp, + int result; + int i, j; + caddr_t p; +-#if defined(openbsd4) || defined(freebsd3) ++#if defined(openbsd4) + static struct inpcb in6pcb, savpcb; ++#elif defined(freebsd3) ++ static struct xinpcb in6pcb, savpcb; + #else + static struct in6pcb in6pcb, savpcb; + #endif +@@ -1614,8 +1613,7 @@ var_udp6(register struct variable * vp, + DEBUGMSGTL(("mibII/ipv6", "looping: p=%p\n", p)); + + #if defined(freebsd3) +- /* To do: fill in in6pcb properly. */ +- memset(&in6pcb, 0, sizeof(in6pcb)); ++ in6pcb = *(struct xinpcb *) xig; + #elif defined(darwin) + in6pcb = ((struct xinpcb *) xig)->xi_inp; + #else +@@ -2108,12 +2106,18 @@ var_tcp6(register struct variable * vp, + int result; + int i, j; + caddr_t p; +-#if defined(openbsd4) || defined(freebsd3) ++#if defined(openbsd4) + static struct inpcb in6pcb, savpcb; ++#elif defined(freebsd3) ++ static struct xinpcb in6pcb; ++ static int savstate; + #else + static struct in6pcb in6pcb, savpcb; + #endif ++#if !defined(freebsd3) + struct tcpcb tcpcb; ++#endif ++ int state; + int found, savnameLen; + #if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000 || defined(openbsd4) /*1.6Y*/ + struct inpcbtable tcbtable; +@@ -2208,8 +2212,7 @@ var_tcp6(register struct variable * vp, + DEBUGMSGTL(("mibII/ipv6", "looping: p=%p\n", p)); + + #if defined(freebsd3) +- /* To do: fill in in6pcb properly. */ +- memset(&in6pcb, 0, sizeof(in6pcb)); ++ in6pcb = ((struct xtcpcb *) xig)->xt_inp; + #elif defined(dragonfly) + in6pcb = xtp->xt_inp; + #elif defined(darwin) +@@ -2294,7 +2297,11 @@ var_tcp6(register struct variable * vp, + #endif + result = snmp_oid_compare(name, *length, newname, j); + if (exact && (result == 0)) { ++#if defined(freebsd3) ++ savstate = ((struct xtcpcb *) xig)->t_state; ++#else + memcpy(&savpcb, &in6pcb, sizeof(savpcb)); ++#endif + savnameLen = j; + memcpy(savname, newname, j * sizeof(oid)); + found++; +@@ -2305,7 +2312,11 @@ var_tcp6(register struct variable * vp, + */ + if ((savnameLen == 0) || + (snmp_oid_compare(savname, savnameLen, newname, j) > 0)) { ++#if defined(freebsd3) ++ savstate = ((struct xtcpcb *) xig)->t_state; ++#else + memcpy(&savpcb, &in6pcb, sizeof(savpcb)); ++#endif + savnameLen = j; + memcpy(savname, newname, j * sizeof(oid)); + found++; +@@ -2344,19 +2355,27 @@ var_tcp6(register struct variable * vp, + return NULL; + *length = savnameLen; + memcpy((char *) name, (char *) savname, *length * sizeof(oid)); ++#if defined(freebsd3) ++ state = savstate; ++#elif defined(__NetBSD__) && __NetBSD_Version__ >= 999010400 + memcpy(&in6pcb, &savpcb, sizeof(savpcb)); +-#if defined(__NetBSD__) && __NetBSD_Version__ >= 999010400 + if (!NETSNMP_KLOOKUP(in6pcb.in6p_pcb.inp_ppcb, (char *) &tcpcb, sizeof(tcpcb))) { + DEBUGMSGTL(("mibII/ipv6", "klookup fail for tcb6.tcpcb at %p\n", + in6pcb.in6p_pcb.inp_ppcb)); ++ found = 0; ++ return NULL; ++ } ++ state = (int)tcpcb.t_state; + #else ++ memcpy(&in6pcb, &savpcb, sizeof(savpcb)); + if (!NETSNMP_KLOOKUP(in6pcb.inp_ppcb, (char *) &tcpcb, sizeof(tcpcb))) { + DEBUGMSGTL(("mibII/ipv6", "klookup fail for tcb6.tcpcb at %p\n", + in6pcb.inp_ppcb)); +-#endif + found = 0; + return NULL; + } ++ state = (int)tcpcb.t_state; ++#endif + *write_method = 0; + *var_len = sizeof(long); /* default to 'long' results */ + +@@ -2368,7 +2387,7 @@ var_tcp6(register struct variable * vp, + DEBUGMSGTL(("mibII/ipv6", "magic=%d\n", vp->magic)); + switch (vp->magic) { + case IPV6TCPCONNSTATE: +- long_return = mapTcpState((int)tcpcb.t_state); ++ long_return = mapTcpState(state); + return (u_char *) & long_return; + default: + break;