mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-04-02 07:00:42 -04:00
selftests: net: lib: Add ip_link_has_flag()
Add a helper to determine whether a given netdevice has a given flag. Rewrite ip_link_is_up() in terms of the new helper. Signed-off-by: Petr Machata <petrm@nvidia.com> Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org> Link: https://patch.msgid.link/e1eb174a411f9d24735d095984c731d1d4a5a592.1750113335.git.petrm@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
2a719b7bac
commit
4baa1d3a50
@@ -547,13 +547,19 @@ ip_link_set_addr()
|
||||
defer ip link set dev "$name" address "$old_addr"
|
||||
}
|
||||
|
||||
ip_link_is_up()
|
||||
ip_link_has_flag()
|
||||
{
|
||||
local name=$1; shift
|
||||
local flag=$1; shift
|
||||
|
||||
local state=$(ip -j link show "$name" |
|
||||
jq -r '(.[].flags[] | select(. == "UP")) // "DOWN"')
|
||||
[[ $state == "UP" ]]
|
||||
jq --arg flag "$flag" 'any(.[].flags.[]; . == $flag)')
|
||||
[[ $state == true ]]
|
||||
}
|
||||
|
||||
ip_link_is_up()
|
||||
{
|
||||
ip_link_has_flag "$1" UP
|
||||
}
|
||||
|
||||
ip_link_set_up()
|
||||
|
||||
Reference in New Issue
Block a user