6
24
Fork
You've already forked ifstate
13

Ignore missing interfaces #152

Closed
opened 2026年01月28日 13:14:12 +01:00 by magic_rb · 2 comments
Contributor
Copy link

I'm putting ifstate on my laptop since i want to have multiple network namespaces, which as we both know are poorly supported outside of ifstate :). However the issue is that my laptop doesn't have a physical rj45 ethernet, therefore i carry around a dongle which i plug in when i need a rj45. Issues arise when i try to run ifstate with a interface that may not exists:

interfaces."eth1" = {
 identify.perm_address = "xx:xx:xx:xx:xx:xx";
 link = {
 kind = "physical";
 state = "up";
 };
 hooks = [
 {
 name = "dhcpcd";
 args.IFACE = "eth1";
 }
 ];
};

(i have 2 dongles, eth0 and eth1 as i call them, currently my laptop is docked, so eth0 is connected, eth1 is the portable one)

this then leads to ifstate erroring out:

Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486]
Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] configure sysctl settings...
Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] ipv6/optimistic_dad ok
Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486]
Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] configure interfaces...
Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] lo
Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] link ok
Jan 28 13:00:55 omen ifstatecli[55486]: addresses = 127.0.0.1/8
Jan 28 13:00:55 omen ifstatecli[55486]: addresses = ::1/128
Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] addresses = 127.0.0.1/8
Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] addresses = ::1/128
Jan 28 13:00:55 omen ifstatecli[55486]: eth0
Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] eth0
Jan 28 13:00:55 omen ifstatecli[55486]: link ok
Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] link ok
Jan 28 13:00:55 omen ifstatecli[55575]: read_config: /etc/dhcpcd.conf: No such file or directory
Jan 28 13:00:55 omen ifstatecli[55575]: sending commands to dhcpcd process
Jan 28 13:00:55 omen dhcpcd[55575]: read_config: /etc/dhcpcd.conf: No such file or directory
Jan 28 13:00:55 omen dhcpcd[55575]: sending commands to dhcpcd process
Jan 28 13:00:55 omen ifstatecli[55486]: hooks = dhcpcd
Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] hooks = dhcpcd
Jan 28 13:00:55 omen ifstatecli[55486]: eth1
Jan 28 13:00:55 omen ifstatecli[55486]: eth1 unable to create physical link
Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] eth1
Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] eth1 unable to create physical link
Jan 28 13:00:55 omen ifstatecli[55486]: eth1 link missing
Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] eth1 link missing
Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] eth1 link missing
Jan 28 13:00:55 omen ifstatecli[55486]: eth1 link missing
Jan 28 13:00:55 omen ifstatecli[55486]: AttributeError: 'PhysicalLink' object has no attribute 'iface'

I see two issues here:

  1. i would like to be able to tell ifstate to fully ignore missing interfaces, so that if i end up searching the logs for warnings or in some other way looking for warnings, i dont get false positives
  2. ifstate exits with a unhandled exception

ifstatecli --version reports:

ifstatecli 2.2.3
I'm putting ifstate on my laptop since i want to have multiple network namespaces, which as we both know are poorly supported outside of ifstate :). However the issue is that my laptop doesn't have a physical rj45 ethernet, therefore i carry around a dongle which i plug in when i need a rj45. Issues arise when i try to run ifstate with a interface that may not exists: ``` interfaces."eth1" = { identify.perm_address = "xx:xx:xx:xx:xx:xx"; link = { kind = "physical"; state = "up"; }; hooks = [ { name = "dhcpcd"; args.IFACE = "eth1"; } ]; }; ``` (i have 2 dongles, `eth0` and `eth1` as i call them, currently my laptop is docked, so `eth0` is connected, `eth1` is the portable one) this then leads to ifstate erroring out: ``` Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] configure sysctl settings... Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] ipv6/optimistic_dad ok Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] configure interfaces... Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] lo Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] link ok Jan 28 13:00:55 omen ifstatecli[55486]: addresses = 127.0.0.1/8 Jan 28 13:00:55 omen ifstatecli[55486]: addresses = ::1/128 Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] addresses = 127.0.0.1/8 Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] addresses = ::1/128 Jan 28 13:00:55 omen ifstatecli[55486]: eth0 Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] eth0 Jan 28 13:00:55 omen ifstatecli[55486]: link ok Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] link ok Jan 28 13:00:55 omen ifstatecli[55575]: read_config: /etc/dhcpcd.conf: No such file or directory Jan 28 13:00:55 omen ifstatecli[55575]: sending commands to dhcpcd process Jan 28 13:00:55 omen dhcpcd[55575]: read_config: /etc/dhcpcd.conf: No such file or directory Jan 28 13:00:55 omen dhcpcd[55575]: sending commands to dhcpcd process Jan 28 13:00:55 omen ifstatecli[55486]: hooks = dhcpcd Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] hooks = dhcpcd Jan 28 13:00:55 omen ifstatecli[55486]: eth1 Jan 28 13:00:55 omen ifstatecli[55486]: eth1 unable to create physical link Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] eth1 Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] eth1 unable to create physical link Jan 28 13:00:55 omen ifstatecli[55486]: eth1 link missing Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] eth1 link missing Jan 28 13:00:55 omen ifstate-apply[55486]: ifstate-apply[55486] eth1 link missing Jan 28 13:00:55 omen ifstatecli[55486]: eth1 link missing Jan 28 13:00:55 omen ifstatecli[55486]: AttributeError: 'PhysicalLink' object has no attribute 'iface' ``` I see two issues here: 1. i would like to be able to tell ifstate to fully ignore missing interfaces, so that if i end up searching the logs for warnings or in some other way looking for warnings, i dont get false positives 2. ifstate exits with a unhandled exception `ifstatecli --version` reports: ``` ifstatecli 2.2.3 ```
Owner
Copy link
  1. You could consider to abuse the vrrp tagging to ignore those interfaces by default. If the ifaces are plugged in you could run ifstatecli vrrp instance $NAME master to configure the interface (maybe event trigger this somehow from udev)

  2. yes this is a bug, I will look into it (later)

