From 41a74cba1bec349d1e1c5be4442e7fddb2d4adf7 Mon Sep 17 00:00:00 2001 From: Dainis Jonitis Date: Fri, 12 Apr 2019 13:46:43 +0300 Subject: config: remove 'ignore' config option 1. Remove 'ignore' config option for interface. Interface is still used if any of 'ra', 'ndp', 'dhcpv4' or 'dhcpv6' options are different from default 'disabled' mode. In config_parse_interface() update runtime ignore value according to all mode values. 2. Reset ignore, ra, ndp, dhcpv4 and dhcpv6 values in set_interface_defaults(). Otherwise if option is deleted from config file and config is reloaded, it will use the value from old config, potentiallly not turning services off. 3. Do not use implicit checks that 0 server mode means MODE_DISABLED. 4. Simplify code of all service setup functions if passed enabled = true argument, but service mode is disabled. Signed-off-by: Dainis Jonitis Signed-off-by: Hans Dedecker --- src/dhcpv6-ia.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/dhcpv6-ia.c') diff --git a/src/dhcpv6-ia.c b/src/dhcpv6-ia.c index 9559b96..c0dfa2d 100644 --- a/src/dhcpv6-ia.c +++ b/src/dhcpv6-ia.c @@ -62,16 +62,9 @@ int dhcpv6_ia_init(void) int dhcpv6_ia_setup_interface(struct interface *iface, bool enable) { - if (!enable) { - struct dhcp_assignment *c; - - while (!list_empty(&iface->ia_assignments)) { - c = list_first_entry(&iface->ia_assignments, struct dhcp_assignment, head); - free_assignment(c); - } - } + enable = enable && (iface->dhcpv6 == MODE_SERVER); - if (enable && iface->dhcpv6 == MODE_SERVER) { + if (enable) { struct dhcp_assignment *border; if (list_empty(&iface->ia_assignments)) { @@ -88,7 +81,15 @@ int dhcpv6_ia_setup_interface(struct interface *iface, bool enable) border = list_last_entry(&iface->ia_assignments, struct dhcp_assignment, head); set_border_assignment_size(iface, border); + } else { + struct dhcp_assignment *c; + + while (!list_empty(&iface->ia_assignments)) { + c = list_first_entry(&iface->ia_assignments, struct dhcp_assignment, head); + free_assignment(c); + } } + return 0; } -- cgit v1.2.3