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: 39bfcf7aab ('all: add "link" setting')
This commit is contained in:
Beniamino Galvani 2023-03-16 11:02:41 +01:00
parent 043c18bf0f
commit e96bb430e2
2 changed files with 7 additions and 2 deletions

View file

@ -334,7 +334,7 @@ DEVICETYPE=TeamPort
<xsl:template match="setting">
<xsl:variable name="setting_name" select="../@name"/>
<xsl:variable name="unsupported" select="'6lowpan, 802-11-olpc-mesh, adsl, bluetooth, cdma, dummy, generic, gsm, ip-tunnel, loopback, macsec, macvlan, ovs-bridge, ovs-dpdk, ovs-interface, ovs-patch, ovs-port, ppp, pppoe, serial, tun, veth, vpn, vrf, vxlan, wifi-p2p, wimax, wireguard, wpan'"/>
<xsl:variable name="unsupported" select="'6lowpan, 802-11-olpc-mesh, adsl, bluetooth, cdma, dummy, generic, gsm, ip-tunnel, link, loopback, macsec, macvlan, ovs-bridge, ovs-dpdk, ovs-interface, ovs-patch, ovs-port, ppp, pppoe, serial, tun, veth, vpn, vrf, vxlan, wifi-p2p, wimax, wireguard, wpan'"/>
<xsl:if test="not (contains(concat(' ', $unsupported, ','), concat(' ', @name, ',')))">
<table>
<title><xsl:value-of select="@name"/> setting</title>

View file

@ -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);