1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #18836 from benpicco/gnrc_border_router-native

examples/gnrc_border_router: add option to re-use existing TAP interface
This commit is contained in:
benpicco 2022-12-07 22:34:01 +01:00 committed by GitHub
commit 154b1d6397
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 52 additions and 12 deletions

View File

@ -25,7 +25,9 @@ remove_tap() {
cleanup() {
echo "Cleaning up..."
remove_tap
if [ "${CREATE_TAP}" -eq 1 ]; then
remove_tap
fi
if [ -n "${UHCPD_PID}" ]; then
kill "${UHCPD_PID}"
fi
@ -64,6 +66,13 @@ start_zep_dispatch() {
ZEP_DISPATCH_PID=$!
}
if [ "$1" = "-c" ] || [ "$1" = "--create-tap" ]; then
CREATE_TAP=1
shift 1
else
CREATE_TAP=0
fi
if [ "$1" = "-d" ] || [ "$1" = "--use-dhcpv6" ]; then
USE_DHCPV6=1
shift 1
@ -101,7 +110,9 @@ for TAP in "$@"; do :; done
trap "cleanup" INT QUIT TERM EXIT
create_tap
if [ ${CREATE_TAP} -eq 1 ]; then
create_tap
fi
if [ ${USE_ZEP_DISPATCH} -eq 1 ]; then
start_zep_dispatch

View File

@ -43,7 +43,7 @@ USEMODULE += ps
#USEMODULE += gnrc_ipv6_nib_dns # include RDNSS option handling
# When using a regular network uplink we should use DHCPv6
ifneq (,$(filter cdc-ecm wifi ethernet,$(UPLINK)))
ifneq (,$(filter cdc-ecm wifi ethernet,$(UPLINK)) $(REUSE_TAP))
PREFIX_CONF ?= dhcpv6
else
PREFIX_CONF ?= uhcp

View File

@ -1,14 +1,21 @@
CFLAGS += -DETHOS_BAUDRATE=$(ETHOS_BAUDRATE)
STATIC_ROUTES ?= 1
ifeq (dhcpv6,$(PREFIX_CONF))
FLAGS_EXTRAS=--use-dhcpv6
else ifeq (auto_subnets,$(PREFIX_CONF))
FLAGS_EXTRAS=--use-radvd
endif
# Configure terminal parameters
ifeq (1, $(REUSE_TAP))
# Use ethos directly
TERMPROG ?= $(RIOTTOOLS)/ethos/ethos
TERMFLAGS ?= $(TAP) $(PORT) $(ETHOS_BAUDRATE)
else
STATIC_ROUTES ?= 1
# Set up network, ethos started by start_network.sh
TERMPROG ?= sudo sh $(RIOTTOOLS)/ethos/start_network.sh
TERMFLAGS ?= $(FLAGS_EXTRAS) $(PORT) $(TAP) $(IPV6_PREFIX) $(ETHOS_BAUDRATE)
endif
TERMDEPS += host-tools
TERMPROG ?= sudo sh $(RIOTTOOLS)/ethos/start_network.sh
TERMFLAGS ?= $(FLAGS_EXTRAS) $(PORT) $(TAP) $(IPV6_PREFIX) $(ETHOS_BAUDRATE)

View File

@ -9,10 +9,14 @@ CFLAGS += -DASYNC_READ_NUMOF=$(shell expr $(ZEP_DEVICES) + 1)
# Set CFLAGS if not being set via Kconfig
CFLAGS += $(if $(CONFIG_KCONFIG_MODULE_DHCPV6),,-DCONFIG_DHCPV6_CLIENT_PFX_LEASE_MAX=$(ZEP_DEVICES))
ifeq (dhcpv6,$(PREFIX_CONF))
FLAGS_EXTRAS += --use-dhcpv6
else ifeq (auto_subnets,$(PREFIX_CONF))
FLAGS_EXTRAS += --use-radvd
# create a new TAP interface if not re-using an existing one
ifneq (1, $(REUSE_TAP))
FLAGS_EXTRAS += --create-tap
ifeq (dhcpv6,$(PREFIX_CONF))
FLAGS_EXTRAS += --use-dhcpv6
else ifeq (auto_subnets,$(PREFIX_CONF))
FLAGS_EXTRAS += --use-radvd
endif
endif
# enable the ZEP dispatcher
@ -30,3 +34,6 @@ TERMFLAGS ?= $(patsubst %,-z [::1]:%, $(shell seq $(ZEP_PORT_BASE) $(ZEP_PORT_MA
ifneq (,$(ZEP_MAC))
TERMFLAGS += --eui64=$(ZEP_MAC)
endif
# native uses $PORT to specify the TAP interface
PORT ?= $(TAP)

View File

@ -44,6 +44,21 @@ credentials. You can alternatively edit the `Makefile`.
Currently, `wifi` requires an esp8266 or esp32 for the border router and will default
to using `esp_now` for the downstream interface.
### Connection sharing with host
If the host (Linux) computer has an IPv6 uplink that can be shard with the RIOT border
router to provide it with an uplink.
This requires the host network to be bridged with the TAP network by connecting it to
the TAP bridge:
sudo dist/tools/tapsetup/tapsetup -u eno1
where `eno1` is the host's uplink interface.
Then specify `REUSE_TAP=1` when building / running the border router application.
This works with both `native` and the `ethos` uplink.
## Requirements
This functionality works only on Linux machines.