From e91ae5988228ba73e25dd9c2f40b98d48ea24062 Mon Sep 17 00:00:00 2001 From: Bertrand Jacquin Date: Sun, 15 Jun 2025 22:53:18 +0100 Subject: [PATCH] interface: handle name@link from iproute2 Since #1090, iproute2 is preferred over ifconfig, however iproute2 provide the list of network interface in name@link in case an interface is bound to another one (such as macvtap for example), while the real interface name is not. $ ip link show 2: eth0: mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether 48:21:0b:52:19:22 brd ff:ff:ff:ff:ff:ff 4: eth0.128@eth0: mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000 link/ether 48:21:0b:52:19:22 brd ff:ff:ff:ff:ff:ff bash-completion using name@link as provided by iproute2 output then provide such name in auto completion list, leading to invalid interface name when auto completing tcpdump arguments. $ tcpdump -i eth0 eth0.128@eth0 This commit handle this use case to drop link name after name@. $ tcpdump -i eth0 eth0.128 See: https://github.com/scop/bash-completion/pull/1090 See: https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/lib/utils.c?h=v6.15.0#n1306 --- bash_completion | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash_completion b/bash_completion index 64ca04c4c81..0ae42b4221e 100644 --- a/bash_completion +++ b/bash_completion @@ -1821,7 +1821,7 @@ _comp_compgen_available_interfaces() ip -c=never link show || ip link show || ifconfig -a fi } 2>/dev/null | _comp_awk \ - '/^[^ \t]/ { if ($1 ~ /^[0-9]+:/) { print $2 } else { print $1 } }')" && + '/^[^ \t]/ { if ($1 ~ /^[0-9]+:/) { sub(/@.*/, "", $2); print $2 } else { print $1 } }')" && _comp_compgen -U generated set "${generated[@]%:}" }