diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2021-07-17 08:27:32 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2021-07-17 08:27:32 +0200 |
commit | 69c8e5b5984f6cb90482973e76a9d6d928715f5e (patch) | |
tree | 405a3a2ac3fd53c8f5efa73ff5917e2227f1be43 /doc/demo.sh | |
parent | 90078ebc5911f2dc7cb2290e92db67b78a0b9f1e (diff) | |
download | passt-69c8e5b5984f6cb90482973e76a9d6d928715f5e.tar passt-69c8e5b5984f6cb90482973e76a9d6d928715f5e.tar.gz passt-69c8e5b5984f6cb90482973e76a9d6d928715f5e.tar.bz2 passt-69c8e5b5984f6cb90482973e76a9d6d928715f5e.tar.lz passt-69c8e5b5984f6cb90482973e76a9d6d928715f5e.tar.xz passt-69c8e5b5984f6cb90482973e76a9d6d928715f5e.tar.zst passt-69c8e5b5984f6cb90482973e76a9d6d928715f5e.zip |
doc/demo.sh: Support IPv4-only environments too
If no IPv6 global addresses are available, proceed with just IPv4
addresses and routes.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'doc/demo.sh')
-rwxr-xr-x | doc/demo.sh | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/doc/demo.sh b/doc/demo.sh index 83f9e78..de5f546 100755 --- a/doc/demo.sh +++ b/doc/demo.sh @@ -84,18 +84,21 @@ nft add chain "${ns}_nat" postrouting '{ type nat hook postrouting priority -100 nft add rule "${ns}_nat" postrouting ip saddr "${ipv4_ns}" masquerade ipv6_addr="$(ipv6_devaddr "$(ipv6_dev)")" -ipv6_passt="$(ipv6_mangle "${ipv6_addr}" ${ns_idx})" -ndp_setup "${ipv6_passt}" "veth_${ns}" -ip -n "${ns}" addr add "${ipv6_passt}/$(ipv6_mask "${ipv6_addr}")" dev "veth_${ns}" -ip addr add "${ipv6_addr}" dev "veth_${ns}" -ip route add "${ipv6_passt}" dev "veth_${ns}" -passt_ll="$(ipv6_ll_addr "veth_${ns}")" -main_ll="$(get_token "link/ether" $(ip -o li sh "veth_${ns}"))" -ip neigh add "${passt_ll%%/*}" dev "veth_${ns}" lladdr "${main_ll}" -ip -n "${ns}" route add default via "${passt_ll%%/*}" dev "veth_${ns}" - -sysctl -w net.ipv6.conf.all.forwarding=1 - +if [ -n "${ipv6_addr}" ]; then + ipv6_passt="$(ipv6_mangle "${ipv6_addr}" ${ns_idx})" + ndp_setup "${ipv6_passt}" "veth_${ns}" + ip -n "${ns}" addr add "${ipv6_passt}/$(ipv6_mask "${ipv6_addr}")" dev "veth_${ns}" + ip addr add "${ipv6_addr}" dev "veth_${ns}" + ip route add "${ipv6_passt}" dev "veth_${ns}" + passt_ll="$(ipv6_ll_addr "veth_${ns}")" + main_ll="$(get_token "link/ether" $(ip -o li sh "veth_${ns}"))" + ip neigh add "${passt_ll%%/*}" dev "veth_${ns}" lladdr "${main_ll}" + ip -n "${ns}" route add default via "${passt_ll%%/*}" dev "veth_${ns}" + + sysctl -w net.ipv6.conf.all.forwarding=1 +else + ipv6_passt= +fi ethtool -K "veth_${ns}" tx off ip netns exec "${ns}" ethtool -K "veth_${ns}" tx off |