mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-10 21:00:23 +01:00
ifcfg-rh: treat base name as numbered tag and fix detection of NETMASK
We call svFindFirstNumberedKey() to check whether we have any NETMASK set. Since commit9085c5c3a9('ifcfg-rh: rename svFindFirstKeyWithPrefix() to svFindFirstNumberedKey() for finding NETMASK') that function would no longer find the "NETMASK" without number. Fix that, by letting nms_ifcfg_rh_utils_is_numbered_tag() return TRUE for the tag itself. This also makes more sense, because it matches our common understanding what numbered tags are. Adjust the other callers that don't want this behavior to explicitly check. Fixes:9085c5c3a9('ifcfg-rh: rename svFindFirstKeyWithPrefix() to svFindFirstNumberedKey() for finding NETMASK')
This commit is contained in:
parent
6404a363bd
commit
003a657c5c
2 changed files with 37 additions and 21 deletions
|
|
@ -607,8 +607,14 @@ nms_ifcfg_rh_utils_is_numbered_tag_impl (const char *key,
|
|||
|
||||
key += tag_len;
|
||||
|
||||
if (key[0] == '\0')
|
||||
return FALSE;
|
||||
if (key[0] == '\0') {
|
||||
/* The key has no number suffix. We treat this also as a numbered
|
||||
* tag, and it is for certain tags like "IPADDR", but not so much
|
||||
* for others like "ROUTING_RULE_". The caller may want to handle
|
||||
* this case specially. */
|
||||
NM_SET_OUT (out_idx, -1);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!NM_STRCHAR_ALL (key, ch, g_ascii_isdigit (ch)))
|
||||
return FALSE;
|
||||
|
|
@ -885,11 +891,14 @@ nms_ifcfg_rh_utils_is_well_known_key (const char *key)
|
|||
if (ti) {
|
||||
if (NM_FLAGS_ANY (ti->key_flags, NMS_IFCFG_KEY_TYPE_IS_PLAIN
|
||||
| NMS_IFCFG_KEY_TYPE_IS_NUMBERED)) {
|
||||
/* these tags are valid on full match. */
|
||||
/* These tags are valid on full match.
|
||||
*
|
||||
* Note that numbered tags we also treat as valid if they have no
|
||||
* suffix. That is correct for "IPADDR", but less so for "ROUTING_RULE_". */
|
||||
return ti;
|
||||
}
|
||||
nm_assert (NM_FLAGS_HAS (ti->key_flags, NMS_IFCFG_KEY_TYPE_IS_PREFIX));
|
||||
/* a prefix tag needs some extra words afterwards. */
|
||||
/* a prefix tag needs some extra suffix afterwards to be valid. */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -927,19 +927,27 @@ _svKeyMatchesType (const char *key, SvKeyType match_key_type)
|
|||
if (NM_FLAGS_HAS (match_key_type, SV_KEY_TYPE_ANY))
|
||||
return TRUE;
|
||||
|
||||
#define _IS_NUMBERED(key, tag) \
|
||||
({ \
|
||||
gint64 _idx; \
|
||||
\
|
||||
NMS_IFCFG_RH_UTIL_IS_NUMBERED_TAG (key, tag, &_idx) \
|
||||
&& _idx >= 0; \
|
||||
})
|
||||
|
||||
if (NM_FLAGS_HAS (match_key_type, SV_KEY_TYPE_ROUTE_SVFORMAT)) {
|
||||
if ( NMS_IFCFG_RH_UTIL_IS_NUMBERED_TAG (key, "ADDRESS", NULL)
|
||||
|| NMS_IFCFG_RH_UTIL_IS_NUMBERED_TAG (key, "NETMASK", NULL)
|
||||
|| NMS_IFCFG_RH_UTIL_IS_NUMBERED_TAG (key, "GATEWAY", NULL)
|
||||
|| NMS_IFCFG_RH_UTIL_IS_NUMBERED_TAG (key, "METRIC", NULL)
|
||||
|| NMS_IFCFG_RH_UTIL_IS_NUMBERED_TAG (key, "OPTIONS", NULL))
|
||||
if ( _IS_NUMBERED (key, "ADDRESS")
|
||||
|| _IS_NUMBERED (key, "NETMASK")
|
||||
|| _IS_NUMBERED (key, "GATEWAY")
|
||||
|| _IS_NUMBERED (key, "METRIC")
|
||||
|| _IS_NUMBERED (key, "OPTIONS"))
|
||||
return TRUE;
|
||||
}
|
||||
if (NM_FLAGS_HAS (match_key_type, SV_KEY_TYPE_IP4_ADDRESS)) {
|
||||
if ( NMS_IFCFG_RH_UTIL_IS_NUMBERED_TAG (key, "IPADDR", NULL)
|
||||
|| NMS_IFCFG_RH_UTIL_IS_NUMBERED_TAG (key, "PREFIX", NULL)
|
||||
|| NMS_IFCFG_RH_UTIL_IS_NUMBERED_TAG (key, "NETMASK", NULL)
|
||||
|| NMS_IFCFG_RH_UTIL_IS_NUMBERED_TAG (key, "GATEWAY", NULL))
|
||||
if ( _IS_NUMBERED (key, "IPADDR")
|
||||
|| _IS_NUMBERED (key, "PREFIX")
|
||||
|| _IS_NUMBERED (key, "NETMASK")
|
||||
|| _IS_NUMBERED (key, "GATEWAY"))
|
||||
return TRUE;
|
||||
}
|
||||
if (NM_FLAGS_HAS (match_key_type, SV_KEY_TYPE_USER)) {
|
||||
|
|
@ -947,20 +955,20 @@ _svKeyMatchesType (const char *key, SvKeyType match_key_type)
|
|||
return TRUE;
|
||||
}
|
||||
if (NM_FLAGS_HAS (match_key_type, SV_KEY_TYPE_TC)) {
|
||||
if ( NMS_IFCFG_RH_UTIL_IS_NUMBERED_TAG (key, "QDISC", NULL)
|
||||
|| NMS_IFCFG_RH_UTIL_IS_NUMBERED_TAG (key, "FILTER", NULL))
|
||||
if ( _IS_NUMBERED (key, "QDISC")
|
||||
|| _IS_NUMBERED (key, "FILTER"))
|
||||
return TRUE;
|
||||
}
|
||||
if (NM_FLAGS_HAS (match_key_type, SV_KEY_TYPE_SRIOV_VF)) {
|
||||
if (NMS_IFCFG_RH_UTIL_IS_NUMBERED_TAG (key, "SRIOV_VF", NULL))
|
||||
if (_IS_NUMBERED (key, "SRIOV_VF"))
|
||||
return TRUE;
|
||||
}
|
||||
if (NM_FLAGS_HAS (match_key_type, SV_KEY_TYPE_ROUTING_RULE4)) {
|
||||
if (NMS_IFCFG_RH_UTIL_IS_NUMBERED_TAG (key, "ROUTING_RULE_", NULL))
|
||||
if (_IS_NUMBERED (key, "ROUTING_RULE_"))
|
||||
return TRUE;
|
||||
}
|
||||
if (NM_FLAGS_HAS (match_key_type, SV_KEY_TYPE_ROUTING_RULE6)) {
|
||||
if (NMS_IFCFG_RH_UTIL_IS_NUMBERED_TAG (key, "ROUTING_RULE6_", NULL))
|
||||
if (_IS_NUMBERED (key, "ROUTING_RULE6_"))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -972,9 +980,8 @@ svNumberedParseKey (const char *key)
|
|||
{
|
||||
gint64 idx;
|
||||
|
||||
if (NMS_IFCFG_RH_UTIL_IS_NUMBERED_TAG (key, "ROUTING_RULE_", &idx))
|
||||
return idx;
|
||||
if (NMS_IFCFG_RH_UTIL_IS_NUMBERED_TAG (key, "ROUTING_RULE6_", &idx))
|
||||
if ( NMS_IFCFG_RH_UTIL_IS_NUMBERED_TAG (key, "ROUTING_RULE_", &idx)
|
||||
|| NMS_IFCFG_RH_UTIL_IS_NUMBERED_TAG (key, "ROUTING_RULE6_", &idx))
|
||||
return idx;
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue