Difference between revisions of "Library layering"

From Net-SNMP Wiki
Jump to: navigation, search
(Problem)
(Proposal)
Line 69: Line 69:
  
 
|- align=left bgcolor=pink
 
|- align=left bgcolor=pink
|| introduce callbacks for the other dependencies || rstory has offered to come up with a patch || TODO
+
|| introduce callbacks for the agent->helpers dependencies || rstory has offered to come up with a patch || TODO
  
 
|- align=left bgcolor=pink
 
|- align=left bgcolor=pink
 
|| rework Makefiles/configure to fullfil internal and external library dependencies correctly (see below) || tanders || TODO
 
|| rework Makefiles/configure to fullfil internal and external library dependencies correctly (see below) || tanders || TODO
 +
 +
|}
 +
 +
==Dependency cleanup==
 +
 +
Here are the details of what library linking dependencies need to be cleaned up.
 +
 +
{| width=100%
 +
|- align=center bgcolor=lightblue
 +
| shared object/library/binary || currently linked against || dependencies to be added/removed || Comment
 +
 +
|- align=left bgcolor=lightgreen
 +
|| libnetsnmp.so || -lcrypto || -lcrypto || ok
 +
 +
|- align=left bgcolor=pink
 +
|| libnetsnmpagent.so || - || -lnetsnmp -lperl || TODO
 +
 +
|- align=left bgcolor=pink
 +
|| libnetsnmphelpers.so || - || -lnetsnmpagent -lnetsnmp || TODO
 +
 +
|- align=left bgcolor=pink
 +
|| libnetsnmpmibs.so || - || -lnetsnmphelpers -lnetsnmpagent -lnetsnmp -ldl -lrpm -lrpmio -lpopt  -lz ... || TODO
 +
 +
|- align=left bgcolor=pink
 +
|| libnetsnmptrapd.so || - || -lnetsnmpmibs -lnetsnmp || TODO
 +
 +
|- align=left bgcolor=lightgreen
 +
|| Perl SNMP/SNMP.so || -lnetsnmp -lcrypto || - || ok
 +
 +
|- align=left bgcolor=lightgreen
 +
|| Perl NetSNMP/ASN/ASN.so || -lnetsnmp -lcrypto || - || ok
 +
 +
|- align=left bgcolor=pink
 +
|| Perl NetSNMP/OID/OID.so || || || TODO
 +
 +
|- align=left bgcolor=pink
 +
|| Perl NetSNMP/agent/agent.so || '''almost everything''' || remove: most external references ? (dependencies are in libnetsnmpmibs instead) || TODO
 +
 +
|- align=left bgcolor=pink
 +
|| Perl NetSNMP/agent/default_store/default_store.so || -lnetsnmp -lcrypto || remove: both ? || TODO
 +
 +
|- align=left bgcolor=pink
 +
|| Perl NetSNMP/TrapReceiver/TrapReceiver.so || - || -lnetsnmptrapd -lnetsnmpagent -lnetsnmp || TODO
 +
 +
|- align=left bgcolor=pink
 +
|| Perl NetSNMP/default_store/default_store.so || -lnetsnmp -lcrypto || remove: both ? || TODO
 +
 +
|- align=left bgcolor=lightgreen
 +
|| Python netsnmp/client_intf.so || -lnetsnmp -lcrypto || - || ok
 +
 +
|- align=left bgcolor=pink
 +
|| agent/snmpd || '''almost everything''' || remove: most external references ? (dependencies are in libnetsnmpmibs instead) || TODO
 +
 +
|- align=left bgcolor=pink
 +
|| apps/snmptrapd || '''almost everything''' || remove: most external references ? (dependencies are in libnetsnmpmibs instead) || TODO
 +
 +
|- align=left bgcolor=pink
 +
|| apps/snmp{get,set,walk,...} || '''almost everything''' || remove: most external references ? (not needed at all) || TODO
  
 
|}
 
|}

Revision as of 14:48, 15 January 2007

Problem

The three libraries libnetsnmpmibs, libnetsnmphelpers and libnetsnmpagent have circular dependencies instead of what should be a clean mibs -> helpers -> agent -> main library dependency chain:

  • libnetsnmpmibs depends on libnetsnmphelpers
  • both of these depend on libnetsnmpagent
  • all 3 of these depend on libnetsnmp

There are only a few problematic calls/functions that violate this dependency chain:

