summaryrefslogtreecommitdiff
path: root/libnm-core/nm-setting-team-port.c
blob: 6c087aa9a78461b0cc2cc5bc2686603010cb49c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
/*
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA.
 *
 * Copyright 2017 Red Hat, Inc.
 * Copyright 2013 Jiri Pirko <jiri@resnulli.us>
 */

#include "nm-default.h"

#include "nm-setting-team-port.h"

#include <ctype.h>
#include <stdlib.h>

#include "nm-utils.h"
#include "nm-utils-private.h"
#include "nm-connection-private.h"
#include "nm-setting-connection.h"
#include "nm-team-utils.h"

/**
 * SECTION:nm-setting-team-port
 * @short_description: Describes connection properties for team ports
 *
 * The #NMSettingTeamPort object is a #NMSetting subclass that describes
 * optional properties that apply to team ports.
 **/

/*****************************************************************************/

static GParamSpec *obj_properties[_NM_TEAM_ATTRIBUTE_PORT_NUM] = { NULL, };

typedef struct {
	NMTeamSetting *team_setting;
} NMSettingTeamPortPrivate;

G_DEFINE_TYPE (NMSettingTeamPort, nm_setting_team_port, NM_TYPE_SETTING)

#define NM_SETTING_TEAM_PORT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_TEAM_PORT, NMSettingTeamPortPrivate))

/*****************************************************************************/

NMTeamSetting *
_nm_setting_team_port_get_team_setting (NMSettingTeamPort *setting)
{
	return NM_SETTING_TEAM_PORT_GET_PRIVATE (setting)->team_setting;
}

/*****************************************************************************/

#define _maybe_changed(self, changed) \
	nm_team_setting_maybe_changed (NM_SETTING (_NM_ENSURE_TYPE (NMSettingTeamPort *, self)), (const GParamSpec *const*) obj_properties, (changed))

#define _maybe_changed_with_assert(self, changed) \
	G_STMT_START { \
		if (!_maybe_changed ((self), (changed))) \
			nm_assert_not_reached (); \
	} G_STMT_END

/*****************************************************************************/

/**
 * nm_setting_team_port_get_config:
 * @setting: the #NMSettingTeamPort
 *
 * Returns: the #NMSettingTeamPort:config property of the setting
 **/
const char *
nm_setting_team_port_get_config (NMSettingTeamPort *setting)
{
	g_return_val_if_fail (NM_IS_SETTING_TEAM_PORT (setting), NULL);

	return nm_team_setting_config_get (NM_SETTING_TEAM_PORT_GET_PRIVATE (setting)->team_setting);
}

/**
 * nm_setting_team_port_get_queue_id:
 * @setting: the #NMSettingTeamPort
 *
 * Returns: the #NMSettingTeamPort:queue_id property of the setting
 *
 * Since: 1.12
 **/
int
nm_setting_team_port_get_queue_id (NMSettingTeamPort *setting)
{
	g_return_val_if_fail (NM_IS_SETTING_TEAM_PORT (setting), -1);

	return NM_SETTING_TEAM_PORT_GET_PRIVATE (setting)->team_setting->d.port.queue_id;
}

/**
 * nm_setting_team_port_get_prio:
 * @setting: the #NMSettingTeamPort
 *
 * Returns: the #NMSettingTeamPort:prio property of the setting
 *
 * Since: 1.12
 **/
int
nm_setting_team_port_get_prio (NMSettingTeamPort *setting)
{
	g_return_val_if_fail (NM_IS_SETTING_TEAM_PORT (setting), 0);

	return NM_SETTING_TEAM_PORT_GET_PRIVATE (setting)->team_setting->d.port.prio;
}

/**
 * nm_setting_team_port_get_sticky:
 * @setting: the #NMSettingTeamPort
 *
 * Returns: the #NMSettingTeamPort:sticky property of the setting
 *
 * Since: 1.12
 **/
gboolean
nm_setting_team_port_get_sticky (NMSettingTeamPort *setting)
{
	g_return_val_if_fail (NM_IS_SETTING_TEAM_PORT (setting), FALSE);

	return NM_SETTING_TEAM_PORT_GET_PRIVATE (setting)->team_setting->d.port.sticky;
}

/**
 * nm_setting_team_port_get_lacp_prio:
 * @setting: the #NMSettingTeamPort
 *
 * Returns: the #NMSettingTeamPort:lacp-prio property of the setting
 *
 * Since: 1.12
 **/
