ebtables: replace ebtables-save perl script with bash rewrite

Fedora provides a bash replacement for the default ebtables-save perl
script. Using it allows the ebtables run-time dependency on perl to
be replaced with a runtime dependency on bash - which is lower
overhead and more likely to be present on typical embedded systems
already.

  https://bugzilla.redhat.com/show_bug.cgi?id=746040
  http://pkgs.fedoraproject.org/cgit/rpms/ebtables.git/tree/ebtables-save

Since ebtables-save no longer contains a references to /usr, the
previous QA issue workaround of moving it from ${base_sbindir} to
${sbindir} is no longer required.

  http://git.openembedded.org/meta-openembedded/commit/?id=a7c6fcebee7d9f86c356ea92de445d89e714ff62

Signed-off-by: Andre McCurdy <armccurdy@gmail.com>
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
This commit is contained in:
Andre McCurdy 2017-07-11 10:09:11 -07:00 committed by Joe MacDonald
parent 18b8535e1a
commit 7f72300736
2 changed files with 50 additions and 8 deletions

View File

@ -0,0 +1,43 @@
#!/bin/bash
EBTABLES="/sbin/ebtables"
[ -x "$EBTABLES" ] || exit 1
echo "# Generated by ebtables-save v1.0 on $(date)"
cnt=""
[ "x$EBTABLES_SAVE_COUNTER" = "xyes" ] && cnt="--Lc"
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; }
chain=""
rules=""
while read line; do
[ -z "$line" ] && continue
case "$line" in
Bridge\ table:\ *)
echo "*${line:14}"
;;
Bridge\ chain:\ *)
chain="${line:14}"
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"
;;
esac
done <<EOF
$table
EOF
echo -e $rules
done

View File

@ -4,14 +4,15 @@ DESCRIPTION = "Utility for basic Ethernet frame filtering on a Linux bridge, \
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=53b4a999993871a28ab1488fdbd2e73e"
SECTION = "net"
PR = "r3"
PR = "r4"
RDEPENDS_${PN} += "perl"
RDEPENDS_${PN} += "bash"
RRECOMMENDS_${PN} += "kernel-module-ebtables \
"
SRC_URI = "${SOURCEFORGE_MIRROR}/ebtables/ebtables-v${PV}.tar.gz \
file://ebtables-save \
file://installnonroot.patch \
file://01debian_defaultconfig.patch \
file://ebtables.init \
@ -78,12 +79,10 @@ do_install () {
mv ${D}${sysconfdir}/default/ebtables-config ${D}${sysconfdir}/default/ebtables
sed -i 's!/usr/sbin/!${sbindir}/!g' ${D}${sysconfdir}/init.d/ebtables
# The script ebtables-save refernces perl in exec_prefix, so
# move it to sbindir to avoid QA issue
if ${base_sbindir} != ${sbindir} ; then
install -d ${D}/${sbindir}
mv ${D}/${base_sbindir}/ebtables-save ${D}/${sbindir}
fi
# Replace upstream ebtables-save perl script with Fedora bash based rewrite
# http://pkgs.fedoraproject.org/cgit/rpms/ebtables.git/tree/ebtables-save
install -m 0755 ${WORKDIR}/ebtables-save ${D}${base_sbindir}/ebtables-save
sed -i 's!/sbin/!${base_sbindir}/!g' ${D}${base_sbindir}/ebtables-save
# Install systemd service files
install -d ${D}${systemd_unitdir}/system