Critical dependency Symbol/function implementation (under agent/) caller(s) (under agent/) Comment
agent -> mibs make_tempfile mibgroup/util_funcs.c mibgroup/utilities/execute.c:run_shell_command() fixed in 5.4+ by introducing netsnmp_mktemp
agent -> helpers netsnmp_init_helpers helpers/all_helpers.c snmp_vars.c:init_agent() The most difficult one?
agent -> helpers netsnmp_register_null helpers/null.c agent_registry.c:setup_tree()  ?
agent -> helpers netsnmp_register_null_context helpers/null.c agent_registry.c:netsnmp_subtree_load()  ?
agent -> helpers netsnmp_register_old_api helpers/old_api.c agent_registry.c:register_mib_context()  ?
agent -> helpers netsnmp_bulk_to_next_fix_requests helpers/bulk_to_next.c mibgroup/agentx/master.c:agentx_got_response()  ?
agent -> helpers netsnmp_get_bulk_to_next_handler helpers/bulk_to_next.c agent_handler.c:netsnmp_register_handler()  ?
other strange dependencies
libnetsnmptrapd -> snmptrapd extern int dropauth apps/snmptrapd.c apps/snmptrapd_handlers.c:print_handler()  ?
libnetsnmptrapd -> snmptrapd extern int SyslogTrap apps/snmptrapd.c apps/snmptrapd_handlers.c:syslog_handler()  ?
libnetsnmptrapd -> snmptrapd event_input apps/snmptrapd.c apps/snmptrapd_handlers.c:event_handler()  ?

Discussion

The brute-force approach is to move all three mibs/helpers/agent libraries into one huge libagent library again. Downside: even a minimal subagent needs to link in all the mib code which it shouldn't need. That's like it effectively already is today, but it lowers the chance to ever sort it out.

The clever way would be to sensibly restructure the library while maintaining backward-compatibility and not causing too much overhead for agent developers. This needs to be investigated and discussed. Not sure if it's possible at all, though.

See the references below for the full discussion and details to date.

Proposal

what? who? status?
rework Makefiles to build libnetsnmp, libnetsnmpagent, libnetsnmphelpers and libnetsnmpmibs in that order tanders done for 5.4+
duplicate libnetsnmpmibs' make_tempfile as netsnmp_mktemp in libnetsnmp (now fixed in 5.4+) tanders done for 5.4+
introduce callbacks for the agent->helpers dependencies rstory has offered to come up with a patch TODO
rework Makefiles/configure to fullfil internal and external library dependencies correctly (see below) tanders TODO

Dependency cleanup

Here are the details of what library linking dependencies need to be cleaned up.

shared object/library/binary currently linked against dependencies to be added/removed Comment
libnetsnmp.so -lcrypto -lcrypto ok
libnetsnmpagent.so - -lnetsnmp -lperl TODO
libnetsnmphelpers.so - -lnetsnmpagent -lnetsnmp TODO
libnetsnmpmibs.so - -lnetsnmphelpers -lnetsnmpagent -lnetsnmp -ldl -lrpm -lrpmio -lpopt -lz ... TODO
libnetsnmptrapd.so - -lnetsnmpmibs -lnetsnmp TODO
Perl SNMP/SNMP.so -lnetsnmp -lcrypto - ok
Perl NetSNMP/ASN/ASN.so -lnetsnmp -lcrypto - ok
Perl NetSNMP/OID/OID.so TODO
Perl NetSNMP/agent/agent.so almost everything remove: most external references ? (dependencies are in libnetsnmpmibs instead) TODO
Perl NetSNMP/agent/default_store/default_store.so -lnetsnmp -lcrypto remove: both ? TODO
Perl NetSNMP/TrapReceiver/TrapReceiver.so - -lnetsnmptrapd -lnetsnmpagent -lnetsnmp TODO
Perl NetSNMP/default_store/default_store.so -lnetsnmp -lcrypto remove: both ? TODO
Python netsnmp/client_intf.so -lnetsnmp -lcrypto - ok
agent/snmpd almost everything remove: most external references ? (dependencies are in libnetsnmpmibs instead) TODO
apps/snmptrapd almost everything remove: most external references ? (dependencies are in libnetsnmpmibs instead) TODO
apps/snmp{get,set,walk,...} almost everything remove: most external references ? (not needed at all) TODO

References