]> git.proxmox.com Git - mirror_frr.git/commit - ldpd/ldpd.c
ldpd: simplify handling of configuration commands
authorRenato Westphal <renato@opensourcerouting.org>
Thu, 23 Mar 2017 17:49:28 +0000 (14:49 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Mon, 27 Mar 2017 17:54:28 +0000 (14:54 -0300)
commit56b8a8d231bf36a7011eb97eb115a148b3395635
tree6779b393c0a44a9acbd7013e505e6379e8df191e
parent83139e57e96493d00cf46c403845c45b6ef2a37c
ldpd: simplify handling of configuration commands

The logic to make configuration changes in ldpd is as follows:
1 - duplicate the current configuration;
2 - modify the duplicated configuration (delta);
3 - merge the duplicated configuration into the current configuration.

We can however change things a little bit in order to simplify the code.

If we provide a global vty_conf variable and make sure that it's
always an up-to-date duplicate of ldpd_conf, then we don't need to call
ldp_dup_config() in the callback of each configuration command. Instead
of that, we just need to duplicate ldpd_conf in the startup of the daemon
and in the end of the ldp_reload() function. Doing this is safe because,
due to the single-threaded nature of the parent process, it's impossible
to have multiple requests to change the configuration at the same time.

Also, we can remove the *_ref() functions and do something much simpler
instead.  The problem we have to deal with here is that VTY_GET_CONTEXT()
returns a pointer to an element of ldpd_conf, and what we want is a
pointer to an element of vty_conf (e.g. an l2vpn).  To solve this,
we just need to look for the equivalent element inside vty_conf using
standard functions from ldpd like l2vpn_find() and others.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
ldpd/ldp_vty_conf.c
ldpd/ldpd.c
ldpd/ldpd.h