diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/shared/netif-naming-scheme.c | 10 | ||||
-rw-r--r-- | src/shared/netif-naming-scheme.h | 2 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/shared/netif-naming-scheme.c b/src/shared/netif-naming-scheme.c index 287a942014..d949f7381a 100644 --- a/src/shared/netif-naming-scheme.c +++ b/src/shared/netif-naming-scheme.c @@ -22,16 +22,22 @@ static const NamingScheme naming_schemes[] = { { "v247", NAMING_V247 }, { "v249", NAMING_V249 }, /* … add more schemes here, as the logic to name devices is updated … */ + + EXTRA_NET_NAMING_MAP }; const NamingScheme* naming_scheme_from_name(const char *name) { - if (streq(name, "latest")) - return naming_schemes + ELEMENTSOF(naming_schemes) - 1; + /* "latest" may either be defined explicitly by the extra map, in which case we we will find it in + * the table like any other name. After iterating through the table, we check for "latest" again, + * which means that if not mapped explicitly, it maps to the last defined entry, whatever that is. */ for (size_t i = 0; i < ELEMENTSOF(naming_schemes); i++) if (streq(naming_schemes[i].name, name)) return naming_schemes + i; + if (streq(name, "latest")) + return naming_schemes + ELEMENTSOF(naming_schemes) - 1; + return NULL; } diff --git a/src/shared/netif-naming-scheme.h b/src/shared/netif-naming-scheme.h index f5d040cc09..0141a4fb90 100644 --- a/src/shared/netif-naming-scheme.h +++ b/src/shared/netif-naming-scheme.h @@ -46,6 +46,8 @@ typedef enum NamingSchemeFlags { NAMING_V247 = NAMING_V245 | NAMING_BRIDGE_NO_SLOT, NAMING_V249 = NAMING_V247 | NAMING_SLOT_FUNCTION_ID | NAMING_16BIT_INDEX | NAMING_REPLACE_STRICTLY, + EXTRA_NET_NAMING_SCHEMES + _NAMING_SCHEME_FLAGS_INVALID = -EINVAL, } NamingSchemeFlags; |