Thanks!

1. You could consider to abuse the [vrrp](https://ifstate.net/2.2/docs/vrrp/) tagging to ignore those interfaces by default. If the ifaces are plugged in you could run `ifstatecli vrrp instance $NAME master` to configure the interface (maybe event trigger this somehow from udev) 2. yes this is a bug, I will look into it (later) Thanks!
liske added this to the 2.2.4 milestone 2026年01月28日 14:44:23 +01:00
Owner
Copy link

I wonder why your hook has a IFACE argument, couldn't you use the already provides IFS_IFNAME variable (see also the docs)?

I wonder why your hook has a `IFACE` argument, couldn't you use the already provides `IFS_IFNAME` variable (see also the [docs](https://ifstate.net/2.2/docs/hooks/#invocation))?
Sign in to join this conversation.
No Branch/Tag specified
main
move-paths-into-module
feature-libifstate-rs
ifstate-2.4
pages
ifstate-2.1
ifstate-2.3
ifstate-2.0
ifstate-2.2
ifstate-1.x
2.4.1
2.4.0
2.3.0
2.3.0-pre6
2.2.6
2.3.0-pre5
2.3.0-pre4
2.3.0-pre3
2.3.0-pre2
2.3.0-pre1
2.2.5
2.3.0-pre0
2.2.4
2.2.4-pre2
2.2.4-pre1
2.2.4-pre0
2.2.3
2.2.2
2.2.1
2.2.0
2.1.0
1.13.9
2.0.2
2.0.1
1.13.8
2.0.0
2.0.0rc6
2.0.0rc5
2.0.0rc4
2.0.0rc3
2.0.0rc2
2.0.0rc1
1.13.7
1.13.6
1.13.5
1.13.4
1.13.3
1.13.2
1.13.1
1.13.0
1.12.0
1.11.9
1.11.8
1.11.7
1.11.6
1.11.5
1.11.4
1.11.3
1.11.2
1.11.1
1.11.0
1.10.1
1.10.0
1.9.0
1.8.5
1.8.4
1.8.3
1.8.2
1.8.1
1.8.0
1.7.0
1.6.1
1.6.0
1.5.8
1.5.7
1.5.6
1.5.5
1.5.4
1.5.3
1.5.2
1.5.1
1.5.0
1.4.0
1.3.2
1.3.1
1.3.0
1.2.1
1.2.0
1.1.0
1.0.0
0.9.0
0.8.1
0.8.0
0.7.3
0.7.2
0.7.1
0.7.0
0.6.3
0.6.2
0.6.1
0.6.0
0.5.1
0.5
0.4
0.3
0.2
Labels
Clear labels
bug
Something isn't working
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
more info
Further details are required, the problem may not yet be reproducible, yet
question
Further information is requested
TBD
To be discussed
wontfix
This will not be worked on
AI slop
Burning out
bug
Something is not working
contribution welcome
Contributions are very welcome, get started here
duplicate
This issue or pull request already exists
enhancement
New feature
good first issue
Interested in contributing? Get started here.
help wanted
Need some help
invalid
Something is wrong
question
More information is needed
upstream
Related to an upstream repository, already reported there
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
routerkit/ifstate#152
Reference in a new issue
routerkit/ifstate
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?