FreeBSD Bugzilla – Attachment 147917 Details for
Bug 194096
[patch] net-mgmt/netxms switch to libc API instead of nosing in kernel memory via kvm(3)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
the patch
netxms-port.diff (text/plain), 10.20 KB, created by
Gleb Smirnoff
on 2014-10-02 16:03:22 UTC
(
hide
)
Description:
the patch
Filename:
MIME Type:
Creator:
Gleb Smirnoff
Created:
2014-10-02 16:03:22 UTC
Size:
10.20 KB
patch
obsolete
>Index: Makefile >=================================================================== >--- Makefile (revision 369818) >+++ Makefile (working copy) >@@ -3,7 +3,7 @@ > > PORTNAME= netxms > PORTVERSION= 1.2.14 >-PORTREVISION= 1 >+PORTREVISION= 2 > CATEGORIES= net-mgmt > MASTER_SITES= http://www.netxms.org/download/ \ > http://www.netxms.org/download/archive/ >Index: files/patch-src-agent-subagents-freebsd-freebsd.cpp >=================================================================== >--- files/patch-src-agent-subagents-freebsd-freebsd.cpp (revision 0) >+++ files/patch-src-agent-subagents-freebsd-freebsd.cpp (working copy) >@@ -0,0 +1,23 @@ >+--- src/agent/subagents/freebsd/freebsd.cpp.orig 2014-10-02 16:57:50.000000000 +0400 >++++ src/agent/subagents/freebsd/freebsd.cpp 2014-10-02 16:58:48.000000000 +0400 >+@@ -48,14 +48,14 @@ >+ { _T("FileSystem.UsedPerc(*)"), H_DiskInfo, (const TCHAR *)DISK_USED_PERC, DCI_DT_FLOAT, DCIDESC_FS_USEDPERC }, >+ >+ { _T("Net.Interface.AdminStatus(*)"), H_NetIfAdmStatus, NULL, DCI_DT_INT, DCIDESC_NET_INTERFACE_ADMINSTATUS }, >+- { _T("Net.Interface.BytesIn(*)"), H_NetIfInfoFromKVM, (const TCHAR *)IF_INFO_BYTES_IN, DCI_DT_UINT64, DCIDESC_NET_INTERFACE_BYTESIN }, >+- { _T("Net.Interface.BytesOut(*)"), H_NetIfInfoFromKVM, (const TCHAR *)IF_INFO_BYTES_OUT, DCI_DT_UINT64, DCIDESC_NET_INTERFACE_BYTESOUT }, >+- { _T("Net.Interface.InErrors(*)"), H_NetIfInfoFromKVM, (const TCHAR *)IF_INFO_IN_ERRORS, DCI_DT_UINT64, DCIDESC_NET_INTERFACE_INERRORS }, >++ { _T("Net.Interface.BytesIn(*)"), H_NetIfInfo, (const TCHAR *)IF_INFO_BYTES_IN, DCI_DT_UINT64, DCIDESC_NET_INTERFACE_BYTESIN }, >++ { _T("Net.Interface.BytesOut(*)"), H_NetIfInfo, (const TCHAR *)IF_INFO_BYTES_OUT, DCI_DT_UINT64, DCIDESC_NET_INTERFACE_BYTESOUT }, >++ { _T("Net.Interface.InErrors(*)"), H_NetIfInfo, (const TCHAR *)IF_INFO_IN_ERRORS, DCI_DT_UINT64, DCIDESC_NET_INTERFACE_INERRORS }, >+ { _T("Net.Interface.Link(*)"), H_NetIfLink, NULL, DCI_DT_DEPRECATED, DCIDESC_DEPRECATED }, >+ { _T("Net.Interface.OperStatus(*)"), H_NetIfLink, NULL, DCI_DT_INT, DCIDESC_NET_INTERFACE_OPERSTATUS }, >+- { _T("Net.Interface.OutErrors(*)"), H_NetIfInfoFromKVM, (const TCHAR *)IF_INFO_OUT_ERRORS, DCI_DT_UINT64, DCIDESC_NET_INTERFACE_OUTERRORS }, >+- { _T("Net.Interface.PacketsIn(*)"), H_NetIfInfoFromKVM, (const TCHAR *)IF_INFO_PACKETS_IN, DCI_DT_UINT64, DCIDESC_NET_INTERFACE_PACKETSIN }, >+- { _T("Net.Interface.PacketsOut(*)"), H_NetIfInfoFromKVM, (const TCHAR *)IF_INFO_PACKETS_OUT, DCI_DT_UINT64, DCIDESC_NET_INTERFACE_PACKETSOUT }, >++ { _T("Net.Interface.OutErrors(*)"), H_NetIfInfo, (const TCHAR *)IF_INFO_OUT_ERRORS, DCI_DT_UINT64, DCIDESC_NET_INTERFACE_OUTERRORS }, >++ { _T("Net.Interface.PacketsIn(*)"), H_NetIfInfo, (const TCHAR *)IF_INFO_PACKETS_IN, DCI_DT_UINT64, DCIDESC_NET_INTERFACE_PACKETSIN }, >++ { _T("Net.Interface.PacketsOut(*)"), H_NetIfInfo, (const TCHAR *)IF_INFO_PACKETS_OUT, DCI_DT_UINT64, DCIDESC_NET_INTERFACE_PACKETSOUT }, >+ { _T("Net.IP.Forwarding"), H_NetIpForwarding, (const TCHAR *)4, DCI_DT_INT, DCIDESC_NET_IP_FORWARDING }, >+ { _T("Net.IP6.Forwarding"), H_NetIpForwarding, (const TCHAR *)6, DCI_DT_INT, DCIDESC_NET_IP6_FORWARDING }, >+ > >Property changes on: files/patch-src-agent-subagents-freebsd-freebsd.cpp >___________________________________________________________________ >Added: fbsd:nokeywords >## -0,0 +1 ## >+yes >\ No newline at end of property >Added: svn:eol-style >## -0,0 +1 ## >+native >\ No newline at end of property >Added: svn:mime-type >## -0,0 +1 ## >+text/plain >\ No newline at end of property >Added: svn:keywords >## -0,0 +1 ## >+FreeBSD=%H >\ No newline at end of property >Index: files/patch-src-agent-subagents-freebsd-net.cpp >=================================================================== >--- files/patch-src-agent-subagents-freebsd-net.cpp (revision 0) >+++ files/patch-src-agent-subagents-freebsd-net.cpp (working copy) >@@ -0,0 +1,181 @@ >+--- src/agent/subagents/freebsd/net.cpp.orig 2014-10-02 16:54:48.000000000 +0400 >++++ src/agent/subagents/freebsd/net.cpp 2014-10-02 17:19:53.000000000 +0400 >+@@ -32,7 +32,6 @@ >+ #include <net/if_media.h> >+ #include <net/if_dl.h> >+ #include <net/if_types.h> >+-#include <net/if_var.h> >+ #include <net/route.h> >+ #include <net/iso88025.h> >+ #include <netinet/if_ether.h> >+@@ -40,8 +39,7 @@ >+ #include <ifaddrs.h> >+ #include <arpa/inet.h> >+ #include <net/ethernet.h> >+-#include <kvm.h> >+-#include <nlist.h> >++#include <ifaddrs.h> >+ >+ #include "net.h" >+ >+@@ -60,14 +58,6 @@ >+ int index; >+ } IFLIST; >+ >+-struct nlist nl[] = { >+-#define N_IFNET 0 >+- { (char *)"_ifnet" }, >+- { NULL }, >+-}; >+- >+-kvm_t *kvmd = NULL; >+- >+ LONG H_NetIpForwarding(const TCHAR *pszParam, const TCHAR *pArg, TCHAR *pValue) >+ { >+ int nVer = CAST_FROM_POINTER(pArg, int); >+@@ -568,94 +558,66 @@ >+ return nRet; >+ } >+ >+-LONG H_NetIfInfoFromKVM(const TCHAR *pszParam, const TCHAR *pArg, TCHAR *pValue) >++LONG H_NetIfInfo(const TCHAR *pszParam, const TCHAR *pArg, TCHAR *pValue) >+ { >+- int nRet = SYSINFO_RC_SUCCESS; >+ char szArg[512]; >+- u_long ifnetaddr; >+- struct ifnet ifnet; >+- struct ifnethead ifnethead; >+-#if __FreeBSD__ < 5 >+- char szTName[IFNAMSIZ]; >+-#endif >+- char szName[IFNAMSIZ]; >++ struct ifaddrs *ifap, *ifa; >++ u_int index; >+ >+ AgentGetParameterArgA(pszParam, 1, szArg, sizeof(szArg)); >+ >+- if (szArg[0] != 0) >++ if (szArg[0] == 0) >++ return SYSINFO_RC_SUCCESS; >++ >++ if (szArg[0] >= '0' && szArg[0] <= '9') >++ index = atoi(szArg); >++ else >++ index = 0; >++ >++ if (getifaddrs(&ifap) != 0) >+ { >+- if (szArg[0] >= '0' && szArg[0] <= '9') >+- { >+- // index >+- if (if_indextoname(atoi(szArg), szArg) != szArg) >+- { >+- // not found >+- nRet = SYSINFO_RC_ERROR; >+- } >+- } >++ return SYSINFO_RC_ERROR; >++ } >+ >+- if (nRet == SYSINFO_RC_SUCCESS) >+- { >+- nRet = SYSINFO_RC_ERROR; >++ for (ifa = ifap; ifa; ifa = ifa->ifa_next) { >++ if (ifa->ifa_addr->sa_family != AF_LINK) >++ continue; >++ if (index) { >++ if (index != if_nametoindex(ifa->ifa_name)) >++ continue; >++ } else if (strcmp(ifa->ifa_name, szArg) != 0) >++ continue; >+ >+- if (kvmd == NULL) { >+- kvmd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, NULL); >+- if (kvmd == NULL) >+- return SYSINFO_RC_ERROR; >+- if (kvm_nlist(kvmd, nl) < 0) >+- return SYSINFO_RC_ERROR; >+- if (nl[0].n_type == 0) >+- return SYSINFO_RC_ERROR; >+- } >+- ifnetaddr = nl[N_IFNET].n_value; >+- if (kvm_read(kvmd, ifnetaddr, &ifnethead, sizeof(ifnethead)) != sizeof(ifnethead)) >+- return SYSINFO_RC_ERROR; >+- ifnetaddr = (u_long)TAILQ_FIRST(&ifnethead); >+- while (ifnetaddr) { >+- if (kvm_read(kvmd, ifnetaddr, &ifnet, sizeof(ifnet)) != sizeof(ifnet)) >+- return SYSINFO_RC_ERROR; >+- ifnetaddr = (u_long)TAILQ_NEXT(&ifnet, if_link); >+-#if __FreeBSD__ >= 5 >+- strlcpy(szName, ifnet.if_xname, sizeof(szName)); >+-#else >+- if (kvm_read(kvmd, ifnet.if_name, szTName, sizeof(szTName)) != sizeof(szTName)) >+- return SYSINFO_RC_ERROR; >+- szTName[sizeof(szTName) - 1] = '\0'; >+- snprintf(szName, sizeof(szName), "%s%d", szTName, ifnet.if_unit); >+-#endif >+- if (strcmp(szName, szArg) == 0) { >+- nRet = SYSINFO_RC_SUCCESS; >+- switch((long)pArg) >+- { >+- case IF_INFO_BYTES_IN: >+- ret_uint(pValue, ifnet.if_ibytes); >+- break; >+- case IF_INFO_BYTES_OUT: >+- ret_uint(pValue, ifnet.if_obytes); >+- break; >+- case IF_INFO_IN_ERRORS: >+- ret_uint(pValue, ifnet.if_ierrors); >+- break; >+- case IF_INFO_OUT_ERRORS: >+- ret_uint(pValue, ifnet.if_oerrors); >+- break; >+- case IF_INFO_PACKETS_IN: >+- ret_uint(pValue, ifnet.if_ipackets); >+- break; >+- case IF_INFO_PACKETS_OUT: >+- ret_uint(pValue, ifnet.if_opackets); >+- break; >+- default: >+- nRet = SYSINFO_RC_UNSUPPORTED; >+- break; >+- } >+- break; >+- } >+- else >+- continue; >+- } >++#define IFA_STAT(s) (((struct if_data *)ifa->ifa_data)->ifi_ ## s) >++ >++ switch((long)pArg) >++ { >++ case IF_INFO_BYTES_IN: >++ ret_uint(pValue, IFA_STAT(ibytes)); >++ break; >++ case IF_INFO_BYTES_OUT: >++ ret_uint(pValue, IFA_STAT(obytes)); >++ break; >++ case IF_INFO_IN_ERRORS: >++ ret_uint(pValue, IFA_STAT(ierrors)); >++ break; >++ case IF_INFO_OUT_ERRORS: >++ ret_uint(pValue, IFA_STAT(oerrors)); >++ break; >++ case IF_INFO_PACKETS_IN: >++ ret_uint(pValue, IFA_STAT(ipackets)); >++ break; >++ case IF_INFO_PACKETS_OUT: >++ ret_uint(pValue, IFA_STAT(opackets)); >++ break; >++ default: >++ freeifaddrs(ifap); >++ return SYSINFO_RC_UNSUPPORTED; >+ } >++ freeifaddrs(ifap); >++ return SYSINFO_RC_SUCCESS; >+ } >+ >+- return nRet; >++ freeifaddrs(ifap); >++ return SYSINFO_RC_ERROR; >+ } > >Property changes on: files/patch-src-agent-subagents-freebsd-net.cpp >___________________________________________________________________ >Added: fbsd:nokeywords >## -0,0 +1 ## >+yes >\ No newline at end of property >Added: svn:eol-style >## -0,0 +1 ## >+native >\ No newline at end of property >Added: svn:mime-type >## -0,0 +1 ## >+text/plain >\ No newline at end of property >Added: svn:keywords >## -0,0 +1 ## >+FreeBSD=%H >\ No newline at end of property >Index: files/patch-src-agent-subagents-freebsd-net.h >=================================================================== >--- files/patch-src-agent-subagents-freebsd-net.h (revision 0) >+++ files/patch-src-agent-subagents-freebsd-net.h (working copy) >@@ -0,0 +1,10 @@ >+--- src/agent/subagents/freebsd/net.h.orig 2014-10-02 16:59:04.000000000 +0400 >++++ src/agent/subagents/freebsd/net.h 2014-10-02 16:59:10.000000000 +0400 >+@@ -39,6 +39,6 @@ >+ LONG H_NetArpCache(const TCHAR *, const TCHAR *, StringList *); >+ LONG H_NetIfList(const TCHAR *, const TCHAR *, StringList *); >+ LONG H_NetRoutingTable(const TCHAR *, const TCHAR *, StringList *); >+-LONG H_NetIfInfoFromKVM(const TCHAR *, const TCHAR *, TCHAR *); >++LONG H_NetIfInfo(const TCHAR *, const TCHAR *, TCHAR *); >+ >+ #endif // __NET_H__ > >Property changes on: files/patch-src-agent-subagents-freebsd-net.h >___________________________________________________________________ >Added: svn:mime-type >## -0,0 +1 ## >+text/plain >\ No newline at end of property >Added: svn:keywords >## -0,0 +1 ## >+FreeBSD=%H >\ No newline at end of property >Added: fbsd:nokeywords >## -0,0 +1 ## >+yes >\ No newline at end of property >Added: svn:eol-style >## -0,0 +1 ## >+native >\ No newline at end of property
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 194096
: 147917 |
148020