4 # A script that generates text output of the ebtables rules.
5 # Similar to iptables-save.
7 # It can be used to store active configuration to /etc/sysconfig/ebtables
11 my $ebtables = "__EXEC_PATH__/ebtables";
16 # ========================================================
17 # Process filter table
18 # ========================================================
25 foreach $line (split("\n",$_[0])) {
26 if ($line =~ m/Bridge table: (.*)/) {
30 if ($line =~ m/Bridge chain: (.*?), entries:.* policy: (.*)/) {
31 $chains = $chains . ":$1 $2\n";
39 $line =~ s/, pcnt = (.*) -- bcnt = (.*)/-c $1 $2/;
43 $rules = $rules . "-A $chain $line\n";
50 # ========================================================
52 unless (-x
$ebtables) { exit -1 };
53 print "# Generated by ebtables-save v$version on " . `date`;
54 if (defined($ENV{'EBTABLES_SAVE_COUNTER'}) && $ENV{'EBTABLES_SAVE_COUNTER'} eq "yes") {
57 foreach $table_name (split("\n", `grep -E '^ebtable_' /proc/modules | cut -f1 -d' ' | sed s/ebtable_//`)) {
58 $table =`$ebtables -t $table_name -L $cnt`;
59 unless ($?
== 0) { print $table; exit -1 };
60 &process_table
($table);