Skip to contentSkip to conversation

netsnmp: fix stop and restart actions in init script

PATCH Superseded Luca Ceresoli 4 participants 15 messages Jun 15, 2011 – Sep 11, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 netsnmp: fix stop and restart actions in init script

/etc/init.d/S59snmpd stop (and restart) currently fail if either snmpd or snmptrapd are not running.
This is because start-stop-daemon -K returns nonzero if the process to be killed is not running, and this causes the whole script to fail because it runs under 'set -e'.

This may not be noticed if only the last start-stop-daemon fails, but this is in general wrong. It would also cause a failure in other scripts that execute S59snmpd and check the return value.

Adding the --oknodo (-o) option to start-stop-daemon fixes this.

---
Weird enough, in the current code the ssd_oknodo variable is first set, then cleared. git log does not help to understand why, but this looks really useless.

This is why I removed a line, instead of adding one.

 package/netsnmp/S59snmpd |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
package/netsnmp/S59snmpd +0 -1
index f65317a..5df4b85 100755
@@ -29,7 +29,6 @@ TRAPDOPTS='-Lsd -p /var/run/snmptrapd.pid'
 [ -r /etc/default/snmpd ] && . /etc/default/snmpd
 
 ssd_oknodo="-o"
-ssd_oknodo=""
 
 # Cd to / before starting any daemons.
 cd /
Signature · 1 line
1.7.4.1
#1 lore raw

PATCH 2/2 netsnmp: allow not to install MIB files

---
 package/netsnmp/Config.in  |    7 +++++++
 package/netsnmp/netsnmp.mk |    4 ++++
 2 files changed, 11 insertions(+), 0 deletions(-)
package/netsnmp/Config.in +7 -0
index 5a3e9aa..2aa537e 100644
@@ -6,3 +6,10 @@ config BR2_PACKAGE_NETSNMP
 
 	  http://net-snmp.sourceforge.net/
 
+config BR2_PACKAGE_NETSNMP_INSTALL_MIBS
+	bool "Install MIB files on target"
+	default y
+	depends on BR2_PACKAGE_NETSNMP
+	help
+	  The net-snmp package contains a selection of MIB files.
+	  Say yes if you want those MIB files installed on the target.
package/netsnmp/netsnmp.mk +4 -0
index 5704327..4eae544 100644
@@ -43,6 +43,10 @@ ifneq ($(BR2_HAVE_DOCUMENTATION),y)
 	NETSNMP_CONF_OPT += --disable-manuals
 endif
 
+ifneq ($(BR2_PACKAGE_NETSNMP_INSTALL_MIBS),y)
+	NETSNMP_CONF_OPT += --disable-mibs
+endif
+
 # Remove IPv6 MIBs if there's no IPv6
 ifneq ($(BR2_INET_IPV6),y)
 define NETSNMP_REMOVE_MIBS_IPV6
Signature · 1 line
1.7.4.1
#2 lore raw

v2 cover netsnmp improvements

In reply to Luca Ceresoli

Hi,

please ignore the two patches I sent yesterday for netsnmp. Patch 2 introduced an annoying series of warnings, as net-snmp requires the MIB files to be installed if the MIB loading code is enabled.

The present patch series addresses this issue correctly, allowing in addition to disable the MIB loading code.

Patch 1 is unchanged.

Luca

Luca Ceresoli (3):
netsnmp: fix stop and restart actions in init script
netsnmp: allow to disable MIB loading code
netsnmp: allow not to install MIB files

 package/netsnmp/Config.in  |   15 +++++++++++++++
 package/netsnmp/S59snmpd   |    1 -
 package/netsnmp/netsnmp.mk |    8 ++++++++
 3 files changed, 23 insertions(+), 1 deletions(-)
Signature · 1 line
1.7.4.1
#3 lore raw

PATCH v2 1/3 netsnmp: fix stop and restart actions in init script

/etc/init.d/S59snmpd stop (and restart) currently fail if either snmpd or snmptrapd are not running.
This is because start-stop-daemon -K returns nonzero if the process to be killed is not running, and this causes the whole script to fail because it runs under 'set -e'.

This may not be noticed if only the last start-stop-daemon fails, but this is in general wrong. It would also cause a failure in other scripts that execute S59snmpd and check the return value.

Adding the --oknodo (-o) option to start-stop-daemon fixes this.

---
Changes in v2: none.

 package/netsnmp/S59snmpd |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
