Difference between revisions of "Library layering"

From Net-SNMP Wiki
Jump to: navigation, search
(Problem)
(Remove non-problems)
Line 15: Line 15:
 
|- align=left bgcolor=pink
 
|- align=left bgcolor=pink
 
|| agent -> mibs || make_tempfile || mibgroup/util_funcs.c || mibgroup/utilities/execute.c:run_shell_command() || Move to agent lib? Duplicate?
 
|| agent -> mibs || make_tempfile || mibgroup/util_funcs.c || mibgroup/utilities/execute.c:run_shell_command() || Move to agent lib? Duplicate?
 
|- align=left bgcolor=pink
 
|| agent -> mibs || init_{module} || mibgroup/* + mibgroup/mib_modules_inits.h || mib_modules.c:init_mib_modules()  || ?
 
 
|- align=left bgcolor=pink
 
|| agent -> mibs || shutdown_{module} || mibgroup/* + mibgroup/mib_modules_shutdown.h || mib_modules.c:_shutdown_mib_modules() || ?
 
  
 
|- align=left bgcolor=pink
 
|- align=left bgcolor=pink

Revision as of 16:11, 8 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() Move to agent lib? Duplicate?
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()  ?

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

  • rework Makefiles to build libnetsnmp, libnetsnmpagent, libnetsnmphelpers and libnetsnmpmibs in that order (done for MAIN)
  • rework Makefiles/configure to fullfil internal and external library dependencies correctly
  • move:
    • make_tempfile from libnetsnmpmibs to libnetsnmpagent
    • ...
  • ...

References