int
nm_setting_team_port_get_lacp_prio (NMSettingTeamPort *setting)
{
	g_return_val_if_fail (NM_IS_SETTING_TEAM_PORT (setting), 0);

	return NM_SETTING_TEAM_PORT_GET_PRIVATE (setting)->team_setting->d.port.lacp_prio;
}

/**
 * nm_setting_team_port_get_lacp_key:
 * @setting: the #NMSettingTeamPort
 *
 * Returns: the #NMSettingTeamPort:lacp-key property of the setting
 *
 * Since: 1.12
 **/
int
nm_setting_team_port_get_lacp_key (NMSettingTeamPort *setting)
{
	g_return_val_if_fail (NM_IS_SETTING_TEAM_PORT (setting), 0);

	return NM_SETTING_TEAM_PORT_GET_PRIVATE (setting)->team_setting->d.port.lacp_key;
}

/**
 * nm_setting_team_port_get_num_link_watchers:
 * @setting: the #NMSettingTeamPort
 *
 * Returns: the number of configured link watchers
 *
 * Since: 1.12
 **/
guint
nm_setting_team_port_get_num_link_watchers (NMSettingTeamPort *setting)
{
	g_return_val_if_fail (NM_IS_SETTING_TEAM_PORT (setting), 0);

	return NM_SETTING_TEAM_PORT_GET_PRIVATE (setting)->team_setting->d.link_watchers->len;
}

/**
 * nm_setting_team_port_get_link_watcher:
 * @setting: the #NMSettingTeamPort
 * @idx: index number of the link watcher to return
 *
 * Returns: (transfer none): the link watcher at index @idx.
 *
 * Since: 1.12
 **/
NMTeamLinkWatcher *
nm_setting_team_port_get_link_watcher (NMSettingTeamPort *setting, guint idx)
{
	NMSettingTeamPortPrivate *priv;

	g_return_val_if_fail (NM_IS_SETTING_TEAM_PORT (setting), NULL);

	priv = NM_SETTING_TEAM_PORT_GET_PRIVATE (setting);

	g_return_val_if_fail (idx < priv->team_setting->d.link_watchers->len, NULL);

	return priv->team_setting->d.link_watchers->pdata[idx];
}

/**
 * nm_setting_team_port_add_link_watcher:
 * @setting: the #NMSettingTeamPort
 * @link_watcher: the link watcher to add
 *
 * Appends a new link watcher to the setting.
 *
 * Returns: %TRUE if the link watcher is added; %FALSE if an identical link
 * watcher was already there.
 *
 * Since: 1.12
 **/
gboolean
nm_setting_team_port_add_link_watcher (NMSettingTeamPort *setting,
                                       NMTeamLinkWatcher *link_watcher)
{
	g_return_val_if_fail (NM_IS_SETTING_TEAM_PORT (setting), FALSE);
	g_return_val_if_fail (link_watcher != NULL, FALSE);

	return _maybe_changed (setting,
	                       nm_team_setting_value_link_watchers_add (NM_SETTING_TEAM_PORT_GET_PRIVATE (setting)->team_setting,
	                                                                link_watcher));
}

/**
 * nm_setting_team_port_remove_link_watcher:
 * @setting: the #NMSettingTeamPort
 * @idx: index number of the link watcher to remove
 *
 * Removes the link watcher at index #idx.
 *
 * Since: 1.12
 **/
void
nm_setting_team_port_remove_link_watcher (NMSettingTeamPort *setting, guint idx)
{
	NMSettingTeamPortPrivate *priv;

	g_return_if_fail (NM_IS_SETTING_TEAM_PORT (setting));

	priv = NM_SETTING_TEAM_PORT_GET_PRIVATE (setting);

	g_return_if_fail (idx < priv->team_setting->d.link_watchers->len);

	_maybe_changed_with_assert (setting,
	                            nm_team_setting_value_link_watchers_remove (priv->team_setting,
	                                                                        idx));
}

/**
 * nm_setting_team_port_remove_link_watcher_by_value:
 * @setting: the #NMSettingTeamPort
 * @link_watcher: the link watcher to remove
 *
 * Removes the link watcher entry matching link_watcher.
 *
 * Returns: %TRUE if the link watcher was found and removed, %FALSE otherwise.
 *
 * Since: 1.12
 **/
