Commit e65646dc authored by Dimitris Aragiorgis's avatar Dimitris Aragiorgis

Create examples dir

..and add interfaces, vmrouter ifup and ifdown scripts, and
prv-net-helper.
Signed-off-by: default avatarDimitris Aragiorgis <dimara@grnet.gr>
parent 60d4b2a5
#!/bin/bash
function usage {
echo "Usage: $0 <mode> <parent interface> <prv min> <prv max> <offset>"
exit 1
}
if [ $# -ne 5 ]; then
usage
fi
function up {
iface=$1
prv_min=$2
prv_max=$3
offset=$4
echo "Adding VLANs $2 - $3"
vconfig set_name_type DEV_PLUS_VID_NO_PAD
for prv in $(seq $prv_min $prv_max); do
vlan=$(($prv+$offset))
bridge=prv$prv
vconfig add $iface $vlan
ifconfig $iface.$vlan up
brctl addbr $bridge
brctl setfd $bridge 0
brctl addif $bridge $iface.$vlan # dev_plus_vid
ifconfig $bridge up
done
}
function down {
iface=$1
prv_min=$2
prv_max=$3
offset=$4
echo "Removing VLANs $2 - $3"
for prv in $(seq $prv_min $prv_max); do
vlan=$(($prv+$offset))
bridge=prv$prv
(
ifconfig $bridge down
brctl delif $bridge $iface.$vlan # dev_plus_vid
vconfig rem $iface.$vlan
brctl delbr $bridge
) 2>/dev/null
done
}
mode=$1; shift
if [ "$mode" = "up" ]; then
up $@
elif [ "$mode" = "down" ]; then
down $@
else
usage
fi
#!/bin/bash
if [ ! -n "$IF_IP_ROUTING_TABLE" ]; then
# bail out early if there's no ip-routing-table defined
exit 0
fi
if [ "$ADDRFAM" = "inet" ]; then
IP="ip"
elif [ "$ADDRFAM" = "inet6" ]; then
IP="ip -6"
else
exit 0
fi
while $IP rule del iif $IFACE;do :; done 2>/dev/null
if [ "$ADDRFAM" = "inet" ]; then
if [ -n "$IF_ARP_IP" ]; then
arptables -D OUTPUT -o $IFACE --opcode request -j mangle 2>/dev/null || true
fi
fi
#!/bin/bash
#
# if-up.d hook to do some weird networking stuff on IP-less interfaces
#
# Example:
#
# auto bond0.90
# iface bond0.90 inet manual
# ip-routing-table 90
# ip-routes 192.0.2.0/24
# ip-gateway 192.0.2.1
# ip-forwarding 1
# ip-proxy-arp 1
# arp-ip 192.0.2.254
#
# iface bond0.90 inet6 manual
# ip-routing-table 90
# ip-routes 2001:db8::/64
# ip-gateway 2001:db8::1
# ip-forwarding 1
# ip-proxy-ndp 1
PATH=/usr/sbin:/usr/bin:/sbin:/bin
ip link set $IFACE up
if [ "$ADDRFAM" = "inet" ]; then
IP="ip"
elif [ "$ADDRFAM" = "inet6" ]; then
IP="ip -6"
else
exit 0
fi
if [ -n "$IF_IP_ROUTING_TABLE" ]; then
TABLE="table $IF_IP_ROUTING_TABLE"
else
# bail out early if there's no ip-routing-table defined
exit 0
fi
while $IP rule del iif $IFACE;do :; done 2>/dev/null
$IP rule add iif $IFACE $TABLE
for route in $IF_IP_ROUTES; do
$IP route add $route dev $IFACE table main
$IP route add $route dev $IFACE $TABLE
done
if [ -n "$IF_IP_GATEWAY" ]; then
$IP route add default via $IF_IP_GATEWAY dev $IFACE $TABLE
fi
if [ -n "$IF_IP_FORWARDING" ]; then
[ "$ADDRFAM" = "inet" ] && echo 1 > /proc/sys/net/ipv4/conf/all/forwarding
[ "$ADDRFAM" = "inet6" ] && echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
fi
[ "$IF_IP_PROXY_NDP" = "1" ] && [ "$ADDRFAM" = "inet6" ] && echo 1 > /proc/sys/net/ipv6/conf/$IFACE/proxy_ndp
if [ "$ADDRFAM" = "inet" ]; then
if [ -n "$IF_ARP_IP" ]; then
arptables -D OUTPUT -o $IFACE --opcode request -j mangle 2>/dev/null || true
arptables -A OUTPUT -o $IFACE --opcode request -j mangle --mangle-ip-s $IF_ARP_IP
fi
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment