cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

router_bridge.sh (1794B)


      1#!/bin/bash
      2# SPDX-License-Identifier: GPL-2.0
      3
      4ALL_TESTS="
      5	ping_ipv4
      6	ping_ipv6
      7"
      8NUM_NETIFS=4
      9source lib.sh
     10
     11h1_create()
     12{
     13	simple_if_init $h1 192.0.2.1/28 2001:db8:1::1/64
     14	ip -4 route add 192.0.2.128/28 vrf v$h1 nexthop via 192.0.2.2
     15	ip -6 route add 2001:db8:2::/64 vrf v$h1 nexthop via 2001:db8:1::2
     16}
     17
     18h1_destroy()
     19{
     20	ip -6 route del 2001:db8:2::/64 vrf v$h1
     21	ip -4 route del 192.0.2.128/28 vrf v$h1
     22	simple_if_fini $h1 192.0.2.1/28 2001:db8:1::1/64
     23}
     24
     25h2_create()
     26{
     27	simple_if_init $h2 192.0.2.130/28 2001:db8:2::2/64
     28	ip -4 route add 192.0.2.0/28 vrf v$h2 nexthop via 192.0.2.129
     29	ip -6 route add 2001:db8:1::/64 vrf v$h2 nexthop via 2001:db8:2::1
     30}
     31
     32h2_destroy()
     33{
     34	ip -6 route del 2001:db8:1::/64 vrf v$h2
     35	ip -4 route del 192.0.2.0/28 vrf v$h2
     36	simple_if_fini $h2 192.0.2.130/28 2001:db8:2::2/64
     37}
     38
     39router_create()
     40{
     41	ip link add name br1 type bridge vlan_filtering 1
     42	ip link set dev br1 up
     43
     44	ip link set dev $swp1 master br1
     45	ip link set dev $swp1 up
     46	__addr_add_del br1 add 192.0.2.2/28 2001:db8:1::2/64
     47
     48	ip link set dev $swp2 up
     49	__addr_add_del $swp2 add 192.0.2.129/28 2001:db8:2::1/64
     50}
     51
     52router_destroy()
     53{
     54	__addr_add_del $swp2 del 192.0.2.129/28 2001:db8:2::1/64
     55	ip link set dev $swp2 down
     56
     57	__addr_add_del br1 del 192.0.2.2/28 2001:db8:1::2/64
     58	ip link set dev $swp1 down
     59	ip link set dev $swp1 nomaster
     60
     61	ip link del dev br1
     62}
     63
     64setup_prepare()
     65{
     66	h1=${NETIFS[p1]}
     67	swp1=${NETIFS[p2]}
     68
     69	swp2=${NETIFS[p3]}
     70	h2=${NETIFS[p4]}
     71
     72	vrf_prepare
     73
     74	h1_create
     75	h2_create
     76
     77	router_create
     78
     79	forwarding_enable
     80}
     81
     82cleanup()
     83{
     84	pre_cleanup
     85
     86	forwarding_restore
     87
     88	router_destroy
     89
     90	h2_destroy
     91	h1_destroy
     92
     93	vrf_cleanup
     94}
     95
     96ping_ipv4()
     97{
     98	ping_test $h1 192.0.2.130
     99}
    100
    101ping_ipv6()
    102{
    103	ping6_test $h1 2001:db8:2::2
    104}
    105
    106trap cleanup EXIT
    107
    108setup_prepare
    109setup_wait
    110
    111tests_run
    112
    113exit $EXIT_STATUS