From 22cd86012469e38abfa6b865ff51d19a8bdd5293 Mon Sep 17 00:00:00 2001 From: Simon Kelley Date: Sun, 14 Jan 2018 22:57:14 +0000 Subject: [PATCH] Allow more than one --bridge-interface option to refer to an interface. --- CHANGELOG | 8 ++++++++ man/dnsmasq.8 | 6 +++++- src/option.c | 21 +++++++++++++++------ 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0b76ecd..b95c7ec 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -23,6 +23,14 @@ version 2.79 time validation when --dnssec-no-timecheck is in use. Note that this is an incompatible change from earlier releases. + Allow more than one --bridge-interface option to refer to an + interface, so that we can use + --bridge-interface=int1,alias1 + --bridge-interface=int1,alias2 + as an alternative to + --bridge-interface=int1,alias1,alias2 + Thanks to Neil Jerram for work on this. + version 2.78 Fix logic of appending "." to PXE basename. Thanks to Chris diff --git a/man/dnsmasq.8 b/man/dnsmasq.8 index ac70974..6b914ec 100644 --- a/man/dnsmasq.8 +++ b/man/dnsmasq.8 @@ -1695,13 +1695,17 @@ option also forces the leasechange script to be called on changes to the client-id and lease length and expiry time. .TP .B --bridge-interface=,[,] -Treat DHCP (v4 and v6) request and IPv6 Router Solicit packets +Treat DHCP (v4 and v6) requests and IPv6 Router Solicit packets arriving at any of the interfaces as if they had arrived at . This option allows dnsmasq to provide DHCP and RA service over unaddressed and unbridged Ethernet interfaces, e.g. on an OpenStack compute host where each such interface is a TAP interface to a VM, or as in "old style bridging" on BSD platforms. A trailing '*' wildcard can be used in each . + +It is permissible to add more than one alias using more than one --bridge-interface option since +--bridge-interface=int1,alias1,alias2 is exactly equivalent to +--bridge-interface=int1,alias1 --bridge-interface=int1,alias2 .TP .B \-s, --domain=[,
[,local]] Specifies DNS domains for the DHCP server. Domains may be be given diff --git a/src/option.c b/src/option.c index 3ab1533..1a5e359 100644 --- a/src/option.c +++ b/src/option.c @@ -2733,15 +2733,24 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma case LOPT_BRIDGE: /* --bridge-interface */ { - struct dhcp_bridge *new = opt_malloc(sizeof(struct dhcp_bridge)); + struct dhcp_bridge *new; + if (!(comma = split(arg)) || strlen(arg) > IF_NAMESIZE - 1 ) ret_err(_("bad bridge-interface")); - - strcpy(new->iface, arg); - new->alias = NULL; - new->next = daemon->bridges; - daemon->bridges = new; + for (new = daemon->bridges; new; new = new->next) + if (strcmp(new->iface, arg) == 0) + break; + + if (!new) + { + new = opt_malloc(sizeof(struct dhcp_bridge)); + strcpy(new->iface, arg); + new->alias = NULL; + new->next = daemon->bridges; + daemon->bridges = new; + } + do { arg = comma; comma = split(arg);