From a4e2799b90d7dbc205683b5436672b0cf7b1df23 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 23 Feb 2022 17:23:01 +0100 Subject: [PATCH] multi-ap: ts rework for eth suport --- map-agent/files/lib/wifi/traffic_separation | 160 ++++++++++++-------- 1 file changed, 95 insertions(+), 65 deletions(-) diff --git a/map-agent/files/lib/wifi/traffic_separation b/map-agent/files/lib/wifi/traffic_separation index 307d66914..3bbe15822 100755 --- a/map-agent/files/lib/wifi/traffic_separation +++ b/map-agent/files/lib/wifi/traffic_separation @@ -64,21 +64,26 @@ EOF iface=$1 # real iface vid=$2 # Vlan ID bridge=$3 # bridge iface should be connected + vlan_dev=$4 + old_bridge="$(_get_bridge $iface)" # bridge iface is connected to - vlan_dev=${iface}_vlan${vid} # name of vlan device to create # remove interface from bridge if it is in one [ -n "$old_bridge" ] && brctl delif $old_bridge $iface &> /dev/null - # create vlan device - ip link show $vlan_dev &> /dev/null && vlanctl --if-delete $vlan_dev &> /dev/null + # (re)create vlan device + ip link show $vlan_dev && vlanctl --if-delete $vlan_dev vlanctl --mcast --if-create-name $iface $vlan_dev --if $iface --set-if-mode-rg + vlanctl --if $iface --tx --tags 0 --default-miss-drop + vlanctl --if $iface --tx --tags 1 --default-miss-drop + vlanctl --if $iface --tx --tags 2 --default-miss-drop + vlanctl --if $iface --rx --tags 0 --default-miss-drop + vlanctl --if $iface --rx --tags 1 --default-miss-drop + vlanctl --if $iface --rx --tags 2 --default-miss-drop + # bring the vlan device up and add back to bridge if it was in one brctl addif $bridge $vlan_dev &> /dev/null - ip link set $vlan_dev up - - echo $vlan_dev } ts_create_fh() { @@ -94,59 +99,32 @@ EOF } # create vlan device - set_wireless_bridge $iface $bridge - vlan_dev=$(_create_vlan_dev $iface $vid $bridge) + #set_wireless_bridge $iface $bridge + + vlan_dev=${iface}_vlan${vid} + ip link set $vlan_dev down + _create_vlan_dev $iface $vid $bridge $vlan_dev # add rules - # Note: removing these for now since these packets are read directly from the iface anyway -# vlanctl --if $iface --rx --tags 0 --filter-ethertype 0x888e --set-rxif $vlan_dev --rule-append # incoming EAPOL # vlanctl --if $iface --rx --tags 0 --filter-ethertype 0x886c --set-rxif $vlan_dev --rule-append # incoming brcm + + # EAPOL frames + vlanctl --if $iface --rx --tags 0 --filter-ethertype 34958 --set-rxif $vlan_dev --rule-append + vlanctl --if $iface --rx --tags 1 --filter-ethertype 34958 --pop-tag --set-rxif $vlan_dev --rule-append + vlanctl --if $iface --tx --tags 0 --filter-txif $vlan_dev --filter-ethertype 34958 --rule-append + + # 8021q vlan id TAG/UNTAG vlanctl --if $iface --rx --tags 0 --set-rxif $vlan_dev --push-tag --set-vid $vid 0 --rule-append vlanctl --if $iface --tx --tags 1 --filter-txif $vlan_dev --filter-vid $vid 0 --pop-tag --dscp2pbits 0 --rule-append + + ip link set $iface up + ip link set $vlan_dev up } -# Note: Currently not used (will be needed for Profile 1) ts_create_bh() { iface=$1 # bh iface vid=$2 # primary vid profile=$3 # agent profile (1 or 2) - - [ -n "$iface" ] && [ -n "$vid" ] && [ -n "$profile" ] || { - cat < /dev/null } - ts_create_eth() { - iface=$1 # Multi-AP Logical Ethernet Interface - vid=$2 # primary vid - pbits=$3 # default pbits to apply - vlan_bridge=$4 # name of ts subsystem bridge - lan_bridge=$5 # name of node local bridge + ts_create_lei() { + vid=$1 # primary vid + pbits=$2 # default pbits to apply + vlan_bridge=$3 # name of ts subsystem bridge + lan_bridge=$4 # name of node local bridge - [ -n "$iface" ] && [ -n "$vid" ] && [ -n "$pbits" ] && [ -n "$vlan_bridge" ] && [ -n "$lan_bridge" ] || { + [ -n "$vid" ] && [ -n "$pbits" ] && [ -n "$vlan_bridge" ] && [ -n "$lan_bridge" ] || { cat < /dev/null || { + ip link add link lei name lei_lan type vlan id 1 2>/dev/null + } - old_bridge="$(_get_bridge lei_lan)" - [ -n "$old_bridge" ] && brctl delif $old_bridge lei_lan &> /dev/null + old_vid=$(ip -d link show lei_lan | sed -n 's/vlan.*id \([0-9][0-9]*\) .*/\1/p') - ip link show lei_lan || ip link del lei_lan - ip link add link lei name lei_lan type vlan id ${vid} + [ "$old_vid" != "$vid" ] && { + ip link del lei_lan + ip link add link lei name lei_lan type vlan id ${vid} + } brctl addif ${lan_bridge} lei_lan &>/dev/null brctl addif ${vlan_bridge} lei_map &>/dev/null @@ -202,6 +181,57 @@ EOF ip link set lei_lan up } + _create_eth() { + iface=$1 # Multi-AP Logical Ethernet Interface + vid=$2 # primary vid + bridge=$3 # name of ts subsystem bridge + pbits=0 + + [ -n "$iface" ] && [ -n "$vid" ] && [ -n "$bridge" ] || { + cat <