-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #441 from tiiuae/upgrade-cbma-to-v0.1.3
- Loading branch information
Showing
6 changed files
with
175 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
GIT_VERSION=v0.1.2-old_requirements_fixes | ||
GIT_SHA=845b15b2bdf90862d40ec851066a8319552118dc | ||
EPOCH_TIMESTAMP=1711146541 | ||
PRECISE_DATE_TIMESTAMP="2024-03-22 - 22:29:01.515125682" | ||
GIT_VERSION=v0.1.3-old_requirements_fixes | ||
GIT_SHA=9092b41ff906eb78dbeacf4e43cb2dcb2e3d5ec2 | ||
EPOCH_TIMESTAMP=1713779760 | ||
PRECISE_DATE_TIMESTAMP="2024-04-22 - 09:56:00.316748021" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
modules/sc-mesh-secure-deployment/src/nats/cbma/scripts/mess/cleanup_bridge.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
|
||
export SCN='/sys/class/net' | ||
|
||
cleanup_bridge_if_needed() | ||
{ | ||
for I in $SCN/$MACBR_NAME/lower_*; do | ||
if [ "$I" = "$SCN/$MACBR_NAME/lower_*" ]; then | ||
ebtables -t nat -D OUTPUT -j "$MACBR_NAME" --logical-out "$MACBR_NAME" | ||
ebtables -t nat -X "$MACBR_NAME" | ||
ip link delete "$MACBR_NAME" | ||
fi | ||
break | ||
done | ||
} | ||
|
||
if [ $# -ne 2 ]; then | ||
>&2 echo "Usage: $0 u bat0" | ||
>&2 echo "Usage: $0 l wlan0" | ||
exit 1 | ||
fi | ||
export L_OR_U="$1" | ||
export BASE_INTERFACE_NAME="$2" | ||
|
||
MAC_REGEX='[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}' | ||
if ! grep -Eiqx "$MAC_REGEX" "$SCN/$BASE_INTERFACE_NAME/address"; then | ||
>&2 echo "Error: '$BASE_INTERFACE_NAME' does not look like a usable interface" | ||
exit 2 | ||
fi | ||
export LOCAL_MAC=`cat "$SCN/$BASE_INTERFACE_NAME/address"` | ||
export MACBR_NAME=`echo "${L_OR_U}mb$LOCAL_MAC" | tr -d ':'` | ||
|
||
# Workaround to use ebtables-legacy as "--logical-out" seems to be broken in ebtables-nft | ||
if ! ebtables -V | grep -iq legacy; then | ||
! type ebtables-legacy >/dev/null 2>&1 || alias ebtables="ebtables-legacy" | ||
fi | ||
|
||
cleanup_bridge_if_needed | ||
exit $? |
75 changes: 75 additions & 0 deletions
75
modules/sc-mesh-secure-deployment/src/nats/cbma/scripts/mess/create_bridge.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/bin/bash | ||
|
||
|
||
# kernel bugs force MACSEC_OVERHEAD=24 in create_macscbub_interface() but should still be ok | ||
export MACSEC_OVERHEAD=16 | ||
|
||
# needs more testing, an overhead of 32 might even occur if batman-adv uses 4 address mode | ||
export BATMAN_OVERHEAD=24 | ||
|
||
export HOPEFULLY1500=1400 | ||
export SCN='/sys/class/net' | ||
|
||
|
||
create_bridge_if_needed() | ||
{ | ||
if [ ! -e "$SCN/$MACBR_NAME/bridge" ]; then | ||
if ! ip link add name "$MACBR_NAME" address "$LOCAL_MAC" mtu "$MACBR_MTU" type bridge; then | ||
return `false` | ||
fi | ||
ip link set dev "$MACBR_NAME" group "$GROUP_ID" || true | ||
ip link set dev "$MACBR_NAME" arp off || true | ||
ip link set dev "$MACBR_NAME" multicast off || true | ||
ip link set dev "$MACBR_NAME" alias "$LEVEL MACVLAN/MACsec bridge above $BASE_INTERFACE_NAME" || true | ||
ip link set dev "$MACBR_NAME" addrgenmode eui64 || true | ||
ip link set dev "$MACBR_NAME" type bridge no_linklocal_learn 1 || true | ||
ebtables -t nat -N "$MACBR_NAME" || true | ||
ebtables -t nat -A OUTPUT -j "$MACBR_NAME" --logical-out "$MACBR_NAME" || true | ||
if ! ip link set dev "$MACBR_NAME" up \ | ||
|| ! batctl meshif "$BATMAN_NAME" interface add "$MACBR_NAME"; then | ||
ip link delete "$MACBR_NAME" | ||
return `false` | ||
fi | ||
fi | ||
} | ||
|
||
|
||
if [ $# -ne 2 ]; then | ||
>&2 echo "Usage: $0 u bat0" | ||
>&2 echo "Usage: $0 l wlan0" | ||
exit 1 | ||
fi | ||
export L_OR_U="$1" | ||
export BASE_INTERFACE_NAME="$2" | ||
|
||
case "$L_OR_U" in | ||
u) | ||
export LEVEL='Upper' | ||
export BATMAN_NAME='bat1' | ||
export MACBR_MTU=$(( $HOPEFULLY1500 + $BATMAN_OVERHEAD )) | ||
;; | ||
l) | ||
export LEVEL='Lower' | ||
export BATMAN_NAME='bat0' | ||
export MACBR_MTU=$(( $HOPEFULLY1500 + $BATMAN_OVERHEAD + $MACSEC_OVERHEAD + $BATMAN_OVERHEAD )) | ||
;; | ||
*) | ||
>&2 echo "Error: unknown level '$L_OR_U'" | ||
exit 2 | ||
esac | ||
MAC_REGEX='[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}' | ||
if ! grep -Eiqx "$MAC_REGEX" "$SCN/$BASE_INTERFACE_NAME/address"; then | ||
>&2 echo "Error: '$BASE_INTERFACE_NAME' does not look like a usable interface" | ||
exit 3 | ||
fi | ||
export GROUP_ID=`cat "$SCN/$BASE_INTERFACE_NAME/ifindex"` | ||
export LOCAL_MAC=`cat "$SCN/$BASE_INTERFACE_NAME/address"` | ||
export MACBR_NAME=`echo "${L_OR_U}mb$LOCAL_MAC" | tr -d ':'` | ||
|
||
# Workaround to use ebtables-legacy as "--logical-out" seems to be broken in ebtables-nft | ||
if ! ebtables -V | grep -iq legacy; then | ||
! type ebtables-legacy >/dev/null 2>&1 || alias ebtables="ebtables-legacy" | ||
fi | ||
|
||
create_bridge_if_needed | ||
exit $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters