From e96bb430e2b8b28275803cf7e448caff60347260 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 16 Mar 2023 11:02:41 +0100 Subject: [PATCH] ifcfg-rh: fail to save connections with the 'link' setting Fail to save a connection with a 'link' setting instead of just ignoring it. Now: $ nmcli connection add type ethernet ifname foobar Connection 'ethernet-foobar' (c3f6f067-e1d5-4bb1-8d67-e09109253a79) successfully added. $ nmcli connection modify ethernet-foobar link.tx-queue-length 1234 Error: Failed to modify connection 'ethernet-foobar': failed to update connection: The ifcfg-rh plugin doesn't support setting 'link'. If you are modifying an existing connection profile saved in ifcfg-rh format, please migrate the connection to keyfile using 'nmcli connection migrate c3f6f067-e1d5-4bb1-8d67-e09109253a79' or via the Update2() D-Bus API and try again. $ nmcli connection migrate c3f6f067-e1d5-4bb1-8d67-e09109253a79 Connection 'ethernet-foobar' (c3f6f067-e1d5-4bb1-8d67-e09109253a79) successfully migrated. $ nmcli connection modify ethernet-foobar link.tx-queue-length 1234 $ Fixes: 39bfcf7aab97 ('all: add "link" setting') --- man/nm-settings-ifcfg-rh.xsl | 2 +- src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/man/nm-settings-ifcfg-rh.xsl b/man/nm-settings-ifcfg-rh.xsl index 69e3b7b44d..b389b7e913 100644 --- a/man/nm-settings-ifcfg-rh.xsl +++ b/man/nm-settings-ifcfg-rh.xsl @@ -334,7 +334,7 @@ DEVICETYPE=TeamPort - + <xsl:value-of select="@name"/> setting diff --git a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c index cbf26540fe..08deaf5abd 100644 --- a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c +++ b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c @@ -61,7 +61,7 @@ /*****************************************************************************/ -static void _nm_unused +static void set_error_unsupported(GError **error, NMConnection *connection, const char *name, @@ -3506,6 +3506,11 @@ do_write_construct(NMConnection *connection, write_sriov_setting(connection, ifcfg); write_tc_setting(connection, ifcfg); + if (_nm_connection_get_setting(connection, NM_TYPE_SETTING_LINK)) { + set_error_unsupported(error, connection, "link", TRUE); + return FALSE; + } + route_path_is_svformat = utils_has_route_file_new_syntax(route_path); has_complex_routes_v4 = utils_has_complex_routes(ifcfg_name, AF_INET);