summary refs log tree commit diff
path: root/src/libnm-core-impl/nm-setting-bridge.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2023-02-10 11:50:34 +0100
committerMichael Biebl <biebl@debian.org>2023-02-10 11:50:34 +0100
commit1372848511cb896b80b51ed1a3e9606bd9816631 (patch)
tree674792b9385bdef935988894b45f06b2af39f88c /src/libnm-core-impl/nm-setting-bridge.c
parent40ec077ea305994c1fc2130add6787ca0c73e2c6 (diff)
New upstream version 1.42.0 upstream/1.42.0
Diffstat (limited to 'src/libnm-core-impl/nm-setting-bridge.c')
-rw-r--r--src/libnm-core-impl/nm-setting-bridge.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/src/libnm-core-impl/nm-setting-bridge.c b/src/libnm-core-impl/nm-setting-bridge.c
index 89611147..c1a2621d 100644
--- a/src/libnm-core-impl/nm-setting-bridge.c
+++ b/src/libnm-core-impl/nm-setting-bridge.c
@@ -109,7 +109,7 @@ G_DEFINE_TYPE(NMSettingBridge, nm_setting_bridge, NM_TYPE_SETTING)
 G_DEFINE_BOXED_TYPE(NMBridgeVlan, nm_bridge_vlan, _nm_bridge_vlan_dup, nm_bridge_vlan_unref)
 
 struct _NMBridgeVlan {
-    guint   refcount;
+    int     refcount;
     guint16 vid_start;
     guint16 vid_end;
     bool    untagged : 1;
@@ -132,6 +132,8 @@ NM_IS_BRIDGE_VLAN(const NMBridgeVlan *self, gboolean also_sealed)
  * Setting @vid_end to 0 is equivalent to setting it to @vid_start
  * and creates a single-id VLAN.
  *
+ * Since 1.42, ref-counting of #NMBridgeVlan is thread-safe.
+ *
  * Returns: (transfer full): the new #NMBridgeVlan object.
  *
  * Since: 1.18
@@ -148,11 +150,12 @@ nm_bridge_vlan_new(guint16 vid_start, guint16 vid_end)
     g_return_val_if_fail(vid_end <= NM_BRIDGE_VLAN_VID_MAX, NULL);
     g_return_val_if_fail(vid_start <= vid_end, NULL);
 
-    vlan            = g_slice_new0(NMBridgeVlan);
-    vlan->refcount  = 1;
-    vlan->vid_start = vid_start;
-    vlan->vid_end   = vid_end;
-
+    vlan  = g_slice_new(NMBridgeVlan);
+    *vlan = (NMBridgeVlan){
+        .refcount  = 1,
+        .vid_start = vid_start,
+        .vid_end   = vid_end,
+    };
     return vlan;
 }
 
@@ -164,6 +167,8 @@ nm_bridge_vlan_new(guint16 vid_start, guint16 vid_end)
  *
  * Returns: the input argument @vlan object.
  *
+ * Since 1.42, ref-counting of #NMBridgeVlan is thread-safe.
+ *
  * Since: 1.18
  **/
 NMBridgeVlan *
@@ -171,9 +176,9 @@ nm_bridge_vlan_ref(NMBridgeVlan *vlan)
 {
     g_return_val_if_fail(NM_IS_BRIDGE_VLAN(vlan, TRUE), NULL);
 
-    nm_assert(vlan->refcount < G_MAXUINT);
+    nm_assert(vlan->refcount < G_MAXINT);
 
-    vlan->refcount++;
+    g_atomic_int_inc(&vlan->refcount);
     return vlan;
 }
 
@@ -184,6 +189,8 @@ nm_bridge_vlan_ref(NMBridgeVlan *vlan)
  * Decreases the reference count of the object.  If the reference count
  * reaches zero the object will be destroyed.
  *
+ * Since 1.42, ref-counting of #NMBridgeVlan is thread-safe.
+ *
  * Since: 1.18
  **/
 void
@@ -191,7 +198,7 @@ nm_bridge_vlan_unref(NMBridgeVlan *vlan)
 {
     g_return_if_fail(NM_IS_BRIDGE_VLAN(vlan, TRUE));
 
-    if (--vlan->refcount == 0)
+    if (g_atomic_int_dec_and_test(&vlan->refcount))
         g_slice_free(NMBridgeVlan, vlan);
 }
 
@@ -1426,10 +1433,9 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
      * If this field is left unspecified, the "ethernet.cloned-mac-address" is
      * referred instead to generate the initial MAC address. Note that setting
      * "ethernet.cloned-mac-address" anyway overwrites the MAC address of
-     * the bridge later while activating the bridge. Hence, this property
-     * is deprecated.
+     * the bridge later while activating the bridge.
      *
-     * Deprecated: 1.12: Use the ethernet.cloned-mac-address property instead.
+     * Deprecated: 1.12: Use the #NMSettingWired:cloned-mac-address property instead.
      **/
     /* ---keyfile---
      * property: mac-address
@@ -1439,7 +1445,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
      * example: mac-address=00:22:68:12:79:A2
      *  mac-address=0;34;104;18;121;162;
      * ---end---
-     * ---ifcfg-rh---
+     */
+    /* ---ifcfg-rh---
      * property: mac-address
      * variable: BRIDGE_MACADDR(+)
      * description: MAC address of the bridge. Note that this requires a recent
@@ -1454,7 +1461,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
                                                    NM_SETTING_PARAM_INFERRABLE,
                                                    NMSettingBridge,
                                                    _priv.mac_address,
-                                                   .direct_set_string_mac_address_len = ETH_ALEN);
+                                                   .direct_set_string_mac_address_len = ETH_ALEN,
+                                                   .is_deprecated                     = TRUE, );
 
     /**
      * NMSettingBridge:stp:
@@ -1748,7 +1756,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
      */
     _nm_properties_override_dbus(properties_override,
                                  "interface-name",
-                                 &nm_sett_info_propert_type_deprecated_interface_name);
+                                 &nm_sett_info_propert_type_deprecated_interface_name,
+                                 .dbus_deprecated = TRUE, );
 
     /**
      * NMSettingBridge:group-address: