diff options
author | 2020-11-20 22:53:54 -0800 | |
---|---|---|
committer | 2021-03-11 17:53:33 +0100 | |
commit | f56e5753063e4d461b3e140e50bcbd6a60b0c1eb (patch) | |
tree | 67516aad2295579407fa3ffad2f40df2332cee0a | |
parent | net/bridge.sh: Add support for network namespaces when using iproute2 (diff) | |
download | netifrc-f56e5753063e4d461b3e140e50bcbd6a60b0c1eb.tar.gz netifrc-f56e5753063e4d461b3e140e50bcbd6a60b0c1eb.tar.bz2 netifrc-f56e5753063e4d461b3e140e50bcbd6a60b0c1eb.zip |
net/dummy.sh: Add support for network namespaces
Closes: https://github.com/gentoo/netifrc/pull/35
Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
-rw-r--r-- | net/dummy.sh | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/net/dummy.sh b/net/dummy.sh index 421d951..091e08c 100644 --- a/net/dummy.sh +++ b/net/dummy.sh @@ -13,16 +13,20 @@ _is_dummy() { is_interface_type dummy } +_ip() +{ + veinfo ip "${@}" + _netns ip "${@}" +} + dummy_pre_start() { local dummy= - eval dummy=\$type_${IFVAR} + eval dummy="\$type_${IFVAR}" [ "${dummy}" = "dummy" ] || return 0 ebegin "Creating dummy interface ${IFACE}" - cmd="ip link add name "${IFACE}" type dummy" - veinfo $cmd - if $cmd ; then + if _ip link add name "${IFACE}" type dummy ; then eend 0 && _up && set_interface_type dummy else eend 1 @@ -35,8 +39,6 @@ dummy_post_stop() _is_dummy || return 0 ebegin "Removing dummy ${IFACE}" - cmd="ip link delete "${IFACE}" type dummy" - veinfo "$cmd" - $cmd + _ip link delete "${IFACE}" type dummy eend $? } |