Debian Codegraph @

executor-scripts/linux/mpls

raw
1 #!/bin/sh
2 #
3 # Maximilian Wilhelm <[email protected]>
4 # -- Thu, 17 Dec 2020 03:02:10 +0100
5 #
6 # This executor is responsible for setting up MPLS decapsulation on a given interface.
7 #
8 # See interfaces-mpls(5) for a list of supported options.
9 #
10
11 yesno() {
12 case "$1" in
13 yes|1) echo 1 ;;
14 *) echo 0 ;;
15 esac
16 }
17
18 [ -z "$VERBOSE" ] || set -x
19
20 # We only operate in pre-up phase
21 [ "$PHASE" != "pre-up" ] && exit 0
22
23
24 if [ "$IF_MPLS_ENABLE" ]; then
25 value=$(yesno $IF_MPLS_ENABLE)
26
27 # Load mpls module if we should enable MPLS decap on (at least) one interface
28 if [ "${value}" = 1 ]; then
29 ${MOCK} modprobe mpls_iptunnel
30 fi
31
32 # If MPLS support isn't loaded and we are not MOCKing, carry on
33 if [ -f "/proc/sys/net/mpls/conf/$IFACE/input" -o "${MOCK}" ]; then
34 ${MOCK} /bin/sh -c "echo ${value} > /proc/sys/net/mpls/conf/$IFACE/input"
35 fi
36 fi