VETH_EXTERNAL_PEER:="tom"
VETH_INTERNAL_PEER:="jerry"
INTERNAL_NS:="wb"

# Create both veths pair and namespace and put them in different namespaces
veth-setup:
	@sudo ip link add dev {{VETH_EXTERNAL_PEER}} type veth \
		peer name {{VETH_INTERNAL_PEER}}
	@echo "`tput setaf 2``tput sgr0` Create veth pair (i.e., {{VETH_EXTERNAL_PEER}}/{{VETH_INTERNAL_PEER}})"

	@sudo ip netns add {{INTERNAL_NS}}
	@echo "`tput setaf 2``tput sgr0` Create namespace (i.e., {{INTERNAL_NS}})"

	@sudo ip link set {{VETH_INTERNAL_PEER}} netns {{INTERNAL_NS}}
	@echo "`tput setaf 2``tput sgr0` Put {{VETH_INTERNAL_PEER}} into {{INTERNAL_NS}}"

# Clear-up what previously made by just veth-setup
veth-teardown:
	@sudo ip link del dev {{VETH_EXTERNAL_PEER}}
	@echo "`tput setaf 2``tput sgr0` Remove veth pair"

	@sudo ip netns delete {{INTERNAL_NS}}
	@echo "`tput setaf 2``tput sgr0` Remove namespace"

# Run interactively inside ns
run-into-ns:
	@sudo ip netns exec {{INTERNAL_NS}} /bin/bash || true
