On ons, 2007-01-17 at 11:20 -0800, Kapil Sharma wrote:
> I am looking to using net-snmp in an embedded device, and the limits
> available to me, though not extremely rigid, are fairly tight.
> Typically, I would be looking to have all snmp related stuff within
> 500kb.
> 
> Therefore, I am working with 5.2.1 instead of 5.4 because it is
> substantially smaller, and most likely I'd not need newer features.
> 
> I don't need any application, other than snmpd. (I load my .so file by
> calling dlmod from the conf file).
> 
> The files generated after doing a compile and make/install are
> libnetsnmphelpers.so, libnetsnmpagent.so, netsnmpmibs.so,
> netsnmptrapd.so and libnetsnmp.so.
> 
> Would I need all these files on my target (with the correct
> LD_LIBRARY_PATH set) to be able to run the agent?
> 
> My primary use of net-snmp would be for SNMPv1/v2c only.
> 
> I don't even need mib2c because I create pdu "by hand" instead of
> auto-generated code.
> 
> I did a configure with the following options:
> ./configure --disable-debugging --enable-mini-agent
> --with-transports=UDP --without-kmem-usage --disable-mib-loading
> --disable-applications --disable-manuals --disable-scripts
> 
> This led to the following .so files:
> agent/helpers/.libs/libnetsnmphelpers.so.5.2.1    300103 bytes
> agent/.libs/libnetsnmpagent.so.5.2.1    248522 bytes
> agent/.libs/netsnmpmibs.so.5.2.1    170280 bytes
> apps/.libs/libnetsnmptrapd.5.2.1    81850 bytes
> snmplib/.libs/libnetsnmp.so.5.2.1    811169 bytes
> 
> Looking at the configure-summary file after running configure:
> 
>   SNMP Versions Supported:    1 2c 3
>   Net-SNMP Version:           5.2.1.2
>   Building for:               linux
>   Network transport support:  Callback Unix TCP UDP
>   SNMPv3 Security Modules:    usm
>   Agent MIB code:             snmpv3mibs mibII/snmp_mib
> mibII/system_mib mibII/sysORTable mibII/vacm_vars utilities/execute
>   SNMP Perl modules:          disabled
>   Embedded perl support:      disabled
>   Authentication support:     MD5
>   Encryption support:
> 
> Though I chose default SNMPv2 support, it still is going to compile in
> SNMPv3 support.
> 
> Is there some way I can keep SNMPv3 part from being compiled into
> the .so files? 
> 
> I believe one possible way is to keep out files like snmpusm.c, vacm.c
> and snmpv3.c out from the agent/Makefile. But since so many other
> files reference those functions, it would get pretty painful manually
> removing those references from those files.

I sure wish it was a way to configure with --disable-snmpv3 but sadly
there isn't and sadly it is hard to add it.

> Is there an easier and cleaner way of reducing the foorprint of the
> net-snmp agent running on an embedded platform?

I would do as follows - starting with your config i get:

267439 libnetsnmpagent.so.15.0.0
384879 libnetsnmphelpers.so.15.0.0
176661 libnetsnmpmibs.so.15.0.0
923210 libnetsnmp.so.15.0.0

The first step is to not build with debug information and optimize for
size (add --with-cflags=-Os)

102936 libnetsnmpagent.so.15.0.0
94980 libnetsnmphelpers.so.15.0.0
66539 libnetsnmpmibs.so.15.0.0
303307 libnetsnmp.so.15.0.0

Next step is to start turning off things.

--without-openssl gives me the following but shouldn't affect you as you
doesn't seem to have it in the first place:

102936 libnetsnmpagent.so.15.0.0
94980 libnetsnmphelpers.so.15.0.0
66539 libnetsnmpmibs.so.15.0.0
298566 libnetsnmp.so.15.0.0

Changing --with-transports=UDP to
--without-out-transports=TCP,Unix,Callback gives me:

102442 libnetsnmpagent.so.15.0.0
94980 libnetsnmphelpers.so.15.0.0
66535 libnetsnmpmibs.so.15.0.0
286262 libnetsnmp.so.15.0.0

Since you weren't interested in snmpv3 I suppose you won't mind if the
snmpv3mib is removed, so let's add --with-out-mib-modules=snmpv3mibs,
this gives me:

102293 libnetsnmpagent.so.15.0.0
94980 libnetsnmphelpers.so.15.0.0
49989 libnetsnmpmibs.so.15.0.0
286262 libnetsnmp.so.15.0.0

This is as far as I get without changing the code.

The command used at this point is:

configure --disable-debugging --enable-mini-agent --without-kmem-usage
--disable-mib-loading --disable-applications --disable-manuals
--disable-scripts --with-cflags=-Os --without-openssl
--with-out-transports=TCP,Unix,Callback
--with-out-mib-modules=snmpv3mibs

