]> xenbits.xensource.com Git - libvirt.git/commitdiff
nwfilter: remove target table before renaming it
authorStefan Berger <stefannb@linux.vnet.ibm.com>
Thu, 9 Aug 2012 20:17:13 +0000 (16:17 -0400)
committerStefan Berger <stefanb@us.ibm.com>
Thu, 9 Aug 2012 20:17:13 +0000 (16:17 -0400)
Remove the target table before renaming a table to it, i.e.,
remove table B before renaming A to B. This makes the
renaming more robust against unconnected left-over tables.

src/nwfilter/nwfilter_ebiptables_driver.c

index 6d6bc3b5f3b95db6109b0eb6db28ed38c3654acd..1aa70910997c74f2e50063ea1d6019ed63146a01 100644 (file)
@@ -125,12 +125,18 @@ static const char ebiptables_script_func_rm_chains[] =
     "}\n";
 
 static const char ebiptables_script_func_rename_chains[] =
+    "rename_chain()\n"
+    "{\n"
+    "  $EBT -t nat -F $2\n"
+    "  $EBT -t nat -X $2\n"
+    "  $EBT -t nat -E $1 $2\n"
+    "}\n"
     "rename_chains()\n"
     "{\n"
     "  for tmp in $*; do\n"
     "    case $tmp in\n"
-    "      %c*) $EBT -t nat -E $tmp %c${tmp#?} ;;\n"
-    "      %c*) $EBT -t nat -E $tmp %c${tmp#?} ;;\n"
+    "      %c*) rename_chain $tmp %c${tmp#?} ;;\n"
+    "      %c*) rename_chain $tmp %c${tmp#?} ;;\n"
     "    esac\n"
     "  done\n"
     "}\n";