mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-02 13:53:01 +02:00
confd: allow interface description as ifAlias
This patch adds support for setting the free form description string as the interface alias. This can be read from /sys/class/net/*/ifalias, or using the 'ip link show' command. The ifalias is reported by SNMP and LLDP by default, and now also in the operational datastore. Linux supports 250 characters in ifalias, but the IF-MIB is restricted to 64 characters, so we add a local deviation to limit the type. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -1889,6 +1889,10 @@ static sr_error_t netdag_gen_iface(sr_session_ctx_t *session, struct dagger *net
|
||||
if (err)
|
||||
goto err_close_ip;
|
||||
|
||||
/* ifAlias, should skip for container-network types */
|
||||
attr = lydx_get_cattr(cif, "description");
|
||||
fprintf(ip, "link set alias \"%s\" dev %s\n", attr ?: "", ifname);
|
||||
|
||||
/* Bring interface back up, if enabled */
|
||||
attr = lydx_get_cattr(cif, "enabled");
|
||||
if (!attr || !strcmp(attr, "true"))
|
||||
|
||||
@@ -37,7 +37,7 @@ MODULES=(
|
||||
"ieee802-ethernet-interface@2019-06-21.yang"
|
||||
"infix-ethernet-interface@2024-02-27.yang"
|
||||
"infix-factory-default@2023-06-28.yang"
|
||||
"infix-interfaces@2024-10-14.yang -e vlan-filtering"
|
||||
"infix-interfaces@2024-10-28.yang -e vlan-filtering"
|
||||
|
||||
# from rousette
|
||||
"ietf-restconf@2017-01-26.yang"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- sh -*-
|
||||
# REMEMBER TO UPDATE infix-interfaces ALSO IN confd.inc
|
||||
MODULES=(
|
||||
"infix-interfaces@2024-10-14.yang -e vlan-filtering -e containers"
|
||||
"infix-interfaces@2024-10-28.yang -e vlan-filtering -e containers"
|
||||
"infix-containers@2024-10-14.yang"
|
||||
)
|
||||
|
||||
@@ -23,6 +23,11 @@ module infix-interfaces {
|
||||
contact "kernelkit@googlegroups.com";
|
||||
description "Linux bridge and lag extensions for ietf-interfaces.";
|
||||
|
||||
revision 2024-10-28 {
|
||||
description "Limit description to 64 chars, matching IF-MIB max.";
|
||||
reference "internal";
|
||||
}
|
||||
|
||||
revision 2024-10-14 {
|
||||
description "Deviate link-up-down-trap-enable not-supported.";
|
||||
reference "internal";
|
||||
@@ -84,6 +89,18 @@ module infix-interfaces {
|
||||
}
|
||||
}
|
||||
|
||||
deviation "/if:interfaces/if:interface/if:description" {
|
||||
deviate replace {
|
||||
type string {
|
||||
length "0..64";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
deviation "/if:interfaces/if:interface/if:link-up-down-trap-enable" {
|
||||
deviate not-supported;
|
||||
}
|
||||
|
||||
augment "/if:interfaces/if:interface" {
|
||||
description "Custom phys-address management, static or derived from chassis MAC.";
|
||||
|
||||
@@ -114,7 +131,4 @@ module infix-interfaces {
|
||||
}
|
||||
}
|
||||
}
|
||||
deviation "/if:interfaces/if:interface/if:link-up-down-trap-enable" {
|
||||
deviate not-supported;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -645,6 +645,9 @@ def add_ip_link(ifname, iface_in, iface_out):
|
||||
if 'ifindex' in iface_in:
|
||||
iface_out['if-index'] = iface_in['ifindex']
|
||||
|
||||
if 'ifalias' in iface_in:
|
||||
iface_out['description'] = iface_in['ifalias']
|
||||
|
||||
if 'address' in iface_in:
|
||||
iface_out['phys-address'] = iface_in['address']
|
||||
|
||||
|
||||
Reference in New Issue
Block a user