Skip to content

Commit

Permalink
confd: allow interface description as ifAlias
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
troglobit committed Oct 28, 2024
1 parent 710616f commit 0284e2c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/confd/src/ietf-interfaces.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
2 changes: 1 addition & 1 deletion src/confd/yang/confd.inc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ MODULES=(
"[email protected]"
"[email protected]"
"[email protected]"
"infix-interfaces@2024-10-14.yang -e vlan-filtering"
"infix-interfaces@2024-10-28.yang -e vlan-filtering"

# from rousette
"[email protected]"
Expand Down
2 changes: 1 addition & 1 deletion src/confd/yang/containers.inc
Original file line number Diff line number Diff line change
@@ -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"
"[email protected]"
)
20 changes: 17 additions & 3 deletions src/confd/yang/infix-interfaces.yang
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ module infix-interfaces {
contact "[email protected]";
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";
Expand Down Expand Up @@ -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.";

Expand Down Expand Up @@ -114,7 +131,4 @@ module infix-interfaces {
}
}
}
deviation "/if:interfaces/if:interface/if:link-up-down-trap-enable" {
deviate not-supported;
}
}
File renamed without changes.
3 changes: 3 additions & 0 deletions src/statd/python/yanger/yanger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand Down

0 comments on commit 0284e2c

Please sign in to comment.