Calico [1] with OpenStack (
https://docs.projectcalico.org/v2.6/getting-started/openstack/) uses
dnsmasq with a very long --bridge-interface option:

--bridge-interface=<context-if-name>,<alias-if-name>,<alias-if-name>,...,

where each occurrence of ",<alias-if-name>" occupies 15 characters, and
there can in principle be as many <alias-if-name>s as you can have VMs on a
single OpenStack compute host.  Currently an option arg is limited in
dnsmasq to 1025 chars overall, which only allows for 67 <alias-if-name>s,
which is not necessarily enough, on a powerful compute host.

So I wonder what folk would think about reallocating as necessary to allow
an option arg to be arbitrarily long?  (Or at least, as long as getopt and
the containing shell will allow.)  For reference I've attached a patch that
I think would implement that - but I haven't yet been able to test it at
all, so please don't merge it yet!

Thanks in advance for your thoughts!
      Neil
From b39df72629f4226a2fcba104ff108d155a7e7372 Mon Sep 17 00:00:00 2001
From: Neil Jerram <n...@tigera.io>
Date: Sat, 6 Jan 2018 01:03:26 +0000
Subject: [PATCH] Allow options longer than 1025 chars

Calico [1] with OpenStack uses dnsmasq with a very long
--bridge-interface option:
--bridge-interface=<context-if-name>,<alias-if-name>,<alias-if-name>,...,
where each occurrence of ",<alias-if-name>" occupies 15 characters, and
there can in principle be as many <alias-if-name>s as you can have VMs
on a single OpenStack compute host.

Currently the option is limited to 1025 chars overall, which only allows
for 67 <alias-if-name>s, which is not necessarily enough.  This patch
removes the limit by reallocating the arg buffer when necessary.

[1] https://docs.projectcalico.org/v2.6/getting-started/openstack/
---
 src/option.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/option.c b/src/option.c
index 3ab1533..9c3d85a 100644
--- a/src/option.c
+++ b/src/option.c
@@ -4612,6 +4612,8 @@ void reread_dhcp(void)
     
 void read_opts(int argc, char **argv, char *compile_opts)
 {
+  size_t argbuf_size = MAXDNAME;
+  char *argbuf = opt_malloc(argbuf_size);
   char *buff = opt_malloc(MAXDNAME);
   int option, conffile_opt = '7', testmode = 0;
   char *arg, *conffile = CONFFILE;
@@ -4681,9 +4683,15 @@ void read_opts(int argc, char **argv, char *compile_opts)
       /* Copy optarg so that argv doesn't get changed */
       if (optarg)
 	{
-	  strncpy(buff, optarg, MAXDNAME);
-	  buff[MAXDNAME-1] = 0;
-	  arg = buff;
+	  if (strlen(optarg) >= argbuf_size)
+	    {
+	      free(argbuf);
+	      argbuf_size = strlen(optarg) + 1;
+	      argbuf = opt_malloc(argbuf_size);
+	    }
+	  strncpy(argbuf, optarg, argbuf_size);
+	  argbuf[argbuf_size-1] = 0;
+	  arg = argbuf;
 	}
       else
 	arg = NULL;
@@ -4731,6 +4739,8 @@ void read_opts(int argc, char **argv, char *compile_opts)
 	}
     }
 
+  free(argbuf);
+
   if (conffile)
     {
       one_file(conffile, conffile_opt);
-- 
2.7.4

_______________________________________________
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss

Reply via email to