route-change-netlink-if.sh 932 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0-or-later
  3. # Copyright (c) 2020 Petr Vorel <pvorel@suse.cz>
  4. #
  5. # Change route interface
  6. # gw (on rhost): 10.23.x.1, rhost: 10.23.0.1, switching ifaces on lhost
  7. # lhost (iface set, but not specified in Netlink API): 10.23.x.2
  8. TST_SETUP="setup"
  9. TST_CLEANUP="cleanup_if"
  10. TST_TESTFUNC="test_netlink"
  11. . route-lib.sh
  12. setup()
  13. {
  14. local gw gw_all iface iface_all
  15. local cnt=0
  16. tst_res TINFO "change IPv$TST_IPVER route interface $ROUTE_CHANGE_NETLINK times"
  17. setup_if
  18. while [ $cnt -lt $(tst_get_ifaces_cnt) ]; do
  19. gw="$(tst_ipaddr_un -n1 $cnt 1)"
  20. iface="$(tst_iface lhost $cnt)"
  21. lhost="$(tst_ipaddr_un -n1 $cnt 2)"
  22. tst_add_ipaddr -s -q -a $lhost lhost $cnt
  23. tst_add_ipaddr -s -q -a $gw rhost $cnt
  24. gw_all="$gw$IP_ADDR_DELIM$gw_all"
  25. iface_all="$iface$IP_ADDR_DELIM$iface_all"
  26. cnt=$((cnt+1))
  27. done
  28. ROUTE_CHANGE_NETLINK_PARAMS="-d '$iface_all' -g '$gw_all' -r $rhost"
  29. }
  30. tst_run