Skip to content

Commit

Permalink
zeth-vlan: Add priority mapping config file
Browse files Browse the repository at this point in the history
The zeth-vlan-priority.conf file contains commands that setup
socket priority to VLAN priority mapping.

Signed-off-by: Jukka Rissanen <[email protected]>
  • Loading branch information
jukkar committed May 14, 2020
1 parent c4fedea commit f89636e
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions zeth-vlan-priority.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Configuration file for setting IP addresses for a network interface
# and setting up two VLANs and one non-VLAN interfaces.

INTERFACE="$1"

HWADDR="00:00:5e:00:53:ff"

VLAN_NAME_PREFIX="vlan"
VLAN_1_ID=100
VLAN_2_ID=200

PREFIX_1_IPV6="2001:db8:100"
PREFIXLEN_1_IPV6="64"
PREFIX_2_IPV6="2001:db8:200"
PREFIXLEN_2_IPV6="64"

# From RFC 5737
PREFIX_1_IPV4="198.51.100"
PREFIXLEN_1_IPV4="24"
PREFIX_2_IPV4="203.0.113"
PREFIXLEN_2_IPV4="24"

IPV6_ADDR_1="2001:db8::2"
IPV6_ROUTE_1="2001:db8::/64"

IPV4_ADDR_1="192.0.2.2/24"
IPV4_ROUTE_1="192.0.2.0/24"

ip link set dev ${INTERFACE} up

ip link set dev ${INTERFACE} address ${HWADDR}

ip -6 address add ${IPV6_ADDR_1} dev ${INTERFACE}
ip -6 route add ${IPV6_ROUTE_1} dev ${INTERFACE}
ip address add ${IPV4_ADDR_1} dev ${INTERFACE}
ip route add ${IPV4_ROUTE_1} dev ${INTERFACE}

iptables -t mangle -A POSTROUTING -o ${VLAN_NAME_PREFIX}.${VLAN_1_ID} \
-j CLASSIFY --set-class "0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7"
ip link add link ${INTERFACE} name ${VLAN_NAME_PREFIX}.${VLAN_1_ID} \
type vlan id ${VLAN_1_ID} \
ingress-qos-map 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7 \
egress-qos-map 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7

iptables -t mangle -A POSTROUTING -o ${VLAN_NAME_PREFIX}.${VLAN_2_ID} \
-j CLASSIFY --set-class "0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7"
ip link add link ${INTERFACE} name ${VLAN_NAME_PREFIX}.${VLAN_2_ID} \
type vlan id ${VLAN_2_ID} \
ingress-qos-map 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7 \
egress-qos-map 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7

ip link set ${VLAN_NAME_PREFIX}.${VLAN_1_ID} up
ip link set ${VLAN_NAME_PREFIX}.${VLAN_2_ID} up

ip -6 addr add ${PREFIX_1_IPV6}::2 dev ${VLAN_NAME_PREFIX}.${VLAN_1_ID}
ip -6 route add ${PREFIX_1_IPV6}::/${PREFIXLEN_1_IPV6} \
dev ${VLAN_NAME_PREFIX}.${VLAN_1_ID}

ip -6 addr add ${PREFIX_2_IPV6}::2 dev ${VLAN_NAME_PREFIX}.${VLAN_2_ID}
ip -6 route add ${PREFIX_2_IPV6}::/${PREFIXLEN_2_IPV6} \
dev ${VLAN_NAME_PREFIX}.${VLAN_2_ID}

ip addr add ${PREFIX_1_IPV4}.2/${PREFIXLEN_1_IPV4} \
dev ${VLAN_NAME_PREFIX}.${VLAN_1_ID}
ip route add ${PREFIX_1_IPV4}/${PREFIXLEN_1_IPV4} \
dev ${VLAN_NAME_PREFIX}.${VLAN_1_ID}

ip addr add ${PREFIX_2_IPV4}.2/${PREFIXLEN_2_IPV4} \
dev ${VLAN_NAME_PREFIX}.${VLAN_2_ID}
ip route add ${PREFIX_2_IPV4}/${PREFIXLEN_2_IPV4} \
dev ${VLAN_NAME_PREFIX}.${VLAN_2_ID}

0 comments on commit f89636e

Please sign in to comment.