[PATCH] nwfilter: Pass additional parameter into applyDHCPOnly function

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

 



In preparation for the DHCP Snooping code:
Pass an additional parameter into the applyDHCPOnly function
of the 'techdriver'.

---
 src/conf/nwfilter_conf.h                  |    3 ++-
 src/nwfilter/nwfilter_ebiptables_driver.c |   13 ++++++++++---
 src/nwfilter/nwfilter_learnipaddr.c       |    2 +-
 3 files changed, 13 insertions(+), 5 deletions(-)

Index: libvirt-acl/src/conf/nwfilter_conf.h
===================================================================
--- libvirt-acl.orig/src/conf/nwfilter_conf.h
+++ libvirt-acl/src/conf/nwfilter_conf.h
@@ -630,7 +630,8 @@ typedef int (*virNWFilterApplyBasicRules

 typedef int (*virNWFilterApplyDHCPOnlyRules)(const char *ifname,
                                              const unsigned char *macaddr,
-                                             const char *dhcpserver);
+                                             const char *dhcpserver,
+                                             bool leaveTemporary);

 typedef int (*virNWFilterRemoveBasicRules)(const char *ifname);

Index: libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_ebiptables_driver.c
+++ libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -3191,6 +3191,9 @@ tear_down_tmpebchains:
  *    interface
  * @dhcpserver: The DHCP server from which the VM may receive traffic
  *    from; may be NULL
+ * @leaveTemporary: Whether to leave the table names with their temporary
+ *    names (true) or also perform the renaming to their final names as
+ *    part of this call (false)
  *
  * Returns 0 on success, 1 on failure with the rules removed
  *
@@ -3200,7 +3203,8 @@ tear_down_tmpebchains:
 static int
 ebtablesApplyDHCPOnlyRules(const char *ifname,
                            const unsigned char *macaddr,
-                           const char *dhcpserver)
+                           const char *dhcpserver,
+                           bool leaveTemporary)
 {
     virBuffer buf = VIR_BUFFER_INITIALIZER;
     char chain_in [MAX_CHAINNAME_LENGTH],
@@ -3281,8 +3285,11 @@ ebtablesApplyDHCPOnlyRules(const char *i

     ebtablesLinkTmpRootChain(&buf, 1, ifname, 1);
     ebtablesLinkTmpRootChain(&buf, 0, ifname, 1);
-    ebtablesRenameTmpRootChain(&buf, 1, ifname);
-    ebtablesRenameTmpRootChain(&buf, 0, ifname);
+
+    if (!leaveTemporary) {
+        ebtablesRenameTmpRootChain(&buf, 1, ifname);
+        ebtablesRenameTmpRootChain(&buf, 0, ifname);
+    }

     if (ebiptablesExecCLI(&buf, NULL, NULL) < 0)
         goto tear_down_tmpebchains;
Index: libvirt-acl/src/nwfilter/nwfilter_learnipaddr.c
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_learnipaddr.c
+++ libvirt-acl/src/nwfilter/nwfilter_learnipaddr.c
@@ -460,7 +460,7 @@ learnIPAddressThread(void *arg)
     case DETECT_DHCP:
         if (techdriver->applyDHCPOnlyRules(req->ifname,
                                            req->macaddr,
-                                           NULL)) {
+                                           NULL, false)) {
             req->status = EINVAL;
             goto done;
         }

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


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]