Re: [libvirt] [PATCH V11 5/7] nwfilter: move code for IP address map into separate file

2012-04-19 Thread Daniel Veillard
On Tue, Apr 17, 2012 at 10:44:06AM -0400, Stefan Berger wrote:
 The goal of this patch is to prepare for support for multiple IP
 addresses per interface in the DHCP snooping code.
 
 Move the code for the IP address map that maps interface names to
 IP addresses into their own file. Rename the functions on the way
 but otherwise leave the code as-is. Initialize this new layer
 separately before dependent layers (iplearning, dhcpsnooping)
 and shut it down after them.
 
 ---
  src/Makefile.am|4 
  src/conf/nwfilter_ipaddrmap.c  |  167 
 +
  src/conf/nwfilter_ipaddrmap.h  |   37 +++
  src/libvirt_private.syms   |8 +
  src/nwfilter/nwfilter_driver.c |   11 +-
  src/nwfilter/nwfilter_gentech_driver.c |5 
  src/nwfilter/nwfilter_learnipaddr.c|  126 
  src/nwfilter/nwfilter_learnipaddr.h|3 
  8 files changed, 229 insertions(+), 132 deletions(-)
 
 Index: libvirt-acl/src/Makefile.am
 ===
 --- libvirt-acl.orig/src/Makefile.am
 +++ libvirt-acl/src/Makefile.am
 @@ -159,9 +159,11 @@ NETWORK_CONF_SOURCES =   
 \
  # Network filter driver generic impl APIs
  NWFILTER_PARAM_CONF_SOURCES =\
   conf/nwfilter_params.c conf/nwfilter_params.h   \
 + conf/nwfilter_ipaddrmap.c   \
 + conf/nwfilter_ipaddrmap.h   \
   conf/nwfilter_conf.h
  
 -NWFILTER_CONF_SOURCES =  \
 +NWFILTER_CONF_SOURCES =  \
   $(NWFILTER_PARAM_CONF_SOURCES)  \
   conf/nwfilter_conf.c conf/nwfilter_conf.h
  
 Index: libvirt-acl/src/nwfilter/nwfilter_driver.c
 ===
 --- libvirt-acl.orig/src/nwfilter/nwfilter_driver.c
 +++ libvirt-acl/src/nwfilter/nwfilter_driver.c
 @@ -39,6 +39,7 @@
  #include nwfilter_gentech_driver.h
  #include configmake.h
  
 +#include nwfilter_ipaddrmap.h
  #include nwfilter_dhcpsnoop.h
  #include nwfilter_learnipaddr.h
  
 @@ -67,10 +68,12 @@ static int
  nwfilterDriverStartup(int privileged) {
  char *base = NULL;
  
 -if (virNWFilterDHCPSnoopInit()  0)
 +if (virNWFilterIPAddrMapInit()  0)
  return -1;
  if (virNWFilterLearnInit()  0)
 -return -1;
 +goto err_exit_ipaddrmapshutdown;
 +if (virNWFilterDHCPSnoopInit()  0)
 +goto err_exit_learnshutdown;
  
  virNWFilterTechDriversInit(privileged);
  
 @@ -131,7 +134,10 @@ alloc_err_exit:
  conf_init_err:
  virNWFilterTechDriversShutdown();
  virNWFilterDHCPSnoopShutdown();
 +err_exit_learnshutdown:
  virNWFilterLearnShutdown();
 +err_exit_ipaddrmapshutdown:
 +virNWFilterIPAddrMapShutdown();
  
  return -1;
  }
 @@ -210,6 +216,7 @@ nwfilterDriverShutdown(void) {
  virNWFilterTechDriversShutdown();
  virNWFilterDHCPSnoopShutdown();
  virNWFilterLearnShutdown();
 +virNWFilterIPAddrMapShutdown();
  
  nwfilterDriverLock(driverState);
  
 Index: libvirt-acl/src/nwfilter/nwfilter_gentech_driver.c
 ===
 --- libvirt-acl.orig/src/nwfilter/nwfilter_gentech_driver.c
 +++ libvirt-acl/src/nwfilter/nwfilter_gentech_driver.c
 @@ -33,6 +33,7 @@
  #include nwfilter_gentech_driver.h
  #include nwfilter_ebiptables_driver.h
  #include nwfilter_dhcpsnoop.h
 +#include nwfilter_ipaddrmap.h
  #include nwfilter_learnipaddr.h
  #include virnetdev.h
  #include datatypes.h
 @@ -870,7 +871,7 @@ __virNWFilterInstantiateFilter(const uns
  goto err_exit;
  }
  
 -ipaddr = virNWFilterGetIpAddrForIfname(ifname);
 +ipaddr = virNWFilterIPAddrMapGetIPAddr(ifname);
  
  vars1 = virNWFilterCreateVarHashmap(str_macaddr, ipaddr);
  if (!vars1) {
 @@ -1132,7 +1133,7 @@ _virNWFilterTeardownFilter(const char *i
  
  techdriver-allTeardown(ifname);
  
 -virNWFilterDelIpAddrForIfname(ifname, NULL);
 +virNWFilterIPAddrMapDelIPAddr(ifname, NULL);
  
  virNWFilterUnlockIface(ifname);
  
 Index: libvirt-acl/src/nwfilter/nwfilter_learnipaddr.c
 ===
 --- libvirt-acl.orig/src/nwfilter/nwfilter_learnipaddr.c
 +++ libvirt-acl/src/nwfilter/nwfilter_learnipaddr.c
 @@ -52,6 +52,7 @@
  #include conf/domain_conf.h
  #include nwfilter_gentech_driver.h
  #include nwfilter_ebiptables_driver.h
 +#include nwfilter_ipaddrmap.h
  #include nwfilter_learnipaddr.h
  
  #define VIR_FROM_THIS VIR_FROM_NWFILTER
 @@ -118,9 +119,6 @@ struct ether_vlan_header
  static virMutex pendingLearnReqLock;
  static virHashTablePtr pendingLearnReq;
  
 -static virMutex ipAddressMapLock;
 -static virNWFilterHashTablePtr ipAddressMap;
 -
  static virMutex 

Re: [libvirt] [PATCH V11 5/7] nwfilter: move code for IP address map into separate file

2012-04-19 Thread Stefan Berger

On 04/19/2012 05:58 AM, Daniel Veillard wrote:

On Tue, Apr 17, 2012 at 10:44:06AM -0400, Stefan Berger wrote:

[...]


Index: libvirt-acl/src/libvirt_private.syms
===
--- libvirt-acl.orig/src/libvirt_private.syms
+++ libvirt-acl/src/libvirt_private.syms
@@ -853,6 +853,14 @@ virNWFilterTestUnassignDef;
  virNWFilterUnlockFilterUpdates;


+# nwfilter_ipaddrmap
+virNWFilterIPAddrMapAddIPAddr;
+virNWFilterIPAddrMapDelIPAddr;
+virNWFilterIPAddrMapGetIPAddr;
+virNWFilterIPAddrMapInit;
+virNWFilterIPAddrMapShutdown;
+
+
  # nwfilter_params.h
  virNWFilterHashTableCreate;
  virNWFilterHashTableFree;

   Weird I would have expected some of the renamed/moved functions
to be removed from the libvirt_private.syms, I'm surprized to see
only additions :)


[...]

   ACK, but double check the syms, thanks,



There were none there before.

Regards,

Stefan

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH V11 5/7] nwfilter: move code for IP address map into separate file

2012-04-19 Thread Daniel Veillard
On Thu, Apr 19, 2012 at 06:51:46AM -0400, Stefan Berger wrote:
 On 04/19/2012 05:58 AM, Daniel Veillard wrote:
 On Tue, Apr 17, 2012 at 10:44:06AM -0400, Stefan Berger wrote:
 [...]
 
 Index: libvirt-acl/src/libvirt_private.syms
 ===
 --- libvirt-acl.orig/src/libvirt_private.syms
 +++ libvirt-acl/src/libvirt_private.syms
 @@ -853,6 +853,14 @@ virNWFilterTestUnassignDef;
   virNWFilterUnlockFilterUpdates;
 
 
 +# nwfilter_ipaddrmap
 +virNWFilterIPAddrMapAddIPAddr;
 +virNWFilterIPAddrMapDelIPAddr;
 +virNWFilterIPAddrMapGetIPAddr;
 +virNWFilterIPAddrMapInit;
 +virNWFilterIPAddrMapShutdown;
 +
 +
   # nwfilter_params.h
   virNWFilterHashTableCreate;
   virNWFilterHashTableFree;
Weird I would have expected some of the renamed/moved functions
 to be removed from the libvirt_private.syms, I'm surprized to see
 only additions :)
 
 [...]
