Skip to content

Commit e91ae59

Browse files
committed
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: <BROADCAST,MULTICAST,UP,LOWER_UP> 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: <BROADCAST,MULTICAST,NOARP,UP,LOWER_UP> 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 <TAB> eth0 eth0.128@eth0 This commit handle this use case to drop link name after name@. $ tcpdump -i <TAB> eth0 eth0.128 See: #1090 See: https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/lib/utils.c?h=v6.15.0#n1306
1 parent 90ef9a2 commit e91ae59

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

bash_completion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1821,7 +1821,7 @@ _comp_compgen_available_interfaces()
18211821
ip -c=never link show || ip link show || ifconfig -a
18221822
fi
18231823
} 2>/dev/null | _comp_awk \
1824-
'/^[^ \t]/ { if ($1 ~ /^[0-9]+:/) { print $2 } else { print $1 } }')" &&
1824+
'/^[^ \t]/ { if ($1 ~ /^[0-9]+:/) { sub(/@.*/, "", $2); print $2 } else { print $1 } }')" &&
18251825
_comp_compgen -U generated set "${generated[@]%:}"
18261826
}
18271827

0 commit comments

Comments
 (0)