package/netsnmp/S59snmpd +0 -1
index f65317a..5df4b85 100755
@@ -29,7 +29,6 @@ TRAPDOPTS='-Lsd -p /var/run/snmptrapd.pid'
 [ -r /etc/default/snmpd ] && . /etc/default/snmpd
 
 ssd_oknodo="-o"
-ssd_oknodo=""
 
 # Cd to / before starting any daemons.
 cd /
Signature · 1 line
1.7.4.1
#4 lore raw

PATCH v2 2/3 netsnmp: allow to disable MIB loading code

In reply to Luca Ceresoli

---
Changes in v2:
- this patch is new in v2.

 package/netsnmp/Config.in  |    7 +++++++
 package/netsnmp/netsnmp.mk |    4 ++++
 2 files changed, 11 insertions(+), 0 deletions(-)
package/netsnmp/Config.in +7 -0
index 5a3e9aa..6f88b03 100644
@@ -6,3 +6,10 @@ config BR2_PACKAGE_NETSNMP
 
 	  http://net-snmp.sourceforge.net/
 
+config BR2_PACKAGE_NETSNMP_ENABLE_MIB_LOADING
+	bool "Enable MIB loading code"
+	default y
+	depends on BR2_PACKAGE_NETSNMP
+	help
+	  Include code that parses and manipulates the mib files.
+
package/netsnmp/netsnmp.mk +4 -0
index 5704327..c0e631b 100644
@@ -43,6 +43,10 @@ ifneq ($(BR2_HAVE_DOCUMENTATION),y)
 	NETSNMP_CONF_OPT += --disable-manuals
 endif
 
+ifneq ($(BR2_PACKAGE_NETSNMP_ENABLE_MIB_LOADING),y)
+	NETSNMP_CONF_OPT += --disable-mib-loading
+endif
+
 # Remove IPv6 MIBs if there's no IPv6
 ifneq ($(BR2_INET_IPV6),y)
 define NETSNMP_REMOVE_MIBS_IPV6
Signature · 1 line
1.7.4.1
#5 lore raw

PATCH v2 3/3 netsnmp: allow not to install MIB files

In reply to Luca Ceresoli

---
Changes in v2:
- MIB installation is forcibly enabled with the MIB loading code; otherwise net-snmp would loudly flood the console for missing MIBs.

 package/netsnmp/Config.in  |    8 ++++++++
 package/netsnmp/netsnmp.mk |    4 ++++
 2 files changed, 12 insertions(+), 0 deletions(-)
package/netsnmp/Config.in +8 -0
index 6f88b03..a6a768c 100644
@@ -10,6 +10,14 @@ config BR2_PACKAGE_NETSNMP_ENABLE_MIB_LOADING
 	bool "Enable MIB loading code"
 	default y
 	depends on BR2_PACKAGE_NETSNMP
+	select BR2_PACKAGE_NETSNMP_INSTALL_MIBS
 	help
 	  Include code that parses and manipulates the mib files.
 
+config BR2_PACKAGE_NETSNMP_INSTALL_MIBS
+	bool "Install MIB files on target"
+	default y
+	depends on BR2_PACKAGE_NETSNMP
+	help
+	  The net-snmp package contains a selection of MIB files.
+	  Say yes if you want those MIB files installed on the target.
package/netsnmp/netsnmp.mk +4 -0
index c0e631b..09111bf 100644
@@ -47,6 +47,10 @@ ifneq ($(BR2_PACKAGE_NETSNMP_ENABLE_MIB_LOADING),y)
 	NETSNMP_CONF_OPT += --disable-mib-loading
 endif
 
+ifneq ($(BR2_PACKAGE_NETSNMP_INSTALL_MIBS),y)
+	NETSNMP_CONF_OPT += --disable-mibs
+endif
+
 # Remove IPv6 MIBs if there's no IPv6
 ifneq ($(BR2_INET_IPV6),y)
 define NETSNMP_REMOVE_MIBS_IPV6
Signature · 1 line
1.7.4.1
#6 lore raw

PATCH v2 3/3 netsnmp: allow not to install MIB files

Luca, All,

Quoted 15 lines · On Thursday 16 June 2011 17:27:13 Luca Ceresoli wrote:

---
Changes in v2:
- MIB installation is forcibly enabled with the MIB loading code; otherwise net-snmp would loudly flood the console for missing MIBs.

 package/netsnmp/Config.in  |    8 ++++++++
 package/netsnmp/netsnmp.mk |    4 ++++
 2 files changed, 12 insertions(+), 0 deletions(-)
