[lwip-users] Lwip SNMP support: adding LWIP_IPSTACK_MIB2 Compile-Time configuration

10 views
Skip to first unread message

Yigal Hochberg

unread,
Feb 15, 2010, 3:07:45 PM2/15/10
to Mailing list for lwIP users

Hello Simon,

Thank you for your response.

I would like to clarify the goal and purpose of my thoughts. I will be
happy to to make the code change in lwip if I can get a cvs permission
or if I can work with someone who can commit changes.

My suggestion is to separate between a specific SNMP-Agent and the
access to Ipstack MIB2 information maintained by the lwip Ipstack.

This is kind to separation and functional breakdown already exists
very nicely in the lwip implementation.

The suggestion:

Adding Compile-Time configuration for the support Ipstack MIB2 access
functions and structures.

(1) In op.h

Add Compile-Time configuration for Ipstack MIB2 access functions

Something like this:

example:

/**
* LWIP_SNMP==1: Turn on SNMP module. UDP must be available for SNMP
* transport.
*/
#ifndef LWIP_SNMP
#define LWIP_SNMP 0
#endif

/**
* \def LWIP_IPSTACK_MIB2==1: Compile-Time configuration to turn on
* SNMP Ipstack MIB-2 Access functions (counters and internal tables)
*
* This Compile-Time configuration maybe independent of LWIP_SNMP
* above.
*/
#ifndef LWIP_IPSTACK_MIB2
#define LWIP_IPSTACK_MIB2 0
#endif

(2) In all relevant Ipstack mib-2 were LWIP_SNMP is used
add

#if defined(LWIP_SNMP) || defined(LWIP_IPSTACK_MIB2)
... some code..
#endif

example:

/**
* Bring an interface up, available for processing
* traffic.
*
* @note: Enabling DHCP on a down interface will make it come
* up once configured.
*
* @see dhcp_start()
*/
void netif_set_up(struct netif *netif)
{
if ( !(netif->flags & NETIF_FLAG_UP )) {
netif->flags |= NETIF_FLAG_UP;

#if defined(LWIP_SNMP) || defined(LWIP_IPSTACK_MIB2)
snmp_get_sysuptime(&netif->ts);
#endif /* LWIP_SNMP || LWIP_IPSTACK_MIB2 */

--
- Yigal

Yigal Hochberg wrote:

> > Unfortunately no response from from Christiaan Simons
>
> I didn't hear (or see an email) from Christiaan for nearly 3 years
> now, he might well not be working at axon any more by now...
>
> > I would appreciate if anyone can "connect" me to the SNMP of Lwip.
>
> I'm not sure I understand you here...
>
> I guess that your agent is not open source or for free. Personally,
> I'm against changing the lwIP code to adapt to 3rd party closed source
> software - if I understood you correctly, this is what you want. lwIP
> already has an snmp agent and if you'd like to improve it to support
> snmp v2(c) or v3, that's of course welcome!
>
> Simon
>


_______________________________________________
lwip-users mailing list
lwip-...@nongnu.org
http://lists.nongnu.org/mailman/listinfo/lwip-users

Kieran Mansley

unread,
Feb 16, 2010, 4:08:49 AM2/16/10
to Mailing list for lwIP users
On Mon, 2010-02-15 at 15:07 -0500, Yigal Hochberg wrote:
> My suggestion is to separate between a specific SNMP-Agent and the
> access to Ipstack MIB2 information maintained by the lwip Ipstack.

I'm no expert on SNMP, but I don't quite follow what this change is for.
Can you give some justification for it? A more comprehensive patch
would help to illustrate what the LWIP_IPSTACK_MIB2 option would do. In
the patch fragment you included it's just used in the same way and at
the same time as LWIP_SNMP, so seems to add nothing.

Simon is right that the best way to contribute to lwIP is to improve the
open source distribution of it and help everyone benefit. However I
understand that this isn't always possible, and lwIP is deliberately
licensed using a BSD license to allow use in commercial and closed
source products. With that in mind I've got no objection in principal
to a change that makes such integration better and so improves the ways
in which lwIP can be used, but I'd want to understand what was being
proposed before making any such change.

Thanks

Kieran

Yigal Hochberg

unread,
Feb 16, 2010, 8:19:01 AM2/16/10
to Mailing list for lwIP users
Kieran,

Thanks for the reply.

There are two separate parts in the current lwip snmp:

1. snmp agent protocol (BER functions + parsing snmp messages and responding to them).
2. access to ipstack mib-2 information. (how to get mib-2 related information maintined by the ipstack).

Currently LWIP_SNMP contorls all code generated related to (1) and (2).
I would like ot make each part independet, controlled by a spearate compile-time config.

The chnage is the correct design and breakdown. It has nothing to do with the
discussion of open-source or not.

The change is mechanical and should not uase any problem.
If you explain to me the development model adn how to actually
give someone a diff, I can do this work.

Thanks,

Yigal
--
Yigal

Kieran Mansley

unread,
Feb 16, 2010, 8:27:43 AM2/16/10
to Mailing list for lwIP users
On Tue, 2010-02-16 at 08:19 -0500, Yigal Hochberg wrote:
> The change is mechanical and should not uase any problem.
> If you explain to me the development model adn how to actually
> give someone a diff, I can do this work.

Check out current CVS head, make your changes, prepare a diff that
contains your changes (ideally a unified diff so easier to read) and add
this as a patch to the lwIP's patch tracker. This should then get
reviewed and applied if appropriate.

http://lwip.wikia.com/wiki/Contributing_to_lwIP

Kieran Mansley

unread,
Feb 16, 2010, 8:43:19 AM2/16/10
to Mailing list for lwIP users
On Tue, 2010-02-16 at 08:19 -0500, Yigal Hochberg wrote:
>
> 1. snmp agent protocol (BER functions + parsing snmp messages and
> responding
> to them).
> 2. access to ipstack mib-2 information. (how to get mib-2 related
> information maintined by the ipstack).
>
> Currently LWIP_SNMP contorls all code generated related to (1) and
> (2).
> I would like ot make each part independet, controlled by a spearate
> compile-time config.

I'm still not quite sure why you would ever need

#if defined(LWIP_SNMP) || defined(LWIP_SNMP_MIB2)

as in your previous example. Surely code in lwIP will either be part of
the SNMP agent protocol (and so controlled by LWIP_SNMP) or be the MIB-2
interface (and so controlled by LWIP_SNMP_MIB2) but not both (which
would require LWIP_SNMP || LWIP_SNMP_MIB2).

I assume it's the case that it doesn't make much sense to have LWIP_SNMP
defined without LWIP_SNMP_MIB2. If that's right, we should have a
compile time check that this dependency is met as with some of the other
options in src/core/init.c

Mike Kleshov

unread,
Feb 16, 2010, 10:33:18 AM2/16/10
to Mailing list for lwIP users
I'd like to share my experience with SNMP too.
I had to add SNMP support to my application. I looked at lwip's SNMP agent and decided that it was too big and complicated for me (I didn't need all the features.) So I decided to create my own SNMP agent. The result is a small (650 lines) and simple SNMPv1 agent with no write support. I didn't need MIB parsing either, so OIDs were hard-coded in binary representation. I didn't need any of the MIB-2 data either. So I guess it is possible to have an SNMP agent and not have MIB-2 info collection.

- mike

gold...@gmx.de

unread,
Feb 16, 2010, 10:40:43 AM2/16/10
to Mailing list for lwIP users
Kieran Mansley wrote:
> I'm still not quite sure why you would ever need
>
> #if defined(LWIP_SNMP) || defined(LWIP_SNMP_MIB2)
>
> as in your previous example. Surely code in lwIP will either be part of
> the SNMP agent protocol (and so controlled by LWIP_SNMP) or be the MIB-2
> interface (and so controlled by LWIP_SNMP_MIB2) but not both (which
> would require LWIP_SNMP || LWIP_SNMP_MIB2).
>
> I assume it's the case that it doesn't make much sense to have LWIP_SNMP
> defined without LWIP_SNMP_MIB2. If that's right, we should have a
> compile time check that this dependency is met as with some of the other
> options in src/core/init.c
>
Yep, the places where SNMP functions for mib2 are called should only
need LWIP_SNMP_MIB2 (or whatever name that define has) and check add the
check in init.c.
Thinking about it, the change is rather trivial: the guards in snmp.h
and netif.h would have to be changed from LWIP_SNMP to LWIP_MIB2 and the
usages of LWIP_SNMP/snmp_get_sysuptime() in netif.c would have to be
fixed and that should be it.

Simon

Kieran Mansley

unread,
Feb 16, 2010, 10:46:07 AM2/16/10
to Mailing list for lwIP users
On Tue, 2010-02-16 at 18:33 +0300, Mike Kleshov wrote:
> I'd like to share my experience with SNMP too.
> I had to add SNMP support to my application. I looked at lwip's SNMP
> agent and decided that it was too big and complicated for me (I didn't
> need all the features.) So I decided to create my own SNMP agent. The
> result is a small (650 lines) and simple SNMPv1 agent with no write
> support. I didn't need MIB parsing either, so OIDs were hard-coded in
> binary representation.

OK, so it sounds like this idea of replacing lwIP's SNMP with a
roll-your-own version is something that we should do our best to
support.

> I didn't need any of the MIB-2 data either. So I guess it is possible


> to have an SNMP agent and not have MIB-2 info collection.

I meant "is MIB-2 required for the agent currently in lwIP", not "is
MIB-2 required for all any SNMP agent".

In general, if the SNMP agent already in lwIP is considered too
heavyweight, is there any interest in cutting it down, either by adding
a complete replacement along the lines of your version, or by making
more of the features in the lwIP agent compile-time configurable? I've
no idea how feasible either of those are, but wondered if it warrants a
task opening in savannah.

gold...@gmx.de

unread,
Feb 16, 2010, 10:52:07 AM2/16/10
to Mailing list for lwIP users
Mike Kleshov wrote:
> I'd like to share my experience with SNMP too.
> I had to add SNMP support to my application. I looked at lwip's SNMP
> agent and decided that it was too big and complicated for me (I didn't
> need all the features.) So I decided to create my own SNMP agent. The
> result is a small (650 lines) and simple SNMPv1 agent with no write
> support. I didn't need MIB parsing either, so OIDs were hard-coded in
> binary representation.
The problem of lwIP's SNMP agent is that it seems to be written for
external mibs that get/set their data asynchronously. The second
"feature" many people wouldn't need is the ability to add or remove tree
entries at runtime. The agent could be a lot smaller if these two
features wouldn't be included!

> I didn't need any of the MIB-2 data either. So I guess it is possible
> to have an SNMP agent and not have MIB-2 info collection.
Of course it is, but someone has to do the work (change the code to
support it). Unless that's done, adding a compile-time check that for
LWIP_SNMP (use lwIP's agent), LWIP_MIB2 is necessary is a good thing to do.

Simon

Yigal Hochberg

unread,
Feb 16, 2010, 12:28:33 PM2/16/10
to Mailing list for lwIP users
mib-2 includes the system-group as well. any agent will want it.
(btw: rfc1213 is gone).

the scope of discussion are mib-2 objects related to the ipstack.
therefore i suggested the flag LWIP_IPSTACK_MIB2
this scopes the following mibs: if-mib, ip-mib, udp-mib, tcp-mib and forward-mib

i can add this flag across the code.

thanks,

yigal
--
Yigal

gold...@gmx.de

unread,
Feb 16, 2010, 1:11:51 PM2/16/10
to lwip-...@nongnu.org
Yigal Hochberg wrote:
> mib-2 includes the system-group as well. any agent will want it.
> (btw: rfc1213 is gone).
>
> the scope of discussion are mib-2 objects related to the ipstack.
> therefore i suggested the flag LWIP_IPSTACK_MIB2
> this scopes the following mibs: if-mib, ip-mib, udp-mib, tcp-mib and
> forward-mib
>
> i can add this flag across the code.
Did you read my previous mail? Thanks :-)

If not, the contents was this:

> Thinking about it, the change is rather trivial: the guards in snmp.h
> and netif.h would have to be changed from LWIP_SNMP to LWIP_MIB2 and the
> usages of LWIP_SNMP/snmp_get_sysuptime() in netif.c would have to be
> fixed and that should be it.

I don't think we need to add a new flag anywhere but in snmp.h. And I would suggest a name not including "IPSTACK". LWIP_MIB2 should be enough.

Reply all
Reply to author
Forward
0 new messages