about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2024-10-02 22:17:51 +0200
committerMichael Biebl <biebl@debian.org>2024-10-02 22:17:51 +0200
commit56928734cbcf1d3a02fae4f152a541df1b04e04a (patch)
treeff88b37a2bf9d26caf1830ceb1e9a131375b6894 /src
parentdf14a83a8b0c4354a51b392ae51a084b4b9c1b5a (diff)
New upstream version 1.50.0 upstream/1.50.0
Diffstat (limited to 'src')
-rw-r--r--src/core/devices/nm-device.c27
-rw-r--r--src/libnm-client-impl/nm-device-hsr.c22
-rw-r--r--src/libnm-client-impl/nm-libnm-utils.c1
-rw-r--r--src/libnm-client-impl/nm-libnm-utils.h3
-rw-r--r--src/libnm-client-impl/tests/test-libnm.c7
-rw-r--r--src/libnm-core-impl/nm-setting-connection.c4
-rw-r--r--src/libnm-core-impl/tests/test-general.c2
-rw-r--r--src/libnmc-setting/settings-docs.h.in8
8 files changed, 53 insertions, 21 deletions
diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c
index 66eba209..82c2d6b8 100644
--- a/src/core/devices/nm-device.c
+++ b/src/core/devices/nm-device.c
@@ -126,12 +126,18 @@ typedef enum _nm_packed {
     ADDR_METHOD_STATE_FAILED,
 } AddrMethodState;
 
+typedef enum {
+    PORT_STATE_NOT_ATTACHED,
+    PORT_STATE_ATTACHED,
+    PORT_STATE_ATTACHING,
+} PortState;
+
 typedef struct {
     CList         lst_port;
     NMDevice     *port;
     GCancellable *cancellable;
     gulong        watch_id;
-    bool          port_is_attached;
+    PortState     port_state;
     bool          configure;
 } PortInfo;
 
@@ -6693,7 +6699,7 @@ attach_port_done(NMDevice *self, NMDevice *port, gboolean success)
     if (!info)
         return;
 
-    info->port_is_attached = success;
+    info->port_state = (success ? PORT_STATE_ATTACHED : PORT_STATE_NOT_ATTACHED);
 
     nm_device_port_notify_attach_as_port(info->port, success);
 