package/netsnmp/Config.in +0 -0
index 6f88b03..a6a768c 100644

package/netsnmp/Config.in config BR2_PACKAGE_NETSNMP_ENABLE_MIB_LOADING · line 13

Quoted 4 lines
package/netsnmp/Config.in +1 -0
@@ -10,6 +10,14 @@ config BR2_PACKAGE_NETSNMP_ENABLE_MIB_LOADING
 	bool "Enable MIB loading code"
 	default y
 	depends on BR2_PACKAGE_NETSNMP
+	select BR2_PACKAGE_NETSNMP_INSTALL_MIBS

Well, I'd do the other way around: if MIB files are to be installed, then we need to be able to load them, so I'd do either:

config BR2_PACKAGE_NETSNMP_INSTALL_MIBS
depends on BR2_PACKAGE_NETSNMP_ENABLE_MIB_LOADING

Or:

config BR2_PACKAGE_NETSNMP_INSTALL_MIBS
depends on BR2_PACKAGE_NETSNMP
select BR2_PACKAGE_NETSNMP_ENABLE_MIB_LOADING

After all, maybe the user wants to be able to load MIBs, but will provide its own set, and not the bundled ones, so we should have the possibility to enable MIB loading, and not install the bundled ones. But if we install those, we need to be able to load them.

Quoted 16 lines
package/netsnmp/Config.in +7 -0
 	help
 	  Include code that parses and manipulates the mib files.
 
+config BR2_PACKAGE_NETSNMP_INSTALL_MIBS
+	bool "Install MIB files on target"
+	default y
+	depends on BR2_PACKAGE_NETSNMP
+	help
+	  The net-snmp package contains a selection of MIB files.
+	  Say yes if you want those MIB files installed on the target.
package/netsnmp/netsnmp.mk +0 -0
index c0e631b..09111bf 100644

package/netsnmp/netsnmp.mk ifneq ($(BR2_PACKAGE_NETSNMP_ENABLE_MIB_LOADING),y) · line 56

Quoted 10 lines
package/netsnmp/netsnmp.mk +4 -0
@@ -47,6 +47,10 @@ ifneq ($(BR2_PACKAGE_NETSNMP_ENABLE_MIB_LOADING),y)
 	NETSNMP_CONF_OPT += --disable-mib-loading
 endif
 
+ifneq ($(BR2_PACKAGE_NETSNMP_INSTALL_MIBS),y)
+	NETSNMP_CONF_OPT += --disable-mibs
+endif
+
 # Remove IPv6 MIBs if there's no IPv6
 ifneq ($(BR2_INET_IPV6),y)
 define NETSNMP_REMOVE_MIBS_IPV6

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#7 lore raw

PATCH v2 3/3 netsnmp: allow not to install MIB files

Quoted 26 lines · Yann E. MORIN

Luca, All,

Quoted 15 lines · On Thursday 16 June 2011 17:27:13 Luca Ceresoli wrote:

---
Changes in v2:
- MIB installation is forcibly enabled with the MIB loading code; otherwise net-snmp would loudly flood the console for missing MIBs.

  package/netsnmp/Config.in  |    8 ++++++++
  package/netsnmp/netsnmp.mk |    4 ++++
  2 files changed, 12 insertions(+), 0 deletions(-)
package/netsnmp/Config.in +0 -0
index 6f88b03..a6a768c 100644

package/netsnmp/Config.in config BR2_PACKAGE_NETSNMP_ENABLE_MIB_LOADING · line 13

Quoted 4 lines
package/netsnmp/Config.in +1 -0
@@ -10,6 +10,14 @@ config BR2_PACKAGE_NETSNMP_ENABLE_MIB_LOADING
  	bool "Enable MIB loading code"
  	default y
  	depends on BR2_PACKAGE_NETSNMP
+	select BR2_PACKAGE_NETSNMP_INSTALL_MIBS

Well, I'd do the other way around: if MIB files are to be installed, then we need to be able to load them, so I'd do either:

Quoted 8 lines

config BR2_PACKAGE_NETSNMP_INSTALL_MIBS
depends on BR2_PACKAGE_NETSNMP_ENABLE_MIB_LOADING

Or:

config BR2_PACKAGE_NETSNMP_INSTALL_MIBS
depends on BR2_PACKAGE_NETSNMP select BR2_PACKAGE_NETSNMP_ENABLE_MIB_LOADING

