net-snmp: fix failure when starting on system without pci bus
PATCH v3 1/3 net-snmp: fix failure when starting on system without pci bus
From: Jack Mitchell <[email protected]>
The snmpd daemon cannot start on platforms without a pci bus:
snmpd[15460]: pcilib: Cannot open /proc/bus/pci snmpd[15460]: pcilib: Cannot find any working access method.
snmpd should not depend on a PCI bus and should simply move on.
--- .../recipes-extended/net-snmp/files/ifmib.patch | 66 ++++++++++++++++++++++ .../recipes-extended/net-snmp/net-snmp_5.7.1.bb | 1 + 2 files changed, 67 insertions(+) create mode 100644 meta-oe/recipes-extended/net-snmp/files/ifmib.patch
meta-oe/recipes-extended/net-snmp/files/ifmib.patch new file +66 -0
@@ -0,0 +1,66 @@ +Signed-off-by: Jack Mitchell <[email protected]> +Upstream-Status: Pending +Bug-Report: http://sourceforge.net/p/net-snmp/bugs/2449/ + +diff --git a/agent/mibgroup/if-mib/data_access/interface_linux.c b/agent/mibgroup/if-mib/data_access/interface_linux.c +index 3419811..d6eb91a 100644 +--- a/agent/mibgroup/if-mib/data_access/interface_linux.c ++++ b/agent/mibgroup/if-mib/data_access/interface_linux.c +@@ -18,7 +18,31 @@ netsnmp_feature_require(interface_ioctl_flags_set) + + #ifdef HAVE_PCI_LOOKUP_NAME + #include <pci/pci.h> ++#include <setjmp.h> + static struct pci_access *pci_access; ++ ++/* Avoid letting libpci call exit(1) when no PCI bus is available. */ ++static int do_longjmp =0; ++static jmp_buf err_buf; ++static void ++netsnmp_pci_error(char *msg, ...) ++{ ++ va_list args; ++ char *buf; ++ int buflen; ++ ++ va_start(args, msg); ++ buflen = strlen("pcilib: ")+strlen(msg)+2; ++ buf = malloc(buflen); ++ snprintf(buf, buflen, "pcilib: %s\n", msg); ++ snmp_vlog(LOG_ERR, buf, args); ++ free(buf); ++ va_end(args); ++ if (do_longjmp) ++ longjmp(err_buf, 1); ++ else ++ exit(1); ++} + #endif + + #ifdef HAVE_LINUX_ETHTOOL_H +@@ -147,10 +171,22 @@ netsnmp_arch_interface_init(void) + + #ifdef HAVE_PCI_LOOKUP_NAME + pci_access = pci_alloc(); +- if (pci_access) ++ if (!pci_access) { ++ snmp_log(LOG_ERR, "pcilib: pci_alloc failed\n"); ++ return; ++ } ++ ++ pci_access->error = netsnmp_pci_error; ++ ++ do_longjmp = 1; ++ if (setjmp(err_buf)) { ++ pci_cleanup(pci_access); ++ snmp_log(LOG_ERR, "pcilib: pci_init failed\n"); ++ pci_access = NULL; ++ } ++ else if (pci_access) + pci_init(pci_access); +- else +- snmp_log(LOG_ERR, "Unable to create pci access method\n"); ++ do_longjmp = 0; + #endif + } +
meta-oe/recipes-extended/net-snmp/net-snmp_5.7.1.bb +1 -0
@@ -12,6 +12,7 @@ SRC_URI = "${SOURCEFORGE_MIRROR}/net-snmp/net-snmp-${PV}.tar.gz \ file://systemd-support.patch \ file://snmpd.service \ file://snmptrapd.service \ + file://ifmib.patch \ " EXTRA_OECONF += "--disable-embedded-perl --with-perl-modules=no"
Signature · 1 line
1.8.2
PATCH v3 2/3 net-snmp: Update to 5.7.2
From: Jack Mitchell <[email protected]>
- Removed some un-needed patches
---
.../net-snmp/files/libnl-3-support.patch | 69 -
.../net-snmp/files/sync-with-5.7-branch.patch | 19998 -------------------
.../{net-snmp_5.7.1.bb => net-snmp_5.7.2.bb} | 9 +-
3 files changed, 4 insertions(+), 20072 deletions(-)
delete mode 100644 meta-oe/recipes-extended/net-snmp/files/libnl-3-support.patch
delete mode 100644 meta-oe/recipes-extended/net-snmp/files/sync-with-5.7-branch.patch
rename meta-oe/recipes-extended/net-snmp/{net-snmp_5.7.1.bb => net-snmp_5.7.2.bb} (76%)meta-oe/recipes-extended/net-snmp/files/libnl-3-support.patch deleted +0 -69
@@ -1,69 +0,0 @@ -Add support to libnl-3 - -Upstream-Status: Pending - ---- net-snmp-5.6.1/agent/mibgroup/mibII/tcpTable.c.org 2011-03-27 22:39:13.428728506 +0200 -+++ net-snmp-5.6.1/agent/mibgroup/mibII/tcpTable.c 2011-03-27 22:39:47.606956561 +0200 -@@ -555,8 +555,9 @@ - static int - tcpTable_load_netlink(void) - { -+ int err; - /* TODO: perhaps use permanent nl handle? */ -- struct nl_handle *nl = nl_handle_alloc(); -+ struct nl_sock *nl = nl_socket_alloc(); - - if (nl == NULL) { - DEBUGMSGTL(("mibII/tcpTable", "Failed to allocate netlink handle\n")); -@@ -564,10 +565,10 @@ - return -1; - } - -- if (nl_connect(nl, NETLINK_INET_DIAG) < 0) { -- DEBUGMSGTL(("mibII/tcpTable", "Failed to connect to netlink: %s\n", nl_geterror())); -- snmp_log(LOG_ERR, "snmpd: Couldn't connect to netlink: %s\n", nl_geterror()); -- nl_handle_destroy(nl); -+ if ((err = nl_connect(nl, NETLINK_INET_DIAG)) < 0) { -+ DEBUGMSGTL(("mibII/tcpTable", "Failed to connect to netlink: %s\n", nl_geterror(err))); -+ snmp_log(LOG_ERR, "snmpd: Couldn't connect to netlink: %s\n", nl_geterror(err)); -+ nl_socket_free(nl); - return -1; - } - -@@ -579,10 +580,10 @@ - struct nl_msg *nm = nlmsg_alloc_simple(TCPDIAG_GETSOCK, NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST); - nlmsg_append(nm, &req, sizeof(struct inet_diag_req), 0); - -- if (nl_send_auto_complete(nl, nm) < 0) { -- DEBUGMSGTL(("mibII/tcpTable", "nl_send_autocomplete(): %s\n", nl_geterror())); -- snmp_log(LOG_ERR, "snmpd: nl_send_autocomplete(): %s\n", nl_geterror()); -- nl_handle_destroy(nl); -+ if ((err = nl_send_auto_complete(nl, nm)) < 0) { -+ DEBUGMSGTL(("mibII/tcpTable", "nl_send_autocomplete(): %s\n", nl_geterror(err))); -+ snmp_log(LOG_ERR, "snmpd: nl_send_autocomplete(): %s\n", nl_geterror(err)); -+ nl_socket_free(nl); - return -1; - } - nlmsg_free(nm); -@@ -593,9 +594,9 @@ - - while (running) { - if ((len = nl_recv(nl, &peer, &buf, NULL)) <= 0) { -- DEBUGMSGTL(("mibII/tcpTable", "nl_recv(): %s\n", nl_geterror())); -- snmp_log(LOG_ERR, "snmpd: nl_recv(): %s\n", nl_geterror()); -- nl_handle_destroy(nl); -+ DEBUGMSGTL(("mibII/tcpTable", "nl_recv(): %s\n", nl_geterror(len))); -+ snmp_log(LOG_ERR, "snmpd: nl_recv(): %s\n", nl_geterror(len)); -+ nl_socket_free(nl); - return -1; - } - -@@ -644,7 +645,7 @@ - free(buf); - } - -- nl_handle_destroy(nl); -+ nl_socket_free(nl); - - if (tcp_head) { - DEBUGMSGTL(("mibII/tcpTable", "Loaded TCP Table using netlink\n"));
meta-oe/recipes-extended/net-snmp/files/sync-with-5.7-branch.patch deleted +0 -19998
2,931 lines not on this page · raw message
meta-oe/recipes-extended/net-snmp/net-snmp_5.7.2.bb renamed from meta-oe/recipes-extended/net-snmp/net-snmp_5.7.1.bb +4 -5
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.8.2
Part of the diff is not shown here. View the raw message.
PATCH v3 3/3 net-snmp: merge .inc into .bb and clean up obsolete parts of recipe
In reply to Jack MitchellFrom: Jack Mitchell <[email protected]>
--- meta-oe/recipes-extended/net-snmp/net-snmp.inc | 95 ----------------- .../recipes-extended/net-snmp/net-snmp_5.7.2.bb | 112 ++++++++++++++++++--- 2 files changed, 98 insertions(+), 109 deletions(-) delete mode 100644 meta-oe/recipes-extended/net-snmp/net-snmp.inc
meta-oe/recipes-extended/net-snmp/net-snmp.inc deleted +0 -95
@@ -1,95 +0,0 @@ -DESCRIPTION = "Various tools relating to the Simple Network Management Protocol" -HOMEPAGE = "http://www.net-snmp.org/" -LICENSE = "BSD" - -DEPENDS = "openssl libnl pciutils" -RDEPENDS_${PN}-server-snmpd += "net-snmp-mibs" -RDEPENDS_${PN}-server-snmptrapd += "net-snmp-server-snmpd" -RDEPENDS_${PN}-server += "net-snmp-server-snmpd net-snmp-server-snmptrapd" -RDEPENDS_${PN}-client += "net-snmp-mibs" -RDEPENDS_${PN}-dev = "net-snmp-client (= ${EXTENDPKGV}) net-snmp-server (= ${EXTENDPKGV})" -RRECOMMENDS_${PN}-dbg = "net-snmp-client (= ${EXTENDPKGV}) net-snmp-server (= ${EXTENDPKGV})" -INC_PR = "r6" - -inherit autotools update-rc.d siteinfo systemd - -TARGET_CC_ARCH += "${LDFLAGS}" - -EXTRA_OECONF = "--enable-shared --disable-manuals --with-defaults \ -${@base_conditional('SITEINFO_ENDIANNESS', 'le', '--with-endianness=little', '--with-endianness=big', d)}" - -do_install () { - oe_runmake install -} - -do_install_append() { - install -d ${D}${sysconfdir}/snmp - install -d ${D}${sysconfdir}/init.d - install -m 755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/snmpd - install -m 644 ${WORKDIR}/snmpd.conf ${D}${sysconfdir}/snmp/ - install -m 644 ${WORKDIR}/snmptrapd.conf ${D}${sysconfdir}/snmp/ - install -d ${STAGING_BINDIR} - install -m 0755 ${D}${bindir}/net-snmp-config ${STAGING_BINDIR}/ - sed -e "s@-I/usr/include@@g" \ - -e "s@^prefix=.*@prefix=${STAGING_DIR_HOST}@g" \ - -e "s@^exec_prefix=.*@exec_prefix=${STAGING_DIR_HOST}@g" \ - -e "s@^includedir=.*@includedir=${STAGING_INCDIR}@g" \ - -e "s@^libdir=.*@libdir=${STAGING_LIBDIR}@g" \ - -i ${STAGING_BINDIR}/net-snmp-config - install -d ${D}${systemd_unitdir}/system - install -m 0644 ${WORKDIR}/snmpd.service ${D}${systemd_unitdir}/system - install -m 0644 ${WORKDIR}/snmptrapd.service ${D}${systemd_unitdir}/system -} - -PACKAGES = "${PN}-dbg ${PN}-doc ${PN}-dev ${PN}-staticdev ${PN}-static ${PN}-libs \ - ${PN}-mibs ${PN}-server ${PN}-client ${PN}-server-snmpd ${PN}-server-snmptrapd" - -ALLOW_EMPTY_${PN}-server = "1" -FILES_${PN}-libs = "${libdir}/lib*${SOLIBS}" -FILES_${PN}-mibs = "${datadir}/snmp/mibs" -FILES_${PN}-server-snmpd = "${sbindir}/snmpd \ - ${sysconfdir}/snmp/snmpd.conf \ - ${sysconfdir}/init.d \ - ${systemd_unitdir}/system/snmpd.service \ -" -FILES_${PN}-server-snmptrapd = "${sbindir}/snmptrapd \ - ${sysconfdir}/snmp/snmptrapd.conf \ - ${systemd_unitdir}/system/snmptrapd.service \ -" -FILES_${PN}-client = "${bindir}/* ${datadir}/snmp/" -FILES_${PN}-dbg += "${libdir}/.debug/ ${sbindir}/.debug/ ${bindir}/.debug/" -FILES_${PN}-dev += "${bindir}/net-snmp-config ${bindir}/mib2c ${bindir}/mib2c-update" - -CONFFILES_${PN}-server-snmpd = "${sysconfdir}/snmp/snmpd.conf" -CONFFILES_${PN}-server-snmptrapd = "${sysconfdir}/snmp/snmptrapd.conf" - -INITSCRIPT_PACKAGES = "${PN}-server" -INITSCRIPT_NAME_${PN}-server = "snmpd" -INITSCRIPT_PARAMS_${PN}-server = "defaults" - -EXTRA_OECONF += "${@base_contains('DISTRO_FEATURES', 'systemd', '--with-systemd', '--without-systemd', d)}" - -SYSTEMD_PACKAGES = "${PN}-server-snmpd-systemd \ - ${PN}-server-snmptrapd-systemd" - -SYSTEMD_SERVICE_${PN}-server-snmpd = "snmpd.service" -SYSTEMD_SERVICE_${PN}-server-snmptrapd = "snmptrapd.service" - -RPROVIDES_${PN}-server-snmpd += "${PN}-server-snmpd-systemd" -RREPLACES_${PN}-server-snmpd += "${PN}-server-snmpd-systemd" -RCONFLICTS_${PN}-server-snmpd += "${PN}-server-snmpd-systemd" - -RPROVIDES_${PN}-server-snmptrapd += "${PN}-server-snmptrapd-systemd" -RREPLACES_${PN}-server-snmptrapd += "${PN}-server-snmptrapd-systemd" -RCONFLICTS_${PN}-server-snmptrapd += "${PN}-server-snmptrapd-systemd" - -LEAD_SONAME = "libnetsnmp.so" - -pkg_postrm_${PN}-server() { - if test "x$D" != "x"; then - OPT="-r $D " - else - OPT="" - /etc/init.d/snmpd stop - fi -}
meta-oe/recipes-extended/net-snmp/net-snmp_5.7.2.bb +98 -14
124 lines not on this page · raw message
Signature · 1 line
1.8.2
Quoted 7 lines · Jack Mitchell
From: Jack Mitchell <[email protected]>
The snmpd daemon cannot start on platforms without a pci bus:
snmpd[15460]: pcilib: Cannot open
/proc/bus/pcisnmpd[15460]: pcilib: Cannot find any working access method.
Quoted 8 lines
snmpd should not depend on a PCI bus and should simply move on.
Signed-off-by Jack Mitchell <[email protected]>--- .../recipes-extended/net-snmp/files/ifmib.patch | 66 ++++++++++++++++++++++ .../recipes-extended/net-snmp/net-snmp_5.7.1.bb | 1 + 2 files changed, 67 insertions(+)create mode 100644
meta-oe/recipes-extended/net-snmp/files/ifmib.patch
I've pushed to my github here to try solve the patches failing.
git://github.com/CommunistCode/meta-oe.git
Signature · 5 lines
Jack Mitchell ([email protected]) Embedded Systems Engineer http://www.embed.me.uk --
Quoted 19 lines · On Wednesday 17 April 2013 13:12:08 Jack Mitchell wrote:
Quoted 9 lines · Jack Mitchell
From: Jack Mitchell <[email protected]>
The snmpd daemon cannot start on platforms without a pci bus:
snmpd[15460]: pcilib: Cannot open
/proc/bus/pcisnmpd[15460]: pcilib: Cannot find any working access method.snmpd should not depend on a PCI bus and should simply move on.
Quoted 8 lines
Signed-off-by Jack Mitchell <[email protected]>---
.../recipes-extended/net-snmp/files/ifmib.patch | 66 ++++++++++++++++++++++ .../recipes-extended/net-snmp/net-snmp_5.7.1.bb | 1 + 2 files changed, 67 insertions(+)create mode 100644
meta-oe/recipes-extended/net-snmp/files/ifmib.patch
Quoted 3 lines
I've pushed to my github here to try solve the patches failing.
git://github.com/CommunistCode/meta-oe.git
FWIW, I get the same build failure I got with the old recipe:
| arm-poky-linux-gnueabi-libtool: link: arm-poky-linux-gnueabi-gcc -march=armv5te -marm -mthumb-interwork -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed --sysroot=/home/paul/poky/poky/build/tmp/sysroots/qemuarm -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -Ulinux -Dlinux=linux -o .libs/snmpd .libs/snmpd.o -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed ./.libs/libnetsnmpagent.so ./.libs/libnetsnmpmibs.so /home/paul/poky/poky/build/tmp/work/armv5te-poky-linux-gnueabi/net-snmp/5.7.2-r0/net-snmp-5.7.2/agent/.libs/libnetsnmpagent.so /home/paul/poky/poky/build/tmp/work/armv5te-poky-linux-gnueabi/net-snmp/5.7.2-r0/net-snmp-5.7.2/snmplib/.libs/libnetsnmp.so -lpci -ldl ../snmplib/.libs/libnetsnmp.so -lcrypto -lm | .libs/snmpd.o: In function `main': | /home/paul/poky/poky/build/tmp/work/armv5te-poky-linux-gnueabi/net-snmp/5.7.2-r0/net-snmp-5.7.2/agent/snmpd.c:459: undefined reference to `netsnmp_sd_listen_fds' | collect2: error: ld returned 1 exit status | make[1]: *** [snmpd] Error 1 | make[1]: Leaving directory `/home/paul/poky/poky/build/tmp/work/armv5te-poky-linux-gnueabi/net-snmp/5.7.2-r0/net-snmp-5.7.2/agent' | make: *** [subdirs] Error 1 | ERROR: oe_runmake failed | ERROR: Function failed: do_compile (see /home/paul/poky/poky/build/tmp/work/armv5te-poky-linux-gnueabi/net-snmp/5.7.2-r0/temp/log.do_compile.4144 for further information)
Not that that should in any way block this patchset from going in since this hasn't changed, but there does appear to be a problem somewhere :(
Cheers,
Paul
Signature · 2 lines
Paul Eggleton Intel Open Source Technology Centre
Quoted 17 lines · Jack Mitchell
Quoted 7 lines · Jack Mitchell
From: Jack Mitchell <[email protected]>
The snmpd daemon cannot start on platforms without a pci bus:
snmpd[15460]: pcilib: Cannot open
/proc/bus/pcisnmpd[15460]: pcilib: Cannot find any working access method.Quoted 8 lines
snmpd should not depend on a PCI bus and should simply move on.
Signed-off-by Jack Mitchell <[email protected]>--- .../recipes-extended/net-snmp/files/ifmib.patch | 66 ++++++++++++++++++++++ .../recipes-extended/net-snmp/net-snmp_5.7.1.bb | 1 + 2 files changed, 67 insertions(+)create mode 100644
meta-oe/recipes-extended/net-snmp/files/ifmib.patch
Quoted 3 lines
I've pushed to my github here to try solve the patches failing.
git://github.com/CommunistCode/meta-oe.git
2/3 and 3/3 are in wrong order (3/3 causes PR going backwards), but I'm willing to accept this - broken upgrade path while bisecting git repo is kind of expected.
Signature · 1 line
Martin 'JaMa' Jansa jabber: [email protected]