From 1219bf8a90a7bf8cd3a5363551ef635d51e8fc8e Mon Sep 17 00:00:00 2001 From: Tudor Florea Date: Thu, 8 Oct 2015 22:51:41 +0200 Subject: initial commit for Enea Linux 5.0 arm Signed-off-by: Tudor Florea --- .../recipes-protocols/accel-ppp/accel-ppp_git.bb | 41 + .../recipes-protocols/net-snmp/files/ifmib.patch | 66 + .../recipes-protocols/net-snmp/files/init | 63 + .../recipes-protocols/net-snmp/files/snmpd.conf | 422 +++++ .../net-snmp/files/snmptrapd.conf | 18 + ...s-for-printing-variables-with-wrong-types.patch | 455 ++++++ .../net-snmp/net-snmp/snmpd.service | 13 + .../net-snmp/net-snmp/snmptrapd.service | 13 + .../net-snmp/net-snmp/systemd-support.patch | 1618 ++++++++++++++++++++ .../recipes-protocols/net-snmp/net-snmp_5.7.2.1.bb | 136 ++ .../recipes-protocols/openflow/openflow.inc | 35 + .../recipes-protocols/openflow/openflow_1.0.bb | 4 + .../recipes-protocols/openflow/openflow_git.bb | 4 + ...kefile-modify-CFLAGS-to-aviod-build-error.patch | 106 ++ .../openl2tp-simplify-gcc-warning-hack.patch | 41 + .../recipes-protocols/openl2tp/openl2tp_1.8.bb | 36 + .../pptp-linux-1.7.2/fix-parallel-build.patch | 19 + .../pptp-linux/pptp-linux-1.7.2/options.pptp | 30 + .../pptp-linux/pptp-linux_1.7.2.bb | 31 + ...c-zebra-routing-table-with-the-kernel-one.patch | 48 + ...ose-the-stdout-stderr-as-in-other-daemons.patch | 50 + .../recipes-protocols/quagga/files/babeld.service | 14 + .../recipes-protocols/quagga/files/bgpd.service | 14 + .../recipes-protocols/quagga/files/isisd.service | 14 + .../recipes-protocols/quagga/files/ospf6d.service | 14 + .../recipes-protocols/quagga/files/ospfd.service | 14 + .../quagga-Avoid-duplicate-connected-address.patch | 54 + .../recipes-protocols/quagga/files/quagga.default | 13 + .../recipes-protocols/quagga/files/quagga.init | 200 +++ .../recipes-protocols/quagga/files/quagga.pam | 13 + .../ripd-fix-two-bugs-after-received-SIGHUP.patch | 50 + .../recipes-protocols/quagga/files/ripd.service | 14 + .../recipes-protocols/quagga/files/ripngd.service | 14 + .../quagga/files/volatiles.03_quagga | 3 + .../quagga/files/watchquagga.default | 12 + .../quagga/files/watchquagga.init | 64 + .../recipes-protocols/quagga/files/zebra.service | 15 + .../recipes-protocols/quagga/quagga.inc | 250 +++ .../recipes-protocols/quagga/quagga_0.99.23.bb | 9 + .../rp-pppoe/rp-pppoe-3.8/configure.patch | 11 + .../rp-pppoe/rp-pppoe-3.8/configure_in_cross.patch | 142 ++ .../discard-use-of-dnl-in-Makefile.am.patch | 27 + .../rp-pppoe-3.8/dont-swallow-errors.patch | 15 + .../rp-pppoe/rp-pppoe-3.8/pppoe-server.default | 22 + .../rp-pppoe/rp-pppoe-3.8/pppoe-server.init | 59 + .../rp-pppoe-3.8/pppoe-src-restrictions.patch | 20 + .../rp-pppoe/rp-pppoe-3.8/top-autoconf.patch | 27 + .../rp-pppoe/rp-pppoe-3.8/update-config.patch | 32 + .../rp-pppoe/rp-pppoe-3.8/use-ldflags.patch | 27 + .../recipes-protocols/rp-pppoe/rp-pppoe_3.8.bb | 59 + .../recipes-protocols/xl2tpd/xl2tpd.inc | 40 + .../recipes-protocols/xl2tpd/xl2tpd_git.bb | 5 + .../zeroconf/zeroconf/compilefix.patch | 19 + .../zeroconf/zeroconf/debian-zeroconf | 51 + .../zeroconf/zeroconf/zeroconf-default | 17 + .../recipes-protocols/zeroconf/zeroconf_0.9.bb | 34 + 56 files changed, 4637 insertions(+) create mode 100644 meta-networking/recipes-protocols/accel-ppp/accel-ppp_git.bb create mode 100644 meta-networking/recipes-protocols/net-snmp/files/ifmib.patch create mode 100755 meta-networking/recipes-protocols/net-snmp/files/init create mode 100644 meta-networking/recipes-protocols/net-snmp/files/snmpd.conf create mode 100644 meta-networking/recipes-protocols/net-snmp/files/snmptrapd.conf create mode 100644 meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Added-checks-for-printing-variables-with-wrong-types.patch create mode 100644 meta-networking/recipes-protocols/net-snmp/net-snmp/snmpd.service create mode 100644 meta-networking/recipes-protocols/net-snmp/net-snmp/snmptrapd.service create mode 100644 meta-networking/recipes-protocols/net-snmp/net-snmp/systemd-support.patch create mode 100644 meta-networking/recipes-protocols/net-snmp/net-snmp_5.7.2.1.bb create mode 100644 meta-networking/recipes-protocols/openflow/openflow.inc create mode 100644 meta-networking/recipes-protocols/openflow/openflow_1.0.bb create mode 100644 meta-networking/recipes-protocols/openflow/openflow_git.bb create mode 100644 meta-networking/recipes-protocols/openl2tp/openl2tp/Makefile-modify-CFLAGS-to-aviod-build-error.patch create mode 100644 meta-networking/recipes-protocols/openl2tp/openl2tp/openl2tp-simplify-gcc-warning-hack.patch create mode 100644 meta-networking/recipes-protocols/openl2tp/openl2tp_1.8.bb create mode 100644 meta-networking/recipes-protocols/pptp-linux/pptp-linux-1.7.2/fix-parallel-build.patch create mode 100644 meta-networking/recipes-protocols/pptp-linux/pptp-linux-1.7.2/options.pptp create mode 100644 meta-networking/recipes-protocols/pptp-linux/pptp-linux_1.7.2.bb create mode 100644 meta-networking/recipes-protocols/quagga/files/Zebra-sync-zebra-routing-table-with-the-kernel-one.patch create mode 100644 meta-networking/recipes-protocols/quagga/files/babel-close-the-stdout-stderr-as-in-other-daemons.patch create mode 100644 meta-networking/recipes-protocols/quagga/files/babeld.service create mode 100644 meta-networking/recipes-protocols/quagga/files/bgpd.service create mode 100644 meta-networking/recipes-protocols/quagga/files/isisd.service create mode 100644 meta-networking/recipes-protocols/quagga/files/ospf6d.service create mode 100644 meta-networking/recipes-protocols/quagga/files/ospfd.service create mode 100644 meta-networking/recipes-protocols/quagga/files/quagga-Avoid-duplicate-connected-address.patch create mode 100644 meta-networking/recipes-protocols/quagga/files/quagga.default create mode 100644 meta-networking/recipes-protocols/quagga/files/quagga.init create mode 100644 meta-networking/recipes-protocols/quagga/files/quagga.pam create mode 100644 meta-networking/recipes-protocols/quagga/files/ripd-fix-two-bugs-after-received-SIGHUP.patch create mode 100644 meta-networking/recipes-protocols/quagga/files/ripd.service create mode 100644 meta-networking/recipes-protocols/quagga/files/ripngd.service create mode 100644 meta-networking/recipes-protocols/quagga/files/volatiles.03_quagga create mode 100644 meta-networking/recipes-protocols/quagga/files/watchquagga.default create mode 100644 meta-networking/recipes-protocols/quagga/files/watchquagga.init create mode 100644 meta-networking/recipes-protocols/quagga/files/zebra.service create mode 100644 meta-networking/recipes-protocols/quagga/quagga.inc create mode 100644 meta-networking/recipes-protocols/quagga/quagga_0.99.23.bb create mode 100644 meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/configure.patch create mode 100644 meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/configure_in_cross.patch create mode 100644 meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/discard-use-of-dnl-in-Makefile.am.patch create mode 100644 meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/dont-swallow-errors.patch create mode 100644 meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/pppoe-server.default create mode 100755 meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/pppoe-server.init create mode 100644 meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/pppoe-src-restrictions.patch create mode 100644 meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/top-autoconf.patch create mode 100644 meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/update-config.patch create mode 100644 meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/use-ldflags.patch create mode 100644 meta-networking/recipes-protocols/rp-pppoe/rp-pppoe_3.8.bb create mode 100644 meta-networking/recipes-protocols/xl2tpd/xl2tpd.inc create mode 100644 meta-networking/recipes-protocols/xl2tpd/xl2tpd_git.bb create mode 100644 meta-networking/recipes-protocols/zeroconf/zeroconf/compilefix.patch create mode 100644 meta-networking/recipes-protocols/zeroconf/zeroconf/debian-zeroconf create mode 100644 meta-networking/recipes-protocols/zeroconf/zeroconf/zeroconf-default create mode 100644 meta-networking/recipes-protocols/zeroconf/zeroconf_0.9.bb (limited to 'meta-networking/recipes-protocols') diff --git a/meta-networking/recipes-protocols/accel-ppp/accel-ppp_git.bb b/meta-networking/recipes-protocols/accel-ppp/accel-ppp_git.bb new file mode 100644 index 0000000000..526818c05e --- /dev/null +++ b/meta-networking/recipes-protocols/accel-ppp/accel-ppp_git.bb @@ -0,0 +1,41 @@ +SUMMARY = "ACCEL-PPP is a high performance VPN server application for linux" +HOMEPAGE = "http://sourceforge.net/apps/trac/accel-ppp/wiki" + +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://COPYING;md5=eb723b61539feef013de476e68b5c50a" + +DEPENDS = "openssl libpcre" + +inherit cmake + +PR = "r1" +PV = "1.7.3+git" + +SRCREV = "4acfa46c321a344b9a6ce4128e72d1e02828d8a0" +SRC_URI = "git://accel-ppp.git.sourceforge.net/gitroot/accel-ppp/accel-ppp;branch=1.7" + +S = "${WORKDIR}/git" + +EXTRA_OECMAKE = " \ + -DBUILD_DRIVER=FALSE \ + -DCMAKE_INSTALL_PREFIX=${prefix} \ + -DCMAKE_BUILD_TYPE=Release \ + -DLOG_PGSQL=FALSE \ + -DRADIUS=FALSE \ + -DNETSNMP=FALSE \ +" +FILES_${PN}-dbg += "/usr/lib/${BPN}/.debug/*" + +PACKAGES =+ "${PN}-libs" +FILES_${PN}-libs = "${libdir}/${BPN}/*.so /usr/lib/${BPN}/*.so" +INSANE_SKIP_${PN}-libs = "dev-so" +RDEPENDS_${PN} += "${PN}-libs" + +do_install_prepend() { + cmlist=`find ${S} -name CMakeLists.txt` + for file in $cmlist; do + sed -i -e "s:LIBRARY DESTINATION lib/accel-ppp:LIBRARY DESTINATION ${baselib}/accel-ppp:g" \ + -e "s:\${CMAKE_INSTALL_PREFIX}/lib/accel-ppp:\${CMAKE_INSTALL_PREFIX}/${baselib}/accel-ppp:g" \ + $cmlist + done +} diff --git a/meta-networking/recipes-protocols/net-snmp/files/ifmib.patch b/meta-networking/recipes-protocols/net-snmp/files/ifmib.patch new file mode 100644 index 0000000000..859c52c3e3 --- /dev/null +++ b/meta-networking/recipes-protocols/net-snmp/files/ifmib.patch @@ -0,0 +1,66 @@ +Signed-off-by: Jack Mitchell +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 ++#include + 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 + } + diff --git a/meta-networking/recipes-protocols/net-snmp/files/init b/meta-networking/recipes-protocols/net-snmp/files/init new file mode 100755 index 0000000000..434b2fa3f2 --- /dev/null +++ b/meta-networking/recipes-protocols/net-snmp/files/init @@ -0,0 +1,63 @@ +#! /bin/sh +# /etc/init.d/snmpd: start snmp daemon. + +test -x /usr/sbin/snmpd || exit 0 +test -x /usr/sbin/snmptrapd || exit 0 + +# Defaults +export MIBDIRS=/usr/share/snmp/mibs +SNMPDRUN=yes +SNMPDOPTS='-Lsd -Lf /dev/null -p /var/run/snmpd.pid' +TRAPDRUN=no +TRAPDOPTS='-Lsd -p /var/run/snmptrapd.pid' + +# Cd to / before starting any daemons. +cd / + +case "$1" in + start) + echo -n "Starting network management services:" + if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then + start-stop-daemon -S -x /usr/sbin/snmpd \ + -- $SNMPDOPTS + echo -n " snmpd" + fi + if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then + start-stop-daemon -S -x /usr/sbin/snmptrapd \ + -- $TRAPDOPTS + echo -n " snmptrapd" + fi + echo "." + ;; + stop) + echo -n "Stopping network management services:" + start-stop-daemon -K -x /usr/sbin/snmpd + echo -n " snmpd" + start-stop-daemon -K -x /usr/sbin/snmptrapd + echo -n " snmptrapd" + echo "." + ;; + restart|reload|force-reload) + echo -n "Restarting network management services:" + start-stop-daemon -K -x /usr/sbin/snmpd + start-stop-daemon -K -x /usr/sbin/snmptrapd + # Allow the daemons time to exit completely. + sleep 2 + if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then + start-stop-daemon -S -x /usr/sbin/snmpd -- $SNMPDOPTS + echo -n " snmpd" + fi + if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then + # Allow snmpd time to start up. + sleep 1 + start-stop-daemon -S -x /usr/sbin/snmptrapd -- $TRAPDOPTS + echo -n " snmptrapd" + fi + echo "." + ;; + *) + echo "Usage: /etc/init.d/snmpd {start|stop|restart|reload|force-reload}" + exit 1 +esac + +exit 0 diff --git a/meta-networking/recipes-protocols/net-snmp/files/snmpd.conf b/meta-networking/recipes-protocols/net-snmp/files/snmpd.conf new file mode 100644 index 0000000000..728171c427 --- /dev/null +++ b/meta-networking/recipes-protocols/net-snmp/files/snmpd.conf @@ -0,0 +1,422 @@ +############################################################################### +# +# EXAMPLE.conf: +# An example configuration file for configuring the ucd-snmp snmpd agent. +# +############################################################################### +# +# This file is intended to only be an example. If, however, you want +# to use it, it should be placed in /etc/snmp/snmpd.conf. +# When the snmpd agent starts up, this is where it will look for it. +# +# You might be interested in generating your own snmpd.conf file using +# the "snmpconf" program (perl script) instead. It's a nice menu +# based interface to writing well commented configuration files. Try it! +# +# Note: This file is automatically generated from EXAMPLE.conf.def. +# Do NOT read the EXAMPLE.conf.def file! Instead, after you have run +# configure & make, and then make sure you read the EXAMPLE.conf file +# instead, as it will tailor itself to your configuration. + +# All lines beginning with a '#' are comments and are intended for you +# to read. All other lines are configuration commands for the agent. + +# +# PLEASE: read the snmpd.conf(5) manual page as well! +# + + +############################################################################### +# Access Control +############################################################################### + +# YOU SHOULD CHANGE THE "COMMUNITY" TOKEN BELOW TO A NEW KEYWORD ONLY +# KNOWN AT YOUR SITE. YOU *MUST* CHANGE THE NETWORK TOKEN BELOW TO +# SOMETHING REFLECTING YOUR LOCAL NETWORK ADDRESS SPACE. + +# By far, the most common question I get about the agent is "why won't +# it work?", when really it should be "how do I configure the agent to +# allow me to access it?" +# +# By default, the agent responds to the "public" community for read +# only access, if run out of the box without any configuration file in +# place. The following examples show you other ways of configuring +# the agent so that you can change the community names, and give +# yourself write access as well. +# +# The following lines change the access permissions of the agent so +# that the COMMUNITY string provides read-only access to your entire +# NETWORK (EG: 10.10.10.0/24), and read/write access to only the +# localhost (127.0.0.1, not its real ipaddress). +# +# For more information, read the FAQ as well as the snmpd.conf(5) +# manual page. + +#### +# First, map the community name (COMMUNITY) into a security name +# (local and mynetwork, depending on where the request is coming +# from): + +# sec.name source community +com2sec paranoid default public +#com2sec readonly default public +#com2sec readwrite default private + +#### +# Second, map the security names into group names: + +# sec.model sec.name +group MyROSystem v1 paranoid +group MyROSystem v2c paranoid +group MyROSystem usm paranoid +group MyROGroup v1 readonly +group MyROGroup v2c readonly +group MyROGroup usm readonly +group MyRWGroup v1 readwrite +group MyRWGroup v2c readwrite +group MyRWGroup usm readwrite + +#### +# Third, create a view for us to let the groups have rights to: + +# incl/excl subtree mask +view all included .1 80 +view system included .iso.org.dod.internet.mgmt.mib-2.system + +#### +# Finally, grant the 2 groups access to the 1 view with different +# write permissions: + +# context sec.model sec.level match read write notif +access MyROSystem "" any noauth exact system none none +access MyROGroup "" any noauth exact all none none +access MyRWGroup "" any noauth exact all all none + +# ----------------------------------------------------------------------------- + + +############################################################################### +# System contact information +# + +# It is also possible to set the sysContact and sysLocation system +# variables through the snmpd.conf file. **PLEASE NOTE** that setting +# the value of these objects here makes these objects READ-ONLY +# (regardless of any access control settings). Any attempt to set the +# value of an object whose value is given here will fail with an error +# status of notWritable. + +syslocation Unknown (configure /etc/snmp/snmpd.local.conf) +syscontact Root (configure /etc/snmp/snmpd.local.conf) + +# Example output of snmpwalk: +# % snmpwalk -v 1 -c public localhost system +# system.sysDescr.0 = "SunOS name sun4c" +# system.sysObjectID.0 = OID: enterprises.ucdavis.ucdSnmpAgent.sunos4 +# system.sysUpTime.0 = Timeticks: (595637548) 68 days, 22:32:55 +# system.sysContact.0 = "Me " +# system.sysName.0 = "name" +# system.sysLocation.0 = "Right here, right now." +# system.sysServices.0 = 72 + + +# ----------------------------------------------------------------------------- + + +############################################################################### +# Process checks. +# +# The following are examples of how to use the agent to check for +# processes running on the host. The syntax looks something like: +# +# proc NAME [MAX=0] [MIN=0] +# +# NAME: the name of the process to check for. It must match +# exactly (ie, http will not find httpd processes). +# MAX: the maximum number allowed to be running. Defaults to 0. +# MIN: the minimum number to be running. Defaults to 0. + +# +# Examples: +# + +# Make sure mountd is running +#proc mountd + +# Make sure there are no more than 4 ntalkds running, but 0 is ok too. +#proc ntalkd 4 + +# Make sure at least one sendmail, but less than or equal to 10 are running. +#proc sendmail 10 1 + +# A snmpwalk of the prTable would look something like this: +# +# % snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.2 +# enterprises.ucdavis.procTable.prEntry.prIndex.1 = 1 +# enterprises.ucdavis.procTable.prEntry.prIndex.2 = 2 +# enterprises.ucdavis.procTable.prEntry.prIndex.3 = 3 +# enterprises.ucdavis.procTable.prEntry.prNames.1 = "mountd" +# enterprises.ucdavis.procTable.prEntry.prNames.2 = "ntalkd" +# enterprises.ucdavis.procTable.prEntry.prNames.3 = "sendmail" +# enterprises.ucdavis.procTable.prEntry.prMin.1 = 0 +# enterprises.ucdavis.procTable.prEntry.prMin.2 = 0 +# enterprises.ucdavis.procTable.prEntry.prMin.3 = 1 +# enterprises.ucdavis.procTable.prEntry.prMax.1 = 0 +# enterprises.ucdavis.procTable.prEntry.prMax.2 = 4 +# enterprises.ucdavis.procTable.prEntry.prMax.3 = 10 +# enterprises.ucdavis.procTable.prEntry.prCount.1 = 0 +# enterprises.ucdavis.procTable.prEntry.prCount.2 = 0 +# enterprises.ucdavis.procTable.prEntry.prCount.3 = 1 +# enterprises.ucdavis.procTable.prEntry.prErrorFlag.1 = 1 +# enterprises.ucdavis.procTable.prEntry.prErrorFlag.2 = 0 +# enterprises.ucdavis.procTable.prEntry.prErrorFlag.3 = 0 +# enterprises.ucdavis.procTable.prEntry.prErrMessage.1 = "No mountd process running." +# enterprises.ucdavis.procTable.prEntry.prErrMessage.2 = "" +# enterprises.ucdavis.procTable.prEntry.prErrMessage.3 = "" +# enterprises.ucdavis.procTable.prEntry.prErrFix.1 = 0 +# enterprises.ucdavis.procTable.prEntry.prErrFix.2 = 0 +# enterprises.ucdavis.procTable.prEntry.prErrFix.3 = 0 +# +# Note that the errorFlag for mountd is set to 1 because one is not +# running (in this case an rpc.mountd is, but thats not good enough), +# and the ErrMessage tells you what's wrong. The configuration +# imposed in the snmpd.conf file is also shown. +# +# Special Case: When the min and max numbers are both 0, it assumes +# you want a max of infinity and a min of 1. +# + + +# ----------------------------------------------------------------------------- + + +############################################################################### +# Executables/scripts +# + +# +# You can also have programs run by the agent that return a single +# line of output and an exit code. Here are two examples. +# +# exec NAME PROGRAM [ARGS ...] +# +# NAME: A generic name. +# PROGRAM: The program to run. Include the path! +# ARGS: optional arguments to be passed to the program + +# a simple hello world +#exec echotest /bin/echo hello world + +# Run a shell script containing: +# +# #!/bin/sh +# echo hello world +# echo hi there +# exit 35 +# +# Note: this has been specifically commented out to prevent +# accidental security holes due to someone else on your system writing +# a /tmp/shtest before you do. Uncomment to use it. +# +#exec shelltest /bin/sh /tmp/shtest + +# Then, +# % snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.8 +# enterprises.ucdavis.extTable.extEntry.extIndex.1 = 1 +# enterprises.ucdavis.extTable.extEntry.extIndex.2 = 2 +# enterprises.ucdavis.extTable.extEntry.extNames.1 = "echotest" +# enterprises.ucdavis.extTable.extEntry.extNames.2 = "shelltest" +# enterprises.ucdavis.extTable.extEntry.extCommand.1 = "/bin/echo hello world" +# enterprises.ucdavis.extTable.extEntry.extCommand.2 = "/bin/sh /tmp/shtest" +# enterprises.ucdavis.extTable.extEntry.extResult.1 = 0 +# enterprises.ucdavis.extTable.extEntry.extResult.2 = 35 +# enterprises.ucdavis.extTable.extEntry.extOutput.1 = "hello world." +# enterprises.ucdavis.extTable.extEntry.extOutput.2 = "hello world." +# enterprises.ucdavis.extTable.extEntry.extErrFix.1 = 0 +# enterprises.ucdavis.extTable.extEntry.extErrFix.2 = 0 + +# Note that the second line of the /tmp/shtest shell script is cut +# off. Also note that the exit status of 35 was returned. + +# ----------------------------------------------------------------------------- + + +############################################################################### +# disk checks +# + +# The agent can check the amount of available disk space, and make +# sure it is above a set limit. + +# disk PATH [MIN=DEFDISKMINIMUMSPACE] +# +# PATH: mount path to the disk in question. +# MIN: Disks with space below this value will have the Mib's errorFlag set. +# Default value = DEFDISKMINIMUMSPACE. + +# Check the / partition and make sure it contains at least 10 megs. + +#disk / 10000 + +# % snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.9 +# enterprises.ucdavis.diskTable.dskEntry.diskIndex.1 = 0 +# enterprises.ucdavis.diskTable.dskEntry.diskPath.1 = "/" Hex: 2F +# enterprises.ucdavis.diskTable.dskEntry.diskDevice.1 = "/dev/dsk/c201d6s0" +# enterprises.ucdavis.diskTable.dskEntry.diskMinimum.1 = 10000 +# enterprises.ucdavis.diskTable.dskEntry.diskTotal.1 = 837130 +# enterprises.ucdavis.diskTable.dskEntry.diskAvail.1 = 316325 +# enterprises.ucdavis.diskTable.dskEntry.diskUsed.1 = 437092 +# enterprises.ucdavis.diskTable.dskEntry.diskPercent.1 = 58 +# enterprises.ucdavis.diskTable.dskEntry.diskErrorFlag.1 = 0 +# enterprises.ucdavis.diskTable.dskEntry.diskErrorMsg.1 = "" + +# ----------------------------------------------------------------------------- + + +############################################################################### +# load average checks +# + +# load [1MAX=DEFMAXLOADAVE] [5MAX=DEFMAXLOADAVE] [15MAX=DEFMAXLOADAVE] +# +# 1MAX: If the 1 minute load average is above this limit at query +# time, the errorFlag will be set. +# 5MAX: Similar, but for 5 min average. +# 15MAX: Similar, but for 15 min average. + +# Check for loads: +#load 12 14 14 + +# % snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.10 +# enterprises.ucdavis.loadTable.laEntry.loadaveIndex.1 = 1 +# enterprises.ucdavis.loadTable.laEntry.loadaveIndex.2 = 2 +# enterprises.ucdavis.loadTable.laEntry.loadaveIndex.3 = 3 +# enterprises.ucdavis.loadTable.laEntry.loadaveNames.1 = "Load-1" +# enterprises.ucdavis.loadTable.laEntry.loadaveNames.2 = "Load-5" +# enterprises.ucdavis.loadTable.laEntry.loadaveNames.3 = "Load-15" +# enterprises.ucdavis.loadTable.laEntry.loadaveLoad.1 = "0.49" Hex: 30 2E 34 39 +# enterprises.ucdavis.loadTable.laEntry.loadaveLoad.2 = "0.31" Hex: 30 2E 33 31 +# enterprises.ucdavis.loadTable.laEntry.loadaveLoad.3 = "0.26" Hex: 30 2E 32 36 +# enterprises.ucdavis.loadTable.laEntry.loadaveConfig.1 = "12.00" +# enterprises.ucdavis.loadTable.laEntry.loadaveConfig.2 = "14.00" +# enterprises.ucdavis.loadTable.laEntry.loadaveConfig.3 = "14.00" +# enterprises.ucdavis.loadTable.laEntry.loadaveErrorFlag.1 = 0 +# enterprises.ucdavis.loadTable.laEntry.loadaveErrorFlag.2 = 0 +# enterprises.ucdavis.loadTable.laEntry.loadaveErrorFlag.3 = 0 +# enterprises.ucdavis.loadTable.laEntry.loadaveErrMessage.1 = "" +# enterprises.ucdavis.loadTable.laEntry.loadaveErrMessage.2 = "" +# enterprises.ucdavis.loadTable.laEntry.loadaveErrMessage.3 = "" + +# ----------------------------------------------------------------------------- + + +############################################################################### +# Extensible sections. +# + +# This alleviates the multiple line output problem found in the +# previous executable mib by placing each mib in its own mib table: + +# Run a shell script containing: +# +# #!/bin/sh +# echo hello world +# echo hi there +# exit 35 +# +# Note: this has been specifically commented out to prevent +# accidental security holes due to someone else on your system writing +# a /tmp/shtest before you do. Uncomment to use it. +# +# exec .1.3.6.1.4.1.2021.50 shelltest /bin/sh /tmp/shtest + +# % snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.50 +# enterprises.ucdavis.50.1.1 = 1 +# enterprises.ucdavis.50.2.1 = "shelltest" +# enterprises.ucdavis.50.3.1 = "/bin/sh /tmp/shtest" +# enterprises.ucdavis.50.100.1 = 35 +# enterprises.ucdavis.50.101.1 = "hello world." +# enterprises.ucdavis.50.101.2 = "hi there." +# enterprises.ucdavis.50.102.1 = 0 + +# Now the Output has grown to two lines, and we can see the 'hi +# there.' output as the second line from our shell script. +# +# Note that you must alter the mib.txt file to be correct if you want +# the .50.* outputs above to change to reasonable text descriptions. + +# Other ideas: +# +# exec .1.3.6.1.4.1.2021.51 ps /bin/ps +# exec .1.3.6.1.4.1.2021.52 top /usr/local/bin/top +# exec .1.3.6.1.4.1.2021.53 mailq /usr/bin/mailq + +# ----------------------------------------------------------------------------- + + +############################################################################### +# Pass through control. +# + +# Usage: +# pass MIBOID EXEC-COMMAND +# +# This will pass total control of the mib underneath the MIBOID +# portion of the mib to the EXEC-COMMAND. +# +# Note: You'll have to change the path of the passtest script to your +# source directory or install it in the given location. +# +# Example: (see the script for details) +# (commented out here since it requires that you place the +# script in the right location. (its not installed by default)) + +# pass .1.3.6.1.4.1.2021.255 /bin/sh /usr/local/passtest + +# % snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.255 +# enterprises.ucdavis.255.1 = "life the universe and everything" +# enterprises.ucdavis.255.2.1 = 42 +# enterprises.ucdavis.255.2.2 = OID: 42.42.42 +# enterprises.ucdavis.255.3 = Timeticks: (363136200) 42 days, 0:42:42 +# enterprises.ucdavis.255.4 = IpAddress: 127.0.0.1 +# enterprises.ucdavis.255.5 = 42 +# enterprises.ucdavis.255.6 = Gauge: 42 +# +# % snmpget -v 1 -c public localhost .1.3.6.1.4.1.2021.255.5 +# enterprises.ucdavis.255.5 = 42 +# +# % snmpset -v 1 -c public localhost .1.3.6.1.4.1.2021.255.1 s "New string" +# enterprises.ucdavis.255.1 = "New string" +# + +# For specific usage information, see the man/snmpd.conf.5 manual page +# as well as the local/passtest script used in the above example. + +############################################################################### +# Subagent control +# + +# The agent can support subagents using a number of extension mechanisms. +# From the 4.2.1 release, AgentX support is being compiled in by default. +# However, this is still experimental code, so should not be used on +# critical production systems. +# Please see the file README.agentx for more details. +# +# If having read, marked, learnt and inwardly digested this information, +# you decide that you do wish to make use of this mechanism, simply +# uncomment the following directive. +# +# master agentx +# +# I repeat - this is *NOT* regarded as suitable for front-line production +# systems, though it is probably stable enough for day-to-day use. +# Probably. +# +# No refunds will be given. + +############################################################################### +# Further Information +# +# See the snmpd.conf manual page, and the output of "snmpd -H". +# MUCH more can be done with the snmpd.conf than is shown as an +# example here. diff --git a/meta-networking/recipes-protocols/net-snmp/files/snmptrapd.conf b/meta-networking/recipes-protocols/net-snmp/files/snmptrapd.conf new file mode 100644 index 0000000000..8d2e4375ef --- /dev/null +++ b/meta-networking/recipes-protocols/net-snmp/files/snmptrapd.conf @@ -0,0 +1,18 @@ +############################################################################### +# +# EXAMPLE.conf: +# An example configuration file for configuring the ucd-snmp snmptrapd agent. +# +############################################################################### +# +# This file is intended to only be an example. If, however, you want +# to use it, it should be placed in /etc/snmp/snmptrapd.conf. +# When the snmptrapd agent starts up, this is where it will look for it. +# +# All lines beginning with a '#' are comments and are intended for you +# to read. All other lines are configuration commands for the agent. + +# +# PLEASE: read the snmptrapd.conf(5) manual page as well! +# + diff --git a/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Added-checks-for-printing-variables-with-wrong-types.patch b/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Added-checks-for-printing-variables-with-wrong-types.patch new file mode 100644 index 0000000000..30374cfe96 --- /dev/null +++ b/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Added-checks-for-printing-variables-with-wrong-types.patch @@ -0,0 +1,455 @@ +From 7f4a7b891332899cea26e95be0337aae01648742 Mon Sep 17 00:00:00 2001 +From: Jan Safranek +Date: Thu, 31 Jul 2014 13:46:49 +0200 +Subject: [PATCH] Added checks for printing variables with wrong types. + +Upstream-Status: Backport + +When -OQ command line argument is used, variable formatter preffers the type +of the varible parsed from a MIB file instead of checking type of the variable +as parsed from SNMP message. + +This can lead to crashes when incoming packets contains a variable with +NULL type, while the MIB says the variable should be non-NULL, like Integer. +The formatter then tries to interpret the NULL (from packet) as Integer (from +MIB file). + +Signed-off-by: Jan Safranek +--- + snmplib/mib.c | 270 ++++++++++++++++++++++++++++----------------------------- + 1 file changed, 135 insertions(+), 135 deletions(-) + +diff --git a/snmplib/mib.c b/snmplib/mib.c +index 9d3ca41..c6e0010 100644 +--- a/snmplib/mib.c ++++ b/snmplib/mib.c +@@ -439,17 +439,16 @@ sprint_realloc_octet_string(u_char ** buf, size_t * buf_len, + u_char *cp; + int output_format, cnt; + +- if ((var->type != ASN_OCTET_STR) && +- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) { +- const char str[] = "Wrong Type (should be OCTET STRING): "; +- if (snmp_cstrcat +- (buf, buf_len, out_len, allow_realloc, str)) { +- return sprint_realloc_by_type(buf, buf_len, out_len, ++ if (var->type != ASN_OCTET_STR) { ++ if (!netsnmp_ds_get_boolean( ++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) { ++ const char str[] = "Wrong Type (should be OCTET STRING): "; ++ if (!snmp_cstrcat(buf, buf_len, out_len, allow_realloc, str)) ++ return 0; ++ } ++ return sprint_realloc_by_type(buf, buf_len, out_len, + allow_realloc, var, NULL, NULL, + NULL); +- } else { +- return 0; +- } + } + + +@@ -702,16 +701,16 @@ sprint_realloc_float(u_char ** buf, size_t * buf_len, + const struct enum_list *enums, + const char *hint, const char *units) + { +- if ((var->type != ASN_OPAQUE_FLOAT) && +- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) { +- if (snmp_cstrcat(buf, buf_len, out_len, allow_realloc, +- "Wrong Type (should be Float): ")) { +- return sprint_realloc_by_type(buf, buf_len, out_len, ++ if (var->type != ASN_OPAQUE_FLOAT) { ++ if (!netsnmp_ds_get_boolean( ++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) { ++ u_char str[] = "Wrong Type (should be Float): "; ++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) ++ return 0; ++ } ++ return sprint_realloc_by_type(buf, buf_len, out_len, + allow_realloc, var, NULL, NULL, + NULL); +- } else { +- return 0; +- } + } + + if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) { +@@ -772,17 +771,16 @@ sprint_realloc_double(u_char ** buf, size_t * buf_len, + const struct enum_list *enums, + const char *hint, const char *units) + { +- if ((var->type != ASN_OPAQUE_DOUBLE) && +- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) { +- if (snmp_cstrcat +- (buf, buf_len, out_len, allow_realloc, +- "Wrong Type (should be Double): ")) { +- return sprint_realloc_by_type(buf, buf_len, out_len, ++ if (var->type != ASN_OPAQUE_DOUBLE) { ++ if (!netsnmp_ds_get_boolean( ++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) { ++ u_char str[] = "Wrong Type (should be Double): "; ++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) ++ return 0; ++ } ++ return sprint_realloc_by_type(buf, buf_len, out_len, + allow_realloc, var, NULL, NULL, + NULL); +- } else { +- return 0; +- } + } + + if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) { +@@ -847,20 +845,21 @@ sprint_realloc_counter64(u_char ** buf, size_t * buf_len, size_t * out_len, + { + char a64buf[I64CHARSZ + 1]; + +- if ((var->type != ASN_COUNTER64 ++ if (var->type != ASN_COUNTER64 + #ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES + && var->type != ASN_OPAQUE_COUNTER64 + && var->type != ASN_OPAQUE_I64 && var->type != ASN_OPAQUE_U64 + #endif +- ) && (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) { +- if (snmp_cstrcat(buf, buf_len, out_len, allow_realloc, +- "Wrong Type (should be Counter64): ")) { +- return sprint_realloc_by_type(buf, buf_len, out_len, ++ ) { ++ if (!netsnmp_ds_get_boolean( ++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) { ++ u_char str[] = "Wrong Type (should be Counter64): "; ++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) ++ return 0; ++ } ++ return sprint_realloc_by_type(buf, buf_len, out_len, + allow_realloc, var, NULL, NULL, + NULL); +- } else { +- return 0; +- } + } + + if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) { +@@ -948,23 +947,25 @@ sprint_realloc_opaque(u_char ** buf, size_t * buf_len, + const struct enum_list *enums, + const char *hint, const char *units) + { +- if ((var->type != ASN_OPAQUE ++ if (var->type != ASN_OPAQUE + #ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES + && var->type != ASN_OPAQUE_COUNTER64 + && var->type != ASN_OPAQUE_U64 + && var->type != ASN_OPAQUE_I64 + && var->type != ASN_OPAQUE_FLOAT && var->type != ASN_OPAQUE_DOUBLE + #endif /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */ +- ) && (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) { +- if (snmp_cstrcat(buf, buf_len, out_len, allow_realloc, +- "Wrong Type (should be Opaque): ")) { +- return sprint_realloc_by_type(buf, buf_len, out_len, ++ ) { ++ if (!netsnmp_ds_get_boolean( ++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) { ++ u_char str[] = "Wrong Type (should be Opaque): "; ++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) ++ return 0; ++ } ++ return sprint_realloc_by_type(buf, buf_len, out_len, + allow_realloc, var, NULL, NULL, + NULL); +- } else { +- return 0; +- } + } ++ + #ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES + switch (var->type) { + case ASN_OPAQUE_COUNTER64: +@@ -1040,17 +1041,16 @@ sprint_realloc_object_identifier(u_char ** buf, size_t * buf_len, + { + int buf_overflow = 0; + +- if ((var->type != ASN_OBJECT_ID) && +- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) { +- u_char str[] = +- "Wrong Type (should be OBJECT IDENTIFIER): "; +- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) { +- return sprint_realloc_by_type(buf, buf_len, out_len, ++ if (var->type != ASN_OBJECT_ID) { ++ if (!netsnmp_ds_get_boolean( ++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) { ++ u_char str[] = "Wrong Type (should be OBJECT IDENTIFIER): "; ++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) ++ return 0; ++ } ++ return sprint_realloc_by_type(buf, buf_len, out_len, + allow_realloc, var, NULL, NULL, + NULL); +- } else { +- return 0; +- } + } + + if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) { +@@ -1110,16 +1110,16 @@ sprint_realloc_timeticks(u_char ** buf, size_t * buf_len, size_t * out_len, + { + char timebuf[40]; + +- if ((var->type != ASN_TIMETICKS) && +- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) { +- u_char str[] = "Wrong Type (should be Timeticks): "; +- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) { +- return sprint_realloc_by_type(buf, buf_len, out_len, ++ if (var->type != ASN_TIMETICKS) { ++ if (!netsnmp_ds_get_boolean( ++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) { ++ u_char str[] = "Wrong Type (should be Timeticks): "; ++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) ++ return 0; ++ } ++ return sprint_realloc_by_type(buf, buf_len, out_len, + allow_realloc, var, NULL, NULL, + NULL); +- } else { +- return 0; +- } + } + + if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NUMERIC_TIMETICKS)) { +@@ -1277,17 +1277,18 @@ sprint_realloc_integer(u_char ** buf, size_t * buf_len, size_t * out_len, + { + char *enum_string = NULL; + +- if ((var->type != ASN_INTEGER) && +- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) { +- u_char str[] = "Wrong Type (should be INTEGER): "; +- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) { +- return sprint_realloc_by_type(buf, buf_len, out_len, ++ if (var->type != ASN_INTEGER) { ++ if (!netsnmp_ds_get_boolean( ++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) { ++ u_char str[] = "Wrong Type (should be INTEGER): "; ++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) ++ return 0; ++ } ++ return sprint_realloc_by_type(buf, buf_len, out_len, + allow_realloc, var, NULL, NULL, + NULL); +- } else { +- return 0; +- } + } ++ + for (; enums; enums = enums->next) { + if (enums->value == *var->val.integer) { + enum_string = enums->label; +@@ -1380,16 +1381,16 @@ sprint_realloc_uinteger(u_char ** buf, size_t * buf_len, size_t * out_len, + { + char *enum_string = NULL; + +- if ((var->type != ASN_UINTEGER) && +- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) { +- u_char str[] = "Wrong Type (should be UInteger32): "; +- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) { +- return sprint_realloc_by_type(buf, buf_len, out_len, ++ if (var->type != ASN_UINTEGER) { ++ if (!netsnmp_ds_get_boolean( ++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) { ++ u_char str[] = "Wrong Type (should be UInteger32): "; ++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) ++ return 0; ++ } ++ return sprint_realloc_by_type(buf, buf_len, out_len, + allow_realloc, var, NULL, NULL, + NULL); +- } else { +- return 0; +- } + } + + for (; enums; enums = enums->next) { +@@ -1477,17 +1478,16 @@ sprint_realloc_gauge(u_char ** buf, size_t * buf_len, size_t * out_len, + { + char tmp[32]; + +- if ((var->type != ASN_GAUGE) && +- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) { +- u_char str[] = +- "Wrong Type (should be Gauge32 or Unsigned32): "; +- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) { +- return sprint_realloc_by_type(buf, buf_len, out_len, ++ if (var->type != ASN_GAUGE) { ++ if (!netsnmp_ds_get_boolean( ++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) { ++ u_char str[] = "Wrong Type (should be Gauge32 or Unsigned32): "; ++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) ++ return 0; ++ } ++ return sprint_realloc_by_type(buf, buf_len, out_len, + allow_realloc, var, NULL, NULL, + NULL); +- } else { +- return 0; +- } + } + + if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) { +@@ -1550,16 +1550,16 @@ sprint_realloc_counter(u_char ** buf, size_t * buf_len, size_t * out_len, + { + char tmp[32]; + +- if ((var->type != ASN_COUNTER) && +- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) { +- u_char str[] = "Wrong Type (should be Counter32): "; +- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) { +- return sprint_realloc_by_type(buf, buf_len, out_len, ++ if (var->type != ASN_COUNTER) { ++ if (!netsnmp_ds_get_boolean( ++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) { ++ u_char str[] = "Wrong Type (should be Counter32): "; ++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) ++ return 0; ++ } ++ return sprint_realloc_by_type(buf, buf_len, out_len, + allow_realloc, var, NULL, NULL, + NULL); +- } else { +- return 0; +- } + } + + if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) { +@@ -1613,16 +1613,16 @@ sprint_realloc_networkaddress(u_char ** buf, size_t * buf_len, + { + size_t i; + +- if ((var->type != ASN_IPADDRESS) && +- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) { +- u_char str[] = "Wrong Type (should be NetworkAddress): "; +- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) { +- return sprint_realloc_by_type(buf, buf_len, out_len, ++ if (var->type != ASN_IPADDRESS) { ++ if (!netsnmp_ds_get_boolean( ++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) { ++ u_char str[] = "Wrong Type (should be NetworkAddress): "; ++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) ++ return 0; ++ } ++ return sprint_realloc_by_type(buf, buf_len, out_len, + allow_realloc, var, NULL, NULL, + NULL); +- } else { +- return 0; +- } + } + + if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) { +@@ -1679,16 +1679,16 @@ sprint_realloc_ipaddress(u_char ** buf, size_t * buf_len, size_t * out_len, + { + u_char *ip = var->val.string; + +- if ((var->type != ASN_IPADDRESS) && +- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) { +- u_char str[] = "Wrong Type (should be IpAddress): "; +- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) { +- return sprint_realloc_by_type(buf, buf_len, out_len, ++ if (var->type != ASN_IPADDRESS) { ++ if (!netsnmp_ds_get_boolean( ++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) { ++ u_char str[] = "Wrong Type (should be IpAddress): "; ++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) ++ return 0; ++ } ++ return sprint_realloc_by_type(buf, buf_len, out_len, + allow_realloc, var, NULL, NULL, + NULL); +- } else { +- return 0; +- } + } + + if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) { +@@ -1737,20 +1737,20 @@ sprint_realloc_null(u_char ** buf, size_t * buf_len, size_t * out_len, + const struct enum_list *enums, + const char *hint, const char *units) + { +- if ((var->type != ASN_NULL) && +- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) { +- u_char str[] = "Wrong Type (should be NULL): "; +- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) { +- return sprint_realloc_by_type(buf, buf_len, out_len, ++ if (var->type != ASN_NULL) { ++ if (!netsnmp_ds_get_boolean( ++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) { ++ u_char str[] = "Wrong Type (should be NULL): "; ++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) ++ return 0; ++ } ++ return sprint_realloc_by_type(buf, buf_len, out_len, + allow_realloc, var, NULL, NULL, + NULL); +- } else { +- return 0; +- } +- } else { +- u_char str[] = "NULL"; +- return snmp_strcat(buf, buf_len, out_len, allow_realloc, str); + } ++ ++ u_char str[] = "NULL"; ++ return snmp_strcat(buf, buf_len, out_len, allow_realloc, str); + } + + +@@ -1785,16 +1785,16 @@ sprint_realloc_bitstring(u_char ** buf, size_t * buf_len, size_t * out_len, + u_char *cp; + char *enum_string; + +- if ((var->type != ASN_BIT_STR && var->type != ASN_OCTET_STR) && +- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) { +- u_char str[] = "Wrong Type (should be BITS): "; +- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) { +- return sprint_realloc_by_type(buf, buf_len, out_len, ++ if (var->type != ASN_BIT_STR && var->type != ASN_OCTET_STR) { ++ if (!netsnmp_ds_get_boolean( ++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) { ++ u_char str[] = "Wrong Type (should be BITS): "; ++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) ++ return 0; ++ } ++ return sprint_realloc_by_type(buf, buf_len, out_len, + allow_realloc, var, NULL, NULL, + NULL); +- } else { +- return 0; +- } + } + + if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) { +@@ -1869,16 +1869,16 @@ sprint_realloc_nsapaddress(u_char ** buf, size_t * buf_len, + const struct enum_list *enums, const char *hint, + const char *units) + { +- if ((var->type != ASN_NSAP) && +- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) { +- u_char str[] = "Wrong Type (should be NsapAddress): "; +- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) { +- return sprint_realloc_by_type(buf, buf_len, out_len, ++ if (var->type != ASN_NSAP) { ++ if (!netsnmp_ds_get_boolean( ++ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) { ++ u_char str[] = "Wrong Type (should be NsapAddress): "; ++ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) ++ return 0; ++ } ++ return sprint_realloc_by_type(buf, buf_len, out_len, + allow_realloc, var, NULL, NULL, + NULL); +- } else { +- return 0; +- } + } + + if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) { +-- +1.7.10.4 + diff --git a/meta-networking/recipes-protocols/net-snmp/net-snmp/snmpd.service b/meta-networking/recipes-protocols/net-snmp/net-snmp/snmpd.service new file mode 100644 index 0000000000..10a1eb2128 --- /dev/null +++ b/meta-networking/recipes-protocols/net-snmp/net-snmp/snmpd.service @@ -0,0 +1,13 @@ +[Unit] +Description=Simple Network Management Protocol (SNMP) Daemon. +After=syslog.target network.target + +[Service] +Type=notify +Environment=OPTIONS="-LS0-6d" +EnvironmentFile=-/etc/default/snmpd +ExecStart=/usr/sbin/snmpd $OPTIONS -f +ExecReload=/bin/kill -HUP $MAINPID + +[Install] +WantedBy=multi-user.target diff --git a/meta-networking/recipes-protocols/net-snmp/net-snmp/snmptrapd.service b/meta-networking/recipes-protocols/net-snmp/net-snmp/snmptrapd.service new file mode 100644 index 0000000000..951f9f2707 --- /dev/null +++ b/meta-networking/recipes-protocols/net-snmp/net-snmp/snmptrapd.service @@ -0,0 +1,13 @@ +[Unit] +Description=Simple Network Management Protocol (SNMP) Trap Daemon. +After=syslog.target network.target + +[Service] +Type=notify +Environment=OPTIONS="-Lsd" +EnvironmentFile=-/etc/default/snmptrapd +ExecStart=/usr/sbin/snmptrapd $OPTIONS -f +ExecReload=/bin/kill -HUP $MAINPID + +[Install] +WantedBy=multi-user.target diff --git a/meta-networking/recipes-protocols/net-snmp/net-snmp/systemd-support.patch b/meta-networking/recipes-protocols/net-snmp/net-snmp/systemd-support.patch new file mode 100644 index 0000000000..e19153bbc4 --- /dev/null +++ b/meta-networking/recipes-protocols/net-snmp/net-snmp/systemd-support.patch @@ -0,0 +1,1618 @@ +Systemd support backported from the master branch as of 23/04/2012 (post 5.7.1, pre 5.8). + +The following commits have been cherry-picked: + +19499c3c90bf9d7b2b9e5d08baa26cc6bba28a11 +fef6cddfdb94da1a6b1fb768af62918b80f11fd3 +0641e43c694c485cbbffef0556efc4641bd3ff50 +76530a89f1c8bbd0b63acce63e10d5d4812a1a16 (conflict resolved) +bf108d7f1354f6276fc43c129963f2c49b9fc242 +3692875172352f72cf3afd0d35f355e83d7e421b +74412748067c685e1d8ab6ed3bcc3ca9c2774844 +86132e3f1e6ef7b4e0b96d8fa24e37c81b71b0e0 +63557cf8986a33dba1d4429b583a901361052c4f + +Upstream-Status: Backport + +Signed-off-by: Thomas Fitzsimmons +diff --git a/README.systemd b/README.systemd +new file mode 100644 +index 0000000..f731851 +--- /dev/null ++++ b/README.systemd +@@ -0,0 +1,41 @@ ++README.systemd ++-------------- ++Net-SNMP provides two daemons, which support systemd system manager. ++See http://www.freedesktop.org/wiki/Software/systemd to learn how ++systemd works. Both socket activation and notification is supported by these ++daemons. ++ ++To enable systemd support, the sources must be compiled with ++--with-systemd configure option. ++ ++snmpd - The SNMP agent ++---------------------- ++Socket activation od snmpd daemon is implemented, but it's discouraged. ++The reason is simple - snmpd not only listens and processes SNMP requests ++from network, but also gathers system statistics counters, sends traps and ++communicates with subagents. It even opens few netlink sockets. ++ ++In other words, snmpd should run from system start to properly work. ++This can be done in two ways: ++1) either as snmpd service unit with 'Type=notification' and without a socket ++ unit ++2) or as snmpd service unit with 'Type=simple', appropriate socket socket unit ++ and the snmpd service enabled. This way systemd creates the snmpd listening ++ socket early during boot and passes the sockets to snmpd slightly later ++ (but still during machine boot). This way systemd can paralelize start of ++ services, which depend on snmpd. Admins must adjust the socket file manually, ++ depending if the snmpd support AgentX, IPv6, SMUX etc. ++ ++snmpd should be started with '-f' command line parameter to disable forking - ++systemd does that for us automatically. ++ ++ ++snmptrapd - The trap processing daemon ++-------------------------------------- ++snmptrapd supports full socket activation and also notification (if needed). ++Both 'Type=simple' (with appropriate socket unit) and 'Type=notify' services ++will work. Again, '-f' parameter should be provided on snmptrapd command line. ++ ++If integration with SNMP agent using AgentX protocol is enabled, snmptrapd should ++start during boot and not after first SNMP trap arrives. Same rules as for snmpd ++applies then. +\ No newline at end of file +diff --git a/agent/snmpd.c b/agent/snmpd.c +index b177d5b..08bdfc7 100644 +--- a/agent/snmpd.c ++++ b/agent/snmpd.c +@@ -164,6 +164,10 @@ typedef long fd_mask; + + #endif + ++#ifndef NETSNMP_NO_SYSTEMD ++#include ++#endif ++ + netsnmp_feature_want(logging_file) + netsnmp_feature_want(logging_stdio) + netsnmp_feature_want(logging_syslog) +@@ -441,18 +445,28 @@ main(int argc, char *argv[]) + int agent_mode = -1; + char *pid_file = NULL; + char option_compatability[] = "-Le"; ++#ifndef WIN32 ++ int prepared_sockets = 0; ++#endif + #if HAVE_GETPID + int fd; + FILE *PID; + #endif + + #ifndef WIN32 ++#ifndef NETSNMP_NO_SYSTEMD ++ /* check if systemd has sockets for us and don't close them */ ++ prepared_sockets = netsnmp_sd_listen_fds(0); ++#endif /* NETSNMP_NO_SYSTEMD */ ++ + /* + * close all non-standard file descriptors we may have + * inherited from the shell. + */ +- for (i = getdtablesize() - 1; i > 2; --i) { +- (void) close(i); ++ if (!prepared_sockets) { ++ for (i = getdtablesize() - 1; i > 2; --i) { ++ (void) close(i); ++ } + } + #endif /* #WIN32 */ + +@@ -1100,6 +1114,19 @@ main(int argc, char *argv[]) + netsnmp_addrcache_initialise(); + + /* ++ * Let systemd know we're up. ++ */ ++#ifndef NETSNMP_NO_SYSTEMD ++ netsnmp_sd_notify(1, "READY=1\n"); ++ if (prepared_sockets) ++ /* ++ * Clear the environment variable, we already processed all the sockets ++ * by now. ++ */ ++ netsnmp_sd_listen_fds(1); ++#endif ++ ++ /* + * Forever monitor the dest_port for incoming PDUs. + */ + DEBUGMSGTL(("snmpd/main", "We're up. Starting to process data.\n")); +diff --git a/apps/snmptrapd.c b/apps/snmptrapd.c +index 1a52080..0857ae1 100644 +--- a/apps/snmptrapd.c ++++ b/apps/snmptrapd.c +@@ -125,6 +125,10 @@ SOFTWARE. + + #include + ++#ifndef NETSNMP_NO_SYSTEMD ++#include ++#endif ++ + #ifndef BSD4_3 + #define BSD4_2 + #endif +@@ -655,15 +659,24 @@ main(int argc, char *argv[]) + int agentx_subagent = 1; + #endif + netsnmp_trapd_handler *traph; ++#ifndef WIN32 ++ int prepared_sockets = 0; ++#endif + + + #ifndef WIN32 ++#ifndef NETSNMP_NO_SYSTEMD ++ /* check if systemd has sockets for us and don't close them */ ++ prepared_sockets = netsnmp_sd_listen_fds(0); ++#endif + /* + * close all non-standard file descriptors we may have + * inherited from the shell. + */ +- for (i = getdtablesize() - 1; i > 2; --i) { +- (void) close(i); ++ if (!prepared_sockets) { ++ for (i = getdtablesize() - 1; i > 2; --i) { ++ (void) close(i); ++ } + } + #endif /* #WIN32 */ + +@@ -1311,6 +1324,19 @@ main(int argc, char *argv[]) + #endif + #endif + ++ /* ++ * Let systemd know we're up. ++ */ ++#ifndef NETSNMP_NO_SYSTEMD ++ netsnmp_sd_notify(1, "READY=1\n"); ++ if (prepared_sockets) ++ /* ++ * Clear the environment variable, we already processed all the sockets ++ * by now. ++ */ ++ netsnmp_sd_listen_fds(1); ++#endif ++ + #ifdef WIN32SERVICE + trapd_status = SNMPTRAPD_RUNNING; + #endif +diff --git a/configure.d/config_modules_lib b/configure.d/config_modules_lib +index b6609c1..5849072 100644 +--- a/configure.d/config_modules_lib ++++ b/configure.d/config_modules_lib +@@ -53,6 +53,14 @@ if test "x$PARTIALTARGETOS" = "xmingw32" -o "x$PARTIALTARGETOS" = "xmingw32msvc" + other_ftobjs_list="$other_ftobjs_list winpipe.ft" + fi + ++# Linux systemd ++if test "x$with_systemd" == "xyes"; then ++ other_src_list="$other_src_list sd-daemon.c" ++ other_objs_list="$other_objs_list sd-daemon.o" ++ other_lobjs_list="$other_lobjs_list sd-daemon.lo" ++ other_ftobjs_list="$other_ftobjs_list sd-daemon.ft" ++fi ++ + AC_SUBST(other_src_list) + AC_SUBST(other_objs_list) + AC_SUBST(other_lobjs_list) +diff --git a/configure.d/config_project_with_enable b/configure.d/config_project_with_enable +index 8b46ad2..59d6d5c 100644 +--- a/configure.d/config_project_with_enable ++++ b/configure.d/config_project_with_enable +@@ -689,6 +689,15 @@ if test "x$with_dummy_values" != "xyes"; then + data for]) + fi + ++NETSNMP_ARG_WITH(systemd, ++[ --with-systemd Provide systemd support. See README.systemd ++ for details.]) ++# Define unless specifically suppressed (i.e., option defaults to false). ++if test "x$with_systemd" != "xyes"; then ++ AC_DEFINE(NETSNMP_NO_SYSTEMD, 1, ++ [If you don't want to integrate with systemd.]) ++fi ++ + NETSNMP_ARG_ENABLE(set-support, + [ --disable-set-support Do not allow SNMP set requests.]) + if test "x$enable_set_support" = "xno"; then +diff --git a/dist/snmpd.service b/dist/snmpd.service +new file mode 100644 +index 0000000..31391e5 +--- /dev/null ++++ b/dist/snmpd.service +@@ -0,0 +1,18 @@ ++# ++# SNMP agent service file for systemd ++# ++# ++# The service should be enabled, i.e. snmpd should start during machine boot. ++# Socket activation shall not be used. See README.systemd for details. ++ ++[Unit] ++Description=Simple Network Management Protocol (SNMP) daemon. ++After=syslog.target network.target ++ ++[Service] ++# Type=notify is also supported. It should be set when snmpd.socket is not used. ++Type=simple ++ExecStart=/usr/sbin/snmpd -f ++ ++[Install] ++WantedBy=multi-user.target +diff --git a/dist/snmpd.socket b/dist/snmpd.socket +new file mode 100644 +index 0000000..7f3a2d9 +--- /dev/null ++++ b/dist/snmpd.socket +@@ -0,0 +1,17 @@ ++[Unit] ++Description=Socket listening for SNMP and AgentX messages ++ ++[Socket] ++ListenDatagram=0.0.0.0:161 ++# Uncomment other listening addresses as needed - TCP, UDP6, TCP6. ++# It must match listening addresses/ports defined in snmpd.service ++# or snmpd.conf. ++# ListenStream=0.0.0.0:161 ++# ListenDatagram=[::]:161 ++# ListenStream=[::]:161 ++# ++# Uncomment AgentX socket if snmpd.conf enables AgentX protocol. ++# ListenStream=/var/agentx/master ++ ++[Install] ++WantedBy=sockets.target +diff --git a/dist/snmptrapd.service b/dist/snmptrapd.service +new file mode 100644 +index 0000000..e88a5b4 +--- /dev/null ++++ b/dist/snmptrapd.service +@@ -0,0 +1,16 @@ ++# ++# SNMP trap-processing service file for systemd ++# ++ ++[Unit] ++Description=Simple Network Management Protocol (SNMP) Trap daemon. ++After=syslog.target network.target ++ ++[Service] ++# Type=notify is also supported. It should be set when snmptrapd.socket is not ++# used. ++Type=simple ++ExecStart=/usr/sbin/snmptrapd -f ++ ++[Install] ++WantedBy=multi-user.target +diff --git a/dist/snmptrapd.socket b/dist/snmptrapd.socket +new file mode 100644 +index 0000000..0fc8a7c +--- /dev/null ++++ b/dist/snmptrapd.socket +@@ -0,0 +1,14 @@ ++[Unit] ++Description=Socket listening for SNMP trap messages ++ ++[Socket] ++ListenDatagram=0.0.0.0:162 ++# Uncomment other listening addresses as needed - TCP, UDP6, TCP6. ++# It must match listening addresses/ports defined in snmptrapd.service ++# or snmptrapd.conf. ++# ListenStream=0.0.0.0:162 ++# ListenDatagram=[::]:162 ++# ListenStream=[::]:162 ++ ++[Install] ++WantedBy=sockets.target +diff --git a/include/net-snmp/library/sd-daemon.h b/include/net-snmp/library/sd-daemon.h +new file mode 100644 +index 0000000..85274c9 +--- /dev/null ++++ b/include/net-snmp/library/sd-daemon.h +@@ -0,0 +1,290 @@ ++/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ ++ ++#ifndef SNMPD_SD_DAEMON_H ++#define SNMPD_SD_DAEMON_H ++ ++/*** ++ Copyright 2010 Lennart Poettering ++ ++ Permission is hereby granted, free of charge, to any person ++ obtaining a copy of this software and associated documentation files ++ (the "Software"), to deal in the Software without restriction, ++ including without limitation the rights to use, copy, modify, merge, ++ publish, distribute, sublicense, and/or sell copies of the Software, ++ and to permit persons to whom the Software is furnished to do so, ++ subject to the following conditions: ++ ++ The above copyright notice and this permission notice shall be ++ included in all copies or substantial portions of the Software. ++ ++ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ++ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ++ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS ++ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ++ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN ++ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ++ SOFTWARE. ++***/ ++ ++#ifdef HAVE_SYS_TYPES_H ++#include ++#endif ++#ifdef HAVE_INTTYPES_H ++#include ++#endif ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++/* ++ Reference implementation of a few systemd related interfaces for ++ writing daemons. These interfaces are trivial to implement. To ++ simplify porting we provide this reference implementation. ++ Applications are welcome to reimplement the algorithms described ++ here if they do not want to include these two source files. ++ ++ The following functionality is provided: ++ ++ - Support for logging with log levels on stderr ++ - File descriptor passing for socket-based activation ++ - Daemon startup and status notification ++ - Detection of systemd boots ++ ++ You may compile this with -DDISABLE_SYSTEMD to disable systemd ++ support. This makes all those calls NOPs that are directly related to ++ systemd (i.e. only sd_is_xxx() will stay useful). ++ ++ Since this is drop-in code we don't want any of our symbols to be ++ exported in any case. Hence we declare hidden visibility for all of ++ them. ++ ++ You may find an up-to-date version of these source files online: ++ ++ http://cgit.freedesktop.org/systemd/plain/src/sd-daemon.h ++ http://cgit.freedesktop.org/systemd/plain/src/sd-daemon.c ++ ++ This should compile on non-Linux systems, too, but with the ++ exception of the sd_is_xxx() calls all functions will become NOPs. ++ ++ See sd-daemon(7) for more information. ++*/ ++ ++#ifndef _sd_printf_attr_ ++#if __GNUC__ >= 4 ++#define _sd_printf_attr_(a,b) __attribute__ ((format (printf, a, b))) ++#else ++#define _sd_printf_attr_(a,b) ++#endif ++#endif ++ ++/* ++ Log levels for usage on stderr: ++ ++ fprintf(stderr, SD_NOTICE "Hello World!\n"); ++ ++ This is similar to printk() usage in the kernel. ++*/ ++#define SD_EMERG "<0>" /* system is unusable */ ++#define SD_ALERT "<1>" /* action must be taken immediately */ ++#define SD_CRIT "<2>" /* critical conditions */ ++#define SD_ERR "<3>" /* error conditions */ ++#define SD_WARNING "<4>" /* warning conditions */ ++#define SD_NOTICE "<5>" /* normal but significant condition */ ++#define SD_INFO "<6>" /* informational */ ++#define SD_DEBUG "<7>" /* debug-level messages */ ++ ++/* The first passed file descriptor is fd 3 */ ++#define SD_LISTEN_FDS_START 3 ++ ++/* ++ Returns how many file descriptors have been passed, or a negative ++ errno code on failure. Optionally, removes the $LISTEN_FDS and ++ $LISTEN_PID file descriptors from the environment (recommended, but ++ problematic in threaded environments). If r is the return value of ++ this function you'll find the file descriptors passed as fds ++ SD_LISTEN_FDS_START to SD_LISTEN_FDS_START+r-1. Returns a negative ++ errno style error code on failure. This function call ensures that ++ the FD_CLOEXEC flag is set for the passed file descriptors, to make ++ sure they are not passed on to child processes. If FD_CLOEXEC shall ++ not be set, the caller needs to unset it after this call for all file ++ descriptors that are used. ++ ++ See sd_listen_fds(3) for more information. ++*/ ++int netsnmp_sd_listen_fds(int unset_environment); ++ ++/* ++ Helper call for identifying a passed file descriptor. Returns 1 if ++ the file descriptor is a FIFO in the file system stored under the ++ specified path, 0 otherwise. If path is NULL a path name check will ++ not be done and the call only verifies if the file descriptor ++ refers to a FIFO. Returns a negative errno style error code on ++ failure. ++ ++ See sd_is_fifo(3) for more information. ++*/ ++int netsnmp_sd_is_fifo(int fd, const char *path); ++ ++/* ++ Helper call for identifying a passed file descriptor. Returns 1 if ++ the file descriptor is a special character device on the file ++ system stored under the specified path, 0 otherwise. ++ If path is NULL a path name check will not be done and the call ++ only verifies if the file descriptor refers to a special character. ++ Returns a negative errno style error code on failure. ++ ++ See sd_is_special(3) for more information. ++*/ ++int netsnmp_sd_is_special(int fd, const char *path); ++ ++/* ++ Helper call for identifying a passed file descriptor. Returns 1 if ++ the file descriptor is a socket of the specified family (AF_INET, ++ ...) and type (SOCK_DGRAM, SOCK_STREAM, ...), 0 otherwise. If ++ family is 0 a socket family check will not be done. If type is 0 a ++ socket type check will not be done and the call only verifies if ++ the file descriptor refers to a socket. If listening is > 0 it is ++ verified that the socket is in listening mode. (i.e. listen() has ++ been called) If listening is == 0 it is verified that the socket is ++ not in listening mode. If listening is < 0 no listening mode check ++ is done. Returns a negative errno style error code on failure. ++ ++ See sd_is_socket(3) for more information. ++*/ ++int netsnmp_sd_is_socket(int fd, int family, int type, int listening); ++ ++/* ++ Helper call for identifying a passed file descriptor. Returns 1 if ++ the file descriptor is an Internet socket, of the specified family ++ (either AF_INET or AF_INET6) and the specified type (SOCK_DGRAM, ++ SOCK_STREAM, ...), 0 otherwise. If version is 0 a protocol version ++ check is not done. If type is 0 a socket type check will not be ++ done. If port is 0 a socket port check will not be done. The ++ listening flag is used the same way as in sd_is_socket(). Returns a ++ negative errno style error code on failure. ++ ++ See sd_is_socket_inet(3) for more information. ++*/ ++int netsnmp_sd_is_socket_inet(int fd, int family, int type, int listening, uint16_t port); ++ ++/* ++ Helper call for identifying a passed file descriptor. Returns 1 if ++ the file descriptor is an AF_UNIX socket of the specified type ++ (SOCK_DGRAM, SOCK_STREAM, ...) and path, 0 otherwise. If type is 0 ++ a socket type check will not be done. If path is NULL a socket path ++ check will not be done. For normal AF_UNIX sockets set length to ++ 0. For abstract namespace sockets set length to the length of the ++ socket name (including the initial 0 byte), and pass the full ++ socket path in path (including the initial 0 byte). The listening ++ flag is used the same way as in sd_is_socket(). Returns a negative ++ errno style error code on failure. ++ ++ See sd_is_socket_unix(3) for more information. ++*/ ++int netsnmp_sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t length); ++ ++/* ++ Informs systemd about changed daemon state. This takes a number of ++ newline separated environment-style variable assignments in a ++ string. The following variables are known: ++ ++ READY=1 Tells systemd that daemon startup is finished (only ++ relevant for services of Type=notify). The passed ++ argument is a boolean "1" or "0". Since there is ++ little value in signaling non-readiness the only ++ value daemons should send is "READY=1". ++ ++ STATUS=... Passes a single-line status string back to systemd ++ that describes the daemon state. This is free-from ++ and can be used for various purposes: general state ++ feedback, fsck-like programs could pass completion ++ percentages and failing programs could pass a human ++ readable error message. Example: "STATUS=Completed ++ 66% of file system check..." ++ ++ ERRNO=... If a daemon fails, the errno-style error code, ++ formatted as string. Example: "ERRNO=2" for ENOENT. ++ ++ BUSERROR=... If a daemon fails, the D-Bus error-style error ++ code. Example: "BUSERROR=org.freedesktop.DBus.Error.TimedOut" ++ ++ MAINPID=... The main pid of a daemon, in case systemd did not ++ fork off the process itself. Example: "MAINPID=4711" ++ ++ Daemons can choose to send additional variables. However, it is ++ recommended to prefix variable names not listed above with X_. ++ ++ Returns a negative errno-style error code on failure. Returns > 0 ++ if systemd could be notified, 0 if it couldn't possibly because ++ systemd is not running. ++ ++ Example: When a daemon finished starting up, it could issue this ++ call to notify systemd about it: ++ ++ sd_notify(0, "READY=1"); ++ ++ See sd_notifyf() for more complete examples. ++ ++ See sd_notify(3) for more information. ++*/ ++int netsnmp_sd_notify(int unset_environment, const char *state); ++ ++/* ++ Similar to sd_notify() but takes a format string. ++ ++ Example 1: A daemon could send the following after initialization: ++ ++ sd_notifyf(0, "READY=1\n" ++ "STATUS=Processing requests...\n" ++ "MAINPID=%lu", ++ (unsigned long) getpid()); ++ ++ Example 2: A daemon could send the following shortly before ++ exiting, on failure: ++ ++ sd_notifyf(0, "STATUS=Failed to start up: %s\n" ++ "ERRNO=%i", ++ strerror(errno), ++ errno); ++ ++ See sd_notifyf(3) for more information. ++*/ ++int netsnmp_sd_notifyf(int unset_environment, const char *format, ...) _sd_printf_attr_(2,3); ++ ++/* ++ Returns > 0 if the system was booted with systemd. Returns < 0 on ++ error. Returns 0 if the system was not booted with systemd. Note ++ that all of the functions above handle non-systemd boots just ++ fine. You should NOT protect them with a call to this function. Also ++ note that this function checks whether the system, not the user ++ session is controlled by systemd. However the functions above work ++ for both user and system services. ++ ++ See sd_booted(3) for more information. ++*/ ++int netsnmp_sd_booted(void); ++ ++/** ++ * Find an socket with given parameters. See man sd_is_socket_inet for ++ * description of the arguments. ++ * ++ * Returns the file descriptor if it is found, 0 otherwise. ++ */ ++int netsnmp_sd_find_inet_socket(int family, int type, int listening, int port); ++ ++/** ++ * Find an unix socket with given parameters. See man sd_is_socket_unix for ++ * description of the arguments. ++ * ++ * Returns the file descriptor if it is found, 0 otherwise. ++ */ ++int ++netsnmp_sd_find_unix_socket(int type, int listening, const char *path); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* SNMPD_SD_DAEMON_H */ +diff --git a/snmplib/sd-daemon.c b/snmplib/sd-daemon.c +new file mode 100644 +index 0000000..42dba29 +--- /dev/null ++++ b/snmplib/sd-daemon.c +@@ -0,0 +1,532 @@ ++/* ++ * Systemd integration parts. ++ * ++ * Most of this file is directly copied from systemd sources. ++ * Changes: ++ * - all functions were renamed to have netsnmp_ prefix ++ * - includes were changed to match Net-SNMP style. ++ * - removed gcc export macros ++ * - removed POSIX message queues ++ */ ++ ++#include ++#include ++#include ++#include ++ ++#ifndef NETSNMP_NO_SYSTEMD ++ ++/*** ++ Copyright 2010 Lennart Poettering ++ ++ Permission is hereby granted, free of charge, to any person ++ obtaining a copy of this software and associated documentation files ++ (the "Software"), to deal in the Software without restriction, ++ including without limitation the rights to use, copy, modify, merge, ++ publish, distribute, sublicense, and/or sell copies of the Software, ++ and to permit persons to whom the Software is furnished to do so, ++ subject to the following conditions: ++ ++ The above copyright notice and this permission notice shall be ++ included in all copies or substantial portions of the Software. ++ ++ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ++ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ++ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS ++ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ++ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN ++ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ++ SOFTWARE. ++***/ ++ ++#ifndef _GNU_SOURCE ++#define _GNU_SOURCE ++#endif ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++ ++int netsnmp_sd_listen_fds(int unset_environment) { ++ ++ int r, fd; ++ const char *e; ++ char *p = NULL; ++ unsigned long l; ++ ++ if (!(e = getenv("LISTEN_PID"))) { ++ r = 0; ++ goto finish; ++ } ++ ++ errno = 0; ++ l = strtoul(e, &p, 10); ++ ++ if (errno != 0) { ++ r = -errno; ++ goto finish; ++ } ++ ++ if (!p || *p || l <= 0) { ++ r = -EINVAL; ++ goto finish; ++ } ++ ++ /* Is this for us? */ ++ if (getpid() != (pid_t) l) { ++ r = 0; ++ goto finish; ++ } ++ ++ if (!(e = getenv("LISTEN_FDS"))) { ++ r = 0; ++ goto finish; ++ } ++ ++ errno = 0; ++ l = strtoul(e, &p, 10); ++ ++ if (errno != 0) { ++ r = -errno; ++ goto finish; ++ } ++ ++ if (!p || *p) { ++ r = -EINVAL; ++ goto finish; ++ } ++ ++ for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + (int) l; fd ++) { ++ int flags; ++ ++ if ((flags = fcntl(fd, F_GETFD)) < 0) { ++ r = -errno; ++ goto finish; ++ } ++ ++ if (flags & FD_CLOEXEC) ++ continue; ++ ++ if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) < 0) { ++ r = -errno; ++ goto finish; ++ } ++ } ++ ++ r = (int) l; ++ ++finish: ++ if (unset_environment) { ++ unsetenv("LISTEN_PID"); ++ unsetenv("LISTEN_FDS"); ++ } ++ ++ return r; ++} ++ ++int netsnmp_sd_is_fifo(int fd, const char *path) { ++ struct stat st_fd; ++ ++ if (fd < 0) ++ return -EINVAL; ++ ++ memset(&st_fd, 0, sizeof(st_fd)); ++ if (fstat(fd, &st_fd) < 0) ++ return -errno; ++ ++ if (!S_ISFIFO(st_fd.st_mode)) ++ return 0; ++ ++ if (path) { ++ struct stat st_path; ++ ++ memset(&st_path, 0, sizeof(st_path)); ++ if (stat(path, &st_path) < 0) { ++ ++ if (errno == ENOENT || errno == ENOTDIR) ++ return 0; ++ ++ return -errno; ++ } ++ ++ return ++ st_path.st_dev == st_fd.st_dev && ++ st_path.st_ino == st_fd.st_ino; ++ } ++ ++ return 1; ++} ++ ++int netsnmp_sd_is_special(int fd, const char *path) { ++ struct stat st_fd; ++ ++ if (fd < 0) ++ return -EINVAL; ++ ++ if (fstat(fd, &st_fd) < 0) ++ return -errno; ++ ++ if (!S_ISREG(st_fd.st_mode) && !S_ISCHR(st_fd.st_mode)) ++ return 0; ++ ++ if (path) { ++ struct stat st_path; ++ ++ if (stat(path, &st_path) < 0) { ++ ++ if (errno == ENOENT || errno == ENOTDIR) ++ return 0; ++ ++ return -errno; ++ } ++ ++ if (S_ISREG(st_fd.st_mode) && S_ISREG(st_path.st_mode)) ++ return ++ st_path.st_dev == st_fd.st_dev && ++ st_path.st_ino == st_fd.st_ino; ++ else if (S_ISCHR(st_fd.st_mode) && S_ISCHR(st_path.st_mode)) ++ return st_path.st_rdev == st_fd.st_rdev; ++ else ++ return 0; ++ } ++ ++ return 1; ++} ++ ++static int sd_is_socket_internal(int fd, int type, int listening) { ++ struct stat st_fd; ++ ++ if (fd < 0 || type < 0) ++ return -EINVAL; ++ ++ if (fstat(fd, &st_fd) < 0) ++ return -errno; ++ ++ if (!S_ISSOCK(st_fd.st_mode)) ++ return 0; ++ ++ if (type != 0) { ++ int other_type = 0; ++ socklen_t l = sizeof(other_type); ++ ++ if (getsockopt(fd, SOL_SOCKET, SO_TYPE, &other_type, &l) < 0) ++ return -errno; ++ ++ if (l != sizeof(other_type)) ++ return -EINVAL; ++ ++ if (other_type != type) ++ return 0; ++ } ++ ++ if (listening >= 0) { ++ int accepting = 0; ++ socklen_t l = sizeof(accepting); ++ ++ if (getsockopt(fd, SOL_SOCKET, SO_ACCEPTCONN, &accepting, &l) < 0) ++ return -errno; ++ ++ if (l != sizeof(accepting)) ++ return -EINVAL; ++ ++ if (!accepting != !listening) ++ return 0; ++ } ++ ++ return 1; ++} ++ ++union sockaddr_union { ++ struct sockaddr sa; ++ struct sockaddr_in in4; ++ struct sockaddr_in6 in6; ++ struct sockaddr_un un; ++ struct sockaddr_storage storage; ++}; ++ ++int netsnmp_sd_is_socket(int fd, int family, int type, int listening) { ++ int r; ++ ++ if (family < 0) ++ return -EINVAL; ++ ++ if ((r = sd_is_socket_internal(fd, type, listening)) <= 0) ++ return r; ++ ++ if (family > 0) { ++ union sockaddr_union sockaddr; ++ socklen_t l; ++ ++ memset(&sockaddr, 0, sizeof(sockaddr)); ++ l = sizeof(sockaddr); ++ ++ if (getsockname(fd, &sockaddr.sa, &l) < 0) ++ return -errno; ++ ++ if (l < sizeof(sa_family_t)) ++ return -EINVAL; ++ ++ return sockaddr.sa.sa_family == family; ++ } ++ ++ return 1; ++} ++ ++int netsnmp_sd_is_socket_inet(int fd, int family, int type, int listening, uint16_t port) { ++ union sockaddr_union sockaddr; ++ socklen_t l; ++ int r; ++ ++ if (family != 0 && family != AF_INET && family != AF_INET6) ++ return -EINVAL; ++ ++ if ((r = sd_is_socket_internal(fd, type, listening)) <= 0) ++ return r; ++ ++ memset(&sockaddr, 0, sizeof(sockaddr)); ++ l = sizeof(sockaddr); ++ ++ if (getsockname(fd, &sockaddr.sa, &l) < 0) ++ return -errno; ++ ++ if (l < sizeof(sa_family_t)) ++ return -EINVAL; ++ ++ if (sockaddr.sa.sa_family != AF_INET && ++ sockaddr.sa.sa_family != AF_INET6) ++ return 0; ++ ++ if (family > 0) ++ if (sockaddr.sa.sa_family != family) ++ return 0; ++ ++ if (port > 0) { ++ if (sockaddr.sa.sa_family == AF_INET) { ++ if (l < sizeof(struct sockaddr_in)) ++ return -EINVAL; ++ ++ return htons(port) == sockaddr.in4.sin_port; ++ } else { ++ if (l < sizeof(struct sockaddr_in6)) ++ return -EINVAL; ++ ++ return htons(port) == sockaddr.in6.sin6_port; ++ } ++ } ++ ++ return 1; ++} ++ ++int netsnmp_sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t length) { ++ union sockaddr_union sockaddr; ++ socklen_t l; ++ int r; ++ ++ if ((r = sd_is_socket_internal(fd, type, listening)) <= 0) ++ return r; ++ ++ memset(&sockaddr, 0, sizeof(sockaddr)); ++ l = sizeof(sockaddr); ++ ++ if (getsockname(fd, &sockaddr.sa, &l) < 0) ++ return -errno; ++ ++ if (l < sizeof(sa_family_t)) ++ return -EINVAL; ++ ++ if (sockaddr.sa.sa_family != AF_UNIX) ++ return 0; ++ ++ if (path) { ++ if (length <= 0) ++ length = strlen(path); ++ ++ if (length <= 0) ++ /* Unnamed socket */ ++ return l == offsetof(struct sockaddr_un, sun_path); ++ ++ if (path[0]) ++ /* Normal path socket */ ++ return ++ (l >= offsetof(struct sockaddr_un, sun_path) + length + 1) && ++ memcmp(path, sockaddr.un.sun_path, length+1) == 0; ++ else ++ /* Abstract namespace socket */ ++ return ++ (l == offsetof(struct sockaddr_un, sun_path) + length) && ++ memcmp(path, sockaddr.un.sun_path, length) == 0; ++ } ++ ++ return 1; ++} ++ ++int netsnmp_sd_notify(int unset_environment, const char *state) { ++ int fd = -1, r; ++ struct msghdr msghdr; ++ struct iovec iovec; ++ union sockaddr_union sockaddr; ++ const char *e; ++ ++ if (!state) { ++ r = -EINVAL; ++ goto finish; ++ } ++ ++ if (!(e = getenv("NOTIFY_SOCKET"))) ++ return 0; ++ ++ /* Must be an abstract socket, or an absolute path */ ++ if ((e[0] != '@' && e[0] != '/') || e[1] == 0) { ++ r = -EINVAL; ++ goto finish; ++ } ++ ++ if ((fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0)) < 0) { ++ r = -errno; ++ goto finish; ++ } ++ ++ memset(&sockaddr, 0, sizeof(sockaddr)); ++ sockaddr.sa.sa_family = AF_UNIX; ++ strncpy(sockaddr.un.sun_path, e, sizeof(sockaddr.un.sun_path)); ++ ++ if (sockaddr.un.sun_path[0] == '@') ++ sockaddr.un.sun_path[0] = 0; ++ ++ memset(&iovec, 0, sizeof(iovec)); ++ iovec.iov_base = (char *)state; ++ iovec.iov_len = strlen(state); ++ ++ memset(&msghdr, 0, sizeof(msghdr)); ++ msghdr.msg_name = &sockaddr; ++ msghdr.msg_namelen = offsetof(struct sockaddr_un, sun_path) + strlen(e); ++ ++ if (msghdr.msg_namelen > sizeof(struct sockaddr_un)) ++ msghdr.msg_namelen = sizeof(struct sockaddr_un); ++ ++ msghdr.msg_iov = &iovec; ++ msghdr.msg_iovlen = 1; ++ ++ if (sendmsg(fd, &msghdr, MSG_NOSIGNAL) < 0) { ++ r = -errno; ++ goto finish; ++ } ++ ++ r = 1; ++ ++finish: ++ if (unset_environment) ++ unsetenv("NOTIFY_SOCKET"); ++ ++ if (fd >= 0) ++ close(fd); ++ ++ return r; ++} ++ ++int netsnmp_sd_notifyf(int unset_environment, const char *format, ...) { ++ va_list ap; ++ char *p = NULL; ++ int r; ++ ++ va_start(ap, format); ++ r = vasprintf(&p, format, ap); ++ va_end(ap); ++ ++ if (r < 0 || !p) ++ return -ENOMEM; ++ ++ r = netsnmp_sd_notify(unset_environment, p); ++ free(p); ++ ++ return r; ++} ++ ++int netsnmp_sd_booted(void) { ++ struct stat a, b; ++ ++ /* We simply test whether the systemd cgroup hierarchy is ++ * mounted */ ++ ++ if (lstat("/sys/fs/cgroup", &a) < 0) ++ return 0; ++ ++ if (lstat("/sys/fs/cgroup/systemd", &b) < 0) ++ return 0; ++ ++ return a.st_dev != b.st_dev; ++} ++ ++/* End of original sd-daemon.c from systemd sources */ ++ ++int ++netsnmp_sd_find_inet_socket(int family, int type, int listening, int port) ++{ ++ int count, fd; ++ ++ count = netsnmp_sd_listen_fds(0); ++ if (count <= 0) { ++ DEBUGMSGTL(("systemd:find_inet_socket", "No LISTEN_FDS found.\n")); ++ return 0; ++ } ++ DEBUGMSGTL(("systemd:find_inet_socket", "LISTEN_FDS reports %d sockets.\n", ++ count)); ++ ++ for (fd = 3; fd < 3+count; fd++) { ++ int rc = netsnmp_sd_is_socket_inet(fd, family, type, listening, port); ++ if (rc < 0) ++ DEBUGMSGTL(("systemd:find_inet_socket", ++ "sd_is_socket_inet error: %d\n", rc)); ++ if (rc > 0) { ++ DEBUGMSGTL(("systemd:find_inet_socket", ++ "Found the socket in LISTEN_FDS\n")); ++ return fd; ++ } ++ } ++ DEBUGMSGTL(("systemd:find_inet_socket", "Socket not found in LISTEN_FDS\n")); ++ return 0; ++} ++ ++int ++netsnmp_sd_find_unix_socket(int type, int listening, const char *path) ++{ ++ int count, fd; ++ ++ count = netsnmp_sd_listen_fds(0); ++ if (count <= 0) { ++ DEBUGMSGTL(("systemd:find_unix_socket", "No LISTEN_FDS found.\n")); ++ return 0; ++ } ++ DEBUGMSGTL(("systemd:find_unix_socket", "LISTEN_FDS reports %d sockets.\n", ++ count)); ++ ++ for (fd = 3; fd < 3+count; fd++) { ++ int rc = netsnmp_sd_is_socket_unix(fd, type, listening, path, 0); ++ if (rc < 0) ++ DEBUGMSGTL(("systemd:find_unix_socket", ++ "netsnmp_sd_is_socket_unix error: %d\n", rc)); ++ if (rc > 0) { ++ DEBUGMSGTL(("systemd:find_unix_socket", ++ "Found the socket in LISTEN_FDS\n")); ++ return fd; ++ } ++ } ++ DEBUGMSGTL(("systemd:find_unix_socket", "Socket not found in LISTEN_FDS\n")); ++ return 0; ++} ++ ++#endif /* ! NETSNMP_NO_SYSTEMD */ +diff --git a/snmplib/transports/snmpTCPDomain.c b/snmplib/transports/snmpTCPDomain.c +index b8bdba4..ab7f3a1 100644 +--- a/snmplib/transports/snmpTCPDomain.c ++++ b/snmplib/transports/snmpTCPDomain.c +@@ -43,6 +43,10 @@ + #include + #include + ++#ifndef NETSNMP_NO_SYSTEMD ++#include ++#endif ++ + /* + * needs to be in sync with the definitions in snmplib/snmpUDPDomain.c + * and perl/agent/agent.xs +@@ -149,6 +153,7 @@ netsnmp_tcp_transport(struct sockaddr_in *addr, int local) + netsnmp_transport *t = NULL; + netsnmp_udp_addr_pair *addr_pair = NULL; + int rc = 0; ++ int socket_initialized = 0; + + #ifdef NETSNMP_NO_LISTEN_SUPPORT + if (local) +@@ -178,7 +183,19 @@ netsnmp_tcp_transport(struct sockaddr_in *addr, int local) + t->domain_length = + sizeof(netsnmp_snmpTCPDomain) / sizeof(netsnmp_snmpTCPDomain[0]); + +- t->sock = socket(PF_INET, SOCK_STREAM, 0); ++#ifndef NETSNMP_NO_SYSTEMD ++ /* ++ * Maybe the socket was already provided by systemd... ++ */ ++ if (local) { ++ t->sock = netsnmp_sd_find_inet_socket(PF_INET, SOCK_STREAM, 1, ++ ntohs(addr->sin_port)); ++ if (t->sock) ++ socket_initialized = 1; ++ } ++#endif ++ if (!socket_initialized) ++ t->sock = socket(PF_INET, SOCK_STREAM, 0); + if (t->sock < 0) { + netsnmp_transport_free(t); + return NULL; +@@ -215,11 +232,13 @@ netsnmp_tcp_transport(struct sockaddr_in *addr, int local) + setsockopt(t->sock, SOL_SOCKET, SO_REUSEADDR, (void *)&opt, + sizeof(opt)); + +- rc = bind(t->sock, (struct sockaddr *)addr, sizeof(struct sockaddr)); +- if (rc != 0) { +- netsnmp_socketbase_close(t); +- netsnmp_transport_free(t); +- return NULL; ++ if (!socket_initialized) { ++ rc = bind(t->sock, (struct sockaddr *)addr, sizeof(struct sockaddr)); ++ if (rc != 0) { ++ netsnmp_socketbase_close(t); ++ netsnmp_transport_free(t); ++ return NULL; ++ } + } + + /* +@@ -235,12 +254,13 @@ netsnmp_tcp_transport(struct sockaddr_in *addr, int local) + /* + * Now sit here and wait for connections to arrive. + */ +- +- rc = listen(t->sock, NETSNMP_STREAM_QUEUE_LEN); +- if (rc != 0) { +- netsnmp_socketbase_close(t); +- netsnmp_transport_free(t); +- return NULL; ++ if (!socket_initialized) { ++ rc = listen(t->sock, NETSNMP_STREAM_QUEUE_LEN); ++ if (rc != 0) { ++ netsnmp_socketbase_close(t); ++ netsnmp_transport_free(t); ++ return NULL; ++ } + } + + /* +diff --git a/snmplib/transports/snmpTCPIPv6Domain.c b/snmplib/transports/snmpTCPIPv6Domain.c +index 3c96856..305a861 100644 +--- a/snmplib/transports/snmpTCPIPv6Domain.c ++++ b/snmplib/transports/snmpTCPIPv6Domain.c +@@ -49,6 +49,10 @@ + #include + #include + ++#ifndef NETSNMP_NO_SYSTEMD ++#include ++#endif ++ + #include "inet_ntop.h" + + oid netsnmp_TCPIPv6Domain[] = { TRANSPORT_DOMAIN_TCP_IPV6 }; +@@ -140,6 +144,8 @@ netsnmp_tcp6_transport(struct sockaddr_in6 *addr, int local) + { + netsnmp_transport *t = NULL; + int rc = 0; ++ char *str = NULL; ++ int socket_initialized = 0; + + #ifdef NETSNMP_NO_LISTEN_SUPPORT + if (local) +@@ -174,7 +180,19 @@ netsnmp_tcp6_transport(struct sockaddr_in6 *addr, int local) + t->domain = netsnmp_TCPIPv6Domain; + t->domain_length = sizeof(netsnmp_TCPIPv6Domain) / sizeof(oid); + +- t->sock = socket(PF_INET6, SOCK_STREAM, 0); ++#ifndef NETSNMP_NO_SYSTEMD ++ /* ++ * Maybe the socket was already provided by systemd... ++ */ ++ if (local) { ++ t->sock = netsnmp_sd_find_inet_socket(PF_INET6, SOCK_STREAM, 1, ++ ntohs(addr->sin6_port)); ++ if (t->sock) ++ socket_initialized = 1; ++ } ++#endif ++ if (!socket_initialized) ++ t->sock = socket(PF_INET6, SOCK_STREAM, 0); + if (t->sock < 0) { + netsnmp_transport_free(t); + return NULL; +@@ -220,12 +238,14 @@ netsnmp_tcp6_transport(struct sockaddr_in6 *addr, int local) + + setsockopt(t->sock, SOL_SOCKET, SO_REUSEADDR, (void *)&opt, sizeof(opt)); + +- rc = bind(t->sock, (struct sockaddr *) addr, +- sizeof(struct sockaddr_in6)); +- if (rc != 0) { +- netsnmp_socketbase_close(t); +- netsnmp_transport_free(t); +- return NULL; ++ if (!socket_initialized) { ++ rc = bind(t->sock, (struct sockaddr *) addr, ++ sizeof(struct sockaddr_in6)); ++ if (rc != 0) { ++ netsnmp_socketbase_close(t); ++ netsnmp_transport_free(t); ++ return NULL; ++ } + } + + /* +@@ -242,11 +262,13 @@ netsnmp_tcp6_transport(struct sockaddr_in6 *addr, int local) + * Now sit here and wait for connections to arrive. + */ + +- rc = listen(t->sock, NETSNMP_STREAM_QUEUE_LEN); +- if (rc != 0) { +- netsnmp_socketbase_close(t); +- netsnmp_transport_free(t); +- return NULL; ++ if (!socket_initialized) { ++ rc = listen(t->sock, NETSNMP_STREAM_QUEUE_LEN); ++ if (rc != 0) { ++ netsnmp_socketbase_close(t); ++ netsnmp_transport_free(t); ++ return NULL; ++ } + } + + /* +diff --git a/snmplib/transports/snmpUDPIPv4BaseDomain.c b/snmplib/transports/snmpUDPIPv4BaseDomain.c +index c67427b..428e6d6 100644 +--- a/snmplib/transports/snmpUDPIPv4BaseDomain.c ++++ b/snmplib/transports/snmpUDPIPv4BaseDomain.c +@@ -40,6 +40,10 @@ + + #include + ++#ifndef NETSNMP_NO_SYSTEMD ++#include ++#endif ++ + #if (defined(linux) && defined(IP_PKTINFO)) \ + || defined(IP_RECVDSTADDR) && HAVE_STRUCT_MSGHDR_MSG_CONTROL \ + && HAVE_STRUCT_MSGHDR_MSG_FLAGS +@@ -67,6 +71,7 @@ netsnmp_udpipv4base_transport(struct sockaddr_in *addr, int local) + char *client_socket = NULL; + netsnmp_indexed_addr_pair addr_pair; + socklen_t local_addr_len; ++ int socket_initialized = 0; + + #ifdef NETSNMP_NO_LISTEN_SUPPORT + if (local) +@@ -91,7 +96,19 @@ netsnmp_udpipv4base_transport(struct sockaddr_in *addr, int local) + free(str); + } + +- t->sock = socket(PF_INET, SOCK_DGRAM, 0); ++#ifndef NETSNMP_NO_SYSTEMD ++ /* ++ * Maybe the socket was already provided by systemd... ++ */ ++ if (local) { ++ t->sock = netsnmp_sd_find_inet_socket(PF_INET, SOCK_DGRAM, -1, ++ ntohs(addr->sin_port)); ++ if (t->sock) ++ socket_initialized = 1; ++ } ++#endif ++ if (!socket_initialized) ++ t->sock = socket(PF_INET, SOCK_DGRAM, 0); + DEBUGMSGTL(("UDPBase", "openned socket %d as local=%d\n", t->sock, local)); + if (t->sock < 0) { + netsnmp_transport_free(t); +@@ -141,12 +158,14 @@ netsnmp_udpipv4base_transport(struct sockaddr_in *addr, int local) + DEBUGMSGTL(("netsnmp_udp", "set IP_RECVDSTADDR\n")); + } + #endif +- rc = bind(t->sock, (struct sockaddr *) addr, +- sizeof(struct sockaddr)); +- if (rc != 0) { +- netsnmp_socketbase_close(t); +- netsnmp_transport_free(t); +- return NULL; ++ if (!socket_initialized) { ++ rc = bind(t->sock, (struct sockaddr *) addr, ++ sizeof(struct sockaddr)); ++ if (rc != 0) { ++ netsnmp_socketbase_close(t); ++ netsnmp_transport_free(t); ++ return NULL; ++ } + } + t->data = NULL; + t->data_length = 0; +diff --git a/snmplib/transports/snmpUDPIPv6Domain.c b/snmplib/transports/snmpUDPIPv6Domain.c +index b3eaae4..35b617f 100644 +--- a/snmplib/transports/snmpUDPIPv6Domain.c ++++ b/snmplib/transports/snmpUDPIPv6Domain.c +@@ -67,6 +67,10 @@ static const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT; + #include + #include + ++#ifndef NETSNMP_NO_SYSTEMD ++#include ++#endif ++ + #include "inet_ntop.h" + #include "inet_pton.h" + +@@ -190,6 +194,8 @@ netsnmp_udp6_transport(struct sockaddr_in6 *addr, int local) + { + netsnmp_transport *t = NULL; + int rc = 0; ++ char *str = NULL; ++ int socket_initialized = 0; + + #ifdef NETSNMP_NO_LISTEN_SUPPORT + if (local) +@@ -217,7 +223,19 @@ netsnmp_udp6_transport(struct sockaddr_in6 *addr, int local) + t->domain_length = + sizeof(netsnmp_UDPIPv6Domain) / sizeof(netsnmp_UDPIPv6Domain[0]); + +- t->sock = socket(PF_INET6, SOCK_DGRAM, 0); ++#ifndef NETSNMP_NO_SYSTEMD ++ /* ++ * Maybe the socket was already provided by systemd... ++ */ ++ if (local) { ++ t->sock = netsnmp_sd_find_inet_socket(PF_INET6, SOCK_DGRAM, -1, ++ ntohs(addr->sin6_port)); ++ if (t->sock) ++ socket_initialized = 1; ++ } ++#endif ++ if (!socket_initialized) ++ t->sock = socket(PF_INET6, SOCK_DGRAM, 0); + if (t->sock < 0) { + netsnmp_transport_free(t); + return NULL; +@@ -242,13 +260,14 @@ netsnmp_udp6_transport(struct sockaddr_in6 *addr, int local) + } + } + #endif +- +- rc = bind(t->sock, (struct sockaddr *) addr, +- sizeof(struct sockaddr_in6)); +- if (rc != 0) { +- netsnmp_socketbase_close(t); +- netsnmp_transport_free(t); +- return NULL; ++ if (!socket_initialized) { ++ rc = bind(t->sock, (struct sockaddr *) addr, ++ sizeof(struct sockaddr_in6)); ++ if (rc != 0) { ++ netsnmp_socketbase_close(t); ++ netsnmp_transport_free(t); ++ return NULL; ++ } + } + t->local = (unsigned char*)malloc(18); + if (t->local == NULL) { +diff --git a/snmplib/transports/snmpUnixDomain.c b/snmplib/transports/snmpUnixDomain.c +index 674dc2b..9f3d3cb 100644 +--- a/snmplib/transports/snmpUnixDomain.c ++++ b/snmplib/transports/snmpUnixDomain.c +@@ -37,6 +37,10 @@ + #include /* mkdirhier */ + #include + ++#ifndef NETSNMP_NO_SYSTEMD ++#include ++#endif ++ + netsnmp_feature_child_of(transport_unix_socket_all, transport_all) + netsnmp_feature_child_of(unix_socket_paths, transport_unix_socket_all) + +@@ -295,6 +299,8 @@ netsnmp_unix_transport(struct sockaddr_un *addr, int local) + netsnmp_transport *t = NULL; + sockaddr_un_pair *sup = NULL; + int rc = 0; ++ char *string = NULL; ++ int socket_initialized = 0; + + #ifdef NETSNMP_NO_LISTEN_SUPPORT + /* SPECIAL CIRCUMSTANCE: We still want AgentX to be able to operate, +@@ -333,7 +339,18 @@ netsnmp_unix_transport(struct sockaddr_un *addr, int local) + t->data_length = sizeof(sockaddr_un_pair); + sup = (sockaddr_un_pair *) t->data; + +- t->sock = socket(PF_UNIX, SOCK_STREAM, 0); ++#ifndef NETSNMP_NO_SYSTEMD ++ /* ++ * Maybe the socket was already provided by systemd... ++ */ ++ if (local) { ++ t->sock = netsnmp_sd_find_unix_socket(SOCK_STREAM, 1, addr->sun_path); ++ if (t->sock) ++ socket_initialized = 1; ++ } ++#endif ++ if (!socket_initialized) ++ t->sock = socket(PF_UNIX, SOCK_STREAM, 0); + if (t->sock < 0) { + netsnmp_transport_free(t); + return NULL; +@@ -357,25 +374,26 @@ netsnmp_unix_transport(struct sockaddr_un *addr, int local) + + t->flags |= NETSNMP_TRANSPORT_FLAG_LISTEN; + +- unlink(addr->sun_path); +- rc = bind(t->sock, (struct sockaddr *) addr, SUN_LEN(addr)); +- +- if (rc != 0 && errno == ENOENT && create_path) { +- rc = mkdirhier(addr->sun_path, create_mode, 1); ++ if (!socket_initialized) { ++ unlink(addr->sun_path); ++ rc = bind(t->sock, (struct sockaddr *) addr, SUN_LEN(addr)); ++ if (rc != 0 && errno == ENOENT && create_path) { ++ rc = mkdirhier(addr->sun_path, create_mode, 1); ++ if (rc != 0) { ++ netsnmp_unix_close(t); ++ netsnmp_transport_free(t); ++ return NULL; ++ } ++ rc = bind(t->sock, (struct sockaddr *) addr, SUN_LEN(addr)); ++ } + if (rc != 0) { ++ DEBUGMSGTL(("netsnmp_unix_transport", ++ "couldn't bind \"%s\", errno %d (%s)\n", ++ addr->sun_path, errno, strerror(errno))); + netsnmp_unix_close(t); + netsnmp_transport_free(t); + return NULL; + } +- rc = bind(t->sock, (struct sockaddr *) addr, SUN_LEN(addr)); +- } +- if (rc != 0) { +- DEBUGMSGTL(("netsnmp_unix_transport", +- "couldn't bind \"%s\", errno %d (%s)\n", +- addr->sun_path, errno, strerror(errno))); +- netsnmp_unix_close(t); +- netsnmp_transport_free(t); +- return NULL; + } + + /* +@@ -391,16 +409,17 @@ netsnmp_unix_transport(struct sockaddr_un *addr, int local) + * Now sit here and listen for connections to arrive. + */ + +- rc = listen(t->sock, NETSNMP_STREAM_QUEUE_LEN); +- if (rc != 0) { +- DEBUGMSGTL(("netsnmp_unix_transport", +- "couldn't listen to \"%s\", errno %d (%s)\n", +- addr->sun_path, errno, strerror(errno))); +- netsnmp_unix_close(t); +- netsnmp_transport_free(t); +- return NULL; ++ if (!socket_initialized) { ++ rc = listen(t->sock, NETSNMP_STREAM_QUEUE_LEN); ++ if (rc != 0) { ++ DEBUGMSGTL(("netsnmp_unix_transport", ++ "couldn't listen to \"%s\", errno %d (%s)\n", ++ addr->sun_path, errno, strerror(errno))); ++ netsnmp_unix_close(t); ++ netsnmp_transport_free(t); ++ return NULL; ++ } + } +- + } else { + t->remote = (u_char *)malloc(strlen(addr->sun_path)); + if (t->remote == NULL) { +diff --git a/win32/libsnmp/Makefile.in b/win32/libsnmp/Makefile.in +index 98d83c8..dd5689b 100644 +--- a/win32/libsnmp/Makefile.in ++++ b/win32/libsnmp/Makefile.in +@@ -42,6 +42,7 @@ LIB32_OBJS= \ + "$(INTDIR)\read_config.obj" \ + "$(INTDIR)\readdir.obj" \ + "$(INTDIR)\scapi.obj" \ ++ "$(INTDIR)\sd-daemon.obj" \ + "$(INTDIR)\snmp-tc.obj" \ + "$(INTDIR)\snmp.obj" \ + "$(INTDIR)\snmpCallbackDomain.obj" \ +@@ -307,6 +308,12 @@ SOURCE=..\..\snmplib\scapi.c + $(CPP) $(CPP_PROJ) $(SOURCE) + + ++SOURCE=..\..\snmplib\sd-daemon.c ++ ++"$(INTDIR)\sd-daemon.obj" : $(SOURCE) "$(INTDIR)" ++ $(CPP) $(CPP_PROJ) $(SOURCE) ++ ++ + SOURCE="..\..\snmplib\snmp-tc.c" + + "$(INTDIR)\snmp-tc.obj" : $(SOURCE) "$(INTDIR)" +diff --git a/win32/net-snmp/net-snmp-config.h b/win32/net-snmp/net-snmp-config.h +index 7791ee0..1eccf42 100644 +--- a/win32/net-snmp/net-snmp-config.h ++++ b/win32/net-snmp/net-snmp-config.h +@@ -1705,6 +1705,8 @@ enum { + #define DMALLOC_FUNC_CHECK + #endif + ++#define NETSNMP_NO_SYSTEMD ++ + /* #undef NETSNMP_ENABLE_LOCAL_SMUX */ + + /* define if agentx transport is to use domain sockets only */ +diff --git a/win32/net-snmp/net-snmp-config.h.in b/win32/net-snmp/net-snmp-config.h.in +index 5215865..1607bfa 100644 +--- a/win32/net-snmp/net-snmp-config.h.in ++++ b/win32/net-snmp/net-snmp-config.h.in +@@ -1705,6 +1705,8 @@ enum { + #define DMALLOC_FUNC_CHECK + #endif + ++#define NETSNMP_NO_SYSTEMD ++ + /* #undef NETSNMP_ENABLE_LOCAL_SMUX */ + + /* define if agentx transport is to use domain sockets only */ diff --git a/meta-networking/recipes-protocols/net-snmp/net-snmp_5.7.2.1.bb b/meta-networking/recipes-protocols/net-snmp/net-snmp_5.7.2.1.bb new file mode 100644 index 0000000000..f6ddcaceca --- /dev/null +++ b/meta-networking/recipes-protocols/net-snmp/net-snmp_5.7.2.1.bb @@ -0,0 +1,136 @@ +SUMMARY = "Various tools relating to the Simple Network Management Protocol" +HOMEPAGE = "http://www.net-snmp.org/" +LICENSE = "BSD" + +LIC_FILES_CHKSUM = "file://README;beginline=3;endline=8;md5=7f7f00ba639ac8e8deb5a622ea24634e" + +DEPENDS = "openssl libnl pciutils" + +SRC_URI = "${SOURCEFORGE_MIRROR}/net-snmp/net-snmp-${PV}.zip \ + file://0001-Added-checks-for-printing-variables-with-wrong-types.patch \ + file://init \ + file://snmpd.conf \ + file://snmptrapd.conf \ + file://systemd-support.patch \ + file://snmpd.service \ + file://snmptrapd.service \ + file://ifmib.patch \ +" + +SRC_URI[md5sum] = "a2c83518648b0f2a5d378625e45c0e18" +SRC_URI[sha256sum] = "ac9105539971f7cfb1456a86d479e18e8a8b3712212595ad40504347ba5843da" + +inherit autotools update-rc.d siteinfo systemd + +EXTRA_OEMAKE = "INSTALL_PREFIX=${D}" + +PARALLEL_MAKE = "" +CCACHE = "" + +TARGET_CC_ARCH += "${LDFLAGS}" + +EXTRA_OECONF = "--disable-embedded-perl \ + --with-perl-modules=no \ + --enable-shared \ + --disable-manuals \ + --with-defaults \ + ${@base_conditional('SITEINFO_ENDIANNESS', 'le', '--with-endianness=little', '--with-endianness=big', d)}" + +CACHED_CONFIGUREVARS = " \ + ac_cv_header_valgrind_valgrind_h=no \ + ac_cv_header_valgrind_memcheck_h=no \ +" + +do_configure_prepend() { + export PERLPROG="${bindir}/env perl" +} + +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/ + 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 ${D}${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 +} + +SYSROOT_PREPROCESS_FUNCS += "net_snmp_sysroot_preprocess" + +net_snmp_sysroot_preprocess () { + if [ -e ${D}${bindir}/net-snmp-config ]; then + install -d ${SYSROOT_DESTDIR}${bindir_crossscripts}/ + install -m 755 ${D}${bindir}/net-snmp-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/ + fi +} + +PACKAGES =+ "${PN}-static ${PN}-libs ${PN}-mibs ${PN}-server ${PN}-client ${PN}-server-snmpd \ + ${PN}-server-snmptrapd" + +ALLOW_EMPTY_${PN}-server = "1" +ALLOW_EMPTY_${PN} = "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 \ + ${PN}-server-snmptrapd" + +SYSTEMD_SERVICE_${PN}-server-snmpd = "snmpd.service" +SYSTEMD_SERVICE_${PN}-server-snmptrapd = "snmptrapd.service" + +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})" + +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 +} diff --git a/meta-networking/recipes-protocols/openflow/openflow.inc b/meta-networking/recipes-protocols/openflow/openflow.inc new file mode 100644 index 0000000000..1a226f82ca --- /dev/null +++ b/meta-networking/recipes-protocols/openflow/openflow.inc @@ -0,0 +1,35 @@ +SUMMARY = "OpenFlow communications protocol" +DESCRIPTION = "\ +Open standard that enables researchers to run experimental protocols in \ +contained networks. OpenFlow is a communications interface between \ +control and forwarding planes of a software-defined networking architecture.\ +" +HOMEPAGE = "http://www.openflow.org" + +SECTION = "networking" +LICENSE = "GPLv2" + +LIC_FILES_CHKSUM = "file://COPYING;md5=e870c934e2c3d6ccf085fd7cf0a1e2e2" + +SRC_URI = "git://gitosis.stanford.edu/openflow.git;protocol=git" + +DEPENDS = "virtual/libc" + +EXTRA_OECONF += "KARCH=${TARGET_ARCH}" + +PACKAGECONFIG ??= "openssl" +PACKAGECONFIG[openssl] = "--enable-ssl,--disable-ssl, openssl, libssl" + +S = "${WORKDIR}/git" + +inherit autotools-brokensep + +do_configure() { + ./boot.sh + oe_runconf +} + +do_install_append() { + # Remove /var/run as it is created on startup + rm -rf ${D}${localstatedir}/run +} diff --git a/meta-networking/recipes-protocols/openflow/openflow_1.0.bb b/meta-networking/recipes-protocols/openflow/openflow_1.0.bb new file mode 100644 index 0000000000..a7e254dd85 --- /dev/null +++ b/meta-networking/recipes-protocols/openflow/openflow_1.0.bb @@ -0,0 +1,4 @@ +include ${BPN}.inc + +SRCREV = "5ccca75a69f99791659bcfbcf35353ab1921320a" +PV = "1.0" diff --git a/meta-networking/recipes-protocols/openflow/openflow_git.bb b/meta-networking/recipes-protocols/openflow/openflow_git.bb new file mode 100644 index 0000000000..6403bfb220 --- /dev/null +++ b/meta-networking/recipes-protocols/openflow/openflow_git.bb @@ -0,0 +1,4 @@ +include ${BPN}.inc + +SRCREV = "c84f33f09d5dbcfc9b489f64cb30475bf36f653a" +PV = "1.0+git${SRCPV}" diff --git a/meta-networking/recipes-protocols/openl2tp/openl2tp/Makefile-modify-CFLAGS-to-aviod-build-error.patch b/meta-networking/recipes-protocols/openl2tp/openl2tp/Makefile-modify-CFLAGS-to-aviod-build-error.patch new file mode 100644 index 0000000000..96dbc7551d --- /dev/null +++ b/meta-networking/recipes-protocols/openl2tp/openl2tp/Makefile-modify-CFLAGS-to-aviod-build-error.patch @@ -0,0 +1,106 @@ +From 152486fa3c36c3b99d17d5b553cf87ef412fae8e Mon Sep 17 00:00:00 2001 +From: Li xin +Date: Mon, 1 Dec 2014 01:53:41 +0900 +Subject: [PATCH] Makefile:modify CFLAGS to aviod build error. + +Upstream-Status: pending + +Signed-off-by: Li Xin +--- + Makefile | 22 +++++++++++----------- + plugins/Makefile | 6 +++--- + 2 files changed, 14 insertions(+), 14 deletions(-) + +diff --git a/Makefile b/Makefile +index 4aaa448..baa7882 100644 +--- a/Makefile ++++ b/Makefile +@@ -152,10 +152,10 @@ LIBS.dmalloc= -ldmalloc + export USE_DMALLOC + endif + +-CPPFLAGS= $(CPPFLAGS.l2tptest) $(CPPFLAGS-y) +-CFLAGS= -I. -Iusl -Icli -isystem include \ +- -MMD -Wall -Werror -Wno-strict-aliasing \ +- $(CPPFLAGS) $(CPPFLAGS.dmalloc) \ ++ADD_CPPFLAGS= $(CPPFLAGS.l2tptest) $(CPPFLAGS-y) ++ADD_CFLAGS= -I. -Iusl -Icli -isystem include \ ++ -MMD -Wall -Wno-strict-aliasing \ ++ $(ADD_CPPFLAGS) $(CPPFLAGS.dmalloc) \ + -DSYS_LIBDIR=$(SYS_LIBDIR) + LDFLAGS.l2tpd= -Wl,-E -L. -Lusl -lusl -ldl $(LIBS.dmalloc) -lc + LDFLAGS.l2tpconfig= -Lcli -lcli -lreadline $(LIBS.dmalloc) $(READLINE_LDFLAGS) -lc +@@ -170,10 +170,10 @@ CFLAGS.optimize= $(OPT_CFLAGS) + endif + export CFLAGS.optimize + +-CFLAGS+= $(CFLAGS.optimize) ++ADD_CFLAGS+= $(CFLAGS.optimize) + + ifeq ($(L2TP_USE_ASYNC_RPC),y) +-CPPFLAGS+= -DL2TP_ASYNC_RPC ++ADD_CPPFLAGS+= -DL2TP_ASYNC_RPC + endif + + ifeq ($(L2TP_FEATURE_RPC_MANAGEMENT),y) +@@ -220,13 +220,13 @@ endif + + # Compile without -Wall because rpcgen-generated code is full of warnings. + %_xdr.o: %_xdr.c +- $(CC) -I. -MMD -w $(CFLAGS.optimize) -c $(CPPFLAGS) $< ++ $(CC) -I. -MMD -w $(CFLAGS.optimize) -c $(ADD_CPPFLAGS) $< + + %_client.o: %_client.c +- $(CC) -I. -MMD -w $(CFLAGS.optimize) -c $(CPPFLAGS) $< ++ $(CC) -I. -MMD -w $(CFLAGS.optimize) -c $(ADD_CPPFLAGS) $< + + %_server.o: %_server.c +- $(CC) -I. -MMD -w $(CFLAGS.optimize) -c $(CPPFLAGS) $< ++ $(CC) -I. -MMD -w $(CFLAGS.optimize) -c $(ADD_CPPFLAGS) $< + + %_xdr.c: %.x + -$(RM) $@ +@@ -272,7 +272,7 @@ l2tpconfig: $(L2TPCONFIG_SRCS.o) + $(CC) -o $@ $^ $(LDFLAGS.l2tpconfig) + + %.o: %.c +- $(CC) -c $(CFLAGS) $< -o $@ ++ $(CC) -c $(CFLAGS) $(ADD_CFLAGS) $< -o $@ + + l2tp_options.h: FORCE + @rm -f $@.tmp +@@ -325,7 +325,7 @@ install: install-all + install-all: all install-daemon install-app + + install-daemon: +- @for d in $(filter-out usl,$(SUBDIRS)); do $(MAKE) -C $$d $(MFLAGS) EXTRA_CFLAGS="$(CPPFLAGS)" install; if [ $$? -ne 0 ]; then exit 1; fi; done ++ @for d in $(filter-out usl,$(SUBDIRS)); do $(MAKE) -C $$d $(MFLAGS) EXTRA_CFLAGS="$(CPPFLAGS) $(ADD_CPPFLAGS)" install; if [ $$? -ne 0 ]; then exit 1; fi; done + $(INSTALL) -d $(DESTDIR)/usr/sbin + $(INSTALL) openl2tpd $(DESTDIR)/usr/sbin + +diff --git a/plugins/Makefile b/plugins/Makefile +index 5be996d..6810236 100644 +--- a/plugins/Makefile ++++ b/plugins/Makefile +@@ -1,7 +1,7 @@ +-CFLAGS := $(CFLAGS.optimize) -MMD -Wall \ ++ADD_CFLAGS := $(CFLAGS.optimize) -MMD -Wall \ + -isystem ../include \ + -I. -I.. -I../usl -fPIC $(EXTRA_CFLAGS) +-LDFLAGS := -shared ++ADD_LDFLAGS := -shared + + PLUGINS.c:= ppp_unix.c ppp_null.c ipsec.c event_sock.c + +@@ -21,7 +21,7 @@ clean: + $(RM) $(PLUGINS.so) $(wildcard *.o) $(wildcard *.d) $(SRC.generated) + + %.so: %.c +- $(CC) -o $@ $(LDFLAGS) $(CFLAGS) $< ++ $(CC) -o $@ $(LDFLAGS) $(ADD_LDFLAGS) $(CFLAGS) $(ADD_CFLAGS) $< + + install: all + $(INSTALL) -d $(DESTDIR)$(SYS_LIBDIR)/openl2tp +-- +1.8.4.2 + diff --git a/meta-networking/recipes-protocols/openl2tp/openl2tp/openl2tp-simplify-gcc-warning-hack.patch b/meta-networking/recipes-protocols/openl2tp/openl2tp/openl2tp-simplify-gcc-warning-hack.patch new file mode 100644 index 0000000000..c11a127b81 --- /dev/null +++ b/meta-networking/recipes-protocols/openl2tp/openl2tp/openl2tp-simplify-gcc-warning-hack.patch @@ -0,0 +1,41 @@ +From 460549a3de27f8dd8371b6d6fc1f69d8bffa102b Mon Sep 17 00:00:00 2001 +From: Joe MacDonald +Date: Tue, 6 Jan 2015 11:23:21 -0500 +Subject: [PATCH] openl2tp: simplify gcc warning hack + +The hack to work around the gcc warning causes problems with some modern +gcc configurations. Since the redef behaviour is essentially correct +everywhere and since the hack is still required on 32-bit builders, leave +it in place but remove the #if guard since it is only there to ensure that +the l2tp_private.h file is updated if the rpc source file is changed and +the two get out of sync. + +Upstream-status: pending + +Signed-off-by: Joe MacDonald +--- + l2tp_private.h | 6 ------ + 1 file changed, 6 deletions(-) + +diff --git a/l2tp_private.h b/l2tp_private.h +index f3c1af7..cca6806 100644 +--- a/l2tp_private.h ++++ b/l2tp_private.h +@@ -89,14 +89,8 @@ + * So we redefine the constant with UL suffix to avoid the gcc warning. + * Is there some C preprocessor magic that could avoid having to do this? + */ +-#if L2TP_API_TUNNEL_FLAG_MTU != 2147483648 +-#error Constant L2TP_API_TUNNEL_FLAG_MTU changed. Update local definition here. +-#endif + #undef L2TP_API_TUNNEL_FLAG_MTU + #define L2TP_API_TUNNEL_FLAG_MTU 2147483648UL +-#if L2TP_API_SESSION_FLAG_NO_PPP != 2147483648 +-#error Constant L2TP_API_SESSION_FLAG_NO_PPP changed. Update local definition here. +-#endif + #undef L2TP_API_SESSION_FLAG_NO_PPP + #define L2TP_API_SESSION_FLAG_NO_PPP 2147483648UL + +-- +1.9.1 + diff --git a/meta-networking/recipes-protocols/openl2tp/openl2tp_1.8.bb b/meta-networking/recipes-protocols/openl2tp/openl2tp_1.8.bb new file mode 100644 index 0000000000..5a041073de --- /dev/null +++ b/meta-networking/recipes-protocols/openl2tp/openl2tp_1.8.bb @@ -0,0 +1,36 @@ +SUMMARY = "An L2TP client/server, designed for VPN use." +DESCRIPTION = "OpenL2TP is an open source L2TP client / server, written \ +specifically for Linux. It has been designed for use as an enterprise \ +L2TP VPN server or in commercial, Linux-based, embedded networking \ +products and is able to support hundreds of sessions, each with \ +different configuration. It is used by several ISPs to provide \ +L2TP services and by corporations to implement L2TP VPNs." +HOMEPAGE = "http://www.openl2tp.org/" +SECTION = "console/network" +LICENSE = "GPL-2.0" +LIC_FILES_CHKSUM = "file://COPYING;md5=e9d9259cbbf00945adc25a470c1d3585" +DEPENDS = "popt flex readline" + +SRC_URI = "http://ftp.jaist.ac.jp/pub/sourceforge/o/op/${PN}/${PN}/${PV}/${BP}.tar.gz \ + file://Makefile-modify-CFLAGS-to-aviod-build-error.patch \ + file://openl2tp-simplify-gcc-warning-hack.patch \ + " +SRC_URI[md5sum] = "e3d08dedfb9e6a9a1e24f6766f6dadd0" +SRC_URI[sha256sum] = "1c97704d4b963a87fbc0e741668d4530933991515ae9ab0dffd11b5444f4860f" + +inherit autotools-brokensep pkgconfig + +PARALLEL_MAKE = "" +EXTRA_OEMAKE = 'CFLAGS="${CFLAGS} -Wno-nused-but-set-variable"' + +do_compile_prepend() { + sed -i -e "s:SYS_LIBDIR=.*:SYS_LIBDIR=${libdir}:g" \ + -e 's:$(CROSS_COMPILE)as:${AS}:g' \ + -e 's:$(CROSS_COMPILE)ld:${LD}:g' \ + -e 's:$(CROSS_COMPILE)gcc:${CC}:g' \ + -e 's:$(CROSS_COMPILE)ar:${AR}:g' \ + -e 's:$(CROSS_COMPILE)nm:${NM}:g' \ + -e 's:$(CROSS_COMPILE)strip:${STRIP}:g' \ + -e 's:$(CROSS_COMPILE)install:install:g' \ + ${S}/Makefile +} diff --git a/meta-networking/recipes-protocols/pptp-linux/pptp-linux-1.7.2/fix-parallel-build.patch b/meta-networking/recipes-protocols/pptp-linux/pptp-linux-1.7.2/fix-parallel-build.patch new file mode 100644 index 0000000000..77722b064d --- /dev/null +++ b/meta-networking/recipes-protocols/pptp-linux/pptp-linux-1.7.2/fix-parallel-build.patch @@ -0,0 +1,19 @@ +pptp.c and version.c depend on config.h + +Upstream-Status: Backport + +Upstream has already similar fixes. Will be available on next release. + +Signed-off-by: Jesse Zhang + +--- a/Makefile 2013-02-27 17:09:24.431226665 +0800 ++++ b/Makefile 2013-02-27 17:09:03.442075550 +0800 +@@ -43,6 +43,8 @@ + pptpsetup.8: pptpsetup + pod2man $? > $@ + ++pptp.o version.o: config.h ++ + config.h: + echo "/* text added by Makefile target config.h */" > config.h + echo "#define PPTP_LINUX_VERSION \"$(VERSION)$(RELEASE)\"" >> config.h diff --git a/meta-networking/recipes-protocols/pptp-linux/pptp-linux-1.7.2/options.pptp b/meta-networking/recipes-protocols/pptp-linux/pptp-linux-1.7.2/options.pptp new file mode 100644 index 0000000000..f446e22a6a --- /dev/null +++ b/meta-networking/recipes-protocols/pptp-linux/pptp-linux-1.7.2/options.pptp @@ -0,0 +1,30 @@ +# +# Lock the port +# +lock + +# +# We don't need the tunnel server to authenticate itself +# +noauth + +# +# Turn off transmission protocols we know won't be used +# +nobsdcomp +nodeflate + +# +# We want MPPE +# (option naming specific to ppp 2.4.0 with unofficial patch) +# +#mppe-40 +mppe-128 +#mppe-stateless + +# +# We want a sane mtu/mru +# (ppp 2.4.0 with unofficial patch) +# +#mtu 1000 +#mru 1000 diff --git a/meta-networking/recipes-protocols/pptp-linux/pptp-linux_1.7.2.bb b/meta-networking/recipes-protocols/pptp-linux/pptp-linux_1.7.2.bb new file mode 100644 index 0000000000..6a90578bc6 --- /dev/null +++ b/meta-networking/recipes-protocols/pptp-linux/pptp-linux_1.7.2.bb @@ -0,0 +1,31 @@ +SUMMARY = "Client for Microsoft PPTP VPNs" +DESCRIPTION = "PPTP Client is a Linux, FreeBSD, NetBSD \ + and OpenBSD client for the proprietary Microsoft Point-to-Point \ + Tunneling Protocol, PPTP. Allows connection to a PPTP based \ + Virtual Private Network (VPN) as used by employers and some \ + cable and ADSL internet service providers." +HOMEPAGE = "http://pptpclient.sourceforge.net" +SECTION = "network" +LICENSE = "GPLv2+" +LIC_FILES_CHKSUM = "file://COPYING;md5=8ca43cbc842c2336e835926c2166c28b" + +PR = "r1" + +SRC_URI = "${SOURCEFORGE_MIRROR}/sourceforge/pptpclient/pptp-${PV}.tar.gz \ + file://options.pptp \ + file://fix-parallel-build.patch \ +" + +SRC_URI[md5sum] = "4c3d19286a37459a632c7128c92a9857" +SRC_URI[sha256sum] = "e98ae0065d2a39fa3131654ff28cb7070e996f668ed6d0e7d9a445b8d37694bc" + +S = "${WORKDIR}/pptp-${PV}" + +do_install() { + install -d ${D}${sbindir} ${D}${sysconfdir}/ppp ${D}${mandir}/man8 + install -m 555 pptp ${D}${sbindir} + install -m 644 pptp.8 ${D}${mandir}/man8 + install -m 644 ${WORKDIR}/options.pptp ${D}${sysconfdir}/ppp +} + +RDEPENDS_${PN} = "ppp" diff --git a/meta-networking/recipes-protocols/quagga/files/Zebra-sync-zebra-routing-table-with-the-kernel-one.patch b/meta-networking/recipes-protocols/quagga/files/Zebra-sync-zebra-routing-table-with-the-kernel-one.patch new file mode 100644 index 0000000000..35f4637d8e --- /dev/null +++ b/meta-networking/recipes-protocols/quagga/files/Zebra-sync-zebra-routing-table-with-the-kernel-one.patch @@ -0,0 +1,48 @@ +sync zebra routing table with the kernel one when interface is down + +Add router to kernel main router table with "ip", then you can see +a router item in kernel main router table. Also can see this router +item in zebra router table. If down the interface, this router item +will be deleted from kernel main router table, but it will not be +deleted from zebra router table, just set as inactive. + +This patch is adopted from [1]. +[1] http://www.gossamer-threads.com/lists/quagga/dev/22609 + +Upstream-Status: Pending + +Signed-of-by: Aws Ismail +Signed-of-by: Roy.Li + +--- + zebra/zebra_rib.c | 7 +++++++ + 1 files changed, 7 insertions(+), 0 deletions(-) + +diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c +index 154e8d5..63434d0 100644 +--- a/zebra/zebra_rib.c ++++ b/zebra/zebra_rib.c +@@ -765,6 +765,9 @@ rib_match_ipv6 (struct in6_addr *addr) + #define RIB_SYSTEM_ROUTE(R) \ + ((R)->type == ZEBRA_ROUTE_KERNEL || (R)->type == ZEBRA_ROUTE_CONNECT) + ++#define RIB_KERNEL_ROUTE(R) \ ++ ((R)->type == ZEBRA_ROUTE_KERNEL) ++ + /* This function verifies reachability of one given nexthop, which can be + * numbered or unnumbered, IPv4 or IPv6. The result is unconditionally stored + * in nexthop->flags field. If the 4th parameter, 'set', is non-zero, +@@ -1135,6 +1138,10 @@ rib_process (struct route_node *rn) + redistribute_delete (&rn->p, fib); + if (! RIB_SYSTEM_ROUTE (fib)) + rib_uninstall_kernel (rn, fib); ++#ifdef GNU_LINUX ++ else if(RIB_KERNEL_ROUTE (fib) && !if_is_up(if_lookup_by_index(fib->nexthop->ifindex))) ++ del=fib; ++#endif + UNSET_FLAG (fib->flags, ZEBRA_FLAG_SELECTED); + + /* Set real nexthop. */ +-- +1.7.4.1 + diff --git a/meta-networking/recipes-protocols/quagga/files/babel-close-the-stdout-stderr-as-in-other-daemons.patch b/meta-networking/recipes-protocols/quagga/files/babel-close-the-stdout-stderr-as-in-other-daemons.patch new file mode 100644 index 0000000000..c2757a2fb7 --- /dev/null +++ b/meta-networking/recipes-protocols/quagga/files/babel-close-the-stdout-stderr-as-in-other-daemons.patch @@ -0,0 +1,50 @@ +From ba71f768e6dbb1f2ac72ed3bd880bff75a48d345 Mon Sep 17 00:00:00 2001 +From: Roy Li +Date: Wed, 19 Feb 2014 14:13:40 +0800 +Subject: [PATCH] babeld: close stdout once the background daemon is created + +Upstream-Status: pending + +Once babald becomes a background daemon, it should not output information to +stdout, so need to close stdout. + +In fact, other daemons close their stdout when they run into background, like +ospfd, isisd and bgpd, by calling daemon() which is in lib/daemon.c + +Closing the stdout can fix a tee hang issue { #/usr/sbin/babeld -d |tee tmp } + +Signed-off-by: Roy Li +--- + babeld/util.c | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +diff --git a/babeld/util.c b/babeld/util.c +index 011f382..76203bc 100644 +--- a/babeld/util.c ++++ b/babeld/util.c +@@ -425,7 +425,7 @@ uchar_to_in6addr(struct in6_addr *dest, const unsigned char *src) + int + daemonise() + { +- int rc; ++ int rc, fd; + + fflush(stdout); + fflush(stderr); +@@ -441,5 +441,13 @@ daemonise() + if(rc < 0) + return -1; + ++ fd = open("/dev/null", O_RDWR, 0); ++ if (fd != -1) ++ { ++ dup2(fd, STDOUT_FILENO); ++ if (fd > 2) ++ close(fd); ++ } ++ + return 1; + } +-- +1.7.10.4 + diff --git a/meta-networking/recipes-protocols/quagga/files/babeld.service b/meta-networking/recipes-protocols/quagga/files/babeld.service new file mode 100644 index 0000000000..dd344b0b34 --- /dev/null +++ b/meta-networking/recipes-protocols/quagga/files/babeld.service @@ -0,0 +1,14 @@ +[Unit] +Description=Babel routing daemon +BindTo=zebra.service +After=zebra.service +ConditionPathExists=@SYSCONFDIR@/quagga/babeld.conf + +[Service] +Type=forking +EnvironmentFile=-@SYSCONFDIR@/default/quagga +ExecStart=@SBINDIR@/babeld -d $babeld_options -f /etc/quagga/babeld.conf +Restart=on-abort + +[Install] +WantedBy=multi-user.target diff --git a/meta-networking/recipes-protocols/quagga/files/bgpd.service b/meta-networking/recipes-protocols/quagga/files/bgpd.service new file mode 100644 index 0000000000..164c81724c --- /dev/null +++ b/meta-networking/recipes-protocols/quagga/files/bgpd.service @@ -0,0 +1,14 @@ +[Unit] +Description=BGP routing daemon +BindTo=zebra.service +After=zebra.service +ConditionPathExists=@SYSCONFDIR@/quagga/bgpd.conf + +[Service] +Type=forking +EnvironmentFile=-@SYSCONFDIR@/default/quagga +ExecStart=@SBINDIR@/bgpd -d $bgpd_options -f /etc/quagga/bgpd.conf +Restart=on-abort + +[Install] +WantedBy=multi-user.target diff --git a/meta-networking/recipes-protocols/quagga/files/isisd.service b/meta-networking/recipes-protocols/quagga/files/isisd.service new file mode 100644 index 0000000000..9bfe7b65ef --- /dev/null +++ b/meta-networking/recipes-protocols/quagga/files/isisd.service @@ -0,0 +1,14 @@ +[Unit] +Description=IS-IS routing daemon +BindTo=zebra.service +After=zebra.service +ConditionPathExists=@SYSCONFDIR@/quagga/isisd.conf + +[Service] +Type=forking +EnvironmentFile=-@SYSCONFDIR@/default/quagga +ExecStart=@SBINDIR@/isisd -d $isisd_options -f /etc/quagga/isisd.conf +Restart=on-abort + +[Install] +WantedBy=multi-user.target diff --git a/meta-networking/recipes-protocols/quagga/files/ospf6d.service b/meta-networking/recipes-protocols/quagga/files/ospf6d.service new file mode 100644 index 0000000000..4b8ebf8026 --- /dev/null +++ b/meta-networking/recipes-protocols/quagga/files/ospf6d.service @@ -0,0 +1,14 @@ +[Unit] +Description=OSPF routing daemon for IPv6 +BindTo=zebra.service +After=zebra.service +ConditionPathExists=@SYSCONFDIR@/quagga/ospf6d.conf + +[Service] +Type=forking +EnvironmentFile=-@SYSCONFDIR@/default/quagga +ExecStart=@SBINDIR@/ospf6d -d $ospf6d_options -f /etc/quagga/ospf6d.conf +Restart=on-abort + +[Install] +WantedBy=multi-user.target diff --git a/meta-networking/recipes-protocols/quagga/files/ospfd.service b/meta-networking/recipes-protocols/quagga/files/ospfd.service new file mode 100644 index 0000000000..f9f5031b4b --- /dev/null +++ b/meta-networking/recipes-protocols/quagga/files/ospfd.service @@ -0,0 +1,14 @@ +[Unit] +Description=OSPF routing daemon +BindTo=zebra.service +After=zebra.service +ConditionPathExists=@SYSCONFDIR@/quagga/ospfd.conf + +[Service] +Type=forking +EnvironmentFile=-@SYSCONFDIR@/default/quagga +ExecStart=@SBINDIR@/ospfd -d $ospfd_options -f /etc/quagga/ospfd.conf +Restart=on-abort + +[Install] +WantedBy=multi-user.target diff --git a/meta-networking/recipes-protocols/quagga/files/quagga-Avoid-duplicate-connected-address.patch b/meta-networking/recipes-protocols/quagga/files/quagga-Avoid-duplicate-connected-address.patch new file mode 100644 index 0000000000..a07e33f9fd --- /dev/null +++ b/meta-networking/recipes-protocols/quagga/files/quagga-Avoid-duplicate-connected-address.patch @@ -0,0 +1,54 @@ +quagga: Avoid duplicate connected address adding to the list + +commit 27ba970b9("quagga/ripd: Fix two bugs after received SIGHUP signal") +introduces an regression: ifp->connected list is cleaned up when ripd is +restarting, however, for interface addresses which are not specified in +ripd configuration file, they are never to be added into ifp->connected +again, this will lead to some abnormal behavior for route advertising. + +Instead of cleaning up the ifp->connected list to avoid duplicated +connected address being added into this list, we can check this +condition during interface address adding process and return early +when an identical address has already been added. + +Upstream-Status: Pending + +Signed-off-by: Hu Yadi +Signed-off-by: Xufeng Zhang +Signed-off-by: Joe MacDonald +--- +--- a/lib/if.c ++++ b/lib/if.c +@@ -738,6 +738,16 @@ connected_add_by_prefix (struct interfac + struct prefix *destination) + { + struct connected *ifc; ++ struct listnode *cnode; ++ struct connected *c; ++ int ret = 0; ++ ++ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, c)) ++ { ++ ret = connected_same_prefix (p, (c->address)); ++ if(ret == 1) ++ return NULL; ++ } + + /* Allocate new connected address. */ + ifc = connected_new (); +--- a/ripd/rip_interface.c ++++ b/ripd/rip_interface.c +@@ -516,13 +516,6 @@ rip_interface_clean (void) + thread_cancel (ri->t_wakeup); + ri->t_wakeup = NULL; + } +- +- for (conn_node = listhead (ifp->connected); conn_node; conn_node = next) +- { +- ifc = listgetdata (conn_node); +- next = conn_node->next; +- listnode_delete (ifp->connected, ifc); +- } + } + } + diff --git a/meta-networking/recipes-protocols/quagga/files/quagga.default b/meta-networking/recipes-protocols/quagga/files/quagga.default new file mode 100644 index 0000000000..0c1ce6c042 --- /dev/null +++ b/meta-networking/recipes-protocols/quagga/files/quagga.default @@ -0,0 +1,13 @@ +# If this option is set the /etc/init.d/quagga script automatically loads +# the config via "vtysh -b" when the servers are started. +vtysh_enable=yes + +# Bind all daemons to loopback only by default +zebra_options=" --daemon -A 127.0.0.1" +babeld_options="--daemon -A 127.0.0.1" +bgpd_options=" --daemon -A 127.0.0.1" +ospfd_options=" --daemon -A 127.0.0.1" +ospf6d_options="--daemon -A ::1" +ripd_options=" --daemon -A 127.0.0.1" +ripngd_options="--daemon -A ::1" +isisd_options=" --daemon -A 127.0.0.1" diff --git a/meta-networking/recipes-protocols/quagga/files/quagga.init b/meta-networking/recipes-protocols/quagga/files/quagga.init new file mode 100644 index 0000000000..60b5ab01a1 --- /dev/null +++ b/meta-networking/recipes-protocols/quagga/files/quagga.init @@ -0,0 +1,200 @@ +#!/bin/sh +# +# /etc/init.d/quagga -- start/stop the Quagga routing daemons +# +# Based on debian version by Endre Hirling and +# Christian Hammers . +# + +### BEGIN INIT INFO +# Provides: quagga +# Required-Start: $local_fs $network $remote_fs $syslog +# Required-Stop: $local_fs $network $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: start and stop the Quagga routing suite +# Description: Quagga is a routing suite for IP routing protocols like +# BGP, OSPF, RIP and others. This script contols the main +# daemon "quagga" as well as the individual protocol daemons. +### END INIT INFO + +# NOTE: sbin must be before bin so we get the iproute2 ip and not the +# busybox ip command. The busybox one flushes all routes instead of just +# the dynamic routes +PATH=/sbin:/usr/sbin:/bin:/usr/bin:/sbin +D_PATH=/usr/sbin +C_PATH=/etc/quagga + +# Keep zebra first and do not list watchquagga! +DAEMONS="zebra bgpd ripd ripngd ospfd ospf6d isisd babeld" + +# Print the name of the pidfile. +pidfile() +{ + echo "/var/run/quagga/$1.pid" +} + +# Check if daemon is started by using the pidfile. +started() +{ + [ -e `pidfile $1` ] && kill -0 `cat \`pidfile $1\`` 2> /dev/null && return 0 + return 1 +} + +# Loads the config via vtysh -b if configured to do so. +vtysh_b () +{ + # Rember, that all variables have been incremented by 1 in convert_daemon_prios() + if [ "$vtysh_enable" = 2 -a -f $C_PATH/Quagga.conf ]; then + /usr/bin/vtysh -b + fi +} + +# Check if the daemon is activated and if its executable and config files +# are in place. +# params: daemon name +# returns: 0=ok, 1=error +check_daemon() +{ + # If the integrated config file is used the others are not checked. + if [ -r "$C_PATH/Quagga.conf" ]; then + return 0 + fi + + # check for config file + if [ ! -r "$C_PATH/$1.conf" ]; then + return 1 + fi + return 0 +} + +# Starts the server if it's not alrady running according to the pid file. +# The Quagga daemons creates the pidfile when starting. +start() +{ + if ! check_daemon $1; then echo -n " (!$1)"; return; fi + echo -n " $1" + start-stop-daemon \ + --start \ + --pidfile=`pidfile $1` \ + --exec "$D_PATH/$1" \ + -- \ + `eval echo "$""$1""_options"` + +} + +# Stop the daemon given in the parameter, printing its name to the terminal. +stop() +{ + if ! started "$1" ; then + echo -n " (!$1)" + return 0 + else + PIDFILE=`pidfile $1` + PID=`cat $PIDFILE 2>/dev/null` + start-stop-daemon --stop --quiet --exec "$D_PATH/$1" + # + # Now we have to wait until $DAEMON has _really_ stopped. + # + if test -n "$PID" && kill -0 $PID 2>/dev/null; then + echo -n " (waiting) ." + cnt=0 + while kill -0 $PID 2>/dev/null; do + cnt=`expr $cnt + 1` + if [ $cnt -gt 60 ]; then + # Waited 120 secs now, fail. + echo -n "Failed.. " + break + fi + sleep 2 + echo -n "." + done + fi + echo -n " $1" + rm -f `pidfile $1` + fi +} + +stop_all() +{ + local daemon_list + daemon_list=${1:-$DAEMONS} + + echo -n "Stopping Quagga daemons:" + for daemon_name in $daemon_list; do + stop "$daemon_name" + done + echo "." +} + +start_all() +{ + local daemon_list + daemon_list=${1:-$DAEMONS} + + echo -n "Starting Quagga daemons:" + for daemon_name in $daemon_list; do + start "$daemon_name" + done + echo "." +} + +status_all() +{ + local daemon_list + daemon_list=${1:-$DAEMONS} + res=1 + + echo -n "quagga: " + for daemon_name in $daemon_list; do + if started "$daemon_name" ; then + id=`cat \`pidfile $daemon_name\`` + echo -n "$daemon_name (pid $id) " + res=0 + fi + done + if [ $res -eq 0 ]; then + echo "is running..." + else + echo "is stopped..." + fi + exit $res +} + +######################################################### +# Main program # +######################################################### + +# Load configuration +test -f /etc/default/quagga && . /etc/default/quagga + +case "$1" in + start) + cd $C_PATH/ + start_all $2 + vtysh_b + ;; + + stop) + stop_all $2 + echo "Removing all routes made by zebra." + ip route flush proto zebra + ;; + + status) + status_all $2 + ;; + + restart|force-reload) + $0 stop $2 + sleep 1 + $0 start $2 + ;; + + *) + echo "Usage: /etc/init.d/quagga {start|stop|restart|status|force-reload} [daemon]" + exit 1 + ;; +esac + +exit 0 diff --git a/meta-networking/recipes-protocols/quagga/files/quagga.pam b/meta-networking/recipes-protocols/quagga/files/quagga.pam new file mode 100644 index 0000000000..3541a975ae --- /dev/null +++ b/meta-networking/recipes-protocols/quagga/files/quagga.pam @@ -0,0 +1,13 @@ +# +# The PAM configuration file for the quagga `vtysh' service +# + +# This allows root to change user infomation without being +# prompted for a password +auth sufficient pam_rootok.so + +# The standard Unix authentication modules, used with +# NIS (man nsswitch) as well as normal /etc/passwd and +# /etc/shadow entries. +auth include common-auth + diff --git a/meta-networking/recipes-protocols/quagga/files/ripd-fix-two-bugs-after-received-SIGHUP.patch b/meta-networking/recipes-protocols/quagga/files/ripd-fix-two-bugs-after-received-SIGHUP.patch new file mode 100644 index 0000000000..4b8c9a929b --- /dev/null +++ b/meta-networking/recipes-protocols/quagga/files/ripd-fix-two-bugs-after-received-SIGHUP.patch @@ -0,0 +1,50 @@ +ripd: Fix two bugs after received SIGHUP signal + +There are two problems for ripd implementation after received +SIGHUP signal: +1). ripd didn't clean up ifp->connected list before reload + configuration file. +2). ripd reset ri->split_horizon flag to RIP_NO_SPLIT_HORIZON + which lead to the unnecessary route to be advertised. + +Upstream-Status: Submitted [http://patchwork.diac24.net/patch/604/] + +Signed-off-by: Xufeng Zhang +Signed-off-by: Joe MacDonald +--- +--- a/ripd/rip_interface.c ++++ b/ripd/rip_interface.c +@@ -500,6 +500,8 @@ + struct listnode *node; + struct interface *ifp; + struct rip_interface *ri; ++ struct connected *ifc; ++ struct listnode *conn_node, *next; + + for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) + { +@@ -514,6 +516,13 @@ + thread_cancel (ri->t_wakeup); + ri->t_wakeup = NULL; + } ++ ++ for (conn_node = listhead (ifp->connected); conn_node; conn_node = next) ++ { ++ ifc = listgetdata (conn_node); ++ next = conn_node->next; ++ listnode_delete (ifp->connected, ifc); ++ } + } + } + +@@ -548,8 +557,8 @@ + ri->key_chain = NULL; + } + +- ri->split_horizon = RIP_NO_SPLIT_HORIZON; +- ri->split_horizon_default = RIP_NO_SPLIT_HORIZON; ++ ri->split_horizon = RIP_SPLIT_HORIZON; ++ ri->split_horizon_default = RIP_SPLIT_HORIZON; + + ri->list[RIP_FILTER_IN] = NULL; + ri->list[RIP_FILTER_OUT] = NULL; diff --git a/meta-networking/recipes-protocols/quagga/files/ripd.service b/meta-networking/recipes-protocols/quagga/files/ripd.service new file mode 100644 index 0000000000..5dfd28b3ad --- /dev/null +++ b/meta-networking/recipes-protocols/quagga/files/ripd.service @@ -0,0 +1,14 @@ +[Unit] +Description=RIP routing daemon +BindTo=zebra.service +After=zebra.service +ConditionPathExists=@SYSCONFDIR@/quagga/ripd.conf + +[Service] +Type=forking +EnvironmentFile=-@SYSCONFDIR@/default/quagga +ExecStart=@SBINDIR@/ripd -d $ripd_options -f /etc/quagga/ripd.conf +Restart=on-abort + +[Install] +WantedBy=multi-user.target diff --git a/meta-networking/recipes-protocols/quagga/files/ripngd.service b/meta-networking/recipes-protocols/quagga/files/ripngd.service new file mode 100644 index 0000000000..936b81fb9e --- /dev/null +++ b/meta-networking/recipes-protocols/quagga/files/ripngd.service @@ -0,0 +1,14 @@ +i[Unit] +Description=RIP routing daemon for IPv6 +BindTo=zebra.service +After=zebra.service +ConditionPathExists=@SYSCONFDIR@/quagga/ripngd.conf + +[Service] +Type=forking +EnvironmentFile=-@SYSCONFDIR@/default/quagga +ExecStart=@SBINDIR@/ripngd -d $ripngd_options -f /etc/quagga/ripngd.conf +Restart=on-abort + +[Install] +WantedBy=multi-user.target diff --git a/meta-networking/recipes-protocols/quagga/files/volatiles.03_quagga b/meta-networking/recipes-protocols/quagga/files/volatiles.03_quagga new file mode 100644 index 0000000000..1f28c0b24d --- /dev/null +++ b/meta-networking/recipes-protocols/quagga/files/volatiles.03_quagga @@ -0,0 +1,3 @@ +# +d quagga quagga 0755 /var/run/quagga none +d quagga quagga 0755 /var/log/quagga none diff --git a/meta-networking/recipes-protocols/quagga/files/watchquagga.default b/meta-networking/recipes-protocols/quagga/files/watchquagga.default new file mode 100644 index 0000000000..2d601ec97d --- /dev/null +++ b/meta-networking/recipes-protocols/quagga/files/watchquagga.default @@ -0,0 +1,12 @@ +# Watchquagga configuration +#watch_daemons="zebra bgpd ospfd ospf6d ripd ripngd" +watch_daemons="zebra" + +# To enable restarts when multiple daemons are being used, uncomment this line (but first be sure to edit +# the WATCH_DAEMONS line to reflect the daemons you are actually using): +#watch_options="-Az -b_ -r/etc/init.d/quagga_restart_%s -s/etc/init.d/quagga_start_%s -k/etc/init.d/quagga_stop_%s" + +# Since we are using one quagga daemon for now, use the following line. If using +# multiple daemons, comment the line below and uncoment the line mentioned +# above. +watch_options="-z -b_ -r/etc/init.d/quagga_restart_%s" diff --git a/meta-networking/recipes-protocols/quagga/files/watchquagga.init b/meta-networking/recipes-protocols/quagga/files/watchquagga.init new file mode 100644 index 0000000000..5ddd94a3d6 --- /dev/null +++ b/meta-networking/recipes-protocols/quagga/files/watchquagga.init @@ -0,0 +1,64 @@ +#!/bin/sh +# +### BEGIN INIT INFO +# Provides: watchquagga +# Required-Start: $local_fs $network $remote_fs $syslog +# Required-Stop: $local_fs $network $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: start and stop the Quagga watchdog +### END INIT INFO + +PATH=/bin:/usr/bin:/sbin:/usr/sbin + +# Load configuration +test -f /etc/default/watchquagga && . /etc/default/watchquagga + +# Check that there are daemons to be monitored. +[ -z "$watch_daemons" ] && exit 0 + +pidfile="/var/run/quagga/watchquagga.pid" + +case "$1" in + start) + echo -n "Starting quagga watchdog daemon: watchquagga" + start-stop-daemon --start \ + --pidfile $pidfile \ + --exec /usr/sbin/watchquagga \ + -- -d $watch_options $watch_daemons + echo "." + ;; + + stop) + echo -n "Stopping quagga watchdog daemon: watchquagga" + start-stop-daemon --stop --quiet \ + --pidfile $pidfile + echo "." + ;; + + status) + echo -n "watchquagga " + res=1 + [ -e $pidfile ] && kill -0 `cat $pidfile` 2> /dev/null + if [ $? -eq 0 ]; then + echo "(pid `cat $pidfile`) is running..." + res=0 + else + echo "is stopped..." + fi + exit $res + ;; + + restart|force-reload) + $0 stop $2 + sleep 1 + $0 start $2 + ;; + + *) + echo "Usage: /etc/init.d/watchquagga {start|stop|restart|force-reload}" + exit 1 + ;; +esac + +exit 0 diff --git a/meta-networking/recipes-protocols/quagga/files/zebra.service b/meta-networking/recipes-protocols/quagga/files/zebra.service new file mode 100644 index 0000000000..afdd9e52db --- /dev/null +++ b/meta-networking/recipes-protocols/quagga/files/zebra.service @@ -0,0 +1,15 @@ +[Unit] +Description=GNU Zebra routing manager +Wants=network.target +Before=network.target +ConditionPathExists=@SYSCONFDIR@/quagga/zebra.conf + +[Service] +Type=forking +EnvironmentFile=-@SYSCONFDIR@/default/quagga +ExecStartPre=@BASE_SBINDIR@/ip route flush proto zebra +ExecStart=@SBINDIR@/zebra -d $zebra_options -f /etc/quagga/zebra.conf +Restart=on-abort + +[Install] +WantedBy=multi-user.target diff --git a/meta-networking/recipes-protocols/quagga/quagga.inc b/meta-networking/recipes-protocols/quagga/quagga.inc new file mode 100644 index 0000000000..2c0817b83f --- /dev/null +++ b/meta-networking/recipes-protocols/quagga/quagga.inc @@ -0,0 +1,250 @@ +SUMMARY = "BGP/OSPF/RIP routing daemon" +DESCRIPTION = "Quagga is a routing software suite, providing \ +implementations of OSPFv2, OSPFv3, RIP v1 and v2, RIPv3 and BGPv4 for \ +Unix platforms, particularly FreeBSD, Linux, Solaris and NetBSD. \ +Quagga is a fork of GNU Zebra which was developed by Kunihiro \ +Ishiguro. The Quagga tree aims to build a more involved community \ +around Quagga than the current centralised model of GNU Zebra." +HOMEPAGE = "http://www.nongnu.org/quagga/" +SECTION = "network" +LICENSE = "GPL-2.0 & LGPL-2.0" +DEPENDS = "readline ncurses perl-native" +DEPENDS += "${@base_contains('DISTRO_FEATURES', 'snmp', 'net-snmp', '', d)}" +SNMP_CONF="${@base_contains('DISTRO_FEATURES', 'snmp', '--enable-snmp', '', d)}" + +LIC_FILES_CHKSUM = "file://COPYING;md5=81bcece21748c91ba9992349a91ec11d \ + file://COPYING.LIB;md5=01ef24401ded36cd8e5d18bfe947240c" + +# the "ip" command from busybox is not sufficient (flush by protocol flushes all routes) +RDEPENDS_${PN} += "iproute2" + +QUAGGASUBDIR = "" +# ${QUAGGASUBDIR} is deal with old versions. Set to "/attic" for old +# versions and leave it empty for recent versions. +SRC_URI = "${SAVANNAH_GNU_MIRROR}/quagga${QUAGGASUBDIR}/quagga-${PV}.tar.gz; \ + file://Zebra-sync-zebra-routing-table-with-the-kernel-one.patch \ + file://quagga.init \ + file://quagga.default \ + file://watchquagga.init \ + file://watchquagga.default \ + file://volatiles.03_quagga \ + file://quagga.pam \ + file://ripd-fix-two-bugs-after-received-SIGHUP.patch \ + file://quagga-Avoid-duplicate-connected-address.patch \ + file://babeld.service \ + file://bgpd.service \ + file://isisd.service \ + file://ospf6d.service \ + file://ospfd.service \ + file://ripd.service \ + file://ripngd.service \ + file://zebra.service \ +" + +PACKAGECONFIG ??= "${@base_contains('DISTRO_FEATURES', 'pam', 'pam', '', d)}" +PACKAGECONFIG[cap] = "--enable-capabilities,--disable-capabilities,libcap" +PACKAGECONFIG[pam] = "--with-libpam, --without-libpam, libpam" + +inherit autotools update-rc.d useradd systemd + +SYSTEMD_PACKAGES = "${PN} ${PN}-babeld ${PN}-bgpd ${PN}-isisd ${PN}-ospf6d ${PN}-ospfd ${PN}-ripd ${PN}-ripngd" +SYSTEMD_SERVICE_${PN}-babeld = "babeld.service" +SYSTEMD_SERVICE_${PN}-bgpd = "bgpd.service" +SYSTEMD_SERVICE_${PN}-isisd = "isisd.service" +SYSTEMD_SERVICE_${PN}-ospf6d = "ospf6d.service" +SYSTEMD_SERVICE_${PN}-ospfd = "ospfd.service" +SYSTEMD_SERVICE_${PN}-ripd = "ripd.service" +SYSTEMD_SERVICE_${PN}-ripngd = "ripngd.service" +SYSTEMD_SERVICE_${PN} = "zebra.service" + +EXTRA_OECONF = "--sysconfdir=${sysconfdir}/quagga \ + --localstatedir=${localstatedir}/run/quagga \ + --enable-exampledir=${docdir}/quagga/examples/ \ + --enable-vtysh \ + --enable-isisd \ + ${@base_contains('DISTRO_FEATURES', 'sysvinit', '--enable-watchquagga', '--disable-watchquagga', d)} \ + --enable-ospf-te \ + --enable-opaque-lsa \ + --enable-ipv6 \ + --enable-ospfclient=yes \ + --enable-multipath=64 \ + --enable-user=quagga \ + --enable-group=quagga \ + --enable-vty-group=quaggavty \ + --enable-configfile-mask=0640 \ + --enable-logfile-mask=0640 \ + --enable-rtadv \ + --enable-linux24-tcp-md5 \ + ap_cv_cc_pie=no \ + ${SNMP_CONF}" + +do_install () { + # Install init script and default settings + install -m 0755 -d ${D}${sysconfdir}/default ${D}${sysconfdir}/init.d \ + ${D}${sysconfdir}/quagga ${D}${sysconfdir}/default/volatiles + install -m 0644 ${WORKDIR}/quagga.default ${D}${sysconfdir}/default/quagga + install -m 0644 ${WORKDIR}/watchquagga.default ${D}${sysconfdir}/default/watchquagga + install -m 0755 ${WORKDIR}/quagga.init ${D}${sysconfdir}/init.d/quagga + install -m 0755 ${WORKDIR}/watchquagga.init ${D}${sysconfdir}/init.d/watchquagga + install -m 0644 ${WORKDIR}/volatiles.03_quagga ${D}${sysconfdir}/default/volatiles/volatiles.03_quagga + + # Install sample configurations for the daemons + for f in bgpd vtysh babeld isisd ospfd ripngd zebra ripd ospf6d; do + install -m 0640 ${S}/$f/$f.conf.sample ${D}${sysconfdir}/quagga/$f.conf.sample + done + + for f in bgpd vtysh babeld isisd ospfd ripngd zebra ripd ospf6d; do + touch ${D}${sysconfdir}/quagga/$f.conf + done + chown quagga:quaggavty ${D}${sysconfdir}/quagga + chown quagga:quagga ${D}${sysconfdir}/quagga/*.conf + chmod 750 ${D}${sysconfdir}/quagga + chmod 640 ${D}${sysconfdir}/quagga/*.conf + + # Install quagga + oe_runmake install DESTDIR=${D} prefix=${prefix} \ + sbindir=${sbindir} \ + sysconfdir=${sysconfdir}/quagga \ + localstatedir=${localstatedir}/run/quagga + + # Fix hardcoded paths + sed -i 's!/usr/sbin/!${sbindir}/!g' ${D}${sysconfdir}/init.d/* + sed -i 's!/usr/bin/!${bindir}/!g' ${D}${sysconfdir}/init.d/quagga + sed -i 's!/etc/!${sysconfdir}/!g' ${D}${sysconfdir}/init.d/* ${D}${sysconfdir}/default/watchquagga + sed -i 's!/var/!${localstatedir}/!g' ${D}${sysconfdir}/init.d/* ${D}${sysconfdir}/default/volatiles/volatiles.03_quagga + sed -i 's!^PATH=.*!PATH=${base_sbindir}:${sbindir}:${base_bindir}:${bindir}!' ${D}${sysconfdir}/init.d/* + + # Remove generated info dir file, it doesn't belong in the generated + # package. + rm -f ${D}${infodir}/dir + + # For PAM + for feature in ${DISTRO_FEATURES}; do + if [ "$feature" = "pam" ]; then + install -D -m 644 ${WORKDIR}/quagga.pam ${D}/${sysconfdir}/pam.d/quagga + break + fi + done + + if ${@base_contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then + install -d ${D}${sysconfdir}/tmpfiles.d + echo "d /var/run/quagga 0755 quagga quagga -" \ + > ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf + fi + + # Remove sysinit script if sysvinit is not in DISTRO_FEATURES + if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'false', 'true', d)}; then + rm -rf ${D}${sysconfdir}/init.d/ + rm -f ${D}${sysconfdir}/default/watchquagga + fi + + install -d ${D}${systemd_unitdir}/system + for i in babeld bgpd isisd ospf6d ospfd ripd ripngd zebra; do + install -m 0644 ${WORKDIR}/$i.service ${D}${systemd_unitdir}/system + done + sed -e 's,@BASE_SBINDIR@,${base_sbindir},g' \ + -e 's,@SYSCONFDIR@,${sysconfdir},g' \ + -e 's,@SBINDIR@,${sbindir},g' \ + -i ${D}${systemd_unitdir}/system/*.service +} + +DEPENDS_append = " ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd-systemctl-native', '', d)}" +pkg_postinst_${PN} () { + if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd sysvinit', 'true', 'false', d)}; then + if [ -n "$D" ]; then + OPTS="--root=$D" + fi + systemctl $OPTS mask quagga.service + fi +} + +# Split into a main package and separate per-protocol packages +PACKAGE_BEFORE_PN = "${PN}-ospfd ${PN}-ospf6d ${PN}-babeld ${PN}-bgpd \ + ${PN}-ripd ${PN}-ripngd ${PN}-isisd \ + ${PN}-ospfclient ${@base_contains('DISTRO_FEATURES', 'sysvinit', '${PN}-watchquagga', '', d)}" + +RDEPENDS_${PN} += "${PN}-babeld ${PN}-bgpd ${PN}-isisd ${PN}-ospf6d ${PN}-ospfd ${PN}-ripd ${PN}-ripngd" + +FILES_${PN}-ospfd = "${sbindir}/ospfd ${libdir}/libospf.so.*" +FILES_${PN}-ospf6d = "${sbindir}/ospf6d" +FILES_${PN}-babeld = "${sbindir}/babeld" +FILES_${PN}-bgpd = "${sbindir}/bgpd" +FILES_${PN}-ripd = "${sbindir}/ripd" +FILES_${PN}-ripngd = "${sbindir}/ripngd" +FILES_${PN}-isisd = "${sbindir}/isisd" +FILES_${PN}-ospfclient = "${sbindir}/ospfclient ${libdir}/libospfapiclient.so.*" +FILES_${PN}-watchquagga = "${sbindir}/watchquagga ${sysconfdir}/default/watchquagga \ + ${sysconfdir}/init.d/watchquagga" + +# Indicate that the default files are configuration files +CONFFILES_${PN} = "${sysconfdir}/default/quagga \ + ${sysconfdir}/quagga/bgpd.conf \ + ${sysconfdir}/quagga/vtysh.conf \ + ${sysconfdir}/quagga/babeld.conf \ + ${sysconfdir}/quagga/isisd.conf \ + ${sysconfdir}/quagga/ospfd.conf \ + ${sysconfdir}/quagga/ripngd.conf \ + ${sysconfdir}/quagga/zebra.conf \ + ${sysconfdir}/quagga/ripd.conf \ + ${sysconfdir}/quagga/ospf6d.conf \ + " +CONFFILES_${PN}-watchquagga = "${sysconfdir}/default/watchquagga" + +# Stop the names being rewritten due to the internal shared libraries +DEBIAN_NOAUTONAME_${PN}-ospfd = "1" +DEBIAN_NOAUTONAME_${PN}-ospfclient = "1" + +# the "ip" command from busybox is not sufficient (flush by protocol flushes all routes) +RDEPENDS_${PN} += "iproute2" + +# Main init script starts all deamons +# Seperate init script for watchquagga +INITSCRIPT_PACKAGES = "${PN} ${PN}-watchquagga" +INITSCRIPT_NAME_${PN} = "quagga" +INITSCRIPT_PARAMS_${PN} = "defaults 15 85" +INITSCRIPT_NAME_${PN}-watchquagga = "watchquagga" +INITSCRIPT_PARAMS_${PN}-watchquagga = "defaults 90 10" + +# Add quagga's user and group +USERADD_PACKAGES = "${PN}" +GROUPADD_PARAM_${PN} = "--system quagga ; --system quaggavty" +USERADD_PARAM_${PN} = "--system --home ${localstatedir}/run/quagga/ -M -g quagga --shell /bin/false quagga" + +pkg_postinst_${PN} () { + if [ -z "$D" ] && [ -e /etc/init.d/populate-volatile.sh ] ; then + ${sysconfdir}/init.d/populate-volatile.sh update + fi +} + +# Stop apps before uninstall +pkg_prerm_${PN} () { + ${sysconfdir}/init.d/quagga stop +} + +pkg_prerm_${PN}-ospfd () { + ${sysconfdir}/init.d/quagga stop ospfd +} + +pkg_prerm_${PN}-ospf6d () { + ${sysconfdir}/init.d/quagga stop ospf6d +} + +pkg_prerm_${PN}-babeld () { + ${sysconfdir}/init.d/quagga stop babeld +} + +pkg_prerm_${PN}-bgpd () { + ${sysconfdir}/init.d/quagga stop bgpd +} + +pkg_prerm_${PN}-ripd () { + ${sysconfdir}/init.d/quagga stop ripd +} + +pkg_prerm_${PN}-ripngd () { + ${sysconfdir}/init.d/quagga stop ripngd +} + +pkg_prerm_${PN}-isisd () { + ${sysconfdir}/init.d/quagga stop isisd +} diff --git a/meta-networking/recipes-protocols/quagga/quagga_0.99.23.bb b/meta-networking/recipes-protocols/quagga/quagga_0.99.23.bb new file mode 100644 index 0000000000..a56767e518 --- /dev/null +++ b/meta-networking/recipes-protocols/quagga/quagga_0.99.23.bb @@ -0,0 +1,9 @@ +require quagga.inc + +SRC_URI += "file://babel-close-the-stdout-stderr-as-in-other-daemons.patch \ +" + +SRC_URI[md5sum] = "d17145e62b6ea14f0f13bb63f59e5166" +SRC_URI[sha256sum] = "2c7798204f35dc7acea9f206647e8aa3957cae3b21733cdff413b506481a101c" + +QUAGGASUBDIR = "" diff --git a/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/configure.patch b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/configure.patch new file mode 100644 index 0000000000..1380ba4891 --- /dev/null +++ b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/configure.patch @@ -0,0 +1,11 @@ +Index: rp-pppoe-3.8/configure.in +=================================================================== +--- rp-pppoe-3.8.orig/configure.in 2014-07-16 19:31:33.549991388 +0000 ++++ rp-pppoe-3.8/configure.in 2014-07-17 22:01:18.116590827 +0000 +@@ -1,4 +1,4 @@ +-AC_INIT(src/pppoe.c) +-AM_INIT_AUTOMAKE([rp-pppoe], [3.8]) ++AC_INIT([rp-pppoe], [3.8]) ++AM_INIT_AUTOMAKE([foreign]) + AC_CONFIG_SUBDIRS(src) + AC_OUTPUT(Makefile) diff --git a/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/configure_in_cross.patch b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/configure_in_cross.patch new file mode 100644 index 0000000000..1896759427 --- /dev/null +++ b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/configure_in_cross.patch @@ -0,0 +1,142 @@ +Update the configure script to cross-compiling with OE. This hard-codes +a few target paths, reworks a few tests to be more friendly for cross +and drops other tests. + +Upstream-Status: Inappropriate [build system specific changes] + +Index: src/configure.in +=================================================================== +--- rp-pppoe-3.8.orig/src/configure.in 2006-04-03 00:29:42.000000000 +1000 ++++ rp-pppoe-3.8/src/configure.in 2007-06-07 22:19:36.000000000 +1000 +@@ -5,6 +5,13 @@ + dnl pppd directory for kernel-mode PPPoE + PPPD_DIR=ppp-2.4.1.pppoe2 + ++dnl hard code some paths ++PPPD=/usr/sbin/pppd ++ID=/usr/bin/id ++ECHO=/bin/echo ++AC_ARG_VAR(PPPD) ++AC_ARG_VAR(ID) ++ + AC_CONFIG_HEADER(config.h) + + AC_PREFIX_DEFAULT(/usr) +@@ -44,7 +51,7 @@ + AC_MSG_RESULT($ac_cv_struct_sockaddr_ll) + + if test "$ac_cv_struct_sockaddr_ll" = yes ; then +-AC_DEFINE(HAVE_STRUCT_SOCKADDR_LL) ++AC_DEFINE([HAVE_STRUCT_SOCKADDR_LL], [], [Have struct SOCKADDR_LL]) + fi + + dnl Check for N_HDLC line discipline +@@ -55,7 +62,7 @@ + ac_cv_n_hdlc=no) + AC_MSG_RESULT($ac_cv_n_hdlc) + if test "$ac_cv_n_hdlc" = yes ; then +-AC_DEFINE(HAVE_N_HDLC) ++AC_DEFINE([HAVE_N_HDLC], [], [Have N_HDLC]) + fi + + AC_ARG_ENABLE(plugin, [ --enable-plugin=pppd_src_path build pppd plugin], ac_cv_pluginpath=$enableval, ac_cv_pluginpath=no) +@@ -100,13 +107,13 @@ + if test "$ac_cv_header_linux_if_pppox_h" = yes ; then + if test "$ac_cv_pluginpath" != no ; then + LINUX_KERNELMODE_PLUGIN=rp-pppoe.so +- AC_DEFINE(HAVE_LINUX_KERNEL_PPPOE) ++ AC_DEFINE([HAVE_LINUX_KERNEL_PPPOE], [], [Have kernel PPPoE]) + PPPD_INCDIR=$ac_cv_pluginpath + fi + fi + + if test "$ac_cv_debugging" = "yes" ; then +- AC_DEFINE(DEBUGGING_ENABLED) ++ AC_DEFINE([DEBUGGING_ENABLED], [], [Debugging enabled]) + fi + + AC_SUBST(LINUX_KERNELMODE_PLUGIN) +@@ -131,15 +138,8 @@ + AC_CHECK_SIZEOF(unsigned int) + AC_CHECK_SIZEOF(unsigned long) + +-dnl Check for location of pppd +-AC_PATH_PROG(PPPD, pppd, NOTFOUND, $PATH:/sbin:/usr/sbin:/usr/local/sbin) +-AC_PATH_PROG(ECHO, echo, echo) +- +-dnl Check for setsid (probably Linux-specific) +-AC_PATH_PROG(SETSID, setsid, "", $PATH:/sbin:/usr/sbin:/usr/local/sbin) +- + dnl Check for an "id" which accepts "-u" option -- hack for Solaris. +-AC_PATH_PROG(ID, id, "", /usr/xpg4/bin:$PATH) ++dnl AC_PATH_PROG(ID, id, "", /usr/xpg4/bin:$PATH) + + dnl Check for Linux-specific kernel support for PPPoE + AC_MSG_CHECKING(for Linux 2.4.X kernel-mode PPPoE support) +@@ -183,44 +183,8 @@ + CFLAGS="$CFLAGS -Wall -Wstrict-prototypes -ansi" + fi + +-dnl If we couldn't find pppd, die +-if test "$PPPD" = "NOTFOUND"; then +- AC_MSG_WARN([*** Oops! I couldn't find pppd, the PPP daemon anywhere.]) +- AC_MSG_WARN([*** You must install pppd, version 2.3.10 or later.]) +- AC_MSG_WARN([*** I will keep going, but it may not work.]) +- PPPD=pppd +-fi +- +-dnl Figure out pppd version. 2.3.7 to 2.3.9 -- issue warning. Less than +-dnl 2.3.7 -- stop +- +-PPPD_VERSION=`$PPPD --version 2>&1 | awk ' /version/ {print $NF}'` +- +-case "$PPPD_VERSION" in +-1.*|2.0.*|2.1.*|2.2.*|2.3.0|2.3.1|2.3.2|2.3.3|2.3.4|2.3.5|2.3.6) +- AC_MSG_WARN([*** Oops! Your version of pppd is $PPPD_VERSION, which is too old.]) +- AC_MSG_WARN([*** You need at least 2.3.7 (2.3.10 or newer recommended.]) +- AC_MSG_WARN([*** I will keep going, but it may not work.]) +- ;; +- +-2.3.7|2.3.8|2.3.9) +- AC_MSG_WARN([*** Warning. Your version of pppd is $PPPD_VERSION. You will]) +- AC_MSG_WARN([*** not be able to use connect-on-demand. Upgrade to pppd]) +- AC_MSG_WARN([*** 2.3.10 or newer if you need connect-on-demand.]) +- ;; +- +-2*|3*|4*|5*|6*|7*|8*|9*) +- ;; +- +-*) +- AC_MSG_WARN([*** Oops. I cannot figure out what version of pppd you have.]) +- AC_MSG_WARN([*** All I got back was '$PPPD_VERSION']) +- AC_MSG_WARN([*** I will keep going, but it may not work.]) +- ;; +-esac +- + dnl Figure out packing order of structures +-AC_MSG_CHECKING([packing order of bit fields]) ++AC_CACHE_CHECK([packing order of bit fields],rpppoe_cv_pack_bitfields,[ + AC_TRY_RUN([ + union foo { + struct bar { +@@ -245,10 +209,11 @@ + } + }], rpppoe_cv_pack_bitfields=normal, rpppoe_cv_pack_bitfields=rev, + $ECHO "no defaults for cross-compiling"; exit 0) ++]) + + if test "$rpppoe_cv_pack_bitfields" = "rev" ; then + AC_MSG_RESULT(reversed) +- AC_DEFINE(PACK_BITFIELDS_REVERSED) ++ AC_DEFINE([PACK_BITFIELDS_REVERSED], [], [Reversed bitfields]) + else + AC_MSG_RESULT(normal) + fi +@@ -312,6 +277,7 @@ + AC_SUBST(RDYNAMIC) + AC_SUBST(LIBEVENT) + AC_SUBST(ECHO) ++AC_SUBST(HAVE_STRUCT_SOCKADDR_LL) + + datadir_evaluated=`eval echo $datadir` + AC_SUBST(datadir_evaluated) diff --git a/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/discard-use-of-dnl-in-Makefile.am.patch b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/discard-use-of-dnl-in-Makefile.am.patch new file mode 100644 index 0000000000..8b7886485a --- /dev/null +++ b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/discard-use-of-dnl-in-Makefile.am.patch @@ -0,0 +1,27 @@ +From 611c9fe719c5aa264a2ad2eb920cf4522ae2ddec Mon Sep 17 00:00:00 2001 +From: Ting Liu +Date: Tue, 12 Jun 2012 14:26:16 -0400 +Subject: [PATCH] discard use of dnl in Makefile.am + +Since Makefile.am is not processed by m4, but by automake, 'dnl' does +not introduce a comment. + +Signed-off-by: Ting Liu +--- + Makefile.am | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/Makefile.am b/Makefile.am +index eff6977..3091c33 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -1,5 +1,5 @@ + PACKAGE = rp-pppoe + VERSION = 3.8 + +-dnl AM_CFLAGS = -Wall -DDEBUG ++##dnl AM_CFLAGS = -Wall -DDEBUG + SUBDIRS = src +-- +1.7.6.5 + diff --git a/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/dont-swallow-errors.patch b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/dont-swallow-errors.patch new file mode 100644 index 0000000000..c7fc9cfacc --- /dev/null +++ b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/dont-swallow-errors.patch @@ -0,0 +1,15 @@ +Further fixup to the configure scripts to not swallow errors + +Upstream-Status: Pending + +--- a/src/configure.in.org 2008-01-14 21:08:38.000000000 +0200 ++++ a/src/configure.in 2008-01-14 21:20:09.000000000 +0200 +@@ -208,7 +208,7 @@ + return 2; + } + }], rpppoe_cv_pack_bitfields=normal, rpppoe_cv_pack_bitfields=rev, +-$ECHO "no defaults for cross-compiling"; exit 0) ++$ECHO "no defaults for cross-compiling"; exit 1) + ]) + + if test "$rpppoe_cv_pack_bitfields" = "rev" ; then diff --git a/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/pppoe-server.default b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/pppoe-server.default new file mode 100644 index 0000000000..996d57f3cf --- /dev/null +++ b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/pppoe-server.default @@ -0,0 +1,22 @@ +# PPPoE Server options + +# Maximum segment size, not used for in kernel PPPoE +#MSS=1412 + +# Device(s) - Space seperated list of devices to listen on +#DEVICES="eth1" + +# Local IP +#LOCAL_IP=10.0.0.1 + +# Starting remote IP +#REMOTE_IP=10.67.15.1 + +# Service name +#SERVICE_NAME="acme" + +# Maximum number of sessions, default is 16 +#MAX_SESSIONS=64 + +# Access concentrator name, default is the hostname +#ACCESS_CONCENTRATOR_NAME="pppoe-rtr-1" diff --git a/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/pppoe-server.init b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/pppoe-server.init new file mode 100755 index 0000000000..21afe0be39 --- /dev/null +++ b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/pppoe-server.init @@ -0,0 +1,59 @@ +#! /bin/sh + +test -f /usr/sbin/pppoe-server || exit 0 +test -f /etc/default/pppoe-server && . /etc/default/pppoe-server + +case $1 in + start) + OPTIONS="" + if [ -n "$MSS" ]; then + OPTIONS="$OPTIONS -m $MSS" + fi + if [ -n "$DEVICES" ]; then + for i in $DEVICES; do + OPTIONS="$OPTIONS -I $i" + done + fi + if [ -n "$LOCAL_IP" ]; then + OPTIONS="$OPTIONS -L $LOCAL_IP" + fi + if [ -n "$REMOTE_IP" ]; then + OPTIONS="$OPTIONS -R $REMOTE_IP" + fi + if [ -n "$SERVICE_NAME" ]; then + OPTIONS="$OPTIONS -S $SERVICE_NAME" + fi + if [ -n "$MAX_SESSIONS" ]; then + OPTIONS="$OPTIONS -N $MAX_SESSIONS" + fi + if [ -n "$ACCESS_CONCENTRATOR_NAME" ]; then + OPTIONS="$OPTIONS -C $ACCESS_CONCENTRATOR_NAME" + fi + echo -n "Starting PPPoE server: pppoe-server" + start-stop-daemon --start --quiet --exec /usr/sbin/pppoe-server -- $OPTIONS + echo "." + ;; + stop) + echo -n "Stopping PPPoE server: pppoe-server" + start-stop-daemon --stop --quiet --exec /usr/sbin/pppoe-server -- $OPTIONS + echo "." + ;; + status) + pid=$(pidof pppoe-server) + if [ -n "$pid" ] ; then + echo "Running with pid $pid" + else + echo "Not running" + fi + ;; + restart|force-reload) + $0 stop + $0 start + ;; + *) + echo "Usage: /etc/init.d/pppoe-server {start|stop|restart|force-reload}" + exit 1 + ;; +esac + +exit 0 diff --git a/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/pppoe-src-restrictions.patch b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/pppoe-src-restrictions.patch new file mode 100644 index 0000000000..bcf4d1164d --- /dev/null +++ b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/pppoe-src-restrictions.patch @@ -0,0 +1,20 @@ +Relax restrictions on the PPPoE src address, as per debian bug +293811: + + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=293811 + +Upstream-Status: Inappropriate [Backport from Debian] + +--- rp-pppoe-3.8.orig/src/discovery.c ++++ rp-pppoe-3.8/src/discovery.c +@@ -376,8 +376,8 @@ + if (!packetIsForMe(conn, &packet)) continue; + + if (packet.code == CODE_PADO) { +- if (NOT_UNICAST(packet.ethHdr.h_source)) { +- printErr("Ignoring PADO packet from non-unicast MAC address"); ++ if (BROADCAST(packet.ethHdr.h_source)) { ++ printErr("Ignoring broadcast PADO packet"); + continue; + } + parsePacket(&packet, parsePADOTags, &pc); diff --git a/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/top-autoconf.patch b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/top-autoconf.patch new file mode 100644 index 0000000000..4fe73d0171 --- /dev/null +++ b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/top-autoconf.patch @@ -0,0 +1,27 @@ +The autoconf stuff is all in a subdirectory, which is rather annoying +as OE expects patches to be applied and autoconf stuff to be done in +S. This adds enough autoconf at the top level to allow it to be +called there - all it does is run a sub autoconf stuff in the src +directory. + +Upstream-Status: Inappropriate [build system specific change] + +Index: rp-pppoe-3.8/Makefile.am +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ rp-pppoe-3.8/Makefile.am 2007-06-08 15:58:16.000000000 +1000 +@@ -0,0 +1,5 @@ ++PACKAGE = rp-pppoe ++VERSION = 3.8 ++ ++dnl AM_CFLAGS = -Wall -DDEBUG ++SUBDIRS = src +Index: rp-pppoe-3.8/configure.in +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ rp-pppoe-3.8/configure.in 2007-06-08 15:58:16.000000000 +1000 +@@ -0,0 +1,4 @@ ++AC_INIT(src/pppoe.c) ++AM_INIT_AUTOMAKE([rp-pppoe], [3.8]) ++AC_CONFIG_SUBDIRS(src) ++AC_OUTPUT(Makefile) diff --git a/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/update-config.patch b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/update-config.patch new file mode 100644 index 0000000000..42a3bc62c8 --- /dev/null +++ b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/update-config.patch @@ -0,0 +1,32 @@ +Set the timeout to 0 since we don't want pppoe to try reconnecting, +we want whatever is calling it to reconnect. Lots of odd things +happen when you have pppoe retrying itself. + +The path for the plugin is wrong, it's now part of ppp and is in a +ppp's plugin lib directory. If no path is specified then that's where +ppp looks, so that's what we do here. + +Upstream-Status: Inappropriate [configuration] + +Index: rp-pppoe-3.8/configs/pppoe.conf +=================================================================== +--- rp-pppoe-3.8.orig/configs/pppoe.conf 2006-04-03 00:29:41.000000000 +1000 ++++ rp-pppoe-3.8/configs/pppoe.conf 2007-06-08 16:02:47.000000000 +1000 +@@ -66,7 +66,7 @@ + # to connect forever after pppoe-start is called. Otherwise, it will + # give out after CONNECT_TIMEOUT seconds and will not attempt to + # connect again, making it impossible to reach. +-CONNECT_TIMEOUT=30 ++CONNECT_TIMEOUT=0 + + # How often in seconds pppoe-start polls to check if link is up + CONNECT_POLL=2 +@@ -115,7 +115,7 @@ + FIREWALL=NONE + + # Linux kernel-mode plugin for pppd. If you want to try the kernel-mode +-# plugin, use LINUX_PLUGIN=/etc/ppp/plugins/rp-pppoe.so ++# plugin, use LINUX_PLUGIN=rp-pppoe.so + LINUX_PLUGIN= + + # Any extra arguments to pass to pppoe. Normally, use a blank string diff --git a/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/use-ldflags.patch b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/use-ldflags.patch new file mode 100644 index 0000000000..95f629298b --- /dev/null +++ b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/use-ldflags.patch @@ -0,0 +1,27 @@ +Make the Makefile obey LDFLAGS. + +Upstream-Status: Pending + +--- a/src/Makefile.in 2006-04-02 18:29:42.000000000 +0400 ++++ b/src/Makefile.in 2010-04-16 17:51:31.000000000 +0400 +@@ -67,16 +67,16 @@ all: $(TARGETS) + @echo "Type 'make install' as root to install the software." + + pppoe-sniff: pppoe-sniff.o if.o common.o debug.o +- @CC@ -o pppoe-sniff pppoe-sniff.o if.o common.o debug.o ++ @CC@ -o pppoe-sniff pppoe-sniff.o if.o common.o debug.o $(LDFLAGS) + + pppoe-server: pppoe-server.o if.o debug.o common.o md5.o libevent/libevent.a @PPPOE_SERVER_DEPS@ +- @CC@ -o pppoe-server @RDYNAMIC@ pppoe-server.o if.o debug.o common.o md5.o $(PPPOE_SERVER_LIBS) -Llibevent -levent ++ @CC@ -o pppoe-server @RDYNAMIC@ pppoe-server.o if.o debug.o common.o md5.o $(PPPOE_SERVER_LIBS) -Llibevent -levent $(LDFLAGS) + + pppoe: pppoe.o if.o debug.o common.o ppp.o discovery.o +- @CC@ -o pppoe pppoe.o if.o debug.o common.o ppp.o discovery.o ++ @CC@ -o pppoe pppoe.o if.o debug.o common.o ppp.o discovery.o $(LDFLAGS) + + pppoe-relay: relay.o if.o debug.o common.o +- @CC@ -o pppoe-relay relay.o if.o debug.o common.o ++ @CC@ -o pppoe-relay relay.o if.o debug.o common.o $(LDFLAGS) + + pppoe.o: pppoe.c pppoe.h + @CC@ $(CFLAGS) '-DVERSION="$(VERSION)"' -c -o pppoe.o pppoe.c diff --git a/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe_3.8.bb b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe_3.8.bb new file mode 100644 index 0000000000..d1b0481b9e --- /dev/null +++ b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe_3.8.bb @@ -0,0 +1,59 @@ +SUMMARY = "A user-mode PPPoE client and server suite for Linux" +HOMEPAGE = "http://www.roaringpenguin.com/products/pppoe" +SECTION = "console/network" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://doc/LICENSE;md5=a194eaefae2be54ee3221339b10d0581" + +PR = "r10" + +SRC_URI = "http://www.roaringpenguin.com/files/download/${BP}.tar.gz \ + file://top-autoconf.patch \ + file://configure_in_cross.patch \ + file://pppoe-src-restrictions.patch \ + file://update-config.patch \ + file://dont-swallow-errors.patch \ + file://discard-use-of-dnl-in-Makefile.am.patch \ + file://use-ldflags.patch \ + file://configure.patch \ + file://pppoe-server.default \ + file://pppoe-server.init" + +SRC_URI[md5sum] = "0e32760f498f9cde44081ee6aafc823b" +SRC_URI[sha256sum] = "d916e9cfe1e62395f63a5361936fa855f6d0f0a37dc7227b394cdb725f553479" + +inherit autotools-brokensep update-rc.d + +do_install() { + # Install init script and default settings + install -m 0755 -d ${D}${sysconfdir}/default ${D}${sysconfdir}/init.d + install -m 0644 ${WORKDIR}/pppoe-server.default ${D}${sysconfdir}/default/pppoe-server + install -m 0755 ${WORKDIR}/pppoe-server.init ${D}${sysconfdir}/init.d/pppoe-server + # Install + oe_runmake -C ${S} RPM_INSTALL_ROOT=${D} docdir=${docdir} install + chmod 4755 ${D}${sbindir}/pppoe +} + +# Insert server package before main package +PACKAGES = "${PN}-dbg ${PN}-server ${PN}-relay ${PN}-sniff ${PN} ${PN}-doc" + +FILES_${PN}-server = "${sysconfdir}/default/pppoe-server \ + ${sysconfdir}/init.d/pppoe-server \ + ${sbindir}/pppoe-server \ + ${sysconfdir}/ppp/pppoe-server-options" +FILES_${PN}-relay = "${sbindir}/pppoe-relay" +FILES_${PN}-sniff = "${sbindir}/pppoe-sniff" + +CONFFILES_${PN} = "${sysconfdir}/ppp/pppoe.conf \ + ${sysconfdir}/ppp/firewall-standalone \ + ${sysconfdir}/ppp/firewall-masq" +CONFFILES_${PN}-server = "${sysconfdir}/ppp/pppoe-server-options \ + ${sysconfdir}/default/pppoe-server" + +INITSCRIPT_PACKAGES = "${PN}-server" +INITSCRIPT_NAME_${PN}-server = "pppoe-server" +INITSCRIPT_PARAMS_${PN}-server = "defaults 92 8" + +RDEPENDS_${PN} = "ppp" +RDEPENDS_${PN}-server = "${PN}" +RRECOMMENDS_${PN} = "ppp-oe" + diff --git a/meta-networking/recipes-protocols/xl2tpd/xl2tpd.inc b/meta-networking/recipes-protocols/xl2tpd/xl2tpd.inc new file mode 100644 index 0000000000..f4ea2b8266 --- /dev/null +++ b/meta-networking/recipes-protocols/xl2tpd/xl2tpd.inc @@ -0,0 +1,40 @@ +SUMMARY = "Xelerance version of the Layer 2 Tunneling Protocol (L2TP) daemon" +HOMEPAGE = "http://www.xelerance.com/software/xl2tpd/" +SECTION = "network" +DEPENDS = "ppp virtual/kernel" + +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://LICENSE;md5=0636e73ff0215e8d672dc4c32c317bb3" + +INC_PR = "r0" + +SRC_URI = "git://github.com/xelerance/xl2tpd.git" + +S = "${WORKDIR}/git" + +inherit update-rc.d + +do_compile () { + oe_runmake CFLAGS="${CFLAGS} -DLINUX" LDFLAGS="${LDFLAGS}" PREFIX="${prefix}" KERNELSRC=${STAGING_KERNEL_DIR} all +} + +do_install () { + oe_runmake PREFIX="${D}${prefix}" install + + install -d ${D}${sysconfdir}/init.d + touch ${D}${sysconfdir}/xl2tpd.conf + install -m 0755 debian/xl2tpd.init ${D}${sysconfdir}/init.d/xl2tpd + sed -i 's!/usr/sbin/!${sbindir}/!g' ${D}${sysconfdir}/init.d/xl2tpd + sed -i 's!/etc/!${sysconfdir}/!g' ${D}${sysconfdir}/init.d/xl2tpd + sed -i 's!/var/!${localstatedir}/!g' ${D}${sysconfdir}/init.d/xl2tpd + sed -i 's!^PATH=.*!PATH=${base_sbindir}:${base_bindir}:${sbindir}:${bindir}!' ${D}${sysconfdir}/init.d/xl2tpd + + install -d ${D}${sysconfdir}/default + install -m 0644 debian/xl2tpd.default ${D}${sysconfdir}/default/xl2tpd +} + +CONFFILES_${PN} += "${sysconfdir}/xl2tpd.conf ${sysconfdir}/default/xl2tpd" + +INITSCRIPT_PACKAGES = "${PN}" +INITSCRIPT_NAME_${PN} = "xl2tpd" + diff --git a/meta-networking/recipes-protocols/xl2tpd/xl2tpd_git.bb b/meta-networking/recipes-protocols/xl2tpd/xl2tpd_git.bb new file mode 100644 index 0000000000..bd084aa009 --- /dev/null +++ b/meta-networking/recipes-protocols/xl2tpd/xl2tpd_git.bb @@ -0,0 +1,5 @@ +require xl2tpd.inc +PR = "${INC_PR}.0" + +SRCREV = "df7e30eb199fc5710faa83866381aea18b66e60c" + diff --git a/meta-networking/recipes-protocols/zeroconf/zeroconf/compilefix.patch b/meta-networking/recipes-protocols/zeroconf/zeroconf/compilefix.patch new file mode 100644 index 0000000000..328e574a9e --- /dev/null +++ b/meta-networking/recipes-protocols/zeroconf/zeroconf/compilefix.patch @@ -0,0 +1,19 @@ +| zeroconf.c: In function 'main': +| zeroconf.c:145: error: 'PATH_MAX' undeclared (first use in this function) + +RP - 4/9/09 + +Upstream-Status: Pending + +Index: zeroconf-0.9/zeroconf.c +=================================================================== +--- zeroconf-0.9.orig/zeroconf.c 2009-09-04 10:05:25.000000000 +0100 ++++ zeroconf-0.9/zeroconf.c 2009-09-04 10:05:42.000000000 +0100 +@@ -33,6 +33,7 @@ + #include + #include + #include ++#include + + #include "delay.h" + diff --git a/meta-networking/recipes-protocols/zeroconf/zeroconf/debian-zeroconf b/meta-networking/recipes-protocols/zeroconf/zeroconf/debian-zeroconf new file mode 100644 index 0000000000..0c9d15ba12 --- /dev/null +++ b/meta-networking/recipes-protocols/zeroconf/zeroconf/debian-zeroconf @@ -0,0 +1,51 @@ +#!/bin/sh + +if [ ! -x /usr/sbin/zeroconf ]; then + exit 0 +fi + +# IPv4 link-local addresses (zeroconf) are +# only applicable on the 'inet' address family +[ "X$ADDRFAM" != "Xinet" ] && exit 0 + +# However there are some methods where it doesn't +# make any sense to configure an IPv4LL address + +# not on loopback +[ "X$METHOD" = "Xloopback" ] && exit 0 + +# not on ppp or wvdial either +[ "X$METHOD" = "Xppp" ] && exit 0 +[ "X$METHOD" = "Xwvdial" ] && exit 0 + +# The administrator may have blacklisted interfaces +# or only want zeroconf in a fallback situation +[ -f /etc/default/zeroconf ] && + . /etc/default/zeroconf + +[ -n "$DISABLE" ] && exit 0 + +for BLACK in $IFBLACKLIST; do + case $IFACE in + $BLACK) + exit 0 + ;; + esac +done + +# should we only allocate an address if we do not already have one? +if [ -n "$FALLBACK" ]; then + /sbin/ip addr show $IFACE scope global | grep -q "inet" + IP=$? + if [ $IP -eq 0 ]; then + /sbin/ip route add 169.254.0.0/16 dev $IFACE + exit 0 + fi +fi + +# otherwise, run if we aren't already going +if [ ! -r /var/run/zeroconf.$IFACE.pid ]; then + /usr/sbin/zeroconf -i $IFACE +fi + +exit 0 diff --git a/meta-networking/recipes-protocols/zeroconf/zeroconf/zeroconf-default b/meta-networking/recipes-protocols/zeroconf/zeroconf/zeroconf-default new file mode 100644 index 0000000000..cc07b275f1 --- /dev/null +++ b/meta-networking/recipes-protocols/zeroconf/zeroconf/zeroconf-default @@ -0,0 +1,17 @@ +# Default for zeroconf + +# disable zeroconf +# If you want to disable zeroconf completely, uncomment the following line +# this may be useful if you are debugging zeroconf or starting it manually +#DISABLE=yes + +# black-listed interfaces +# Interfaces which you never wish to have zeroconf run on should +# be listed here. e.g. "eth2 wlan1" in a space seperated string +IFBLACKLIST="" + +# fallback only +# If you would only like a link-local address if you were unable to +# obtain an address via DHCP then uncomment the following line +#FALLBACK=yes + diff --git a/meta-networking/recipes-protocols/zeroconf/zeroconf_0.9.bb b/meta-networking/recipes-protocols/zeroconf/zeroconf_0.9.bb new file mode 100644 index 0000000000..9307263c7b --- /dev/null +++ b/meta-networking/recipes-protocols/zeroconf/zeroconf_0.9.bb @@ -0,0 +1,34 @@ +SUMMARY = "IPv4 link-local address allocator" +DESCRIPTION = "Zeroconf is a program that is used to claim IPv4 \ +link-local addresses. IPv4 link-local addresses are useful when setting \ +up ad-hoc networking between devices without the involvement of a either \ +a DHCP server or network administrator. \ +These addresses are allocated from the 169.254.0.0/16 address range and \ +are normally attached to each Ethernet device in your computer. \ +Addresses are assigned randomly by each host and, in case of collision, \ +both hosts (are supposed to) renumber." +AUTHOR = "Anand Kumria " +HOMEPAGE = "http://www.progsoc.org/~wildfire/zeroconf/" +LICENSE = "GPLv2+" +LIC_FILES_CHKSUM = "file://COPYING;md5=4325afd396febcb659c36b49533135d4 \ + file://zeroconf.c;beginline=1;endline=13;md5=a5bada96e1e34b08eb7446b28e2630b2" +SECTION = "net" + +PR = "r1" + +SRC_URI = "http://www.progsoc.org/~wildfire/zeroconf/download/${BPN}-${PV}.tar.gz \ + file://compilefix.patch \ + file://zeroconf-default \ + file://debian-zeroconf" + +SRC_URI[md5sum] = "bdafb16b008ebb5633e4e581f77821d2" +SRC_URI[sha256sum] = "a8c74df127753e2310fa1e072f3c9ca44a404bb0bbce9cfec7a84c6dff8bec7b" + +do_install () { + install -d ${D}${sbindir} + install -d ${D}${sysconfdir}/network/if-up.d + install -d ${D}${sysconfdir}/default + install -c -m 755 ${S}/zeroconf ${D}${sbindir}/zeroconf + install -c -m 755 ${WORKDIR}/debian-zeroconf ${D}${sysconfdir}/network/if-up.d/zeroconf + install -c ${WORKDIR}/zeroconf-default ${D}${sysconfdir}/default/zeroconf +} -- cgit v1.2.3-54-g00ecf