diff options
author | Dainis Jonitis <dainis.jonitis@ubnt.com> | 2019-04-12 13:46:43 +0300 |
---|---|---|
committer | Hans Dedecker <dedeckeh@gmail.com> | 2019-05-15 10:57:12 +0200 |
commit | 41a74cba1bec349d1e1c5be4442e7fddb2d4adf7 (patch) | |
tree | c6366d63948eabae512b225c5f149c9306bcee5a /src/dhcpv4.c | |
parent | c0c8034bc17519c7960f40f6d796b5485cfc4cdb (diff) |
config: remove 'ignore' config optionbp
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 <dainis.jonitis@ubnt.com>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'src/dhcpv4.c')
-rw-r--r-- | src/dhcpv4.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/dhcpv4.c b/src/dhcpv4.c index 2634f65..34d925c 100644 --- a/src/dhcpv4.c +++ b/src/dhcpv4.c @@ -77,13 +77,15 @@ int dhcpv4_setup_interface(struct interface *iface, bool enable) { int ret = 0; + enable = enable && (iface->dhcpv4 != MODE_DISABLED); + if (iface->dhcpv4_event.uloop.fd >= 0) { uloop_fd_delete(&iface->dhcpv4_event.uloop); close(iface->dhcpv4_event.uloop.fd); iface->dhcpv4_event.uloop.fd = -1; } - if (iface->dhcpv4 && enable) { + if (enable) { struct sockaddr_in bind_addr = {AF_INET, htons(DHCPV4_SERVER_PORT), {INADDR_ANY}, {0}}; int val = 1; @@ -592,7 +594,7 @@ static void handle_dhcpv4(void *addr, void *data, size_t len, { struct dhcpv4_message *req = data; - if (!iface->dhcpv4) + if (iface->dhcpv4 == MODE_DISABLED) return; if (len < offsetof(struct dhcpv4_message, options) + 4 || |