ACK, but double check the syms, thanks,
 
 
 There were none there before.

  okay the functions were not exported then, thanks !

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH V11 5/7] nwfilter: move code for IP address map into separate file

2012-04-17 Thread Stefan Berger
The goal of this patch is to prepare for support for multiple IP
addresses per interface in the DHCP snooping code.

Move the code for the IP address map that maps interface names to
IP addresses into their own file. Rename the functions on the way
but otherwise leave the code as-is. Initialize this new layer
separately before dependent layers (iplearning, dhcpsnooping)
and shut it down after them.

---
 src/Makefile.am|4 
 src/conf/nwfilter_ipaddrmap.c  |  167 +
 src/conf/nwfilter_ipaddrmap.h  |   37 +++
 src/libvirt_private.syms   |8 +
 src/nwfilter/nwfilter_driver.c |   11 +-
 src/nwfilter/nwfilter_gentech_driver.c |5 
 src/nwfilter/nwfilter_learnipaddr.c|  126 
 src/nwfilter/nwfilter_learnipaddr.h|3 
 8 files changed, 229 insertions(+), 132 deletions(-)

Index: libvirt-acl/src/Makefile.am
===
--- libvirt-acl.orig/src/Makefile.am
+++ libvirt-acl/src/Makefile.am
@@ -159,9 +159,11 @@ NETWORK_CONF_SOURCES = 
\
 # Network filter driver generic impl APIs
 NWFILTER_PARAM_CONF_SOURCES =  \
