From 89d387f782fb4402c7cc32ef524b741c9cbb90cc Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 5 Dec 2019 10:33:54 +0100 Subject: [PATCH] ifcfg-rh: add support for VRF slaves Even if the ifcfg-rh plugin doesn't support VRF connections, it must be able to read and write other connection types that have a VRF master. --- .../plugins/ifcfg-rh/nms-ifcfg-rh-reader.c | 18 ++++++++++++++++++ .../plugins/ifcfg-rh/nms-ifcfg-rh-utils.c | 2 ++ .../plugins/ifcfg-rh/nms-ifcfg-rh-utils.h | 2 +- .../plugins/ifcfg-rh/nms-ifcfg-rh-writer.c | 3 +++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c index 8fc72822de..32364aed55 100644 --- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c @@ -501,6 +501,24 @@ make_connection_setting (const char *file, } } + nm_clear_g_free (&value); + v = svGetValueStr (ifcfg, "VRF_UUID", &value); + if (!v) + v = svGetValueStr (ifcfg, "VRF", &value); + if (v) { + const char *old_value; + + if ((old_value = nm_setting_connection_get_master (s_con))) { + PARSE_WARNING ("Already configured as slave of %s. Ignoring VRF{_UUID}=\"%s\"", + old_value, v); + } else { + g_object_set (s_con, NM_SETTING_CONNECTION_MASTER, v, NULL); + g_object_set (s_con, NM_SETTING_CONNECTION_SLAVE_TYPE, + NM_SETTING_VRF_SETTING_NAME, NULL); + } + } + + nm_clear_g_free (&value); v = svGetValueStr (ifcfg, "GATEWAY_PING_TIMEOUT", &value); if (v) { diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c index 5027171931..a6a4d381ec 100644 --- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c @@ -850,6 +850,8 @@ const NMSIfcfgKeyTypeInfo nms_ifcfg_well_known_keys[] = { _KEY_TYPE ("VLAN_FLAGS", NMS_IFCFG_KEY_TYPE_IS_PLAIN ), _KEY_TYPE ("VLAN_ID", NMS_IFCFG_KEY_TYPE_IS_PLAIN ), _KEY_TYPE ("VLAN_INGRESS_PRIORITY_MAP", NMS_IFCFG_KEY_TYPE_IS_PLAIN ), + _KEY_TYPE ("VRF", NMS_IFCFG_KEY_TYPE_IS_PLAIN ), + _KEY_TYPE ("VRF_UUID", NMS_IFCFG_KEY_TYPE_IS_PLAIN ), _KEY_TYPE ("WEP_KEY_FLAGS", NMS_IFCFG_KEY_TYPE_IS_PLAIN ), _KEY_TYPE ("WPA_ALLOW_WPA", NMS_IFCFG_KEY_TYPE_IS_PLAIN ), _KEY_TYPE ("WPA_ALLOW_WPA2", NMS_IFCFG_KEY_TYPE_IS_PLAIN ), diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h index 734a6a63c2..29c9df7af7 100644 --- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h @@ -33,7 +33,7 @@ typedef struct { NMSIfcfgKeyTypeFlags key_flags; } NMSIfcfgKeyTypeInfo; -const NMSIfcfgKeyTypeInfo nms_ifcfg_well_known_keys[225]; +const NMSIfcfgKeyTypeInfo nms_ifcfg_well_known_keys[227]; const NMSIfcfgKeyTypeInfo *nms_ifcfg_well_known_key_find_info (const char *key, gssize *out_idx); diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c index 19de53ca81..7f26c3edf1 100644 --- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c @@ -1851,6 +1851,9 @@ write_connection_setting (NMSettingConnection *s_con, shvarFile *ifcfg) } else if (nm_setting_connection_is_slave_type (s_con, NM_SETTING_OVS_PORT_SETTING_NAME)) { svSetValueStr (ifcfg, "OVS_PORT_UUID", master); svSetValueStr (ifcfg, "OVS_PORT", master_iface); + } else if (nm_setting_connection_is_slave_type (s_con, NM_SETTING_VRF_SETTING_NAME)) { + svSetValueStr (ifcfg, "VRF_UUID", master); + svSetValueStr (ifcfg, "VRF", master_iface); } else { _LOGW ("don't know how to set master for a %s slave", nm_setting_connection_get_slave_type (s_con));