@@ -6756,7 +6762,7 @@ nm_device_controller_attach_port(NMDevice *self, NMDevice *port, NMConnection *c
     if (!info)
         return;
 
-    if (info->port_is_attached)
+    if (info->port_state == PORT_STATE_ATTACHED)
         success = TRUE;
     else {
         configure = (info->configure && connection != NULL);
@@ -6765,6 +6771,7 @@ nm_device_controller_attach_port(NMDevice *self, NMDevice *port, NMConnection *c
 
         nm_clear_g_cancellable(&info->cancellable);
         info->cancellable = g_cancellable_new();
+        info->port_state  = PORT_STATE_ATTACHING;
         success           = NM_DEVICE_GET_CLASS(self)->attach_port(self,
                                                          port,
                                                          connection,
@@ -6819,6 +6826,7 @@ nm_device_controller_release_port(NMDevice           *self,
     PortInfo                 *info;
     gs_unref_object NMDevice *self_free = NULL;
     gs_unref_object NMDevice *port_free = NULL;
+    const char               *port_state_str;
 
     g_return_if_fail(NM_DEVICE(self));
     g_return_if_fail(NM_DEVICE(port));
@@ -6830,11 +6838,20 @@ nm_device_controller_release_port(NMDevice           *self,
 
     info = find_port_info(self, port);
 
+    if (info->port_state == PORT_STATE_ATTACHED)
+        port_state_str = "(attached)";
+    else if (info->port_state == PORT_STATE_NOT_ATTACHED)
+        port_state_str = "(not attached)";
+    else {
+        nm_assert(info->port_state == PORT_STATE_ATTACHING);
+        port_state_str = "(attaching)";
+    }
+
     _LOGT(LOGD_CORE,
           "controller: release one port " NM_HASH_OBFUSCATE_PTR_FMT "/%s %s%s",
           NM_HASH_OBFUSCATE_PTR(port),
           nm_device_get_iface(port),
-          !info ? "(not registered)" : (info->port_is_attached ? "(attached)" : "(not attached)"),
+          !info ? "(not registered)" : port_state_str,
           release_type == RELEASE_PORT_TYPE_CONFIG_FORCE
               ? " (force-configure)"
               : (release_type == RELEASE_PORT_TYPE_CONFIG ? " (configure)" : "(no-config)"));
@@ -6850,7 +6867,7 @@ nm_device_controller_release_port(NMDevice           *self,
     nm_clear_g_cancellable(&info->cancellable);
 
     /* first, let subclasses handle the release ... */
-    if (info->port_is_attached || nm_device_managed_type_is_external(port)
+    if (info->port_state != PORT_STATE_NOT_ATTACHED || nm_device_managed_type_is_external(port)
         || release_type >= RELEASE_PORT_TYPE_CONFIG_FORCE) {
         NMTernary ret;
 
diff --git a/src/libnm-client-impl/nm-device-hsr.c b/src/libnm-client-impl/nm-device-hsr.c
index 7160bf6d..fd4da41b 100644
--- a/src/libnm-client-impl/nm-device-hsr.c
+++ b/src/libnm-client-impl/nm-device-hsr.c
@@ -20,10 +20,15 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PORT1,
                                   PROP_MULTICAST_SPEC,
                                   PROP_PRP, );
 
+enum {
+    PROPERTY_O_IDX_PORT1,
+    PROPERTY_O_IDX_PORT2,
+    _PROPERTY_O_IDX_NUM,
+};
+
 typedef struct {
     char            *supervision_address;
-    NMLDBusPropertyO port1;
-    NMLDBusPropertyO port2;
+    NMLDBusPropertyO property_o[_PROPERTY_O_IDX_NUM];
     guint8           multicast_spec;
     bool             prp;
 } NMDeviceHsrPrivate;
@@ -57,7 +62,8 @@ nm_device_hsr_get_port1(NMDeviceHsr *device)
 {
     g_return_val_if_fail(NM_IS_DEVICE_HSR(device), NULL);
 
-    return nml_dbus_property_o_get_obj(&NM_DEVICE_HSR_GET_PRIVATE(device)->port1);
+    return nml_dbus_property_o_get_obj(
+        &NM_DEVICE_HSR_GET_PRIVATE(device)->property_o[PROPERTY_O_IDX_PORT1]);
 }
 
 /**
@@ -73,7 +79,8 @@ nm_device_hsr_get_port2(NMDeviceHsr *device)
 {
     g_return_val_if_fail(NM_IS_DEVICE_HSR(device), NULL);
 
-    return nml_dbus_property_o_get_obj(&NM_DEVICE_HSR_GET_PRIVATE(device)->port2);
+    return nml_dbus_property_o_get_obj(
+        &NM_DEVICE_HSR_GET_PRIVATE(device)->property_o[PROPERTY_O_IDX_PORT2]);
 }
 
 /**
@@ -179,12 +186,12 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_hsr = NML_DBUS_META_IFACE_
         NML_DBUS_META_PROPERTY_INIT_O_PROP("Port1",
                                            PROP_PORT1,
                                            NMDeviceHsr,
-                                           _priv.port1,
+                                           _priv.property_o[PROPERTY_O_IDX_PORT1],
                                            nm_device_get_type),
         NML_DBUS_META_PROPERTY_INIT_O_PROP("Port2",
                                            PROP_PORT2,
                                            NMDeviceHsr,
-                                           _priv.port2,
+                                           _priv.property_o[PROPERTY_O_IDX_PORT2],
                                            nm_device_get_type),
         NML_DBUS_META_PROPERTY_INIT_B("Prp", PROP_PRP, NMDeviceHsr, _priv.prp),
         NML_DBUS_META_PROPERTY_INIT_S("SupervisionAddress",
@@ -203,8 +210,7 @@ nm_device_hsr_class_init(NMDeviceHsrClass *klass)
 
     _NM_OBJECT_CLASS_INIT_PRIV_PTR_DIRECT(nm_object_class, NMDeviceHsr);
 
-    _NM_OBJECT_CLASS_INIT_PROPERTY_O_FIELDS_1(nm_object_class, NMDeviceHsrPrivate, port1);
-    _NM_OBJECT_CLASS_INIT_PROPERTY_O_FIELDS_1(nm_object_class, NMDeviceHsrPrivate, port2);
+    _NM_OBJECT_CLASS_INIT_PROPERTY_O_FIELDS_N(nm_object_class, NMDeviceHsrPrivate, property_o);
 
     /**
      * NMDeviceHsr:port1:
diff --git a/src/libnm-client-impl/nm-libnm-utils.c b/src/libnm-client-impl/nm-libnm-utils.c
index 9ebca216..8af234ce 100644
--- a/src/libnm-client-impl/nm-libnm-utils.c
+++ b/src/libnm-client-impl/nm-libnm-utils.c
@@ -782,6 +782,7 @@ const NMLDBusMetaIface *const _nml_dbus_meta_ifaces[] = {
     &_nml_dbus_meta_iface_nm_device_bridge,
     &_nml_dbus_meta_iface_nm_device_dummy,
     &_nml_dbus_meta_iface_nm_device_generic,
+    &_nml_dbus_meta_iface_nm_device_hsr,
     &_nml_dbus_meta_iface_nm_device_iptunnel,
     &_nml_dbus_meta_iface_nm_device_infiniband,
     &_nml_dbus_meta_iface_nm_device_loopback,
diff --git a/src/libnm-client-impl/nm-libnm-utils.h b/src/libnm-client-impl/nm-libnm-utils.h
index fddda077..61ff442d 100644
--- a/src/libnm-client-impl/nm-libnm-utils.h
+++ b/src/libnm-client-impl/nm-libnm-utils.h
@@ -579,7 +579,7 @@ struct _NMLDBusMetaIface {
                              NML_DBUS_META_IFACE_OBJ_PROPERTIES(),                              \
                              ##__VA_ARGS__)
 
-extern const NMLDBusMetaIface *const _nml_dbus_meta_ifaces[45];
+extern const NMLDBusMetaIface *const _nml_dbus_meta_ifaces[46];
 
 extern const NMLDBusMetaIface _nml_dbus_meta_iface_nm;
 extern const NMLDBusMetaIface _nml_dbus_meta_iface_nm_accesspoint;
@@ -593,6 +593,7 @@ extern const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_bond;
 extern const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_bridge;
 extern const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_dummy;
 extern const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_generic;
+extern const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_hsr;
 extern const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_infiniband;
 extern const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_iptunnel;
 extern const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_loopback;
diff --git a/src/libnm-client-impl/tests/test-libnm.c b/src/libnm-client-impl/tests/test-libnm.c
index f677ad8e..f6bf1567 100644
--- a/src/libnm-client-impl/tests/test-libnm.c
+++ b/src/libnm-client-impl/tests/test-libnm.c
@@ -2690,6 +2690,7 @@ test_types(void)
         G(nm_device_ethernet_get_type),
         G(nm_device_generic_get_type),
         G(nm_device_get_type),
+        G(nm_device_hsr_get_type),
         G(nm_device_infiniband_get_type),
         G(nm_device_ip_tunnel_get_type),
         G(nm_device_macsec_get_type),
@@ -2762,6 +2763,7 @@ test_types(void)
         G(nm_setting_generic_get_type),
         G(nm_setting_get_type),
         G(nm_setting_gsm_get_type),
+        G(nm_setting_hsr_get_type),
         G(nm_setting_infiniband_get_type),
         G(nm_setting_ip4_config_get_type),
         G(nm_setting_ip6_config_addr_gen_mode_get_type),
@@ -3384,6 +3386,11 @@ test_dbus_meta_types(void)
             NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_30,
         },
         {
+            NM_DBUS_INTERFACE_DEVICE_HSR,
+            NM_TYPE_DEVICE_HSR,
+            NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_30,
+        },
+        {
             NM_DBUS_INTERFACE_DEVICE_INFINIBAND,
             NM_TYPE_DEVICE_INFINIBAND,
             NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_30,
diff --git a/src/libnm-core-impl/nm-setting-connection.c b/src/libnm-core-impl/nm-setting-connection.c
index b51cd46b..3298dce6 100644
--- a/src/libnm-core-impl/nm-setting-connection.c
+++ b/src/libnm-core-impl/nm-setting-connection.c
@@ -1379,13 +1379,13 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
                 if (connection)
                     goto after_interface_name;
                 iface_type = NMU_IFACE_ANY;
-            } else if (NM_IN_STRSET(ovs_iface_type, "patch")) {
+            } else if (NM_IN_STRSET(ovs_iface_type, "patch", "dpdk")) {
                 /* this interface type is internal to OVS. */
                 iface_type = NMU_IFACE_OVS;
             } else {
                 /* This interface type also requires a netdev. We need to validate
                  * for both OVS and KERNEL. */
-                nm_assert(NM_IN_STRSET(ovs_iface_type, "internal", "system", "dpdk"));
+                nm_assert(NM_IN_STRSET(ovs_iface_type, "internal", "system"));
                 iface_type = NMU_IFACE_OVS_AND_KERNEL;
             }
         } else
diff --git a/src/libnm-core-impl/tests/test-general.c b/src/libnm-core-impl/tests/test-general.c
index 0a39010c..8d4ea069 100644
--- a/src/libnm-core-impl/tests/test-general.c
+++ b/src/libnm-core-impl/tests/test-general.c
@@ -10832,7 +10832,7 @@ test_connection_ovs_ifname(gconstpointer test_data)
     /* good if bridge, port, or patch interface */
     g_object_set(s_con, NM_SETTING_CONNECTION_INTERFACE_NAME, "ovs123123123123130123123", NULL);
 
-    if (!ovs_iface_type || nm_streq(ovs_iface_type, "patch"))
+    if (!ovs_iface_type || NM_IN_STRSET(ovs_iface_type, "patch", "dpdk"))
         nmtst_assert_connection_verifies(con);
     else {
         nmtst_assert_connection_unnormalizable(con,
diff --git a/src/libnmc-setting/settings-docs.h.in b/src/libnmc-setting/settings-docs.h.in
index 091dcd64..731f32a7 100644
--- a/src/libnmc-setting/settings-docs.h.in
+++ b/src/libnmc-setting/settings-docs.h.in
@@ -159,6 +159,10 @@
 #define DESCRIBE_DOC_NM_SETTING_GSM_SIM_ID N_("The SIM card unique identifier (as given by the WWAN management service) which this connection applies to.  If given, the connection will apply to any device also allowed by \"device-id\" which contains a SIM card matching the given identifier.")
 #define DESCRIBE_DOC_NM_SETTING_GSM_SIM_OPERATOR_ID N_("A MCC/MNC string like \"310260\" or \"21601\" identifying the specific mobile network operator which this connection applies to.  If given, the connection will apply to any device also allowed by \"device-id\" and \"sim-id\" which contains a SIM card provisioned by the given operator.")
 #define DESCRIBE_DOC_NM_SETTING_GSM_USERNAME N_("The username used to authenticate with the network, if required.  Many providers do not require a username, or accept any username.  But if a username is required, it is specified here.")
+#define DESCRIBE_DOC_NM_SETTING_HSR_MULTICAST_SPEC N_("The last byte of supervision address.")
+#define DESCRIBE_DOC_NM_SETTING_HSR_PORT1 N_("The port1 interface name of the HSR. This property is mandatory.")
+#define DESCRIBE_DOC_NM_SETTING_HSR_PORT2 N_("The port2 interface name of the HSR. This property is mandatory.")
+#define DESCRIBE_DOC_NM_SETTING_HSR_PRP N_("The protocol used by the interface, whether it is PRP or HSR.")
 #define DESCRIBE_DOC_NM_SETTING_INFINIBAND_MAC_ADDRESS N_("If specified, this connection will only apply to the IPoIB device whose permanent MAC address matches. This property does not change the MAC address of the device (i.e. MAC spoofing).")
 #define DESCRIBE_DOC_NM_SETTING_INFINIBAND_MTU N_("If non-zero, only transmit packets of the specified size or smaller, breaking larger packets up into multiple frames.")
 #define DESCRIBE_DOC_NM_SETTING_INFINIBAND_P_KEY N_("The InfiniBand p-key to use for this device. A value of -1 means to use the default p-key (aka \"the p-key at index 0\"). Otherwise, it is a 16-bit unsigned integer, whose high bit 0x8000 is set if it is a \"full membership\" p-key. The values 0 and 0x8000 are not allowed. With the p-key set, the interface name is always \"$parent.$p_key\". Setting \"connection.interface-name\" to another name is not supported. Note that kernel will internally always set the full membership bit, although the interface name does not reflect that. Usually the user would want to configure a full membership p-key with 0x8000 flag set.")
@@ -464,10 +468,6 @@
 #define DESCRIBE_DOC_NM_SETTING_HOSTNAME_FROM_DNS_LOOKUP N_("Whether the system hostname can be determined from reverse DNS lookup of addresses on this device. When set to \"default\" (-1), the value from global configuration is used. If the property doesn't have a value in the global configuration, NetworkManager assumes the value to be \"true\" (1).")
 #define DESCRIBE_DOC_NM_SETTING_HOSTNAME_ONLY_FROM_DEFAULT N_("If set to \"true\" (1), NetworkManager attempts to get the hostname via DHCPv4/DHCPv6 or reverse DNS lookup on this device only when the device has the default route for the given address family (IPv4/IPv6). If set to \"false\" (0), the hostname can be set from this device even if it doesn't have the default route. When set to \"default\" (-1), the value from global configuration is used. If the property doesn't have a value in the global configuration, NetworkManager assumes the value to be \"false\" (0).")
 #define DESCRIBE_DOC_NM_SETTING_HOSTNAME_PRIORITY N_("The relative priority of this connection to determine the system hostname. A lower numerical value is better (higher priority).  A connection with higher priority is considered before connections with lower priority. If the value is zero, it can be overridden by a global value from NetworkManager configuration. If the property doesn't have a value in the global configuration, the value is assumed to be 100. Negative values have the special effect of excluding other connections with a greater numerical priority value; so in presence of at least one negative priority, only connections with the lowest priority value will be used to determine the hostname.")
-#define DESCRIBE_DOC_NM_SETTING_HSR_MULTICAST_SPEC N_("The last byte of supervision address.")
-#define DESCRIBE_DOC_NM_SETTING_HSR_PORT1 N_("The port1 interface name of the HSR. This property is mandatory.")
-#define DESCRIBE_DOC_NM_SETTING_HSR_PORT2 N_("The port2 interface name of the HSR. This property is mandatory.")
-#define DESCRIBE_DOC_NM_SETTING_HSR_PRP N_("The protocol used by the interface, whether it is PRP or HSR.")
 #define DESCRIBE_DOC_NM_SETTING_LINK_GRO_MAX_SIZE N_("The maximum size of a packet built by the Generic Receive Offload stack for this device. The value must be between 0 and 4294967295. When set to -1, the existing value is preserved.")
 #define DESCRIBE_DOC_NM_SETTING_LINK_GSO_MAX_SEGMENTS N_("The maximum segments of a Generic Segment Offload packet the device should accept. The value must be between 0 and 4294967295. When set to -1, the existing value is preserved.")
 #define DESCRIBE_DOC_NM_SETTING_LINK_GSO_MAX_SIZE N_("The maximum size of a Generic Segment Offload packet the device should accept. The value must be between 0 and 4294967295. When set to -1, the existing value is preserved.")