[LEDE-DEV] [RFC PATCH odhcpd] config: respect ignore uci option

Jo-Philipp Wich jo at mein.io
Tue Jan 3 05:09:08 PST 2017

The odhcpd documentation currently implies that "option ignore 1" in a section
of type "dhcp" will disable any services on the referenced interface while the
code actually ignores the setting when initializing referenced interfaces.

This commonly leads to situations where users think that "option disabled"
will prevent any server activity on a given interface while in reality odhcpd
effectively acts as rogue DHCPv6 server in its default configuration.

To fully inhibit any activity, one has to specify both "option ignore 1" as
well as "option ra disabled", "option ndp disabled" and
"option dhcpv6 disabled" which is highly counter intuitive at best.

A previous commit (5f425ed Respect interface "ignore" settings as documented.)
attempted to address the problem by observing the value of i->ignore instead
of unconditionally enabling all protocols but broke the ability to use DHCPv6
relay mode while having DHCPv4 disabled.

This patch changes ...

 - the enabling of services on an interface to use the value of the ignore
   option as default choice instead of hardcoding "true"

 - the options "ra", "ndp", "dhcpv4" and "dhcpv6" to take precedence over the
   default "ignore" state to allow selectively enabling services on ignored

 - the README to clarify the fact that "ra", "ndp", "dhcpv4" and "dhcpv6" can
   now override "option ignore"

Signed-off-by: Jo-Philipp Wich <jo at mein.io>
 README       | 4 +++-
 src/config.c | 8 ++++----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/README b/README
index e14f822..4ae5ef2 100644
--- a/README
+++ b/README
@@ -70,7 +70,9 @@ Option		Type	Default			Description
 interface	string	<name of UCI section>	logical OpenWrt interface
 ifname		string	<resolved from logical>	physical network interface
 networkid	string	same as ifname		compat. alias for ifname
-ignore		bool	0			ignore this interface
+ignore		bool	0			do not serve this interface
+						unless overridden by ra, ndp,
+						dhcpv4 or dhcpv6 options
 master		bool	0			is a master interface
 						for relaying
diff --git a/src/config.c b/src/config.c
index e3bf78a..ba51375 100644
--- a/src/config.c
+++ b/src/config.c
@@ -721,10 +721,10 @@ void odhcpd_reload(void)
 				i->ndp = (master && master->ndp == RELAYD_RELAY) ?
-			setup_router_interface(i, true);
-			setup_dhcpv6_interface(i, true);
-			setup_ndp_interface(i, true);
-			setup_dhcpv4_interface(i, true);
+			setup_router_interface(i, !i->ignore || i->ra != RELAYD_DISABLED);
+			setup_dhcpv6_interface(i, !i->ignore || i->dhcpv6 != RELAYD_DISABLED);
+			setup_ndp_interface(i, !i->ignore || i->ndp != RELAYD_DISABLED);
+			setup_dhcpv4_interface(i, !i->ignore || i->dhcpv4 != RELAYD_DISABLED);
 		} else {

More information about the Lede-dev mailing list