The problem is net-snmp wants the MIBs installed when the MIB loading code is enabled, so this combination would be very annoying.

The use case you think about is that the user wants to provide his own MIB files. If he did, he would need to install also the base MIBs (the same installed by net-snmp), because it is impossible to load any MIB node without having the definition for the parent MIB nodes.

So I think this use case would be so limited that it's not worth supporting it. At least not until anybody has this need.

So I think Gustavo's proposal is best: one option only to either enable both features or disable both.

If you agree, I'll prepare a new patchset.

Luca

#8 lore raw

PATCH v2 3/3 netsnmp: allow not to install MIB files

Luca, Gustavo, All,

Quoted 3 lines · On Wednesday 31 August 2011 14:48:16 Luca Ceresoli wrote:
Quoted 2 lines · Yann E. MORIN

Well, I'd do the other way around: if MIB files are to be installed, then we need to be able to load them, so I'd do either:

[--SNIP--]

Quoted 2 lines

The problem is net-snmp wants the MIBs installed when the MIB loading code is enabled, so this combination would be very annoying.

Ah, so this is a limitation of the net-snmp build system... OK.

Quoted 4 lines

The use case you think about is that the user wants to provide his own MIB files. If he did, he would need to install also the base MIBs (the same installed by net-snmp), because it is impossible to load any MIB node without having the definition for the parent MIB nodes.

Yes, but I was merely thinking about using a whole set of altenative MIBs.

Quoted 2 lines

So I think this use case would be so limited that it's not worth supporting it. At least not until anybody has this need.

Granted.

Quoted 3 lines

So I think Gustavo's proposal is best: one option only to either enable both features or disable both.
If you agree, I'll prepare a new patchset.

Yes, that's good for me. I was just saying that, in my point of view, the dependency/select was in reverse order from a purely-logical point of view. But your answer clarifies this, and Gustavoz' suggestion is even simpler, and as you said, the alternative would be very seldom used, if at all, so a single option perfectly makes sense. The user would then be free to provide/overide its own set with the custom script that is run just prior to building the images.

Thank you!

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#9 lore raw

v2 cover netsnmp improvements

In reply to Luca Ceresoli
Quoted 14 lines · Luca Ceresoli

Hi,

please ignore the two patches I sent yesterday for netsnmp. Patch 2 introduced
an annoying series of warnings, as net-snmp requires the MIB files to be
installed if the MIB loading code is enabled.

The present patch series addresses this issue correctly, allowing in addition
to disable the MIB loading code.

Patch 1 is unchanged.

Quoted 7 lines

Luca

Luca Ceresoli (3):
netsnmp: fix stop and restart actions in init script
netsnmp: allow to disable MIB loading code
netsnmp: allow not to install MIB files

ACK in principle.
However is there any useful scenario where MIB loading code is disabled and we want to install MIB files?
I think both options could be condensed into a single one if not. Regards.

#10 lore raw

PATCH v3 1/2 netsnmp: fix stop and restart actions in init script

In reply to Luca Ceresoli

/etc/init.d/S59snmpd stop (and restart) currently fail if either snmpd or snmptrapd are not running.
This is because start-stop-daemon -K returns nonzero if the process to be killed is not running, and this causes the whole script to fail because it runs under 'set -e'.

This may not be noticed if only the last start-stop-daemon fails, but this is in general wrong. It would also cause a failure in other scripts that execute S59snmpd and check the return value.

Adding the --oknodo (-o) option to start-stop-daemon fixes this.

---
Changes in v2: none.
Changes in v3: none.

 package/netsnmp/S59snmpd |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
package/netsnmp/S59snmpd +0 -1
index f65317a..5df4b85 100755
@@ -29,7 +29,6 @@ TRAPDOPTS='-Lsd -p /var/run/snmptrapd.pid'
 [ -r /etc/default/snmpd ] && . /etc/default/snmpd
 
 ssd_oknodo="-o"
-ssd_oknodo=""
 
 # Cd to / before starting any daemons.
 cd /
Signature · 1 line
1.7.4.1
#11 lore raw

PATCH v3 2/2 netsnmp: allow to disable MIB files installation and MIB loading code

---
Changes in v2:
- MIB installation is forcibly enabled with the MIB loading code; otherwise net-snmp would loudly flood the console for missing MIBs.

