Skip to content

Commit

Permalink
ebtables: Remove the dependecy on bash
Browse files Browse the repository at this point in the history
Rewrite ebtables-legacy-save to avoid using bashisms.

Signed-off-by: Peter Kjellerstedt <[email protected]>
Signed-off-by: Khem Raj <[email protected]>
  • Loading branch information
Peter Kjellerstedt authored and kraj committed Nov 19, 2024
1 parent 9495b3d commit 9a63490
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

EBTABLES="/usr/sbin/ebtables-legacy"

Expand All @@ -11,7 +11,7 @@ cnt=""

for table_name in $(grep -E '^ebtable_' /proc/modules | cut -f1 -d' ' | sed s/ebtable_//); do
table=$($EBTABLES -t $table_name -L $cnt)
[ $? -eq 0 ] || { echo "$table"; exit -1; }
[ $? -eq 0 ] || { echo "$table"; exit 1; }

chain=""
rules=""
Expand All @@ -20,24 +20,23 @@ for table_name in $(grep -E '^ebtable_' /proc/modules | cut -f1 -d' ' | sed s/eb

case "$line" in
Bridge\ table:\ *)
echo "*${line:14}"
echo "*${line#Bridge table: }"
;;
Bridge\ chain:\ *)
chain="${line:14}"
chain="${line#Bridge chain: }"
chain="${chain%%,*}"
policy="${line##*policy: }"
echo ":$chain $policy"
;;
*)
if [ "$cnt" = "--Lc" ]; then
line=${line/, pcnt \=/ -c}
line=${line/-- bcnt \=/}
fi
rules="$rules-A $chain $line\n"
[ "$cnt" != "--Lc" ] ||
line=$(echo "$line" | sed -e 's/, pcnt =/-c/' -e 's/ -- bcnt =//')
rules="$rules-A $chain $line
"
;;
esac
done <<EOF
$table
EOF
echo -e $rules
echo "$rules"
done
2 changes: 0 additions & 2 deletions meta-networking/recipes-filter/ebtables/ebtables_2.0.11.bb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ LICENSE = "GPL-2.0-only"
LIC_FILES_CHKSUM = "file://COPYING;md5=53b4a999993871a28ab1488fdbd2e73e"
SECTION = "net"

RDEPENDS:${PN} += "bash"

RRECOMMENDS:${PN} += "kernel-module-ebtables \
"

Expand Down

0 comments on commit 9a63490

Please sign in to comment.