yanger: skip internal interfaces

In "14128047e18d statd: remove nl code and improve speed" the handling
of all interfaces where moved from statd to Yanger. This means statd no
longer tracks interfaces using Netlink, but instead relies on Yanger
to recognise and list all interfaces in the system. In the midst of
this change the ignoring of "internal" interfaces where lost.

In this commit we reintroduce this logic in Yanger and add a test case
that ensures internal interfaces isn't listed.

Fixes: 14128047e1 statd: remove nl code and improve speed

Signed-off-by: Richard Alpe <richard@bit42.se>
This commit is contained in:
Richard Alpe
2024-10-01 14:28:31 +02:00
parent 240a292725
commit 707e7d1a29
5 changed files with 148 additions and 0 deletions
+4
View File
@@ -899,6 +899,10 @@ def _add_interface(ifname, ip_link_data, ip_addr_data, yang_ifaces):
if not ip_link_data or not ip_addr_data:
return
# Skip internal interfaces.
if 'group' in ip_link_data and ip_link_data['group'] == "internal":
return
yang_ifaces.append(get_iface_data(ifname, ip_link_data, ip_addr_data))
def add_interface(ifname, yang_ifaces):
@@ -0,0 +1,32 @@
Settings for dsa0:
Supported ports: [ MII ]
Supported link modes: 10000baseT/Full
10000baseKX4/Full
10000baseKR/Full
10000baseCR/Full
10000baseSR/Full
10000baseLR/Full
10000baseLRM/Full
10000baseER/Full
Supported pause frame use: Symmetric Receive-only
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: 10000baseT/Full
10000baseKX4/Full
10000baseKR/Full
10000baseCR/Full
10000baseSR/Full
10000baseLR/Full
10000baseLRM/Full
10000baseER/Full
Advertised pause frame use: Symmetric Receive-only
Advertised auto-negotiation: Yes
Advertised FEC modes: Not reported
Speed: 10000Mb/s
Duplex: Full
Auto-negotiation: on
Port: MII
PHYAD: 0
Transceiver: internal
netlink error: Operation not permitted
Link detected: yes
@@ -0,0 +1,7 @@
[ {
"ifname": "dsa0",
"eth-phy": {},
"eth-mac": {},
"eth-ctrl": {},
"rmon": {}
} ]
@@ -1,4 +1,56 @@
[
{
"ifindex": 2,
"ifname": "dsa0",
"flags": [
"BROADCAST",
"MULTICAST",
"UP",
"LOWER_UP"
],
"mtu": 1504,
"qdisc": "mq",
"operstate": "UP",
"group": "internal",
"txqlen": 2048,
"link_type": "ether",
"address": "02:00:de:ad:02:20",
"broadcast": "ff:ff:ff:ff:ff:ff",
"promiscuity": 0,
"allmulti": 0,
"min_mtu": 68,
"max_mtu": 9888,
"num_tx_queues": 8,
"num_rx_queues": 4,
"gso_max_size": 65536,
"gso_max_segs": 300,
"tso_max_size": 65536,
"tso_max_segs": 300,
"gro_max_size": 65536,
"gso_ipv4_max_size": 65536,
"gro_ipv4_max_size": 65536,
"parentbus": "platform",
"parentdev": "f2000000.ethernet",
"addr_info": [],
"stats64": {
"rx": {
"bytes": 1756811,
"packets": 6777,
"errors": 0,
"dropped": 0,
"over_errors": 0,
"multicast": 0
},
"tx": {
"bytes": 1849127,
"packets": 7157,
"errors": 0,
"dropped": 0,
"carrier_errors": 0,
"collisions": 0
}
}
},
{
"ifindex": 7,
"ifname": "br0",
@@ -1,4 +1,57 @@
[
{
"ifindex": 2,
"ifname": "dsa0",
"flags": [
"BROADCAST",
"MULTICAST",
"UP",
"LOWER_UP"
],
"mtu": 1504,
"qdisc": "mq",
"operstate": "UP",
"linkmode": "DEFAULT",
"group": "internal",
"txqlen": 2048,
"link_type": "ether",
"address": "02:00:de:ad:02:20",
"broadcast": "ff:ff:ff:ff:ff:ff",
"promiscuity": 0,
"allmulti": 0,
"min_mtu": 68,
"max_mtu": 9888,
"inet6_addr_gen_mode": "eui64",
"num_tx_queues": 8,
"num_rx_queues": 4,
"gso_max_size": 65536,
"gso_max_segs": 300,
"tso_max_size": 65536,
"tso_max_segs": 300,
"gro_max_size": 65536,
"gso_ipv4_max_size": 65536,
"gro_ipv4_max_size": 65536,
"parentbus": "platform",
"parentdev": "f2000000.ethernet",
"stats64": {
"rx": {
"bytes": 1751876,
"packets": 6757,
"errors": 0,
"dropped": 0,
"over_errors": 0,
"multicast": 0
},
"tx": {
"bytes": 1843945,
"packets": 7136,
"errors": 0,
"dropped": 0,
"carrier_errors": 0,
"collisions": 0
}
}
},
{
"ifindex": 7,
"ifname": "br0",