diff --git a/net-mgmt/net-snmp/Makefile b/net-mgmt/net-snmp/Makefile --- a/net-mgmt/net-snmp/Makefile +++ b/net-mgmt/net-snmp/Makefile @@ -17,7 +17,7 @@ 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 @@ --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+=--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_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 --- /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;