Commit 08f3e650 authored by nanahira's avatar nanahira

online check

parent 85cb96f2
......@@ -3,19 +3,23 @@
source {{ansible_user_dir}}/nextgen-router/scripts/utility.sh
export BRIDGE_NAME={{br.name}}
{% if br.macvlan is defined and br.macvlan %}
# macvlans
{% if br.linkUp is defined and br.linkUp %}
{{br.linkUp}}
{% endif %}
{% for link in br.links %}
# macvlan {{br.name}}-{{link | regex_replace('\.', '-')}} of {{link}}
# link {{link}}
## Ensure link is up
_wait_for_interface_online "{{link}}"
{% if br.macvlan is defined and br.macvlan %}
## macvlan {{br.name}}-{{link | regex_replace('\.', '-')}} of {{link}}
ip link add link {{link}} dev {{br.name}}-{{link | regex_replace('\.', '-')}} type macvlan
ip link set {{br.name}}-{{link | regex_replace('\.', '-')}} up
{% endfor %}
{% endif %}
{% endfor %}
{% if br.linkUp is defined and br.linkUp %}
{{br.linkUp}}
{% endif %}
{% if br.mac is defined and br.mac %}
# Change mac
......
#!/bin/bash
source {{ansible_user_dir}}/nextgen-router/scripts/utility.sh
_wait_for_interface_online {{ppp.link}}
ip link add link {{ppp.link}} dev pppm{{ppp.id}} type macvlan
ip link set pppm{{ppp.id}} up
{% if ppp.mac is defined and ppp.mac %}
......
......@@ -43,3 +43,18 @@ eth_origin() {
iptables -t mangle "$OPTION" PREROUTING ! -p ospf -i "$BRIDGE_NAME" -m mac --mac-source "$GATEWAY_MAC" -m set ! --match-set localnet src -j CONNMARK --set-xmark "$MARK"
# ip6tables -t mangle "$OPTION" PREROUTING ! -p ospf -i "$BRIDGE_NAME" -m mac --mac-source "$GATEWAY_MAC" -m set ! --match-set localnet src -j CONNMARK --set-xmark "$MARK"
}
_wait_for_interface_online() {
INTERFACE=$1
echo "Waiting for interface $INTERFACE."
CURRENT_STATUS=1
while [[ "$CURRENT_STATUS" != 0 ]]; do
ifconfig "$INTERFACE" | grep 'RUNNING'
CURRENT_STATUS=$?
if [[ "$CURRENT_STATUS" != 0 ]]; then
echo "Interface $INTERFACE is bad. Will try again after 3s."
sleep 3
fi
done
echo "Interface $INTERFACE is OK."
}
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