From 055bf6a8e0c3ed5b39ca215346be40c0b95974f3 Mon Sep 17 00:00:00 2001 From: Ralph Ronnquist Date: Tue, 19 Oct 2021 20:01:56 +1100 Subject: [PATCH] allow iface block without actual interface --- rrqnet-ifupdown.sh | 22 ++++++++++++++++------ rrqnet-ifupdown.sh.8.adoc | 17 ++++++++++------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/rrqnet-ifupdown.sh b/rrqnet-ifupdown.sh index b36131e..4c6ce4d 100755 --- a/rrqnet-ifupdown.sh +++ b/rrqnet-ifupdown.sh @@ -18,7 +18,7 @@ [ -z "$IF_RRQNET_PORT" ] && exit 0 # An rrqnet stanza may have the following settings: -# rrqnet_port +# rrqnet_port [ notap ] # rrqnet_nice # rrqnet_remote # rrqnet_options @@ -29,6 +29,9 @@ : ${RRQDAEMON:=/usr/sbin/rrqnet} : ${NAME:=rrqnet-${IFACE}} +NOTAP="${IF_RRQNET_PORT##notap *}" # empty if 'notap' is used +IF_RRQNET_PORT="${IF_RRQNET_PORT#notap }" + #function configure_tap_bridge() { [ -z "$IF_RRQNET_BRIDGE" ] && return 0 @@ -67,18 +70,25 @@ stop_dhclient() { #function start_cable_pre_up() { - configure_tap_up || return 1 - configure_tap_bridge || return 1 + local TAP + TAP="-t $IFACE" + if [ -z "$NOTAP" ] ; then + echo "Note: $IFACE is an rrqnet without local interface" >&2 + TAP="" + else + configure_tap_up || return 1 + configure_tap_bridge || return 1 + fi [ -z "$IF_RRQNET_NICE" ] || \ RRQDAEMON="/usr/bin/nice -n $IF_RRQNET_NICE $RRQDAEMON" if [ -z "$IF_RRQNET_LOG" ] ; then daemon -U -r -a 10 -n $NAME -- \ $RRQDAEMON $IF_RRQNET_OPTIONS \ - -t $IFACE $IF_RRQNET_PORT $IF_RRQNET_REMOTE + $TAP $IF_RRQNET_PORT $IF_RRQNET_REMOTE else daemon -U -r -a 10 -n $NAME -E "${IF_RRQNET_LOG#* }" -- \ $RRQDAEMON ${IF_RRQNET_LOG%% *} $IF_RRQNET_OPTIONS \ - -t $IFACE $IF_RRQNET_PORT $IF_RRQNET_REMOTE + $TAP $IF_RRQNET_PORT $IF_RRQNET_REMOTE fi } @@ -109,7 +119,7 @@ stop_cable_pre_down() { #function stop_cable_post_down() { - ip link del $IFACE + [ -z "$NOTAP" ] || ip link del $IFACE } # main script body diff --git a/rrqnet-ifupdown.sh.8.adoc b/rrqnet-ifupdown.sh.8.adoc index 787b294..90a502c 100644 --- a/rrqnet-ifupdown.sh.8.adoc +++ b/rrqnet-ifupdown.sh.8.adoc @@ -33,16 +33,19 @@ addresses. This script handles the special purpose "option codes" for the IFACE blocks that are used for declaring the +rrqnet+ daemon configuration to for the +tap+ interface for its virtual cabling. I.e., the IFACE -stanza is made for the tap interface and it includes one or more of +block is made for the tap interface and it includes one or more of these +rrqnet+ options. The list of IFACE options for +rrqnet+ are: -*rrqnet_port* _port_:: +*rrqnet_port* [ notap ] _port_:: -This IFACE option is required both as way of marking that the stanza -is for an +rrqnet+ virtual cable +tap+, and to declare which UDP port -the +rrqnet+ daemon should listen on for incoming cabling. +This IFACE option is required both as way of marking that the +configuration block is for an +rrqnet+ virtual cable +tap+, and to +declare which UDP port the +rrqnet+ daemon should listen on for +incoming cabling. The port number may be preceded by +notap+ to +indcate that this +rrqnet+ should not have an actual tap interface on +the host but rather only serve to interconnect remote connections. *rrqnet_nice* _nice_:: @@ -109,8 +112,8 @@ iface mynet0 inet static The above example declares a virtual cable plug for UDP port +3636+ tunneling through host +111.222.333.444+ port +3636+ where the local +tap+ +mynet0+ has ipv4 address +10.0.0.2+. The +rrqnet_port+ option -marks the stanza as an ++rrqnet+ virtual cabling set up which then is -duly handled by +rrqnet-ifupdown.sh+. +marks the IFACE block as an ++rrqnet+ virtual cabling set up which +then is duly handled by +rrqnet-ifupdown.sh+. The +rrqnet_options+ in the example tells the +rrqnet+ process to use an ipv4-only socket, 10 packet buffers and a single delivery thread, -- 2.39.2