If I apply the attached patch I can further remove parts of the
authentication support and the MD5 support (--disable-md5
--with-out-mib-modules=mibII/vacm_vars) and that gives:

87605 libnetsnmpagent.so.15.0.0
94980 libnetsnmphelpers.so.15.0.0
31448 libnetsnmpmibs.so.15.0.0
279204 libnetsnmp.so.15.0.0

Note that the patch in and by itself is sound, it adds a PRE_READ_CONFIG
callback and uses that to do vacm reinitialization, but I am uncertain
about the effects of using the change in the way indicated here.


> A somewhat related question - is there a configure option that lets me
> build net-snmp for mips-linux? I tried but ran into some problems with
> perl.

Do you need perl? If not, could you try to add --disable-perl and see if
that is enough for you?

> Has someone done that before? As far as I remember, the documentation
> doesn't mention mips-linux as one of the supported platforms.

That only means nobody have tried - please report back of your success
or failure.

/MF
Index: agent/agent_read_config.c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/agent/agent_read_config.c,v
retrieving revision 5.14
diff -u -r5.14 agent_read_config.c
--- agent/agent_read_config.c	15 Sep 2006 00:48:39 -0000	5.14
+++ agent/agent_read_config.c	18 Jan 2007 07:49:46 -0000
@@ -273,7 +273,6 @@
     snmp_call_callbacks(SNMP_CALLBACK_APPLICATION,
                         SNMPD_CALLBACK_PRE_UPDATE_CONFIG, NULL);
     free_config();
-    vacm_standard_views(0,0,NULL,NULL);
     read_configs();
 }
 
Index: agent/mibgroup/mibII/vacm_conf.c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/agent/mibgroup/mibII/vacm_conf.c,v
retrieving revision 5.38
diff -u -r5.38 vacm_conf.c
--- agent/mibgroup/mibII/vacm_conf.c	15 Sep 2006 00:48:40 -0000	5.38
+++ agent/mibgroup/mibII/vacm_conf.c	18 Jan 2007 07:49:55 -0000
@@ -119,7 +119,7 @@
      * Define standard views "_all_" and "_none_"
      */
     snmp_register_callback(SNMP_CALLBACK_LIBRARY,
-                           SNMP_CALLBACK_POST_PREMIB_READ_CONFIG,
+                           SNMP_CALLBACK_PRE_READ_CONFIG,
                            vacm_standard_views, NULL);
     snmp_register_callback(SNMP_CALLBACK_LIBRARY,
                            SNMP_CALLBACK_POST_READ_CONFIG,
Index: include/net-snmp/library/callback.h
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/include/net-snmp/library/callback.h,v
retrieving revision 5.4
diff -u -r5.4 callback.h
--- include/net-snmp/library/callback.h	21 Apr 2005 14:26:10 -0000	5.4
+++ include/net-snmp/library/callback.h	18 Jan 2007 07:49:58 -0000
@@ -27,6 +27,8 @@
 #define SNMP_CALLBACK_POST_PREMIB_READ_CONFIG	3
 #define SNMP_CALLBACK_LOGGING			4
 #define SNMP_CALLBACK_SESSION_INIT		5
+#define SNMP_CALLBACK_PRE_READ_CONFIG	        7
+#define SNMP_CALLBACK_PRE_PREMIB_READ_CONFIG	8
 
 
     /*
Index: snmplib/read_config.c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/snmplib/read_config.c,v
retrieving revision 5.48
diff -u -r5.48 read_config.c
--- snmplib/read_config.c	2 Jan 2007 19:52:25 -0000	5.48
+++ snmplib/read_config.c	18 Jan 2007 07:50:03 -0000
@@ -840,6 +840,9 @@
     char *optional_config = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
 					       NETSNMP_DS_LIB_OPTIONALCONFIG);
 
+    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY,
+                        SNMP_CALLBACK_PRE_READ_CONFIG, NULL);
+
     DEBUGMSGTL(("read_config", "reading normal configuration tokens\n"));
 
     if ((NULL != optional_config) && (*optional_config == '-')) {
@@ -869,6 +872,9 @@
     char *optional_config = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
 					       NETSNMP_DS_LIB_OPTIONALCONFIG);
 
+    snmp_call_callbacks(SNMP_CALLBACK_LIBRARY,
+                        SNMP_CALLBACK_PRE_PREMIB_READ_CONFIG, NULL);
+
     DEBUGMSGTL(("read_config", "reading premib configuration tokens\n"));
 
     if ((NULL != optional_config) && (*optional_config == '-')) {
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to