0001-replace-ebtables-save-perl-script-with-bash.patch 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. From 73536d15c80be96049289d96fc32122467c56b1d Mon Sep 17 00:00:00 2001
  2. From: Matt Weber <matthew.weber@rockwellcollins.com>
  3. Date: Mon, 16 Dec 2019 13:27:30 -0600
  4. Subject: [PATCH] ebtables: replace ebtables-save perl script with bash rewrite
  5. Fedora provides a bash replacement for the default ebtables-save perl
  6. script. Using it allows the ebtables run-time dependency on perl to
  7. be replaced with a runtime dependency on bash - which is lower
  8. overhead and more likely to be present on typical embedded systems
  9. already.
  10. https://bugzilla.redhat.com/show_bug.cgi?id=746040
  11. http://pkgs.fedoraproject.org/cgit/rpms/ebtables.git/tree/ebtables-save
  12. Upstream:
  13. https://github.com/openembedded/meta-openembedded/commit/7f723007364ba79de05447671e83d4eefb3097dc
  14. Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com>
  15. [ryanbarnett3@gmail.com:
  16. - changed EBTABLES executable to /usr/sbin/ebtables-legacy
  17. ]
  18. Signed-off-by: Ryan Barnett <ryanbarnett3@gmail.com>
  19. ---
  20. ebtables-save.sh | 43 +++++++++++++++++++++++++++++++++++++++++++
  21. 1 file changed, 43 insertions(+)
  22. create mode 100644 ebtables-save.sh
  23. diff --git a/ebtables-save.sh b/ebtables-save.sh
  24. new file mode 100644
  25. index 0000000..2d7fc4e
  26. --- /dev/null
  27. +++ b/ebtables-save.sh
  28. @@ -0,0 +1,43 @@
  29. +#!/bin/bash
  30. +
  31. +EBTABLES="/usr/sbin/ebtables-legacy"
  32. +
  33. +[ -x "$EBTABLES" ] || exit 1
  34. +
  35. +echo "# Generated by ebtables-save v1.0 on $(date)"
  36. +
  37. +cnt=""
  38. +[ "x$EBTABLES_SAVE_COUNTER" = "xyes" ] && cnt="--Lc"
  39. +
  40. +for table_name in $(grep -E '^ebtable_' /proc/modules | cut -f1 -d' ' | sed s/ebtable_//); do
  41. + table=$($EBTABLES -t $table_name -L $cnt)
  42. + [ $? -eq 0 ] || { echo "$table"; exit -1; }
  43. +
  44. + chain=""
  45. + rules=""
  46. + while read line; do
  47. + [ -z "$line" ] && continue
  48. +
  49. + case "$line" in
  50. + Bridge\ table:\ *)
  51. + echo "*${line:14}"
  52. + ;;
  53. + Bridge\ chain:\ *)
  54. + chain="${line:14}"
  55. + chain="${chain%%,*}"
  56. + policy="${line##*policy: }"
  57. + echo ":$chain $policy"
  58. + ;;
  59. + *)
  60. + if [ "$cnt" = "--Lc" ]; then
  61. + line=${line/, pcnt \=/ -c}
  62. + line=${line/-- bcnt \=/}
  63. + fi
  64. + rules="$rules-A $chain $line\n"
  65. + ;;
  66. + esac
  67. + done <<EOF
  68. +$table
  69. +EOF
  70. + echo -e $rules
  71. +done
  72. --
  73. 2.17.1