From 7ca82ecbea4a7b8338dc3a4cf9aa57fef3564d1c Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Tue, 22 Nov 2011 15:59:26 -0500 Subject: [PATCH] Pass additional parameter into applyDHCPOnly function 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(-) diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h index 61923aa5a4..90162f6367 100644 --- a/src/conf/nwfilter_conf.h +++ b/src/conf/nwfilter_conf.h @@ -630,7 +630,8 @@ typedef int (*virNWFilterApplyBasicRules)(const char *ifname, typedef int (*virNWFilterApplyDHCPOnlyRules)(const char *ifname, const unsigned char *macaddr, - const char *dhcpserver); + const char *dhcpserver, + bool leaveTemporary); typedef int (*virNWFilterRemoveBasicRules)(const char *ifname); diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfilter_ebiptables_driver.c index ef2ee679d4..434a9b0488 100644 --- a/src/nwfilter/nwfilter_ebiptables_driver.c +++ b/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 *ifname, 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; diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c index d1e5648a22..6e066eeb5e 100644 --- a/src/nwfilter/nwfilter_learnipaddr.c +++ b/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; }