gboolean
nm_setting_team_port_remove_link_watcher_by_value (NMSettingTeamPort *setting,
                                                   NMTeamLinkWatcher *link_watcher)
{
	g_return_val_if_fail (NM_IS_SETTING_TEAM_PORT (setting), FALSE);
	g_return_val_if_fail (link_watcher, FALSE);

	return _maybe_changed (setting,
	                       nm_team_setting_value_link_watchers_remove_by_value (NM_SETTING_TEAM_PORT_GET_PRIVATE (setting)->team_setting,
	                                                                            link_watcher));
}

/**
 * nm_setting_team_port_clear_link_watchers:
 * @setting: the #NMSettingTeamPort
 *
 * Removes all configured link watchers.
 *
 * Since: 1.12
 **/
void
nm_setting_team_port_clear_link_watchers (NMSettingTeamPort *setting)
{
	g_return_if_fail (NM_IS_SETTING_TEAM_PORT (setting));

	_maybe_changed (setting,
	                nm_team_setting_value_link_watchers_set_list (NM_SETTING_TEAM_PORT_GET_PRIVATE (setting)->team_setting,
	                                                              NULL,
	                                                              0));
}

static gboolean
verify (NMSetting *setting, NMConnection *connection, GError **error)
{
	NMSettingTeamPortPrivate *priv = NM_SETTING_TEAM_PORT_GET_PRIVATE (setting);

	if (connection) {
		NMSettingConnection *s_con;
		const char *slave_type;

		s_con = nm_connection_get_setting_connection (connection);
		if (!s_con) {
			g_set_error (error,
			             NM_CONNECTION_ERROR,
			             NM_CONNECTION_ERROR_MISSING_SETTING,
			             _("missing setting"));
			g_prefix_error (error, "%s: ", NM_SETTING_CONNECTION_SETTING_NAME);
			return FALSE;
		}

		slave_type = nm_setting_connection_get_slave_type (s_con);
		if (   slave_type
		    && strcmp (slave_type, NM_SETTING_TEAM_SETTING_NAME)) {
			g_set_error (error,
			             NM_CONNECTION_ERROR,
			             NM_CONNECTION_ERROR_INVALID_PROPERTY,
			             _("A connection with a '%s' setting must have the slave-type set to '%s'. Instead it is '%s'"),
			             NM_SETTING_TEAM_PORT_SETTING_NAME,
			             NM_SETTING_TEAM_SETTING_NAME,
			             slave_type);
			g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_SLAVE_TYPE);
			return FALSE;
		}
	}

	if (!nm_team_setting_verify (priv->team_setting, error))
		return FALSE;

	return TRUE;
}

static NMTernary
compare_property (const NMSettInfoSetting *sett_info,
                  guint property_idx,
                  NMConnection *con_a,
                  NMSetting *set_a,
                  NMConnection *con_b,
                  NMSetting *set_b,
                  NMSettingCompareFlags flags)
{
	NMSettingTeamPortPrivate *a_priv;
	NMSettingTeamPortPrivate *b_priv;

	if (nm_streq (sett_info->property_infos[property_idx].name, NM_SETTING_TEAM_PORT_LINK_WATCHERS)) {

		if (NM_FLAGS_HAS (flags, NM_SETTING_COMPARE_FLAG_INFERRABLE))
			return NM_TERNARY_DEFAULT;
		if (!set_b)
			return TRUE;
		a_priv = NM_SETTING_TEAM_PORT_GET_PRIVATE (set_a);
		b_priv = NM_SETTING_TEAM_PORT_GET_PRIVATE (set_b);
		return nm_team_link_watchers_equal (a_priv->team_setting->d.link_watchers,
		                                    b_priv->team_setting->d.link_watchers,
		                                    TRUE);
	}

	if (nm_streq (sett_info->property_infos[property_idx].name, NM_SETTING_TEAM_PORT_CONFIG)) {
		if (set_b) {
			if (NM_FLAGS_HAS (flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)) {
				/* If we are trying to match a connection in order to assume it (and thus
				 * @flags contains INFERRABLE), use the "relaxed" matching for team
				 * configuration. Otherwise, for all other purposes (including connection
				 * comparison before an update), resort to the default string comparison. */
				return TRUE;
			}

			a_priv = NM_SETTING_TEAM_PORT_GET_PRIVATE (set_a);
			b_priv = NM_SETTING_TEAM_PORT_GET_PRIVATE (set_b);

			return nm_streq0 (nm_team_setting_config_get (a_priv->team_setting),
			                  nm_team_setting_config_get (b_priv->team_setting));
		}

		return TRUE;
	}

	return NM_SETTING_CLASS (nm_setting_team_port_parent_class)->compare_property (sett_info,
	                                                                               property_idx,
	                                                                               con_a,
	                                                                               set_a,
	                                                                               con_b,
	                                                                               set_b,
	                                                                               flags);
}

