1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0-or-later 3# Copyright (c) 2018 Oracle and/or its affiliates. All Rights Reserved. 4 5TST_SETUP="setup" 6TST_TESTFUNC="test" 7TST_CLEANUP="cleanup" 8TST_CNT=3 9TST_MIN_KVER="4.1" 10TST_NEEDS_TMPDIR=1 11TST_NEEDS_ROOT=1 12TST_NEEDS_DRIVERS="mpls_router" 13TST_NEEDS_CMDS="sysctl modprobe" 14 15. tst_net.sh 16 17cleanup() 18{ 19 ip -f mpls route flush dev lo > /dev/null 2>&1 20 ip -f mpls route flush dev $(tst_iface) > /dev/null 2>&1 21} 22 23setup() 24{ 25 ROD modprobe mpls_router 26} 27 28test1() 29{ 30 ROD sysctl -q net.mpls.platform_labels=0xfffff 31 ROD ip -f mpls route add 0xffffe dev lo 32 ROD ip -f mpls route show \> /dev/null 33 ROD ip -f mpls route del 0xffffe dev lo 34 tst_res TPASS "added label 0xffffe to lo dev" 35} 36 37test2() 38{ 39 ROD sysctl -q net.mpls.platform_labels=0xffffe 40 ip -f mpls route add 0xffffe dev lo > /dev/null 2>&1 41 if [ $? -eq 0 ]; then 42 tst_res TFAIL "can add label that is >= platform_labels" 43 return 44 fi 45 46 tst_res TPASS "can't add label >= platform_lables" 47} 48 49test3() 50{ 51 local start=16 52 local end=$((start + NS_TIMES)) 53 54 ROD sysctl -q net.mpls.platform_labels=$((end + 1)) 55 tst_res TINFO "creating mpls routes with labels from $start..$end" 56 for l in $(seq $start $end); do 57 ROD ip -f mpls route add $l dev $(tst_iface) 58 done 59 60 tst_res TINFO "listing created routes" 61 ROD ip -f mpls route show \> /dev/null 62 63 tst_res TINFO "removing the routes" 64 for l in $(seq $start $end); do 65 ROD ip -f mpls route del $l dev $(tst_iface) 66 done 67 tst_res TPASS "created and removed mpls routes" 68} 69 70tst_run 71