summaryrefslogtreecommitdiffstats
path: root/userspace/ebtables2/ebtables-restore
diff options
context:
space:
mode:
authorBart De Schuymer <bdschuym@pandora.be>2005-09-01 20:37:07 +0000
committerBart De Schuymer <bdschuym@pandora.be>2005-09-01 20:37:07 +0000
commitf2a67bbee1be533518b6c49fb747c72a54574514 (patch)
tree44251521552ed6f23b36d81781b166564281b90a /userspace/ebtables2/ebtables-restore
parent1dfb6cc6d0949bc1f882b1b71ff9cbc9e61b86d0 (diff)
try to use ebtablesd/ebtablesu scheme
Diffstat (limited to 'userspace/ebtables2/ebtables-restore')
-rw-r--r--userspace/ebtables2/ebtables-restore71
1 files changed, 62 insertions, 9 deletions
diff --git a/userspace/ebtables2/ebtables-restore b/userspace/ebtables2/ebtables-restore
index abe049d..7c2ea88 100644
--- a/userspace/ebtables2/ebtables-restore
+++ b/userspace/ebtables2/ebtables-restore
@@ -9,6 +9,7 @@ use strict;
my $ebtables = "__EXEC_PATH__/ebtables";
my $table = "";
my $rc;
+my $child;
my $line;
# ==============================
@@ -34,20 +35,58 @@ sub check_chain {
}
# ==============================
-unless (-x $ebtables) { print "ERROR: $ebtables isn't executable\n"; exit -1; };
+if (-x "__EXEC_PATH__/ebtablesd" && -x "__EXEC_PATH__/ebtablesu") {
+ `killall ebtablesd 2>/dev/null`;
+ $child = fork();
+ if ($child == 0) {
+ $rc = `__EXEC_PATH__/ebtablesd`;
+ if (!($rc eq "")) {
+ exit -1;
+ }
+ exit 0;
+ }
+ $ebtables = "__EXEC_PATH__/ebtablesu";
+ while (!(-e "__PIPE__")) {
+ if ((kill 0) < $child) {
+ exit -1;
+ }
+ }
+} else {
+ unless (-x $ebtables) { print "ERROR: $ebtables isn't executable\n"; exit -1; };
+}
+
$line = 0;
while(<>) {
$line++;
if(m/^#/) { next; };
if(m/^$/) { next; };
+ if ($ebtables eq "__EXEC_PATH__/ebtablesu") {
+ if ((kill 0) < $child) {
+ exit -1;
+ }
+ }
if(m/^\*(.*)/) {
- if (defined($ENV{'EBTABLES_SAVE_COUNTER'}) && !($ENV{'EBTABLES_SAVE_COUNTER'} eq "yes") && !($table eq "") ) {
- $rc = `$ebtables -t $table -Z`;
- unless($? == 0) {print "ERROR: $rc\n"; exit -1};
+ if (!($table eq "")) {
+ if (!defined($ENV{'EBTABLES_SAVE_COUNTER'}) || !($ENV{'EBTABLES_SAVE_COUNTER'} eq "yes")) {
+ $rc = `$ebtables -t $table -Z`;
+ unless($? == 0) {print "ERROR: $rc\n"; exit -1};
+ }
+ if ($ebtables eq "__EXEC_PATH__/ebtablesu") {
+ $rc = `$ebtables commit $table`;
+ $rc = `$ebtables free $table`;
+ unless($? == 0) {print "ERROR: $rc\n"; exit -1};
+ }
}
$table = $1;
- $rc = `$ebtables -t filter --init-table`;
- unless($? == 0) {print "ERROR: $rc\n"; exit -1};
+ if ($ebtables eq "__EXEC_PATH__/ebtablesu") {
+ $rc = `$ebtables open $table`;
+ unless($? == 0) {print "ERROR: $rc\n"; exit -1};
+ $rc = `$ebtables -F`;
+ unless($? == 0) {print "ERROR: $rc\n"; exit -1};
+ } else {
+ $rc = `$ebtables -t filter --init-table`;
+ unless($? == 0) {print "ERROR: $rc\n"; exit -1};
+ }
next;
}
if(m/^\:(.*?)\s(.*)/) {
@@ -59,7 +98,21 @@ while(<>) {
$rc = `$ebtables -t $table $_`;
unless($? == 0) {print "ERROR(line $line): $rc\n"; exit -1};
}
-if (defined($ENV{'EBTABLES_SAVE_COUNTER'}) && !($ENV{'EBTABLES_SAVE_COUNTER'} eq "yes") && !($table eq "")) {
- $rc = `$ebtables -t $table -Z`;
- unless($? == 0) {print "ERROR: '-t $table -Z' failed\n"; exit -1};
+
+if (!($table eq "")) {
+ if (!defined($ENV{'EBTABLES_SAVE_COUNTER'}) || !($ENV{'EBTABLES_SAVE_COUNTER'} eq "yes")) {
+ $rc = `$ebtables -t $table -Z`;
+ unless($? == 0) {print "ERROR: '-t $table -Z' failed\n"; exit -1};
+ }
+ if ($ebtables eq "__EXEC_PATH__/ebtablesu") {
+ $rc = `$ebtables commit $table`;
+ unless($? == 0) {print "ERROR: $rc\n"; exit -1};
+ }
+}
+
+if ($ebtables eq "__EXEC_PATH__/ebtablesu") {
+ $rc = `$ebtables quit`;
+ unless($? == 0) {print "ERROR: $rc\n"; exit -1};
+ waitpid($child,0);
+ exit 0;
}