Fix long labels cause ifup/ifdown commands to fail
When labels with more than 15 characters are used for addresses, the ifup/ifdown commands fail due to the hard limit on label length imposed by the linux kernel. The label for addresses in starlingx is composed by the interface name followed by a colon and a string in the format <network_id>-<address_id>, which can surpass the 15 character limit if the interface name is sufficiently long. For example: enp0s10vlan100:0-35 This commit patches the ifupdown package to add a conditional to the source code where the 'ip' command is formatted. The conditional replaces the label name by the interface name itself, if the former is more than 15 characters long. Test plan Setup: - System: AIO-SX - Interfaces: > enp0s8: ethernet, assigned to mgmt and cluster-host networks > enp0s9: bond slave > enp0s10: bond slave > bond0longname: bond on top of enp0s9 and enp0s10, data > vlanshort: vlan id 300 on top of bond0longname, data > vlan400longname: vlan id 400 on top of bond0longname, data - Both mgmt and cluster-host networks are dual stack - All data interfaces have both IPv4 and IPv6 static addresses [PASS] Run ifup command individually for all labels, check that addresses are correctly assigned [PASS] Run ifdown command individually for all labels, check that addresses are correctly removed [PASS] Manually change MTU value in /etc/network/interfaces.d/ifcfg-* files for enp0s8 and enp0s9, call /usr/local/bin/ apply_network_config.sh script, check that all interfaces were correctly configured (changing MTU causes the affected interfaces and all the dependent ones and corresponding labels to be put down and up again, logs are in /var/log/user.log) Story: 2011027 Task: 50775 Change-Id: I10da435437356c943d6e30341e7322e25094f407 Signed-off-by: Lucas Ratusznei Fonseca <lucas.ratuszneifonseca@windriver.com>
This commit is contained in:
parent
dfef542445
commit
64d4d7e522
@ -0,0 +1,37 @@
|
||||
From ab7e1b45ce9c7cb9a43bc82edb706dd9e8b89ee3 Mon Sep 17 00:00:00 2001
|
||||
From: Lucas Ratusznei Fonseca <lucas.ratuszneifonseca@windriver.com>
|
||||
Date: Wed, 7 Aug 2024 01:30:19 -0300
|
||||
Subject: [PATCH] Fix long labels cause command to fail
|
||||
|
||||
---
|
||||
execute.c | 11 +++++++++++
|
||||
1 file changed, 11 insertions(+)
|
||||
|
||||
diff --git a/execute.c b/execute.c
|
||||
index 05fdfd1..3a731f2 100644
|
||||
--- a/execute.c
|
||||
+++ b/execute.c
|
||||
@@ -460,9 +460,20 @@ int strncmpz(const char *l, const char *r, size_t llen) {
|
||||
return i;
|
||||
}
|
||||
|
||||
+#define LINUX_MAX_IFNAME_LEN 15
|
||||
+
|
||||
char *get_var(const char *id, size_t idlen, interface_defn *ifd) {
|
||||
if (strncmpz(id, "iface", idlen) == 0)
|
||||
+ {
|
||||
+ if(strlen(ifd->real_iface) > LINUX_MAX_IFNAME_LEN)
|
||||
+ {
|
||||
+ const char* colon_pos = strchr(ifd->real_iface, ':');
|
||||
+ if(colon_pos)
|
||||
+ return strndup(ifd->real_iface, colon_pos - ifd->real_iface);
|
||||
+ }
|
||||
+
|
||||
return strdup(ifd->real_iface);
|
||||
+ }
|
||||
|
||||
for (int i = 0; i < ifd->n_options; i++) {
|
||||
if (strncmpz(id, ifd->option[i].name, idlen) == 0) {
|
||||
--
|
||||
2.34.1
|
||||
|
@ -1 +1,2 @@
|
||||
0001-Fix-detection-logic.patch
|
||||
0002-Fix-long-labels-cause-command-to-fail.patch
|
||||
|
Loading…
Reference in New Issue
Block a user