Skip to content

cukinia_netif_has_flag: add new cmd to check network interface flags - #109

Merged
anakin-childerhose-sfl merged 1 commit into
savoirfairelinux:masterfrom
edraac:era/master/cukinia_netif_has_flag
Sep 2, 2026
Merged

anakin-childerhose-sfl merged 1 commit into
savoirfairelinux:masterfrom
edraac:era/master/cukinia_netif_has_flag

Conversation

@edraac

@edraac edraac commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

In some scenarios, it might be useful to verify a network interface's flags such as (admin) up/down, loopback, multicast, etc. These flags are either set by the driver, kernel, or triggered by user space utilities, and are exposed by a sysfs entry via /sys/class/net//flags. The particular flags and their bit offset are defined in the kernel in include/uapi/linux/if.h.

The new cukinia_netif_has_flag wraps a check for these flags and PASS if the flag is set, FAIL otherwise. It takes the device name, the flag name as defined in the kernel's net_device_flags enum, and performs the bitwise operations required to verify if the flag is set.

Example:

cukinia_netif_has_flag ethsbc0 IFF_UP
not cukinia_netif_has_flag ethsbc0 IFF_LOOPBACK
cukinia_netif_has_flag ethsbc0 IFF_RUNNING

Output:

[PASS] Checking interface "ethsbc0" has IFF_UP flag
[PASS] Checking interface "ethsbc0" has NOT IFF_LOOPBACK flag [!]
[FAIL] Checking interface "ethsbc0" has IFF_RUNNING flag

@edraac
edraac force-pushed the era/master/cukinia_netif_has_flag branch from 3dc2090 to c6c9a69 Compare August 14, 2026 14:10
Comment thread bats/cukinia.bats
Comment thread tests/testcases.conf
Comment thread cukinia
@anakin-childerhose-sfl

Copy link
Copy Markdown
Contributor

Thank you very much for your PR! I left a few comments but it looks pretty good so far!

@edraac
edraac force-pushed the era/master/cukinia_netif_has_flag branch from c6c9a69 to 232b37f Compare August 25, 2026 09:55

@anakin4747 anakin4747 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good to me!

@anakin-childerhose-sfl anakin-childerhose-sfl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread cukinia Outdated
@edraac
edraac force-pushed the era/master/cukinia_netif_has_flag branch from 232b37f to 11fd045 Compare September 1, 2026 09:44
@edraac

edraac commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

@anakin-childerhose-sfl @anakin4747 the check failure seems unrelated to my latest changes, right?

@anakin-childerhose-sfl

anakin-childerhose-sfl commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Yes, they do seem unrelated, I pulled your latest changes and they pass the tests on my side

@anakin-childerhose-sfl

Copy link
Copy Markdown
Contributor

Actually I found the issue with the CI for the first failing test. echo -ne adds the -ne to the number with dash so the echo -ne in the mock needs to be replaced with printf:

$ docker run -it --rm ubuntu:24.04 /bin/dash 
$ value=$(echo -ne "0x1001")                                                                                                            
$ echo "$((value >> 0))"                                                                                                                  
/bin/dash: 2: Illegal number: -ne 0x1001
$ value=$(printf "0x1001")                                                                                                                
$ echo "$((value >> 0))"                                                                                                                  
4097

Comment thread bats/cukinia.bats Outdated
In some scenarios, it might be useful to verify a network interface's
flags such as (admin) up/down, loopback, multicast, etc. These flags are
either set by the driver, kernel, or triggered by user space utilities,
and are exposed by a sysfs entry via /sys/class/net/<dev>/flags. The
particular flags and their bit offset are defined in the kernel in
include/uapi/linux/if.h.

The new cukinia_netif_has_flag wraps a check for these flags and PASS if
the flag is set, FAIL otherwise. It takes the device name, the flag name
as defined in the kernel's net_device_flags enum, and performs the
bitwise operations required to verify if the flag is set.

Example:

cukinia_netif_has_flag ethsbc0 IFF_UP
not cukinia_netif_has_flag ethsbc0 IFF_LOOPBACK
cukinia_netif_has_flag ethsbc0 IFF_RUNNING

Output:

[PASS]  Checking interface "ethsbc0" has IFF_UP flag
[PASS]  Checking interface "ethsbc0" has NOT IFF_LOOPBACK flag [!]
[FAIL]  Checking interface "ethsbc0" has IFF_RUNNING flag

Signed-off-by: Eduardo Ramirez <eramirez@data-modul.com>
@edraac
edraac force-pushed the era/master/cukinia_netif_has_flag branch from 11fd045 to d55595c Compare September 2, 2026 15:03
@anakin-childerhose-sfl
anakin-childerhose-sfl merged commit 3a2a871 into savoirfairelinux:master Sep 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants