5
24
Fork
You've already forked ifstate
13

Fix link_netnsid: None != 0 when applying DSA interfaces #77

Closed
magic_rb wants to merge 2 commits from magic_rb/ifstate:fix-dsa-linknetns-perpetual-recreation into ifstate-1.x
pull from: magic_rb/ifstate:fix-dsa-linknetns-perpetual-recreation
merge into: routerkit:ifstate-1.x
routerkit:main
routerkit:move-paths-into-module
routerkit:feature-libifstate-rs
routerkit:ifstate-2.4
routerkit:pages
routerkit:ifstate-2.1
routerkit:ifstate-2.3
routerkit:ifstate-2.0
routerkit:ifstate-2.2
routerkit:ifstate-1.x
Contributor
Copy link

See #65 for context.

While this fixes the issue for me, I don't know why its required as the 0 comes from the ifstate.yaml side even though I'm setting that field to null, which I would expect to be deserialized as None.

I haven't actually tried an apply yet, I don't want my flatmates to yell at me in case something breaks, but a check reports ok

See #65 for context. While this fixes the issue for me, I don't know why its required as the `0` comes from the `ifstate.yaml` side even though I'm setting that field to `null`, which I would expect to be deserialized as `None`. I haven't actually tried an apply yet, I don't want my flatmates to yell at me in case something breaks, but a `check` reports `ok`
Signed-off-by: magic_rb <richard@brezak.sk>
Signed-off-by: magic_rb <richard@brezak.sk>
Author
Contributor
Copy link

Flatmates left for a second so I took the liberty of running a apply and it worked, this PR is functional.

Flatmates left for a second so I took the liberty of running a `apply` and it worked, this PR is functional.
Owner
Copy link

@magic_rb wrote in liske/ifstate#77 (comment):

See #65 for context.

While this fixes the issue for me, I don't know why its required as the 0 comes from the ifstate.yaml side even though I'm setting that field to null, which I would expect to be deserialized as None.

The kernel has no concept for netns names but netns IDs to use it as a handle in netlink. The _netns atttributes get transcipted into nsid so they match the nsid value in netlink: liske/ifstate@eef506e565/libifstate/link/base.py (L456-L457)

It seems there is a bug that link_netns is not correctly compared. So the fix is a little bit more complex...

@magic_rb wrote in https://codeberg.org/liske/ifstate/pulls/77#issue-953160: > See #65 for context. > > While this fixes the issue for me, I don't know why its required as the `0` comes from the `ifstate.yaml` side even though I'm setting that field to `null`, which I would expect to be deserialized as `None`. The kernel has no concept for netns names but netns IDs to use it as a handle in netlink. The `_netns` atttributes get transcipted into nsid so they match the nsid value in netlink: https://codeberg.org/liske/ifstate/src/commit/eef506e565f5eeaec1755dba7b7fdf8dce5c0ca6/libifstate/link/base.py#L456-L457 It seems there is a bug that `link_netns` is not correctly compared. So the fix is a little bit more complex...
liske added this to the v1.13.3 milestone 2025年01月26日 22:55:07 +01:00
Owner
Copy link

It seems that I'm not able to debug this issue w/o access to a DSA interface 😢. I did several tests using link_netns on VLAN interfaces which shows no problems - but they are virtual and can be recreated.

It seems that I'm not able to debug this issue w/o access to a DSA interface 😢. I did several tests using `link_netns` on VLAN interfaces which shows no problems - but they are virtual and can be recreated.
Owner
Copy link

@liske wrote in liske/ifstate#77 (comment):

It seems that I'm not able to debug this issue w/o access to a DSA interface 😢. I did several tests using link_netns on VLAN interfaces which shows no problems - but they are virtual and can be recreated.

Thankfully, @m4rc3l has given me access to a SoC router with DSA. Going to refactor the DSA implementation in ifstate... 😎

@liske wrote in https://codeberg.org/liske/ifstate/pulls/77#issuecomment-2653684: > It seems that I'm not able to debug this issue w/o access to a DSA interface :cry:. I did several tests using `link_netns` on VLAN interfaces which shows no problems - but they are virtual and can be recreated. Thankfully, @m4rc3l has given me access to a SoC router with DSA. Going to refactor the DSA implementation in ifstate... 😎
Owner
Copy link

I've tested moving DSA port interfaces with the master branch (ifstate 2.x) and it worked like a charm. I did use the following config w/o using the dsa link kind:

parameters:ignore:ifname:# ignore OpenWRT management- eth0interfaces:- name:dsaaddresses:[]link:state:upkind:physicaladdress:70:a7:41:de:7f:68mtu:1504- name:eth1addresses:[]identify:phys_port_name:p1phys_switch_id:00:00:00:00link:state:upkind:physicaladdress:70:a7:41:de:7f:69- name:eth2addresses:[]identify:phys_port_name:p2phys_switch_id:00:00:00:00link:state:upkind:physicaladdress:70:a7:41:de:7f:6anamespaces:foo:interfaces:- name:eth3addresses:[]identify:phys_port_name:p3phys_switch_id:00:00:00:00link:state:upkind:physicaladdress:70:a7:41:de:7f:6bbar:interfaces:- name:eth4addresses:[]identify:phys_port_name:p4phys_switch_id:00:00:00:00link:state:upkind:physicaladdress:70:a7:41:de:7f:6c