Changes in v3:
- Join in a unique option the choice of not installing MIB files and not enabling MIB loading code. The mixed cases were either problematical or unlikely to be useful. This is per the discussion in
http://lists.busybox.net/pipermail/buildroot/2011-August/045256.html

 package/netsnmp/Config.in  |    8 ++++++++
 package/netsnmp/netsnmp.mk |    5 +++++
 2 files changed, 13 insertions(+), 0 deletions(-)
package/netsnmp/Config.in +8 -0
index 5a3e9aa..431be2d 100644
@@ -6,3 +6,11 @@ config BR2_PACKAGE_NETSNMP
 
 	  http://net-snmp.sourceforge.net/
 
+config BR2_PACKAGE_NETSNMP_ENABLE_MIBS
+	bool "Install MIB files on target and enable MIB loading code"
+	default y
+	depends on BR2_PACKAGE_NETSNMP
+	help
+	  The net-snmp package contains a selection of MIB files.
+	  Say yes if you want those MIB files installed on the target
+	  and enable the code that parses the MIB files.
package/netsnmp/netsnmp.mk +5 -0
index 5704327..cef6583 100644
@@ -43,6 +43,11 @@ ifneq ($(BR2_HAVE_DOCUMENTATION),y)
 	NETSNMP_CONF_OPT += --disable-manuals
 endif
 
+ifneq ($(BR2_PACKAGE_NETSNMP_ENABLE_MIBS),y)
+	NETSNMP_CONF_OPT += --disable-mib-loading
+	NETSNMP_CONF_OPT += --disable-mibs
+endif
+
 # Remove IPv6 MIBs if there's no IPv6
 ifneq ($(BR2_INET_IPV6),y)
 define NETSNMP_REMOVE_MIBS_IPV6
Signature · 1 line
1.7.4.1
#12 lore raw

PATCH v3 2/2 netsnmp: allow to disable MIB files installation and MIB loading code

Quoted 1 line · On Wednesday 31 August 2011 21:46:39 Luca Ceresoli wrote:
Quoted 48 lines

---
Changes in v2:
- MIB installation is forcibly enabled with the MIB loading code; otherwise net-snmp would loudly flood the console for missing MIBs.

Changes in v3:
- Join in a unique option the choice of not installing MIB files and not enabling MIB loading code. The mixed cases were either problematical or unlikely to be useful. This is per the discussion in
http://lists.busybox.net/pipermail/buildroot/2011-August/045256.html

 package/netsnmp/Config.in  |    8 ++++++++
 package/netsnmp/netsnmp.mk |    5 +++++
 2 files changed, 13 insertions(+), 0 deletions(-)
package/netsnmp/Config.in +8 -0
index 5a3e9aa..431be2d 100644
@@ -6,3 +6,11 @@ config BR2_PACKAGE_NETSNMP
 
 	  http://net-snmp.sourceforge.net/
 
+config BR2_PACKAGE_NETSNMP_ENABLE_MIBS
+	bool "Install MIB files on target and enable MIB loading code"
+	default y
+	depends on BR2_PACKAGE_NETSNMP
+	help
+	  The net-snmp package contains a selection of MIB files.
+	  Say yes if you want those MIB files installed on the target
+	  and enable the code that parses the MIB files.
package/netsnmp/netsnmp.mk +5 -0
index 5704327..cef6583 100644
@@ -43,6 +43,11 @@ ifneq ($(BR2_HAVE_DOCUMENTATION),y)
 	NETSNMP_CONF_OPT += --disable-manuals
 endif
 
+ifneq ($(BR2_PACKAGE_NETSNMP_ENABLE_MIBS),y)
+	NETSNMP_CONF_OPT += --disable-mib-loading
+	NETSNMP_CONF_OPT += --disable-mibs
+endif
+
 # Remove IPv6 MIBs if there's no IPv6
 ifneq ($(BR2_INET_IPV6),y)
 define NETSNMP_REMOVE_MIBS_IPV6
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#14 lore raw

PATCH v3 1/2 netsnmp: fix stop and restart actions in init script

In reply to Luca Ceresoli
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Luca" == Luca Ceresoli <[email protected]> writes:

Luca> /etc/init.d/S59snmpd stop (and restart) currently fail if either Luca> snmpd or snmptrapd are not running. This is because Luca> start-stop-daemon -K returns nonzero if the process to be killed Luca> is not running, and this causes the whole script to fail because Luca> it runs under 'set -e'.

Committed. thanks.

Signature · 1 line
Bye, Peter Korsgaard