conf/nwfilter_params.c conf/nwfilter_params.h   \
+   conf/nwfilter_ipaddrmap.c   \
+   conf/nwfilter_ipaddrmap.h   \
conf/nwfilter_conf.h
 
-NWFILTER_CONF_SOURCES =\
+NWFILTER_CONF_SOURCES =\
$(NWFILTER_PARAM_CONF_SOURCES)  \
conf/nwfilter_conf.c conf/nwfilter_conf.h
 
Index: libvirt-acl/src/nwfilter/nwfilter_driver.c
===
--- libvirt-acl.orig/src/nwfilter/nwfilter_driver.c
+++ libvirt-acl/src/nwfilter/nwfilter_driver.c
@@ -39,6 +39,7 @@
 #include nwfilter_gentech_driver.h
 #include configmake.h
 
+#include nwfilter_ipaddrmap.h
 #include nwfilter_dhcpsnoop.h
 #include nwfilter_learnipaddr.h
 
@@ -67,10 +68,12 @@ static int
 nwfilterDriverStartup(int privileged) {
 char *base = NULL;
 
-if (virNWFilterDHCPSnoopInit()  0)
+if (virNWFilterIPAddrMapInit()  0)
 return -1;
 if (virNWFilterLearnInit()  0)
-return -1;
+goto err_exit_ipaddrmapshutdown;
+if (virNWFilterDHCPSnoopInit()  0)
+goto err_exit_learnshutdown;
 
 virNWFilterTechDriversInit(privileged);
 
@@ -131,7 +134,10 @@ alloc_err_exit:
 conf_init_err:
 virNWFilterTechDriversShutdown();
 virNWFilterDHCPSnoopShutdown();
+err_exit_learnshutdown:
 virNWFilterLearnShutdown();
+err_exit_ipaddrmapshutdown:
+virNWFilterIPAddrMapShutdown();
 
 return -1;
 }
@@ -210,6 +216,7 @@ nwfilterDriverShutdown(void) {
 virNWFilterTechDriversShutdown();
 virNWFilterDHCPSnoopShutdown();
 virNWFilterLearnShutdown();
+virNWFilterIPAddrMapShutdown();
 
 nwfilterDriverLock(driverState);
 
Index: libvirt-acl/src/nwfilter/nwfilter_gentech_driver.c
===
--- libvirt-acl.orig/src/nwfilter/nwfilter_gentech_driver.c
+++ libvirt-acl/src/nwfilter/nwfilter_gentech_driver.c
@@ -33,6 +33,7 @@
 #include nwfilter_gentech_driver.h
 #include nwfilter_ebiptables_driver.h
 #include nwfilter_dhcpsnoop.h
+#include nwfilter_ipaddrmap.h
 #include nwfilter_learnipaddr.h
 #include virnetdev.h
 #include datatypes.h
@@ -870,7 +871,7 @@ __virNWFilterInstantiateFilter(const uns
 goto err_exit;
 }
 
-ipaddr = virNWFilterGetIpAddrForIfname(ifname);
+ipaddr = virNWFilterIPAddrMapGetIPAddr(ifname);
 
 vars1 = virNWFilterCreateVarHashmap(str_macaddr, ipaddr);
 if (!vars1) {
@@ -1132,7 +1133,7 @@ _virNWFilterTeardownFilter(const char *i
 
 techdriver-allTeardown(ifname);
 
-virNWFilterDelIpAddrForIfname(ifname, NULL);
+virNWFilterIPAddrMapDelIPAddr(ifname, NULL);
 
 virNWFilterUnlockIface(ifname);
 
Index: libvirt-acl/src/nwfilter/nwfilter_learnipaddr.c
===
--- libvirt-acl.orig/src/nwfilter/nwfilter_learnipaddr.c
+++ libvirt-acl/src/nwfilter/nwfilter_learnipaddr.c
@@ -52,6 +52,7 @@
 #include conf/domain_conf.h
 #include nwfilter_gentech_driver.h
 #include nwfilter_ebiptables_driver.h
+#include nwfilter_ipaddrmap.h
 #include nwfilter_learnipaddr.h
 
 #define VIR_FROM_THIS VIR_FROM_NWFILTER
@@ -118,9 +119,6 @@ struct ether_vlan_header
 static virMutex pendingLearnReqLock;
 static virHashTablePtr pendingLearnReq;
 
-static virMutex ipAddressMapLock;
-static virNWFilterHashTablePtr ipAddressMap;
-
 static virMutex ifaceMapLock;
 static virHashTablePtr ifaceLockMap;
 
@@ -310,113 +308,8 @@ virNWFilterDeregisterLearnReq(int ifinde
 return res;
 }
 
-/* Add an IP address to the list of IP addresses an