static void
duplicate_copy_properties (const NMSettInfoSetting *sett_info,
                           NMSetting *src,
                           NMSetting *dst)
{
	_maybe_changed (NM_SETTING_TEAM_PORT (dst),
	                nm_team_setting_reset (NM_SETTING_TEAM_PORT_GET_PRIVATE (dst)->team_setting,
	                                       NM_SETTING_TEAM_PORT_GET_PRIVATE (src)->team_setting));
}

static gboolean
init_from_dbus (NMSetting *setting,
                GHashTable *keys,
                GVariant *setting_dict,
                GVariant *connection_dict,
                guint /* NMSettingParseFlags */ parse_flags,
                GError **error)
{
	guint32 changed = 0;
	gboolean success;

	success = nm_team_setting_reset_from_dbus (NM_SETTING_TEAM_PORT_GET_PRIVATE (setting)->team_setting,
	                                           setting_dict,
	                                           keys,
	                                           &changed,
	                                           parse_flags,
	                                           error);
	_maybe_changed (NM_SETTING_TEAM_PORT (setting), changed);
	return success;
}

/*****************************************************************************/

static void
get_property (GObject *object, guint prop_id,
              GValue *value, GParamSpec *pspec)
{
	NMSettingTeamPort *setting = NM_SETTING_TEAM_PORT (object);
	NMSettingTeamPortPrivate *priv = NM_SETTING_TEAM_PORT_GET_PRIVATE (setting);

	switch (prop_id) {
	case NM_TEAM_ATTRIBUTE_CONFIG:
		g_value_set_string (value,
		                    nm_team_setting_config_get (priv->team_setting));
		break;
	case NM_TEAM_ATTRIBUTE_PORT_STICKY:
		g_value_set_boolean (value,
		                     nm_team_setting_value_get_bool (priv->team_setting,
		                                                     prop_id));
		break;
	case NM_TEAM_ATTRIBUTE_PORT_QUEUE_ID:
	case NM_TEAM_ATTRIBUTE_PORT_PRIO:
	case NM_TEAM_ATTRIBUTE_PORT_LACP_PRIO:
	case NM_TEAM_ATTRIBUTE_PORT_LACP_KEY:
		g_value_set_int (value,
		                 nm_team_setting_value_get_int32 (priv->team_setting,
		                                                  prop_id));
		break;
	case NM_TEAM_ATTRIBUTE_LINK_WATCHERS:
		g_value_take_boxed (value, _nm_utils_copy_array (priv->team_setting->d.link_watchers,
		                                                 (NMUtilsCopyFunc) _nm_team_link_watcher_ref,
		                                                 (GDestroyNotify) nm_team_link_watcher_unref));
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
		break;
	}
}

static void
set_property (GObject *object, guint prop_id,
              const GValue *value, GParamSpec *pspec)
{
	NMSettingTeamPort *setting = NM_SETTING_TEAM_PORT (object);
	NMSettingTeamPortPrivate *priv = NM_SETTING_TEAM_PORT_GET_PRIVATE (setting);
	guint32 changed;
	const GPtrArray *v_ptrarr;

	switch (prop_id) {
	case NM_TEAM_ATTRIBUTE_CONFIG:
		changed = nm_team_setting_config_set (priv->team_setting, g_value_get_string (value));
		break;
	case NM_TEAM_ATTRIBUTE_PORT_STICKY:
		changed = nm_team_setting_value_set_bool (priv->team_setting,
		                                          prop_id,
		                                          g_value_get_boolean (value));
		break;
	case NM_TEAM_ATTRIBUTE_PORT_QUEUE_ID:
	case NM_TEAM_ATTRIBUTE_PORT_PRIO:
	case NM_TEAM_ATTRIBUTE_PORT_LACP_PRIO:
	case NM_TEAM_ATTRIBUTE_PORT_LACP_KEY:
		changed = nm_team_setting_value_set_int32 (priv->team_setting,
		                                           prop_id,
		                                           g_value_get_int (value));
		break;
	case NM_TEAM_ATTRIBUTE_LINK_WATCHERS:
		v_ptrarr = g_value_get_boxed (value);
		changed = nm_team_setting_value_link_watchers_set_list (priv->team_setting,
		                                                        v_ptrarr ? (const NMTeamLinkWatcher *const*) v_ptrarr->pdata : NULL,
		                                                        v_ptrarr ? v_ptrarr->len                                     : 0u);
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
		return;
	}

	_maybe_changed (setting, changed & ~(((guint32) 1) << prop_id));
}

