From 49f845e2be5070711d36c12c263347d3d4b6e108 Mon Sep 17 00:00:00 2001 From: hanjinpeng Date: Wed, 16 Sep 2026 09:11:37 -0400 Subject: [PATCH] rename_device: recognize quoted and other true values of VLAN= VLAN configurations must be skipped when looking for the name of a physical device by its MAC address. Only the literal line VLAN=yes was recognized, so e.g. VLAN="yes" (common in ifcfg files) or VLAN=true was ignored and the physical NIC was renamed to the VLAN device name (e.g. eth0 -> eth0.100) if the VLAN config contained HWADDR. Dequote the value and evaluate it the same way as is_true() used by ifup does. --- src/rename_device.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/rename_device.c b/src/rename_device.c index e6b09f45..01b246b2 100644 --- a/src/rename_device.c +++ b/src/rename_device.c @@ -140,6 +140,16 @@ int isCfg(const struct dirent *dent) { return 1; } +/* Evaluate shvar-style booleans, see is_true() in /etc/init.d/functions */ +static int is_true(const char *value) { + return !g_ascii_strcasecmp(value, "yes") || + !g_ascii_strcasecmp(value, "y") || + !g_ascii_strcasecmp(value, "true") || + !g_ascii_strcasecmp(value, "t") || + !g_ascii_strcasecmp(value, "on") || + !strcmp(value, "1"); +} + static inline char *dequote(char *start, char *end) { char *c; //remove comments and trailing whitespace @@ -215,8 +225,8 @@ struct netdev *get_configs() { hwaddr = dequote(lines[i] + 7, NULL); } #endif - if (g_str_has_prefix(lines[i],"VLAN=yes")) { - vlan=1; + if (g_str_has_prefix(lines[i],"VLAN=")) { + vlan = is_true(dequote(lines[i] + 5, NULL)); } } if (!devname || !hwaddr || vlan) {