-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Improve firewall and NAT64 rules / enable RCP recovery in beta #4500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 7 commits
89533f1
8a7307c
ba3a54d
dcedd89
c013c51
fb7e361
f710397
77fcdc0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,6 @@ name: Lint | |
|
|
||
| env: | ||
| HADOLINT_VERSION: v1.17.2 | ||
| SHELLCHECK_OPTS: -e SC1008 -s bash | ||
|
|
||
| on: | ||
| pull_request: | ||
|
|
@@ -50,6 +49,8 @@ jobs: | |
|
|
||
| - name: Run linter | ||
| uses: ludeeus/[email protected] | ||
| env: | ||
| SHELLCHECK_OPTS: -e SC1008 -s bash -x | ||
| with: | ||
| # Names of scripts with custom shebangs that the action would not | ||
| # discover on its own: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,7 @@ else | |
| bashio::log.info "otbr-agent exited with code $e (by signal $2)." | ||
| fi | ||
|
|
||
| # shellcheck disable=SC1091 | ||
| # shellcheck source=./openthread_border_router/rootfs/etc/s6-overlay/scripts/otbr-agent-common | ||
| . /etc/s6-overlay/scripts/otbr-agent-common | ||
|
|
||
| ipset_destroy_if_exist() | ||
|
|
@@ -28,34 +28,58 @@ ipset_destroy_if_exist() | |
| done | ||
| } | ||
|
|
||
| # shellcheck disable=SC2154,SC2086 | ||
| while ip6tables -C FORWARD -o $thread_if -j $otbr_forward_ingress_chain 2> /dev/null; do | ||
| # shellcheck disable=SC2086 | ||
| ip6tables -D FORWARD -o $thread_if -j $otbr_forward_ingress_chain | ||
| while ip6tables -C FORWARD -o "${thread_if}" -j "${otbr_forward_ingress_chain}" 2> /dev/null; do | ||
| ip6tables -D FORWARD -o "${thread_if}" -j "${otbr_forward_ingress_chain}" | ||
| done | ||
|
|
||
| # shellcheck disable=SC2086 | ||
| if ip6tables -L $otbr_forward_ingress_chain 2> /dev/null; then | ||
| ip6tables -w -F $otbr_forward_ingress_chain | ||
| ip6tables -w -X $otbr_forward_ingress_chain | ||
| if ip6tables -L "${otbr_forward_ingress_chain}" 2> /dev/null; then | ||
| ip6tables -w -F "${otbr_forward_ingress_chain}" | ||
| ip6tables -w -X "${otbr_forward_ingress_chain}" | ||
| fi | ||
|
|
||
| ipset_destroy_if_exist otbr-ingress-deny-src | ||
| ipset_destroy_if_exist otbr-ingress-deny-src-swap | ||
| ipset_destroy_if_exist otbr-ingress-allow-dst | ||
| ipset_destroy_if_exist otbr-ingress-allow-dst-swap | ||
|
|
||
| # shellcheck disable=SC2154,SC2086 | ||
| while ip6tables -C FORWARD -i $thread_if -j $otbr_forward_egress_chain 2> /dev/null; do | ||
| ip6tables -D FORWARD -i $thread_if -j $otbr_forward_egress_chain | ||
| while ip6tables -C FORWARD -i "${thread_if}" -j "${otbr_forward_egress_chain}" 2> /dev/null; do | ||
| ip6tables -D FORWARD -i "${thread_if}" -j "${otbr_forward_egress_chain}" | ||
| done | ||
|
|
||
| # shellcheck disable=SC2086 | ||
| if ip6tables -L $otbr_forward_egress_chain 2> /dev/null; then | ||
| ip6tables -w -F $otbr_forward_egress_chain | ||
| ip6tables -w -X $otbr_forward_egress_chain | ||
| if ip6tables -L "${otbr_forward_egress_chain}" 2> /dev/null; then | ||
| ip6tables -w -F "${otbr_forward_egress_chain}" | ||
| ip6tables -w -X "${otbr_forward_egress_chain}" | ||
| fi | ||
| bashio::log.info "OTBR firewall teardown completed." | ||
|
|
||
| # Cleanup non-firewall rules | ||
| while ip6tables -C FORWARD -i "${thread_if}" -o "${backbone_if}" -j ACCEPT 2>/dev/null; do | ||
| ip6tables -D FORWARD -i "${thread_if}" -o "${backbone_if}" -j ACCEPT | ||
| done | ||
|
|
||
| while ip6tables -C FORWARD -i "${backbone_if}" -o "${thread_if}" -j ACCEPT 2>/dev/null; do | ||
| ip6tables -D FORWARD -i "${backbone_if}" -o "${thread_if}" -j ACCEPT | ||
| done | ||
|
||
|
|
||
| # Remove FORWARD jump(s) | ||
| while iptables -C FORWARD -j "${otbr_forward_nat64_chain}" 2>/dev/null; do | ||
| iptables -D FORWARD -j "${otbr_forward_nat64_chain}" | ||
| done | ||
|
|
||
| # Flush and delete chain | ||
| if iptables -L "${otbr_forward_nat64_chain}" -n 2>/dev/null; then | ||
| iptables -w -F "${otbr_forward_nat64_chain}" | ||
| iptables -w -X "${otbr_forward_nat64_chain}" | ||
| fi | ||
|
|
||
| # Clean mangle and nat rules | ||
| while iptables -t mangle -C PREROUTING -i "${thread_if}" -j MARK --set-mark "${otbr_fw_mark}" 2>/dev/null; do | ||
| iptables -t mangle -D PREROUTING -i "${thread_if}" -j MARK --set-mark "${otbr_fw_mark}" | ||
| done | ||
|
|
||
| while iptables -t nat -C POSTROUTING -m mark --mark "${otbr_fw_mark}" -j MASQUERADE 2>/dev/null; do | ||
| iptables -t nat -D POSTROUTING -m mark --mark "${otbr_fw_mark}" -j MASQUERADE | ||
| done | ||
| bashio::log.info "OTBR firewall/NAT64 rules teardown completed." | ||
|
|
||
| if test "$e" -ne 0; then | ||
| echo "$e" > /run/s6-linux-init-container-results/exitcode | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,14 @@ | ||
| #!/bin/sh | ||
| # shellcheck shell=bash | ||
| # shellcheck disable=SC2034 | ||
|
|
||
| declare thread_if | ||
| declare otbr_forward_ingress_chain | ||
| declare otbr_forward_egress_chain | ||
| declare otbr_forward_nat64_chain | ||
| declare otbr_fw_mark | ||
| thread_if="wpan0" | ||
| otbr_forward_ingress_chain="OTBR_FORWARD_INGRESS" | ||
| otbr_forward_egress_chain="OTBR_FORWARD_EGRESS" | ||
| otbr_forward_nat64_chain="OTBR_FORWARD_NAT64" | ||
| otbr_fw_mark="0x1001" | ||
|
|
Uh oh!
There was an error while loading. Please reload this page.