Open problems observed for DSA setups:

  • the port devices should not configured before the dsa main link - there is no dependency tracking, yet
  • on the SoC I used for testing the dsa and the eth0 interface are looking identical, how we can distinguish them:
interfaces:- name:dsaidentify:perm_address:70:a7:41:de:7f:68parent_dev_name:1e100000.ethernetparent_dev_bus_name:platform- name:eth0identify:perm_address:70:a7:41:de:7f:68parent_dev_name:1e100000.ethernetparent_dev_bus_name:platform# ...
I've tested moving DSA port interfaces with the master branch (ifstate 2.x) and it worked like a charm. I did use the following config w/o using the `dsa` link kind: ```yaml parameters: ignore: ifname: # ignore OpenWRT management - eth0 interfaces: - name: dsa addresses: [] link: state: up kind: physical address: 70:a7:41:de:7f:68 mtu: 1504 - name: eth1 addresses: [] identify: phys_port_name: p1 phys_switch_id: 00:00:00:00 link: state: up kind: physical address: 70:a7:41:de:7f:69 - name: eth2 addresses: [] identify: phys_port_name: p2 phys_switch_id: 00:00:00:00 link: state: up kind: physical address: 70:a7:41:de:7f:6a namespaces: foo: interfaces: - name: eth3 addresses: [] identify: phys_port_name: p3 phys_switch_id: 00:00:00:00 link: state: up kind: physical address: 70:a7:41:de:7f:6b bar: interfaces: - name: eth4 addresses: [] identify: phys_port_name: p4 phys_switch_id: 00:00:00:00 link: state: up kind: physical address: 70:a7:41:de:7f:6c ``` Open problems observed for DSA setups: - [ ] the port devices should not configured before the `dsa` main link - there is no dependency tracking, yet - [x] on the SoC I used for testing the `dsa` and the `eth0` interface are looking identical, how we can distinguish them: ```yaml interfaces: - name: dsa identify: perm_address: 70:a7:41:de:7f:68 parent_dev_name: 1e100000.ethernet parent_dev_bus_name: platform - name: eth0 identify: perm_address: 70:a7:41:de:7f:68 parent_dev_name: 1e100000.ethernet parent_dev_bus_name: platform # ... ```
Owner
Copy link

Ifstate 2 will provides the device tree reference of_node from sysfs (on platforms with device tree support):

interfaces:- name:dsa0addresses:[]link:state:upkind:physicalmtu:1504identify:of_node:base/ethernet@1e100000/mac@0- name:eth0addresses:- 192.0.2.1/24link:state:upkind:physicalidentify:of_node:base/ethernet@1e100000/mac@1- name:p1addresses:[]identify:of_node:base/ethernet@1e100000/mdio-bus/switch@1f/ports/port@1link:state:upkind:physical- name:p3addresses:[]identify:of_node:base/ethernet@1e100000/mdio-bus/switch@1f/ports/port@3link:state:upkind:physicalnamespaces:bar:interfaces:- name:p2addresses:[]identify:of_node:base/ethernet@1e100000/mdio-bus/switch@1f/ports/port@2link:state:upkind:physicalfoo:interfaces:- name:p4addresses:[]identify:of_node:base/ethernet@1e100000/mdio-bus/switch@1f/ports/port@4link:state:upkind:physical
Ifstate 2 will provides the device tree reference `of_node` from sysfs (on platforms with device tree support): ```yaml interfaces: - name: dsa0 addresses: [] link: state: up kind: physical mtu: 1504 identify: of_node: base/ethernet@1e100000/mac@0 - name: eth0 addresses: - 192.0.2.1/24 link: state: up kind: physical identify: of_node: base/ethernet@1e100000/mac@1 - name: p1 addresses: [] identify: of_node: base/ethernet@1e100000/mdio-bus/switch@1f/ports/port@1 link: state: up kind: physical - name: p3 addresses: [] identify: of_node: base/ethernet@1e100000/mdio-bus/switch@1f/ports/port@3 link: state: up kind: physical namespaces: bar: interfaces: - name: p2 addresses: [] identify: of_node: base/ethernet@1e100000/mdio-bus/switch@1f/ports/port@2 link: state: up kind: physical foo: interfaces: - name: p4 addresses: [] identify: of_node: base/ethernet@1e100000/mdio-bus/switch@1f/ports/port@4 link: state: up kind: physical ```
liske closed this pull request 2025年06月15日 10:21:50 +02:00

Pull request closed

Please reopen this pull request to perform a merge.
Sign in to join this conversation.
No reviewers
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!77
Reference in a new issue
routerkit/ifstate
No description provided.
Delete branch "magic_rb/ifstate:fix-dsa-linknetns-perpetual-recreation"

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?