From 96c727fda6db70352deb62b861e3d6c615dd5740 Mon Sep 17 00:00:00 2001 From: Simon Kelley Date: Tue, 2 Apr 2013 21:35:41 +0100 Subject: [PATCH] Cope with duplicate dhcp-options with tags (last one wins). --- src/dhcp-common.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/dhcp-common.c b/src/dhcp-common.c index 8ddec58..f4fd088 100644 --- a/src/dhcp-common.c +++ b/src/dhcp-common.c @@ -91,6 +91,7 @@ struct dhcp_netid *option_filter(struct dhcp_netid *tags, struct dhcp_netid *con { struct dhcp_netid *tagif = run_tag_if(tags); struct dhcp_opt *opt; + struct dhcp_opt *tmp; /* flag options which are valid with the current tag set (sans context tags) */ for (opt = opts; opt; opt = opt->next) @@ -135,7 +136,6 @@ struct dhcp_netid *option_filter(struct dhcp_netid *tags, struct dhcp_netid *con for (opt = opts; opt; opt = opt->next) if (!(opt->flags & (DHOPT_ENCAPSULATE | DHOPT_VENDOR | DHOPT_RFC3925 | DHOPT_TAGOK)) && !opt->netid) { - struct dhcp_opt *tmp; for (tmp = opts; tmp; tmp = tmp->next) if (tmp->opt == opt->opt && (tmp->flags & DHOPT_TAGOK)) break; @@ -145,6 +145,13 @@ struct dhcp_netid *option_filter(struct dhcp_netid *tags, struct dhcp_netid *con my_syslog(MS_DHCP | LOG_WARNING, _("Ignoring duplicate dhcp-option %d"), tmp->opt); } + /* Finally, eliminate duplicate options later in the chain, and therefore earlier in the config file. */ + for (opt = opts; opt; opt = opt->next) + if (opt->flags & DHOPT_TAGOK) + for (tmp = opt->next; tmp; tmp = tmp->next) + if (tmp->opt == opt->opt) + tmp->flags &= ~DHOPT_TAGOK; + return tagif; }