-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
silabs-multiprotocol: Make the OTBR infrastructure network interface configurable #3416
Changes from all commits
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 | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -5,73 +5,79 @@ | |||||||
|
||||||||
. /etc/s6-overlay/scripts/otbr-agent-common | ||||||||
|
||||||||
declare backbone_if | ||||||||
declare device | ||||||||
declare baudrate | ||||||||
declare flow_control | ||||||||
declare otbr_log_level | ||||||||
declare otbr_log_level_int | ||||||||
declare otbr_infra_if | ||||||||
declare otbr_rest_listen | ||||||||
declare otbr_rest_listen_port | ||||||||
|
||||||||
backbone_if="$(bashio::api.supervisor 'GET' '/network/info' '' 'first(.interfaces[] | select (.primary == true)) .interface')" | ||||||||
|
||||||||
otbr_log_level=$(bashio::string.lower "$(bashio::config otbr_log_level)") | ||||||||
case "${otbr_log_level}" in | ||||||||
debug) | ||||||||
otbr_log_level_int="7" | ||||||||
otbr_log_level_int='7' | ||||||||
;; | ||||||||
info) | ||||||||
otbr_log_level_int="6" | ||||||||
otbr_log_level_int='6' | ||||||||
;; | ||||||||
notice) | ||||||||
otbr_log_level_int="5" | ||||||||
otbr_log_level_int='5' | ||||||||
;; | ||||||||
warning) | ||||||||
otbr_log_level_int="4" | ||||||||
otbr_log_level_int='4' | ||||||||
;; | ||||||||
error) | ||||||||
otbr_log_level_int="3" | ||||||||
otbr_log_level_int='3' | ||||||||
;; | ||||||||
critical) | ||||||||
otbr_log_level_int="2" | ||||||||
otbr_log_level_int='2' | ||||||||
;; | ||||||||
alert) | ||||||||
otbr_log_level_int="1" | ||||||||
otbr_log_level_int='1' | ||||||||
;; | ||||||||
emergency) | ||||||||
otbr_log_level_int="0" | ||||||||
otbr_log_level_int='0' | ||||||||
;; | ||||||||
*) | ||||||||
bashio::exit.nok "Unknown otbr_log_level: ${otbr_log_level}" | ||||||||
;; | ||||||||
esac | ||||||||
|
||||||||
if [ -z ${backbone_if} ]; then | ||||||||
bashio::log.warning "No primary network interface found! Using static eth0." | ||||||||
backbone_if="eth0" | ||||||||
if bashio::config.has_value 'otbr_infra_if'; then | ||||||||
otbr_infra_if="$(bashio::config 'otbr_infra_if')" | ||||||||
bashio::log.info "Using configured network interface ${otbr_infra_if} for otbr_infra_if." | ||||||||
else | ||||||||
otbr_infra_if="$(bashio::api.supervisor 'GET' '/network/info' '' 'first(.interfaces[] | select (.primary == true)) .interface')" | ||||||||
if [ -n "${otbr_infra_if}" ]; then | ||||||||
bashio::log.info "Using primary network interface ${otbr_infra_if} for otbr_infra_if." | ||||||||
else | ||||||||
bashio::log.warning 'No primary network interface found! Using static eth0 for otbr_infra_if.' | ||||||||
otbr_infra_if='eth0' | ||||||||
Comment on lines
+56
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is actually a bit legacy.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. I thought this seemed like an odd choice for a default, but I didn't want to break anyone if this is actually used somewhere. I will change it. |
||||||||
fi | ||||||||
fi | ||||||||
|
||||||||
mkdir -p /data/thread && ln -sft /var/lib /data/thread || bashio::exit.nok "Could not create directory /var/lib/thread to store Thread data." | ||||||||
mkdir -p /data/thread && ln -sft /var/lib /data/thread || bashio::exit.nok 'Could not create directory /var/lib/thread to store Thread data.' | ||||||||
|
||||||||
if bashio::config.true 'otbr_firewall'; then | ||||||||
bashio::log.info "Setup OTBR firewall..." | ||||||||
bashio::log.info 'Setup OTBR firewall...' | ||||||||
ipset create -exist otbr-ingress-deny-src hash:net family inet6 | ||||||||
ipset create -exist otbr-ingress-deny-src-swap hash:net family inet6 | ||||||||
ipset create -exist otbr-ingress-allow-dst hash:net family inet6 | ||||||||
ipset create -exist otbr-ingress-allow-dst-swap hash:net family inet6 | ||||||||
|
||||||||
ip6tables -N $otbr_forward_ingress_chain | ||||||||
ip6tables -I FORWARD 1 -o $thread_if -j $otbr_forward_ingress_chain | ||||||||
ip6tables -I FORWARD 1 -o "${thread_if}" -j $otbr_forward_ingress_chain | ||||||||
|
||||||||
ip6tables -A $otbr_forward_ingress_chain -m pkttype --pkt-type unicast -i ${thread_if} -j DROP | ||||||||
ip6tables -A $otbr_forward_ingress_chain -m pkttype --pkt-type unicast -i "${thread_if}" -j DROP | ||||||||
ip6tables -A $otbr_forward_ingress_chain -m set --match-set otbr-ingress-deny-src src -j DROP | ||||||||
ip6tables -A $otbr_forward_ingress_chain -m set --match-set otbr-ingress-allow-dst dst -j ACCEPT | ||||||||
ip6tables -A $otbr_forward_ingress_chain -m pkttype --pkt-type unicast -j DROP | ||||||||
ip6tables -A $otbr_forward_ingress_chain -j ACCEPT | ||||||||
|
||||||||
ip6tables -N $otbr_forward_egress_chain | ||||||||
ip6tables -I FORWARD 2 -i $thread_if -j $otbr_forward_egress_chain | ||||||||
ip6tables -I FORWARD 2 -i "${thread_if}" -j $otbr_forward_egress_chain | ||||||||
ip6tables -A $otbr_forward_egress_chain -j ACCEPT | ||||||||
else | ||||||||
# Make sure ip6tables (as used by Docker) allow IP forwarding | ||||||||
|
@@ -80,25 +86,25 @@ else | |||||||
ip6tables-legacy -P FORWARD ACCEPT | ||||||||
fi | ||||||||
|
||||||||
otbr_rest_listen="::" | ||||||||
otbr_rest_listen='::' | ||||||||
otbr_rest_listen_port="$(bashio::addon.port 8081)" | ||||||||
|
||||||||
# If user port is not set, listen on local interface only | ||||||||
if ! bashio::var.has_value "${otbr_rest_listen_port}"; then | ||||||||
otbr_rest_listen="$(bashio::addon.ip_address)" | ||||||||
otbr_rest_listen_port="8081" | ||||||||
otbr_rest_listen_port='8081' | ||||||||
elif [ "${otbr_rest_listen_port}" != "8081" ]; then | ||||||||
bashio::log.warning "Custom OpenThread REST API port is not supported. Using 8081." | ||||||||
otbr_rest_listen_port="8081" | ||||||||
bashio::log.warning 'Custom OpenThread REST API port is not supported. Using 8081.' | ||||||||
otbr_rest_listen_port='8081' | ||||||||
fi | ||||||||
|
||||||||
# Store REST API listen information for check script | ||||||||
echo "${otbr_rest_listen}" > /tmp/otbr-agent-rest-api | ||||||||
echo "${otbr_rest_listen_port}" >> /tmp/otbr-agent-rest-api | ||||||||
|
||||||||
bashio::log.info "Starting otbr-agent..." | ||||||||
bashio::log.info 'Starting otbr-agent...' | ||||||||
exec s6-notifyoncheck -d -s 300 -w 300 -n 0 \ | ||||||||
"/usr/sbin/otbr-agent" -I ${thread_if} -B "${backbone_if}" \ | ||||||||
"/usr/sbin/otbr-agent" -I "${thread_if}" -B "${otbr_infra_if}" \ | ||||||||
--rest-listen-address "${otbr_rest_listen}" \ | ||||||||
-d${otbr_log_level_int} -v \ | ||||||||
"spinel+cpc://cpcd_0?iid=2&iid-list=0" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,15 +25,22 @@ configuration: | |
description: Enable tracing for the Co-Processor Communication daemon. | ||
otbr_enable: | ||
name: Enable OpenThread Border Router | ||
description: Enable OpenThread Border Router agent. | ||
description: Enable the OpenThread Border Router. | ||
otbr_log_level: | ||
name: OpenThread Border Router agent log level | ||
description: >- | ||
Set logging level of the OpenThread Border Router agent (otbr-agent). | ||
otbr_infra_if: | ||
name: OpenThread Border Router infrastructure interface | ||
description: >- | ||
HA host network interface name to bind the "infrastructure" side (vs the | ||
"Thread" side) of the OpenThread Border Router to. By default, the | ||
first interface with an associated default route is used. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We use what is considered primary by NetworkManager. Is the first interface with an associated default what NetworkManager considers primary? 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I said "first" here because we used this code: However, I think (but am not entirely sure) that NetworkManager will only ever have one primary interface, and I think the primary interface is the most recently activated interface that has an associated default route (either IPv4 or IPv6 default route). |
||
otbr_firewall: | ||
name: OTBR firewall | ||
description: >- | ||
Use OpenThread Border Router firewall to block unnecessary traffic. | ||
Configure firewall to block unnecessary traffic to/from the OpenThread | ||
Border Router. | ||
network: | ||
9999/tcp: EmberZNet EZSP/ASH port | ||
8080/tcp: OpenThread Web port | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a particular reason to use this style?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Single quote does not interpolate; Double quote interpolates.
So, the idea is to avoid interpolation when it isn't needed.
Obviously this is a minor nit, so if you don't like this change then I can drop it.