[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [libvirt PATCHv3 10/10] support multiple static IP addresses



On 10/12/2011 03:50 PM, David L Stevens wrote:
	This patch adds support for multiple static IP addresses in a
comma-separated list. For example:

     <interface type='network'>
       <filterref filter='clean-traffic'>
         <parameter name='ip_learning' value='none'/>
         <parameter name='IP' value='10.0.0.1,10.1.0.7,10.0.3.8,10.0.9.244'/>
       </filterref>
     ...

Signed-off-by: David L Stevens<dlstevens us ibm com>
---
  src/nwfilter/nwfilter_gentech_driver.c |   26 ++++++++++++++++++++++++++
  1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter_gentech_driver.c
index 577b48d..8f74a01 100644
--- a/src/nwfilter/nwfilter_gentech_driver.c
+++ b/src/nwfilter/nwfilter_gentech_driver.c
@@ -920,6 +920,8 @@ __virNWFilterInstantiateFilter(virConnectPtr conn,
      char *str_macaddr = NULL;
      const char *ipaddr;
      char *str_ipaddr = NULL;
+    char *ipaddrlist = NULL;
+    char *sep;

      techdriver = virNWFilterTechDriverForName(drvname);

@@ -983,6 +985,17 @@ __virNWFilterInstantiateFilter(virConnectPtr conn,
          goto err_exit_vars1;
      }

+    ipaddr = virHashLookup(filterparams->hashTable, NWFILTER_STD_VAR_IP);
+    if (ipaddr) {
+        sep = strchr(ipaddr, ',');
+        if (sep) {
+            str_ipaddr = strndup(ipaddr, sep-ipaddr);
+            ipaddrlist = strdup(sep + 1);
Check for str_ipaddr or ipaddrlist being NULL.
+            virNWFilterHashTablePut(vars, NWFILTER_STD_VAR_IP, str_ipaddr, 1);
+        }
+    }
+    str_ipaddr = NULL;
+
      filter = obj->def;

      switch (useNewFilter) {
@@ -1011,6 +1024,19 @@ __virNWFilterInstantiateFilter(virConnectPtr conn,
                                  driver,
                                  forceWithPendingReq);

+    /* add the rest of the IP list */
+    for (ipaddr = ipaddrlist; ipaddr; ipaddr = sep) {
+        sep = strchr(ipaddr, ',');
+        if (sep) {
+            str_ipaddr = strndup(ipaddr, sep-ipaddr);
Test for NULL result.
+            sep++; /* skip ',' */
+        } else
+            str_ipaddr = strdup(ipaddr);
Also here.
+        virNWFilterChangeVar(conn, techdriver, nettype, filter, ifname, vars,
+                             driver, NWFILTER_STD_VAR_IP, str_ipaddr, 0);
+
+    }
+    str_ipaddr = NULL;
      virNWFilterHashTableFree(vars);

  err_exit_vars1:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]