/*****************************************************************************/

static void
nm_setting_team_port_init (NMSettingTeamPort *setting)
{
	NMSettingTeamPortPrivate *priv = NM_SETTING_TEAM_PORT_GET_PRIVATE (setting);

	priv->team_setting = nm_team_setting_new (TRUE, NULL);
}

/**
 * nm_setting_team_port_new:
 *
 * Creates a new #NMSettingTeamPort object with default values.
 *
 * Returns: (transfer full): the new empty #NMSettingTeamPort object
 **/
NMSetting *
nm_setting_team_port_new (void)
{
	return (NMSetting *) g_object_new (NM_TYPE_SETTING_TEAM_PORT, NULL);
}

static void
finalize (GObject *object)
{
	NMSettingTeamPortPrivate *priv = NM_SETTING_TEAM_PORT_GET_PRIVATE (object);

	nm_team_setting_free (priv->team_setting);

	G_OBJECT_CLASS (nm_setting_team_port_parent_class)->finalize (object);
}

static void
nm_setting_team_port_class_init (NMSettingTeamPortClass *klass)
{
	GObjectClass *object_class = G_OBJECT_CLASS (klass);
	NMSettingClass *setting_class = NM_SETTING_CLASS (klass);
	GArray *properties_override = _nm_sett_info_property_override_create_array ();

	g_type_class_add_private (klass, sizeof (NMSettingTeamPortPrivate));

	object_class->get_property     = get_property;
	object_class->set_property     = set_property;
	object_class->finalize         = finalize;

	setting_class->compare_property          = compare_property;
	setting_class->verify                    = verify;
	setting_class->duplicate_copy_properties = duplicate_copy_properties;
	setting_class->init_from_dbus            = init_from_dbus;

#define _property_override(_properties_override, _param_spec, _variant_type, _is_link_watcher) \
	_properties_override_add ((_properties_override), \
	                          .param_spec          = (_param_spec), \
	                          .dbus_type           = G_VARIANT_TYPE (""_variant_type""), \
	                          .to_dbus_fcn         = _nm_team_settings_property_to_dbus, \
	                          .gprop_from_dbus_fcn = ((_is_link_watcher) ? _nm_team_settings_property_from_dbus_link_watchers : NULL))

	/**
	 * NMSettingTeamPort:config:
	 *
	 * The JSON configuration for the team port. The property should contain raw
	 * JSON configuration data suitable for teamd, because the value is passed
	 * directly to teamd. If not specified, the default configuration is
	 * used. See man teamd.conf for the format details.
	 **/
	/* ---ifcfg-rh---
	 * property: config
	 * variable: TEAM_PORT_CONFIG
	 * description: Team port configuration in JSON. See man teamd.conf for details.
	 * ---end---
	 */
	obj_properties[NM_TEAM_ATTRIBUTE_CONFIG] =
	    g_param_spec_string (NM_SETTING_TEAM_PORT_CONFIG, "", "",
	                         NULL,
	                         G_PARAM_READWRITE |
	                         NM_SETTING_PARAM_INFERRABLE |
	                         G_PARAM_STATIC_STRINGS);
	_property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_CONFIG], "s", FALSE);

	/**
	 * NMSettingTeamPort:queue-id:
	 *
	 * Corresponds to the teamd ports.PORTIFNAME.queue_id.
	 * When set to -1 means the parameter is skipped from the json config.
	 *
	 * Since: 1.12
	 **/
	obj_properties[NM_TEAM_ATTRIBUTE_PORT_QUEUE_ID] =
	    g_param_spec_int (NM_SETTING_TEAM_PORT_QUEUE_ID, "", "",
	                      G_MININT32, G_MAXINT32, -1,
	                      G_PARAM_READWRITE |
	                      G_PARAM_STATIC_STRINGS);
	_property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_PORT_QUEUE_ID], "i", FALSE);

	/**
	 * NMSettingTeamPort:prio:
	 *
	 * Corresponds to the teamd ports.PORTIFNAME.prio.
	 *
	 * Since: 1.12
	 **/
	obj_properties[NM_TEAM_ATTRIBUTE_PORT_PRIO] =
	    g_param_spec_int (NM_SETTING_TEAM_PORT_PRIO, "", "",
	                      G_MININT32, G_MAXINT32, 0,
	                      G_PARAM_READWRITE |
	                      G_PARAM_STATIC_STRINGS);
	_property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_PORT_PRIO], "i", FALSE);

	/**
	 * NMSettingTeamPort:sticky:
	 *
	 * Corresponds to the teamd ports.PORTIFNAME.sticky.
	 *
	 * Since: 1.12
	 **/
	obj_properties[NM_TEAM_ATTRIBUTE_PORT_STICKY] =
	    g_param_spec_boolean (NM_SETTING_TEAM_PORT_STICKY, "", "",
	                          FALSE,
	                          G_PARAM_READWRITE |
	                          G_PARAM_STATIC_STRINGS);
	_property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_PORT_STICKY], "b", FALSE);

	/**
	 * NMSettingTeamPort:lacp-prio:
	 *
	 * Corresponds to the teamd ports.PORTIFNAME.lacp_prio.
	 *
	 * Since: 1.12
	 **/
	obj_properties[NM_TEAM_ATTRIBUTE_PORT_LACP_PRIO] =
	    g_param_spec_int (NM_SETTING_TEAM_PORT_LACP_PRIO, "", "",
	                      G_MININT32, G_MAXINT32, -1,
	                      G_PARAM_READWRITE |
	                      G_PARAM_STATIC_STRINGS);
	_property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_PORT_LACP_PRIO], "i", FALSE);

	/**
	 * NMSettingTeamPort:lacp-key:
	 *
	 * Corresponds to the teamd ports.PORTIFNAME.lacp_key.
	 *
	 * Since: 1.12
	 **/
	obj_properties[NM_TEAM_ATTRIBUTE_PORT_LACP_KEY] =
	    g_param_spec_int (NM_SETTING_TEAM_PORT_LACP_KEY, "", "",
	                      G_MININT32, G_MAXINT32, -1,
	                      G_PARAM_READWRITE |
	                      G_PARAM_STATIC_STRINGS);
	_property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_PORT_LACP_KEY], "i", FALSE);

	/**
	 * NMSettingTeamPort:link-watchers: (type GPtrArray(NMTeamLinkWatcher))
	 *
	 * Link watchers configuration for the connection: each link watcher is
	 * defined by a dictionary, whose keys depend upon the selected link
	 * watcher. Available link watchers are 'ethtool', 'nsna_ping' and
	 * 'arp_ping' and it is specified in the dictionary with the key 'name'.
	 * Available keys are:   ethtool: 'delay-up', 'delay-down', 'init-wait';
	 * nsna_ping: 'init-wait', 'interval', 'missed-max', 'target-host';
	 * arp_ping: all the ones in nsna_ping and 'source-host', 'validate-active',
	 * 'validate-inactive', 'send-always'. See teamd.conf man for more details.
	 *
	 * Since: 1.12
	 **/
	obj_properties[NM_TEAM_ATTRIBUTE_LINK_WATCHERS] =
	    g_param_spec_boxed (NM_SETTING_TEAM_PORT_LINK_WATCHERS, "", "",
	                        G_TYPE_PTR_ARRAY,
	                        G_PARAM_READWRITE |
	                        G_PARAM_STATIC_STRINGS);
	_property_override (properties_override, obj_properties[NM_TEAM_ATTRIBUTE_LINK_WATCHERS], "aa{sv}", TRUE);

	g_object_class_install_properties (object_class, G_N_ELEMENTS (obj_properties), obj_properties);

	_nm_setting_class_commit_full (setting_class, NM_META_SETTING_TYPE_TEAM_PORT,
	                               NULL, properties_override);
}