2 # SPDX-License-Identifier: GPL-2.0
5 readonly NETNS="ns-$(mktemp -u XXXXXX)"
9 addr_v6="2001:0db8:0:f101::1"
15 echo "Usage: $0 [-6 | -4] [-p port] [-a address]"
16 echo -e "\t6: use ipv6"
17 echo -e "\t4: use ipv4"
18 echo -e "\tport: Port number"
19 echo -e "\taddress: ip address"
22 while getopts "ha:p:64" opt; do
39 ip netns add "${NETNS}"
40 ip -netns "${NETNS}" link add veth0 type veth peer name veth1
41 ip -netns "${NETNS}" link set lo up
42 ip -netns "${NETNS}" link set veth0 up
43 ip -netns "${NETNS}" link set veth1 up
45 if [[ "$use_v6" == true ]]; then
46 ip -netns "${NETNS}" addr add $addr_v6 nodad dev veth0
48 ip -netns "${NETNS}" addr add $addr_v4 dev lo
53 ip netns del "${NETNS}"
56 if [[ "$addr" != "" ]]; then
61 if [[ "$use_v6" == true ]] ; then
62 ip netns exec "${NETNS}" sh -c \
63 "ulimit -n ${NR_FILES};./bind_bhash ${port} ipv6 ${addr_v6}"
65 ip netns exec "${NETNS}" sh -c \
66 "ulimit -n ${NR_FILES};./bind_bhash ${port} ipv4 ${addr_v4}"