2014-07-24 08:53:33 -04:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
|
|
|
|
/*
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
2017-11-02 17:13:46 +01:00
|
|
|
* Copyright 2017 Red Hat, Inc.
|
2014-07-24 08:53:33 -04:00
|
|
|
* Copyright 2013 Jiri Pirko <jiri@resnulli.us>
|
|
|
|
|
*/
|
|
|
|
|
|
2016-02-19 14:57:48 +01:00
|
|
|
#include "nm-default.h"
|
2014-11-13 10:07:02 -05:00
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
#include "nm-setting-team.h"
|
|
|
|
|
#include "nm-utils.h"
|
|
|
|
|
#include "nm-utils-private.h"
|
2014-10-21 22:30:31 -04:00
|
|
|
#include "nm-connection-private.h"
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* SECTION:nm-setting-team
|
|
|
|
|
* @short_description: Describes connection properties for teams
|
|
|
|
|
*
|
|
|
|
|
* The #NMSettingTeam object is a #NMSetting subclass that describes properties
|
|
|
|
|
* necessary for team connections.
|
|
|
|
|
**/
|
|
|
|
|
|
2017-11-02 17:13:46 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
|
* NMTeamLinkWatch
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
G_DEFINE_BOXED_TYPE (NMTeamLinkWatcher, nm_team_link_watcher,
|
|
|
|
|
nm_team_link_watcher_dup, nm_team_link_watcher_unref)
|
|
|
|
|
|
|
|
|
|
enum LinkWatcherTypes {
|
|
|
|
|
LINK_WATCHER_ETHTOOL = 0,
|
|
|
|
|
LINK_WATCHER_NSNA_PING = 1,
|
|
|
|
|
LINK_WATCHER_ARP_PING = 2
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const char* _link_watcher_name[] = {
|
|
|
|
|
[LINK_WATCHER_ETHTOOL] = NM_TEAM_LINK_WATCHER_ETHTOOL,
|
|
|
|
|
[LINK_WATCHER_NSNA_PING] = NM_TEAM_LINK_WATCHER_NSNA_PING,
|
|
|
|
|
[LINK_WATCHER_ARP_PING] = NM_TEAM_LINK_WATCHER_ARP_PING
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct NMTeamLinkWatcher {
|
|
|
|
|
guint refcount;
|
|
|
|
|
|
2018-02-02 10:55:34 +01:00
|
|
|
guint8 type; /* LinkWatcherTypes */
|
2017-11-02 17:13:46 +01:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* The union is constructed in order to allow mapping the options of all the
|
|
|
|
|
* watchers on the arp_ping one: this would allow to manipulate all the watchers
|
|
|
|
|
* by using the arp_ping struct. See for instance the nm_team_link_watcher_unref()
|
|
|
|
|
* and nm_team_link_watcher_equal() functions. So, if you need to change the union
|
|
|
|
|
* be careful.
|
|
|
|
|
*/
|
|
|
|
|
union {
|
|
|
|
|
struct {
|
|
|
|
|
int delay_up;
|
|
|
|
|
int delay_down;
|
|
|
|
|
} ethtool;
|
|
|
|
|
struct {
|
|
|
|
|
int init_wait;
|
|
|
|
|
int interval;
|
|
|
|
|
int missed_max;
|
|
|
|
|
char *target_host;
|
|
|
|
|
} nsna_ping;
|
|
|
|
|
struct {
|
|
|
|
|
int init_wait;
|
|
|
|
|
int interval;
|
|
|
|
|
int missed_max;
|
|
|
|
|
char *target_host;
|
|
|
|
|
char *source_host;
|
|
|
|
|
NMTeamLinkWatcherArpPingFlags flags;
|
|
|
|
|
} arp_ping;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define _CHECK_WATCHER_VOID(watcher) \
|
|
|
|
|
G_STMT_START { \
|
|
|
|
|
g_return_if_fail (watcher != NULL); \
|
|
|
|
|
g_return_if_fail (watcher->refcount > 0); \
|
|
|
|
|
g_return_if_fail (watcher->type <= LINK_WATCHER_ARP_PING); \
|
|
|
|
|
} G_STMT_END
|
|
|
|
|
|
|
|
|
|
#define _CHECK_WATCHER(watcher, err_val) \
|
|
|
|
|
G_STMT_START { \
|
|
|
|
|
g_return_val_if_fail (watcher != NULL, err_val); \
|
|
|
|
|
g_return_val_if_fail (watcher->refcount > 0, err_val); \
|
|
|
|
|
g_return_val_if_fail (watcher->type <= LINK_WATCHER_ARP_PING, err_val); \
|
|
|
|
|
} G_STMT_END
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_team_link_watcher_new_ethtool:
|
|
|
|
|
* @delay_up: delay_up value
|
|
|
|
|
* @delay_down: delay_down value
|
|
|
|
|
* @error: this call never fails, so this var is not used but kept for format
|
|
|
|
|
* consistency with the link_watcher constructors of other type
|
|
|
|
|
*
|
|
|
|
|
* Creates a new ethtool #NMTeamLinkWatcher object
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer full): the new #NMTeamLinkWatcher object
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
NMTeamLinkWatcher *
|
all: don't use gchar/gshort/gint/glong but C types
We commonly don't use the glib typedefs for char/short/int/long,
but their C types directly.
$ git grep '\<g\(char\|short\|int\|long\|float\|double\)\>' | wc -l
587
$ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l
21114
One could argue that using the glib typedefs is preferable in
public API (of our glib based libnm library) or where it clearly
is related to glib, like during
g_object_set (obj, PROPERTY, (gint) value, NULL);
However, that argument does not seem strong, because in practice we don't
follow that argument today, and seldomly use the glib typedefs.
Also, the style guide for this would be hard to formalize, because
"using them where clearly related to a glib" is a very loose suggestion.
Also note that glib typedefs will always just be typedefs of the
underlying C types. There is no danger of glib changing the meaning
of these typedefs (because that would be a major API break of glib).
A simple style guide is instead: don't use these typedefs.
No manual actions, I only ran the bash script:
FILES=($(git ls-files '*.[hc]'))
sed -i \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>\( [^ ]\)/\1\2/g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\> /\1 /g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>/\1/g' \
"${FILES[@]}"
2018-07-11 07:40:19 +02:00
|
|
|
nm_team_link_watcher_new_ethtool (int delay_up,
|
|
|
|
|
int delay_down,
|
2017-11-02 17:13:46 +01:00
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
NMTeamLinkWatcher *watcher;
|
|
|
|
|
const char *val_fail = NULL;
|
|
|
|
|
|
|
|
|
|
if (delay_up < 0 || delay_up > G_MAXINT32)
|
|
|
|
|
val_fail = "delay-up";
|
|
|
|
|
if (delay_down < 0 || delay_down > G_MAXINT32)
|
|
|
|
|
val_fail = "delay-down";
|
|
|
|
|
if (val_fail) {
|
|
|
|
|
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_FAILED,
|
|
|
|
|
_("%s is out of range [0, %d]"), val_fail, G_MAXINT32);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
watcher = g_slice_new0 (NMTeamLinkWatcher);
|
|
|
|
|
watcher->refcount = 1;
|
|
|
|
|
|
|
|
|
|
watcher->type = LINK_WATCHER_ETHTOOL;
|
|
|
|
|
watcher->ethtool.delay_up = delay_up;
|
|
|
|
|
watcher->ethtool.delay_down = delay_down;
|
|
|
|
|
|
|
|
|
|
return watcher;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_team_link_watcher_new_nsna_ping:
|
|
|
|
|
* @init_wait: init_wait value
|
|
|
|
|
* @interval: interval value
|
|
|
|
|
* @missed_max: missed_max value
|
|
|
|
|
* @target_host: the host name or the ipv6 address that will be used as
|
|
|
|
|
* target address in the NS packet
|
|
|
|
|
* @error: (out) (allow-none): location to store the error on failure
|
|
|
|
|
*
|
|
|
|
|
* Creates a new nsna_ping #NMTeamLinkWatcher object
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer full): the new #NMTeamLinkWatcher object, or %NULL on error
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
NMTeamLinkWatcher *
|
all: don't use gchar/gshort/gint/glong but C types
We commonly don't use the glib typedefs for char/short/int/long,
but their C types directly.
$ git grep '\<g\(char\|short\|int\|long\|float\|double\)\>' | wc -l
587
$ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l
21114
One could argue that using the glib typedefs is preferable in
public API (of our glib based libnm library) or where it clearly
is related to glib, like during
g_object_set (obj, PROPERTY, (gint) value, NULL);
However, that argument does not seem strong, because in practice we don't
follow that argument today, and seldomly use the glib typedefs.
Also, the style guide for this would be hard to formalize, because
"using them where clearly related to a glib" is a very loose suggestion.
Also note that glib typedefs will always just be typedefs of the
underlying C types. There is no danger of glib changing the meaning
of these typedefs (because that would be a major API break of glib).
A simple style guide is instead: don't use these typedefs.
No manual actions, I only ran the bash script:
FILES=($(git ls-files '*.[hc]'))
sed -i \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>\( [^ ]\)/\1\2/g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\> /\1 /g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>/\1/g' \
"${FILES[@]}"
2018-07-11 07:40:19 +02:00
|
|
|
nm_team_link_watcher_new_nsna_ping (int init_wait,
|
|
|
|
|
int interval,
|
|
|
|
|
int missed_max,
|
2017-11-02 17:13:46 +01:00
|
|
|
const char *target_host,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
NMTeamLinkWatcher *watcher;
|
|
|
|
|
const char *val_fail = NULL;
|
|
|
|
|
|
|
|
|
|
if (!target_host) {
|
|
|
|
|
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_FAILED,
|
|
|
|
|
_("Missing target-host in nsna_ping link watcher"));
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-08 10:09:01 +01:00
|
|
|
if (strpbrk (target_host, " \\/\t=\"\'")) {
|
2017-11-02 17:13:46 +01:00
|
|
|
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_FAILED,
|
|
|
|
|
_("target-host '%s' contains invalid characters"), target_host);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (init_wait < 0 || init_wait > G_MAXINT32)
|
|
|
|
|
val_fail = "init-wait";
|
|
|
|
|
if (interval < 0 || interval > G_MAXINT32)
|
|
|
|
|
val_fail = "interval";
|
|
|
|
|
if (missed_max < 0 || missed_max > G_MAXINT32)
|
|
|
|
|
val_fail = "missed-max";
|
|
|
|
|
if (val_fail) {
|
|
|
|
|
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_FAILED,
|
|
|
|
|
_("%s is out of range [0, %d]"), val_fail, G_MAXINT32);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
watcher = g_slice_new0 (NMTeamLinkWatcher);
|
|
|
|
|
watcher->refcount = 1;
|
|
|
|
|
|
|
|
|
|
watcher->type = LINK_WATCHER_NSNA_PING;
|
|
|
|
|
watcher->nsna_ping.init_wait = init_wait;
|
|
|
|
|
watcher->nsna_ping.interval = interval;
|
|
|
|
|
watcher->nsna_ping.missed_max = missed_max;
|
|
|
|
|
watcher->nsna_ping.target_host = g_strdup (target_host);
|
|
|
|
|
|
|
|
|
|
return watcher;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_team_link_watcher_new_arp_ping:
|
|
|
|
|
* @init_wait: init_wait value
|
|
|
|
|
* @interval: interval value
|
|
|
|
|
* @missed_max: missed_max value
|
|
|
|
|
* @target_host: the host name or the ip address that will be used as destination
|
|
|
|
|
* address in the arp request
|
|
|
|
|
* @source_host: the host name or the ip address that will be used as source
|
|
|
|
|
* address in the arp request
|
|
|
|
|
* @flags: the watcher #NMTeamLinkWatcherArpPingFlags
|
|
|
|
|
* @error: (out) (allow-none): location to store the error on failure
|
|
|
|
|
*
|
|
|
|
|
* Creates a new arp_ping #NMTeamLinkWatcher object
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer full): the new #NMTeamLinkWatcher object, or %NULL on error
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
NMTeamLinkWatcher *
|
all: don't use gchar/gshort/gint/glong but C types
We commonly don't use the glib typedefs for char/short/int/long,
but their C types directly.
$ git grep '\<g\(char\|short\|int\|long\|float\|double\)\>' | wc -l
587
$ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l
21114
One could argue that using the glib typedefs is preferable in
public API (of our glib based libnm library) or where it clearly
is related to glib, like during
g_object_set (obj, PROPERTY, (gint) value, NULL);
However, that argument does not seem strong, because in practice we don't
follow that argument today, and seldomly use the glib typedefs.
Also, the style guide for this would be hard to formalize, because
"using them where clearly related to a glib" is a very loose suggestion.
Also note that glib typedefs will always just be typedefs of the
underlying C types. There is no danger of glib changing the meaning
of these typedefs (because that would be a major API break of glib).
A simple style guide is instead: don't use these typedefs.
No manual actions, I only ran the bash script:
FILES=($(git ls-files '*.[hc]'))
sed -i \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>\( [^ ]\)/\1\2/g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\> /\1 /g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>/\1/g' \
"${FILES[@]}"
2018-07-11 07:40:19 +02:00
|
|
|
nm_team_link_watcher_new_arp_ping (int init_wait,
|
|
|
|
|
int interval,
|
|
|
|
|
int missed_max,
|
2017-11-02 17:13:46 +01:00
|
|
|
const char *target_host,
|
|
|
|
|
const char *source_host,
|
|
|
|
|
NMTeamLinkWatcherArpPingFlags flags,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
NMTeamLinkWatcher *watcher;
|
|
|
|
|
const char *val_fail = NULL;
|
|
|
|
|
|
|
|
|
|
if (!target_host || !source_host) {
|
|
|
|
|
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_FAILED,
|
|
|
|
|
_("Missing %s in arp_ping link watcher"),
|
|
|
|
|
target_host ? "source-host" : "target-host");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-08 10:09:01 +01:00
|
|
|
if (strpbrk (target_host, " \\/\t=\"\'")) {
|
2017-11-02 17:13:46 +01:00
|
|
|
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_FAILED,
|
|
|
|
|
_("target-host '%s' contains invalid characters"), target_host);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-12 10:31:01 +01:00
|
|
|
if (strpbrk (source_host, " \\/\t=\"\'")) {
|
2017-11-02 17:13:46 +01:00
|
|
|
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_FAILED,
|
|
|
|
|
_("source-host '%s' contains invalid characters"), source_host);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (init_wait < 0 || init_wait > G_MAXINT32)
|
|
|
|
|
val_fail = "init-wait";
|
|
|
|
|
if (interval < 0 || interval > G_MAXINT32)
|
|
|
|
|
val_fail = "interval";
|
|
|
|
|
if (missed_max < 0 || missed_max > G_MAXINT32)
|
|
|
|
|
val_fail = "missed-max";
|
|
|
|
|
if (val_fail) {
|
|
|
|
|
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_FAILED,
|
|
|
|
|
_("%s is out of range [0, %d]"), val_fail, G_MAXINT32);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
watcher = g_slice_new0 (NMTeamLinkWatcher);
|
|
|
|
|
watcher->refcount = 1;
|
|
|
|
|
|
|
|
|
|
watcher->type = LINK_WATCHER_ARP_PING;
|
|
|
|
|
watcher->arp_ping.init_wait = init_wait;
|
|
|
|
|
watcher->arp_ping.interval = interval;
|
|
|
|
|
watcher->arp_ping.missed_max = missed_max;
|
|
|
|
|
watcher->arp_ping.target_host = g_strdup (target_host);
|
|
|
|
|
watcher->arp_ping.source_host = g_strdup (source_host);
|
|
|
|
|
watcher->arp_ping.flags = flags;
|
|
|
|
|
|
|
|
|
|
return watcher;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_team_link_watcher_ref:
|
|
|
|
|
* @watcher: the #NMTeamLinkWatcher
|
|
|
|
|
*
|
|
|
|
|
* Increases the reference count of the object.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
nm_team_link_watcher_ref (NMTeamLinkWatcher *watcher){
|
|
|
|
|
_CHECK_WATCHER_VOID (watcher);
|
|
|
|
|
|
|
|
|
|
watcher->refcount++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_team_link_watcher_unref:
|
|
|
|
|
* @watcher: the #NMTeamLinkWatcher
|
|
|
|
|
*
|
|
|
|
|
* Decreases the reference count of the object. If the reference count
|
|
|
|
|
* reaches zero, the object will be destroyed.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
nm_team_link_watcher_unref (NMTeamLinkWatcher *watcher)
|
|
|
|
|
{
|
|
|
|
|
_CHECK_WATCHER_VOID (watcher);
|
|
|
|
|
|
|
|
|
|
watcher->refcount--;
|
|
|
|
|
if (watcher->refcount == 0) {
|
|
|
|
|
g_free (watcher->arp_ping.target_host);
|
|
|
|
|
g_free (watcher->arp_ping.source_host);
|
|
|
|
|
g_slice_free (NMTeamLinkWatcher, watcher);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_team_link_watcher_equal:
|
|
|
|
|
* @watcher: the #NMTeamLinkWatcher
|
|
|
|
|
* @other: the #NMTeamLinkWatcher to compare @watcher to.
|
|
|
|
|
*
|
|
|
|
|
* Determines if two #NMTeamLinkWatcher objects contain the same values
|
|
|
|
|
* in all the properties.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the objects contain the same values, %FALSE if they do not.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_team_link_watcher_equal (NMTeamLinkWatcher *watcher, NMTeamLinkWatcher *other)
|
|
|
|
|
{
|
|
|
|
|
_CHECK_WATCHER (watcher, FALSE);
|
|
|
|
|
_CHECK_WATCHER (other, FALSE);
|
|
|
|
|
|
|
|
|
|
if ( watcher->type != other->type
|
|
|
|
|
|| !nm_streq0 (watcher->arp_ping.target_host, other->arp_ping.target_host)
|
|
|
|
|
|| !nm_streq0 (watcher->arp_ping.source_host, other->arp_ping.source_host)
|
|
|
|
|
|| watcher->arp_ping.init_wait != other->arp_ping.init_wait
|
|
|
|
|
|| watcher->arp_ping.interval != other->arp_ping.interval
|
|
|
|
|
|| watcher->arp_ping.missed_max != other->arp_ping.missed_max
|
|
|
|
|
|| watcher->arp_ping.flags != other->arp_ping.flags)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_team_link_watcher_dup:
|
|
|
|
|
* @watcher: the #NMTeamLinkWatcher
|
|
|
|
|
*
|
|
|
|
|
* Creates a copy of @watcher
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer full): a copy of @watcher
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
NMTeamLinkWatcher *
|
|
|
|
|
nm_team_link_watcher_dup (NMTeamLinkWatcher *watcher)
|
|
|
|
|
{
|
|
|
|
|
_CHECK_WATCHER (watcher, NULL);
|
|
|
|
|
|
|
|
|
|
switch (watcher->type) {
|
|
|
|
|
case LINK_WATCHER_ETHTOOL:
|
|
|
|
|
return nm_team_link_watcher_new_ethtool (watcher->ethtool.delay_up,
|
|
|
|
|
watcher->ethtool.delay_down,
|
|
|
|
|
NULL);
|
|
|
|
|
break;
|
|
|
|
|
case LINK_WATCHER_NSNA_PING:
|
|
|
|
|
return nm_team_link_watcher_new_nsna_ping (watcher->nsna_ping.init_wait,
|
|
|
|
|
watcher->nsna_ping.interval,
|
|
|
|
|
watcher->nsna_ping.missed_max,
|
|
|
|
|
watcher->nsna_ping.target_host,
|
|
|
|
|
NULL);
|
|
|
|
|
break;
|
|
|
|
|
case LINK_WATCHER_ARP_PING:
|
|
|
|
|
return nm_team_link_watcher_new_arp_ping (watcher->arp_ping.init_wait,
|
|
|
|
|
watcher->arp_ping.interval,
|
|
|
|
|
watcher->arp_ping.missed_max,
|
|
|
|
|
watcher->arp_ping.target_host,
|
|
|
|
|
watcher->arp_ping.source_host,
|
|
|
|
|
watcher->arp_ping.flags,
|
|
|
|
|
NULL);
|
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_team_link_watcher_get_name:
|
|
|
|
|
* @watcher: the #NMTeamLinkWatcher
|
|
|
|
|
*
|
|
|
|
|
* Gets the name of the link watcher to be used.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
const char *
|
|
|
|
|
nm_team_link_watcher_get_name (NMTeamLinkWatcher *watcher)
|
|
|
|
|
{
|
|
|
|
|
_CHECK_WATCHER (watcher, NULL);
|
|
|
|
|
|
|
|
|
|
return _link_watcher_name[watcher->type];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_team_link_watcher_get_delay_up:
|
|
|
|
|
* @watcher: the #NMTeamLinkWatcher
|
|
|
|
|
*
|
|
|
|
|
* Gets the delay_up interval (in milliseconds) that elapses between the link
|
|
|
|
|
* coming up and the runner beeing notified about it.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
int
|
|
|
|
|
nm_team_link_watcher_get_delay_up (NMTeamLinkWatcher *watcher)
|
|
|
|
|
{
|
|
|
|
|
_CHECK_WATCHER (watcher, 0);
|
|
|
|
|
|
|
|
|
|
if (watcher->type != LINK_WATCHER_ETHTOOL)
|
|
|
|
|
return -1;
|
|
|
|
|
return watcher->ethtool.delay_up;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_team_link_watcher_get_delay_down:
|
|
|
|
|
* @watcher: the #NMTeamLinkWatcher
|
|
|
|
|
*
|
|
|
|
|
* Gets the delay_down interval (in milliseconds) that elapses between the link
|
|
|
|
|
* going down and the runner beeing notified about it.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
int
|
|
|
|
|
nm_team_link_watcher_get_delay_down (NMTeamLinkWatcher *watcher)
|
|
|
|
|
{
|
|
|
|
|
_CHECK_WATCHER (watcher, 0);
|
|
|
|
|
|
|
|
|
|
if (watcher->type != LINK_WATCHER_ETHTOOL)
|
|
|
|
|
return -1;
|
|
|
|
|
return watcher->ethtool.delay_down;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_team_link_watcher_get_init_wait:
|
|
|
|
|
* @watcher: the #NMTeamLinkWatcher
|
|
|
|
|
*
|
|
|
|
|
* Gets the init_wait interval (in milliseconds) that the team slave should
|
|
|
|
|
* wait before sending the first packet to the target host.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
int
|
|
|
|
|
nm_team_link_watcher_get_init_wait (NMTeamLinkWatcher *watcher)
|
|
|
|
|
{
|
|
|
|
|
_CHECK_WATCHER (watcher, 0);
|
|
|
|
|
|
|
|
|
|
if (!NM_IN_SET (watcher->type,
|
|
|
|
|
LINK_WATCHER_NSNA_PING,
|
|
|
|
|
LINK_WATCHER_ARP_PING))
|
|
|
|
|
return -1;
|
|
|
|
|
return watcher->arp_ping.init_wait;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_team_link_watcher_get_interval:
|
|
|
|
|
* @watcher: the #NMTeamLinkWatcher
|
|
|
|
|
*
|
|
|
|
|
* Gets the interval (in milliseconds) that the team slave should wait between
|
|
|
|
|
* sending two check packets to the target host.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
int
|
|
|
|
|
nm_team_link_watcher_get_interval (NMTeamLinkWatcher *watcher)
|
|
|
|
|
{
|
|
|
|
|
_CHECK_WATCHER (watcher, 0);
|
|
|
|
|
|
|
|
|
|
if (!NM_IN_SET (watcher->type,
|
|
|
|
|
LINK_WATCHER_NSNA_PING,
|
|
|
|
|
LINK_WATCHER_ARP_PING))
|
|
|
|
|
return -1;
|
|
|
|
|
return watcher->arp_ping.interval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_team_link_watcher_get_missed_max:
|
|
|
|
|
* @watcher: the #NMTeamLinkWatcher
|
|
|
|
|
*
|
|
|
|
|
* Gets the number of missed replies after which the link is considered down.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
int
|
|
|
|
|
nm_team_link_watcher_get_missed_max (NMTeamLinkWatcher *watcher)
|
|
|
|
|
{
|
|
|
|
|
_CHECK_WATCHER (watcher, 0);
|
|
|
|
|
|
|
|
|
|
if (!NM_IN_SET (watcher->type,
|
|
|
|
|
LINK_WATCHER_NSNA_PING,
|
|
|
|
|
LINK_WATCHER_ARP_PING))
|
|
|
|
|
return -1;
|
|
|
|
|
return watcher->arp_ping.missed_max;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_team_link_watcher_get_target_host:
|
|
|
|
|
* @watcher: the #NMTeamLinkWatcher
|
|
|
|
|
*
|
|
|
|
|
* Gets the host name/ip address to be used as destination for the link probing
|
|
|
|
|
* packets.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
const char *
|
|
|
|
|
nm_team_link_watcher_get_target_host (NMTeamLinkWatcher *watcher)
|
|
|
|
|
{
|
|
|
|
|
_CHECK_WATCHER (watcher, NULL);
|
|
|
|
|
|
|
|
|
|
return watcher->arp_ping.target_host;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_team_link_watcher_get_source_host:
|
|
|
|
|
* @watcher: the #NMTeamLinkWatcher
|
|
|
|
|
*
|
|
|
|
|
* Gets the ip address to be used as source for the link probing packets.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
const char *
|
|
|
|
|
nm_team_link_watcher_get_source_host (NMTeamLinkWatcher *watcher)
|
|
|
|
|
{
|
|
|
|
|
_CHECK_WATCHER (watcher, NULL);
|
|
|
|
|
|
|
|
|
|
return watcher->arp_ping.source_host;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_team_link_watcher_get_flags:
|
|
|
|
|
* @watcher: the #NMTeamLinkWatcher
|
|
|
|
|
*
|
|
|
|
|
* Gets the arp ping watcher flags.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
NMTeamLinkWatcherArpPingFlags
|
|
|
|
|
nm_team_link_watcher_get_flags (NMTeamLinkWatcher *watcher)
|
|
|
|
|
{
|
|
|
|
|
_CHECK_WATCHER (watcher, 0);
|
|
|
|
|
|
|
|
|
|
return watcher->arp_ping.flags;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
libnm: use NMMetaSettingInfo for tracking setting priority
Previously, each (non abstract) NMSetting class had to register
its name and priority via _nm_register_setting().
Note, that libnm-core.la already links against "nm-meta-setting.c",
which also redundantly keeps track of the settings name and gtype
as well.
Re-use NMMetaSettingInfo also in libnm-core.la, to track this meta
data.
The goal is to get rid of private data structures that track
meta data about NMSetting classes. In this case, "registered_settings"
hash. Instead, we should have one place where all this meta data
is tracked. This was, it is also accessible as internal API,
which can be useful (for keyfile).
Note that NMSettingClass has some overlap with NMMetaSettingInfo.
One difference is, that NMMetaSettingInfo is const, while NMSettingClass
is only initialized during the class_init() method. Appart from that,
it's mostly a matter of taste, whether we attach meta data to
NMSettingClass, to NMMetaSettingInfo, or to a static-array indexed
by NMMetaSettingType.
Note, that previously, _nm_register_setting() was private API. That
means, no user could subclass a functioning NMSetting instance. The same
is still true: NMMetaSettingInfo is internal API and users cannot access
it to create their own NMSetting subclasses. But that is almost desired.
libnm is not designed, to be extensible via subclassing, nor is it
clear why that would be a useful thing to do. One day, we should remove
the NMSetting and NMSettingClass definitions from public headers. Their
only use is subclassing the types, which however does not work.
While libnm-core was linking already against nm-meta-setting.c,
nm_meta_setting_infos was unreferenced. So, this change increases
the binary size of libnm and NetworkManager (1032 bytes). Note however
that roughly the same information was previously allocated at runtime.
2018-07-27 14:08:14 +02:00
|
|
|
G_DEFINE_TYPE (NMSettingTeam, nm_setting_team, NM_TYPE_SETTING)
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
#define NM_SETTING_TEAM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_TEAM, NMSettingTeamPrivate))
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
char *config;
|
all: don't use gchar/gshort/gint/glong but C types
We commonly don't use the glib typedefs for char/short/int/long,
but their C types directly.
$ git grep '\<g\(char\|short\|int\|long\|float\|double\)\>' | wc -l
587
$ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l
21114
One could argue that using the glib typedefs is preferable in
public API (of our glib based libnm library) or where it clearly
is related to glib, like during
g_object_set (obj, PROPERTY, (gint) value, NULL);
However, that argument does not seem strong, because in practice we don't
follow that argument today, and seldomly use the glib typedefs.
Also, the style guide for this would be hard to formalize, because
"using them where clearly related to a glib" is a very loose suggestion.
Also note that glib typedefs will always just be typedefs of the
underlying C types. There is no danger of glib changing the meaning
of these typedefs (because that would be a major API break of glib).
A simple style guide is instead: don't use these typedefs.
No manual actions, I only ran the bash script:
FILES=($(git ls-files '*.[hc]'))
sed -i \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>\( [^ ]\)/\1\2/g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\> /\1 /g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>/\1/g' \
"${FILES[@]}"
2018-07-11 07:40:19 +02:00
|
|
|
int notify_peers_count;
|
|
|
|
|
int notify_peers_interval;
|
|
|
|
|
int mcast_rejoin_count;
|
|
|
|
|
int mcast_rejoin_interval;
|
2017-10-12 12:02:06 +02:00
|
|
|
char *runner;
|
|
|
|
|
char *runner_hwaddr_policy;
|
|
|
|
|
GPtrArray *runner_tx_hash;
|
|
|
|
|
char *runner_tx_balancer;
|
all: don't use gchar/gshort/gint/glong but C types
We commonly don't use the glib typedefs for char/short/int/long,
but their C types directly.
$ git grep '\<g\(char\|short\|int\|long\|float\|double\)\>' | wc -l
587
$ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l
21114
One could argue that using the glib typedefs is preferable in
public API (of our glib based libnm library) or where it clearly
is related to glib, like during
g_object_set (obj, PROPERTY, (gint) value, NULL);
However, that argument does not seem strong, because in practice we don't
follow that argument today, and seldomly use the glib typedefs.
Also, the style guide for this would be hard to formalize, because
"using them where clearly related to a glib" is a very loose suggestion.
Also note that glib typedefs will always just be typedefs of the
underlying C types. There is no danger of glib changing the meaning
of these typedefs (because that would be a major API break of glib).
A simple style guide is instead: don't use these typedefs.
No manual actions, I only ran the bash script:
FILES=($(git ls-files '*.[hc]'))
sed -i \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>\( [^ ]\)/\1\2/g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\> /\1 /g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>/\1/g' \
"${FILES[@]}"
2018-07-11 07:40:19 +02:00
|
|
|
int runner_tx_balancer_interval;
|
2017-10-12 12:02:06 +02:00
|
|
|
gboolean runner_active;
|
|
|
|
|
gboolean runner_fast_rate;
|
all: don't use gchar/gshort/gint/glong but C types
We commonly don't use the glib typedefs for char/short/int/long,
but their C types directly.
$ git grep '\<g\(char\|short\|int\|long\|float\|double\)\>' | wc -l
587
$ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l
21114
One could argue that using the glib typedefs is preferable in
public API (of our glib based libnm library) or where it clearly
is related to glib, like during
g_object_set (obj, PROPERTY, (gint) value, NULL);
However, that argument does not seem strong, because in practice we don't
follow that argument today, and seldomly use the glib typedefs.
Also, the style guide for this would be hard to formalize, because
"using them where clearly related to a glib" is a very loose suggestion.
Also note that glib typedefs will always just be typedefs of the
underlying C types. There is no danger of glib changing the meaning
of these typedefs (because that would be a major API break of glib).
A simple style guide is instead: don't use these typedefs.
No manual actions, I only ran the bash script:
FILES=($(git ls-files '*.[hc]'))
sed -i \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>\( [^ ]\)/\1\2/g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\> /\1 /g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>/\1/g' \
"${FILES[@]}"
2018-07-11 07:40:19 +02:00
|
|
|
int runner_sys_prio;
|
|
|
|
|
int runner_min_ports;
|
2017-10-12 12:02:06 +02:00
|
|
|
char *runner_agg_select_policy;
|
2017-11-06 15:47:32 +01:00
|
|
|
GPtrArray *link_watchers; /* Array of NMTeamLinkWatcher */
|
2014-07-24 08:53:33 -04:00
|
|
|
} NMSettingTeamPrivate;
|
|
|
|
|
|
2017-10-20 11:55:29 +02:00
|
|
|
/* Keep aligned with _prop_to_keys[] */
|
2014-07-24 08:53:33 -04:00
|
|
|
enum {
|
|
|
|
|
PROP_0,
|
|
|
|
|
PROP_CONFIG,
|
2017-10-12 12:02:06 +02:00
|
|
|
PROP_NOTIFY_PEERS_COUNT,
|
|
|
|
|
PROP_NOTIFY_PEERS_INTERVAL,
|
|
|
|
|
PROP_MCAST_REJOIN_COUNT,
|
|
|
|
|
PROP_MCAST_REJOIN_INTERVAL,
|
|
|
|
|
PROP_RUNNER,
|
|
|
|
|
PROP_RUNNER_HWADDR_POLICY,
|
|
|
|
|
PROP_RUNNER_TX_HASH,
|
|
|
|
|
PROP_RUNNER_TX_BALANCER,
|
|
|
|
|
PROP_RUNNER_TX_BALANCER_INTERVAL,
|
|
|
|
|
PROP_RUNNER_ACTIVE,
|
|
|
|
|
PROP_RUNNER_FAST_RATE,
|
|
|
|
|
PROP_RUNNER_SYS_PRIO,
|
|
|
|
|
PROP_RUNNER_MIN_PORTS,
|
|
|
|
|
PROP_RUNNER_AGG_SELECT_POLICY,
|
2017-11-06 15:47:32 +01:00
|
|
|
PROP_LINK_WATCHERS,
|
2014-07-24 08:53:33 -04:00
|
|
|
LAST_PROP
|
|
|
|
|
};
|
|
|
|
|
|
2017-10-20 11:55:29 +02:00
|
|
|
/* Keep aligned with team properties enum */
|
|
|
|
|
static const _NMUtilsTeamPropertyKeys _prop_to_keys[LAST_PROP] = {
|
2017-11-08 18:10:27 +01:00
|
|
|
[PROP_0] = { NULL, NULL, NULL, 0 },
|
|
|
|
|
[PROP_CONFIG] = { NULL, NULL, NULL, 0 },
|
|
|
|
|
[PROP_NOTIFY_PEERS_COUNT] = { "notify_peers", "count", NULL, 0 },
|
|
|
|
|
[PROP_NOTIFY_PEERS_INTERVAL] = { "notify_peers", "interval", NULL, 0 },
|
|
|
|
|
[PROP_MCAST_REJOIN_COUNT] = { "mcast_rejoin", "count", NULL, 0 },
|
|
|
|
|
[PROP_MCAST_REJOIN_INTERVAL] = { "mcast_rejoin", "interval", NULL, 0 },
|
|
|
|
|
[PROP_RUNNER] = { "runner", "name", NULL,
|
|
|
|
|
{.default_str = NM_SETTING_TEAM_RUNNER_DEFAULT} },
|
|
|
|
|
[PROP_RUNNER_HWADDR_POLICY] = { "runner", "hwaddr_policy", NULL, 0 },
|
|
|
|
|
[PROP_RUNNER_TX_HASH] = { "runner", "tx_hash", NULL, 0 },
|
|
|
|
|
[PROP_RUNNER_TX_BALANCER] = { "runner", "tx_balancer", "name", 0 },
|
2017-11-21 16:15:32 +01:00
|
|
|
[PROP_RUNNER_TX_BALANCER_INTERVAL] = { "runner", "tx_balancer", "balancing_interval", -1 },
|
2017-11-08 18:10:27 +01:00
|
|
|
[PROP_RUNNER_ACTIVE] = { "runner", "active", NULL, 0 },
|
|
|
|
|
[PROP_RUNNER_FAST_RATE] = { "runner", "fast_rate", NULL, 0 },
|
2017-11-21 16:15:32 +01:00
|
|
|
[PROP_RUNNER_SYS_PRIO] = { "runner", "sys_prio", NULL, -1 },
|
|
|
|
|
[PROP_RUNNER_MIN_PORTS] = { "runner", "min_ports", NULL, -1 },
|
|
|
|
|
[PROP_RUNNER_AGG_SELECT_POLICY] = { "runner", "agg_select_policy", NULL, 0 },
|
2017-11-06 15:47:32 +01:00
|
|
|
[PROP_LINK_WATCHERS] = { "link_watch", NULL, NULL, 0 }
|
2017-10-20 11:55:29 +02:00
|
|
|
};
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
/**
|
|
|
|
|
* nm_setting_team_new:
|
|
|
|
|
*
|
|
|
|
|
* Creates a new #NMSettingTeam object with default values.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer full): the new empty #NMSettingTeam object
|
|
|
|
|
**/
|
|
|
|
|
NMSetting *
|
|
|
|
|
nm_setting_team_new (void)
|
|
|
|
|
{
|
|
|
|
|
return (NMSetting *) g_object_new (NM_TYPE_SETTING_TEAM, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_team_get_config:
|
|
|
|
|
* @setting: the #NMSettingTeam
|
|
|
|
|
*
|
|
|
|
|
* Returns: the #NMSettingTeam:config property of the setting
|
|
|
|
|
**/
|
|
|
|
|
const char *
|
|
|
|
|
nm_setting_team_get_config (NMSettingTeam *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_TEAM (setting), NULL);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_TEAM_GET_PRIVATE (setting)->config;
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-12 12:02:06 +02:00
|
|
|
/**
|
|
|
|
|
* nm_setting_team_get_notify_peers_count:
|
|
|
|
|
* @setting: the #NMSettingTeam
|
|
|
|
|
*
|
|
|
|
|
* Returns: the ##NMSettingTeam:notify-peers-count property of the setting
|
|
|
|
|
*
|
2017-11-10 12:15:39 +01:00
|
|
|
* Since: 1.12
|
2017-10-12 12:02:06 +02:00
|
|
|
**/
|
all: don't use gchar/gshort/gint/glong but C types
We commonly don't use the glib typedefs for char/short/int/long,
but their C types directly.
$ git grep '\<g\(char\|short\|int\|long\|float\|double\)\>' | wc -l
587
$ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l
21114
One could argue that using the glib typedefs is preferable in
public API (of our glib based libnm library) or where it clearly
is related to glib, like during
g_object_set (obj, PROPERTY, (gint) value, NULL);
However, that argument does not seem strong, because in practice we don't
follow that argument today, and seldomly use the glib typedefs.
Also, the style guide for this would be hard to formalize, because
"using them where clearly related to a glib" is a very loose suggestion.
Also note that glib typedefs will always just be typedefs of the
underlying C types. There is no danger of glib changing the meaning
of these typedefs (because that would be a major API break of glib).
A simple style guide is instead: don't use these typedefs.
No manual actions, I only ran the bash script:
FILES=($(git ls-files '*.[hc]'))
sed -i \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>\( [^ ]\)/\1\2/g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\> /\1 /g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>/\1/g' \
"${FILES[@]}"
2018-07-11 07:40:19 +02:00
|
|
|
int
|
2017-10-12 12:02:06 +02:00
|
|
|
nm_setting_team_get_notify_peers_count (NMSettingTeam *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_TEAM (setting), 0);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_TEAM_GET_PRIVATE (setting)->notify_peers_count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_team_get_notify_peers_interval:
|
|
|
|
|
* @setting: the #NMSettingTeam
|
|
|
|
|
*
|
|
|
|
|
* Returns: the ##NMSettingTeam:notify-peers-interval property of the setting
|
|
|
|
|
*
|
2017-11-10 12:15:39 +01:00
|
|
|
* Since: 1.12
|
2017-10-12 12:02:06 +02:00
|
|
|
**/
|
all: don't use gchar/gshort/gint/glong but C types
We commonly don't use the glib typedefs for char/short/int/long,
but their C types directly.
$ git grep '\<g\(char\|short\|int\|long\|float\|double\)\>' | wc -l
587
$ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l
21114
One could argue that using the glib typedefs is preferable in
public API (of our glib based libnm library) or where it clearly
is related to glib, like during
g_object_set (obj, PROPERTY, (gint) value, NULL);
However, that argument does not seem strong, because in practice we don't
follow that argument today, and seldomly use the glib typedefs.
Also, the style guide for this would be hard to formalize, because
"using them where clearly related to a glib" is a very loose suggestion.
Also note that glib typedefs will always just be typedefs of the
underlying C types. There is no danger of glib changing the meaning
of these typedefs (because that would be a major API break of glib).
A simple style guide is instead: don't use these typedefs.
No manual actions, I only ran the bash script:
FILES=($(git ls-files '*.[hc]'))
sed -i \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>\( [^ ]\)/\1\2/g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\> /\1 /g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>/\1/g' \
"${FILES[@]}"
2018-07-11 07:40:19 +02:00
|
|
|
int
|
2017-10-12 12:02:06 +02:00
|
|
|
nm_setting_team_get_notify_peers_interval (NMSettingTeam *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_TEAM (setting), 0);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_TEAM_GET_PRIVATE (setting)->notify_peers_interval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_team_get_mcast_rejoin_count:
|
|
|
|
|
* @setting: the #NMSettingTeam
|
|
|
|
|
*
|
|
|
|
|
* Returns: the ##NMSettingTeam:mcast-rejoin-count property of the setting
|
|
|
|
|
*
|
2017-11-10 12:15:39 +01:00
|
|
|
* Since: 1.12
|
2017-10-12 12:02:06 +02:00
|
|
|
**/
|
all: don't use gchar/gshort/gint/glong but C types
We commonly don't use the glib typedefs for char/short/int/long,
but their C types directly.
$ git grep '\<g\(char\|short\|int\|long\|float\|double\)\>' | wc -l
587
$ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l
21114
One could argue that using the glib typedefs is preferable in
public API (of our glib based libnm library) or where it clearly
is related to glib, like during
g_object_set (obj, PROPERTY, (gint) value, NULL);
However, that argument does not seem strong, because in practice we don't
follow that argument today, and seldomly use the glib typedefs.
Also, the style guide for this would be hard to formalize, because
"using them where clearly related to a glib" is a very loose suggestion.
Also note that glib typedefs will always just be typedefs of the
underlying C types. There is no danger of glib changing the meaning
of these typedefs (because that would be a major API break of glib).
A simple style guide is instead: don't use these typedefs.
No manual actions, I only ran the bash script:
FILES=($(git ls-files '*.[hc]'))
sed -i \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>\( [^ ]\)/\1\2/g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\> /\1 /g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>/\1/g' \
"${FILES[@]}"
2018-07-11 07:40:19 +02:00
|
|
|
int
|
2017-10-12 12:02:06 +02:00
|
|
|
nm_setting_team_get_mcast_rejoin_count (NMSettingTeam *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_TEAM (setting), 0);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_TEAM_GET_PRIVATE (setting)->mcast_rejoin_count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_team_get_mcast_rejoin_interval:
|
|
|
|
|
* @setting: the #NMSettingTeam
|
|
|
|
|
*
|
|
|
|
|
* Returns: the ##NMSettingTeam:mcast-rejoin-interval property of the setting
|
|
|
|
|
*
|
2017-11-10 12:15:39 +01:00
|
|
|
* Since: 1.12
|
2017-10-12 12:02:06 +02:00
|
|
|
**/
|
all: don't use gchar/gshort/gint/glong but C types
We commonly don't use the glib typedefs for char/short/int/long,
but their C types directly.
$ git grep '\<g\(char\|short\|int\|long\|float\|double\)\>' | wc -l
587
$ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l
21114
One could argue that using the glib typedefs is preferable in
public API (of our glib based libnm library) or where it clearly
is related to glib, like during
g_object_set (obj, PROPERTY, (gint) value, NULL);
However, that argument does not seem strong, because in practice we don't
follow that argument today, and seldomly use the glib typedefs.
Also, the style guide for this would be hard to formalize, because
"using them where clearly related to a glib" is a very loose suggestion.
Also note that glib typedefs will always just be typedefs of the
underlying C types. There is no danger of glib changing the meaning
of these typedefs (because that would be a major API break of glib).
A simple style guide is instead: don't use these typedefs.
No manual actions, I only ran the bash script:
FILES=($(git ls-files '*.[hc]'))
sed -i \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>\( [^ ]\)/\1\2/g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\> /\1 /g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>/\1/g' \
"${FILES[@]}"
2018-07-11 07:40:19 +02:00
|
|
|
int
|
2017-10-12 12:02:06 +02:00
|
|
|
nm_setting_team_get_mcast_rejoin_interval (NMSettingTeam *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_TEAM (setting), 0);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_TEAM_GET_PRIVATE (setting)->mcast_rejoin_interval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_team_get_runner:
|
|
|
|
|
* @setting: the #NMSettingTeam
|
|
|
|
|
*
|
|
|
|
|
* Returns: the ##NMSettingTeam:runner property of the setting
|
|
|
|
|
*
|
2017-11-10 12:15:39 +01:00
|
|
|
* Since: 1.12
|
2017-10-12 12:02:06 +02:00
|
|
|
**/
|
|
|
|
|
const char *
|
|
|
|
|
nm_setting_team_get_runner (NMSettingTeam *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_TEAM (setting), NULL);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_TEAM_GET_PRIVATE (setting)->runner;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_team_get_runner_hwaddr_policy:
|
|
|
|
|
* @setting: the #NMSettingTeam
|
|
|
|
|
*
|
|
|
|
|
* Returns: the ##NMSettingTeam:runner-hwaddr-policy property of the setting
|
|
|
|
|
*
|
2017-11-10 12:15:39 +01:00
|
|
|
* Since: 1.12
|
2017-10-12 12:02:06 +02:00
|
|
|
**/
|
|
|
|
|
const char *
|
|
|
|
|
nm_setting_team_get_runner_hwaddr_policy (NMSettingTeam *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_TEAM (setting), NULL);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_TEAM_GET_PRIVATE (setting)->runner_hwaddr_policy;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_team_get_runner_tx_balancer:
|
|
|
|
|
* @setting: the #NMSettingTeam
|
|
|
|
|
*
|
|
|
|
|
* Returns: the ##NMSettingTeam:runner-tx-balancer property of the setting
|
|
|
|
|
*
|
2017-11-10 12:15:39 +01:00
|
|
|
* Since: 1.12
|
2017-10-12 12:02:06 +02:00
|
|
|
**/
|
|
|
|
|
const char *
|
|
|
|
|
nm_setting_team_get_runner_tx_balancer (NMSettingTeam *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_TEAM (setting), NULL);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_TEAM_GET_PRIVATE (setting)->runner_tx_balancer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_team_get_runner_tx_balancer_interval:
|
|
|
|
|
* @setting: the #NMSettingTeam
|
|
|
|
|
*
|
|
|
|
|
* Returns: the ##NMSettingTeam:runner-tx-balancer_interval property of the setting
|
|
|
|
|
*
|
2017-11-10 12:15:39 +01:00
|
|
|
* Since: 1.12
|
2017-10-12 12:02:06 +02:00
|
|
|
**/
|
all: don't use gchar/gshort/gint/glong but C types
We commonly don't use the glib typedefs for char/short/int/long,
but their C types directly.
$ git grep '\<g\(char\|short\|int\|long\|float\|double\)\>' | wc -l
587
$ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l
21114
One could argue that using the glib typedefs is preferable in
public API (of our glib based libnm library) or where it clearly
is related to glib, like during
g_object_set (obj, PROPERTY, (gint) value, NULL);
However, that argument does not seem strong, because in practice we don't
follow that argument today, and seldomly use the glib typedefs.
Also, the style guide for this would be hard to formalize, because
"using them where clearly related to a glib" is a very loose suggestion.
Also note that glib typedefs will always just be typedefs of the
underlying C types. There is no danger of glib changing the meaning
of these typedefs (because that would be a major API break of glib).
A simple style guide is instead: don't use these typedefs.
No manual actions, I only ran the bash script:
FILES=($(git ls-files '*.[hc]'))
sed -i \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>\( [^ ]\)/\1\2/g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\> /\1 /g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>/\1/g' \
"${FILES[@]}"
2018-07-11 07:40:19 +02:00
|
|
|
int
|
2017-10-12 12:02:06 +02:00
|
|
|
nm_setting_team_get_runner_tx_balancer_interval (NMSettingTeam *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_TEAM (setting), 0);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_TEAM_GET_PRIVATE (setting)->runner_tx_balancer_interval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_team_get_runner_active:
|
|
|
|
|
* @setting: the #NMSettingTeam
|
|
|
|
|
*
|
|
|
|
|
* Returns: the ##NMSettingTeam:runner_active property of the setting
|
|
|
|
|
*
|
2017-11-10 12:15:39 +01:00
|
|
|
* Since: 1.12
|
2017-10-12 12:02:06 +02:00
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_setting_team_get_runner_active (NMSettingTeam *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_TEAM (setting), FALSE);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_TEAM_GET_PRIVATE (setting)->runner_active;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_team_get_runner_fast_rate:
|
|
|
|
|
* @setting: the #NMSettingTeam
|
|
|
|
|
*
|
|
|
|
|
* Returns: the ##NMSettingTeam:runner-fast-rate property of the setting
|
|
|
|
|
*
|
2017-11-10 12:15:39 +01:00
|
|
|
* Since: 1.12
|
2017-10-12 12:02:06 +02:00
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_setting_team_get_runner_fast_rate (NMSettingTeam *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_TEAM (setting), FALSE);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_TEAM_GET_PRIVATE (setting)->runner_fast_rate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_team_get_runner_sys_prio:
|
|
|
|
|
* @setting: the #NMSettingTeam
|
|
|
|
|
*
|
|
|
|
|
* Returns: the ##NMSettingTeam:runner-sys-prio property of the setting
|
|
|
|
|
*
|
2017-11-10 12:15:39 +01:00
|
|
|
* Since: 1.12
|
2017-10-12 12:02:06 +02:00
|
|
|
**/
|
all: don't use gchar/gshort/gint/glong but C types
We commonly don't use the glib typedefs for char/short/int/long,
but their C types directly.
$ git grep '\<g\(char\|short\|int\|long\|float\|double\)\>' | wc -l
587
$ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l
21114
One could argue that using the glib typedefs is preferable in
public API (of our glib based libnm library) or where it clearly
is related to glib, like during
g_object_set (obj, PROPERTY, (gint) value, NULL);
However, that argument does not seem strong, because in practice we don't
follow that argument today, and seldomly use the glib typedefs.
Also, the style guide for this would be hard to formalize, because
"using them where clearly related to a glib" is a very loose suggestion.
Also note that glib typedefs will always just be typedefs of the
underlying C types. There is no danger of glib changing the meaning
of these typedefs (because that would be a major API break of glib).
A simple style guide is instead: don't use these typedefs.
No manual actions, I only ran the bash script:
FILES=($(git ls-files '*.[hc]'))
sed -i \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>\( [^ ]\)/\1\2/g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\> /\1 /g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>/\1/g' \
"${FILES[@]}"
2018-07-11 07:40:19 +02:00
|
|
|
int
|
2017-10-12 12:02:06 +02:00
|
|
|
nm_setting_team_get_runner_sys_prio (NMSettingTeam *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_TEAM (setting), 0);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_TEAM_GET_PRIVATE (setting)->runner_sys_prio;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_team_get_runner_min_ports:
|
|
|
|
|
* @setting: the #NMSettingTeam
|
|
|
|
|
*
|
|
|
|
|
* Returns: the ##NMSettingTeam:runner-min-ports property of the setting
|
|
|
|
|
*
|
2017-11-10 12:15:39 +01:00
|
|
|
* Since: 1.12
|
2017-10-12 12:02:06 +02:00
|
|
|
**/
|
all: don't use gchar/gshort/gint/glong but C types
We commonly don't use the glib typedefs for char/short/int/long,
but their C types directly.
$ git grep '\<g\(char\|short\|int\|long\|float\|double\)\>' | wc -l
587
$ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l
21114
One could argue that using the glib typedefs is preferable in
public API (of our glib based libnm library) or where it clearly
is related to glib, like during
g_object_set (obj, PROPERTY, (gint) value, NULL);
However, that argument does not seem strong, because in practice we don't
follow that argument today, and seldomly use the glib typedefs.
Also, the style guide for this would be hard to formalize, because
"using them where clearly related to a glib" is a very loose suggestion.
Also note that glib typedefs will always just be typedefs of the
underlying C types. There is no danger of glib changing the meaning
of these typedefs (because that would be a major API break of glib).
A simple style guide is instead: don't use these typedefs.
No manual actions, I only ran the bash script:
FILES=($(git ls-files '*.[hc]'))
sed -i \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>\( [^ ]\)/\1\2/g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\> /\1 /g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>/\1/g' \
"${FILES[@]}"
2018-07-11 07:40:19 +02:00
|
|
|
int
|
2017-10-12 12:02:06 +02:00
|
|
|
nm_setting_team_get_runner_min_ports (NMSettingTeam *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_TEAM (setting), 0);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_TEAM_GET_PRIVATE (setting)->runner_min_ports;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_team_get_runner_agg_select_policy:
|
|
|
|
|
* @setting: the #NMSettingTeam
|
|
|
|
|
*
|
|
|
|
|
* Returns: the ##NMSettingTeam:runner-agg-select-policy property of the setting
|
|
|
|
|
*
|
2017-11-10 12:15:39 +01:00
|
|
|
* Since: 1.12
|
2017-10-12 12:02:06 +02:00
|
|
|
**/
|
|
|
|
|
const char *
|
|
|
|
|
nm_setting_team_get_runner_agg_select_policy (NMSettingTeam *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_TEAM (setting), NULL);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_TEAM_GET_PRIVATE (setting)->runner_agg_select_policy;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_team_remove_runner_tx_hash_by_value:
|
|
|
|
|
* @setting: the #NMSetetingTeam
|
|
|
|
|
* @txhash: the txhash element to remove
|
|
|
|
|
*
|
|
|
|
|
* Removes the txhash element #txhash
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the txhash element was found and removed; %FALSE if it was not.
|
|
|
|
|
*
|
2017-11-10 12:15:39 +01:00
|
|
|
* Since: 1.12
|
2017-10-12 12:02:06 +02:00
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_setting_team_remove_runner_tx_hash_by_value (NMSettingTeam *setting,
|
|
|
|
|
const char *txhash)
|
|
|
|
|
{
|
|
|
|
|
NMSettingTeamPrivate *priv = NM_SETTING_TEAM_GET_PRIVATE (setting);
|
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_TEAM (setting), FALSE);
|
|
|
|
|
g_return_val_if_fail (txhash != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (txhash[0] != '\0', FALSE);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < priv->runner_tx_hash->len; i++) {
|
|
|
|
|
if (nm_streq (txhash, priv->runner_tx_hash->pdata[i])) {
|
|
|
|
|
g_ptr_array_remove_index (priv->runner_tx_hash, i);
|
|
|
|
|
g_object_notify (G_OBJECT (setting), NM_SETTING_TEAM_RUNNER_TX_HASH);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_team_get_num_runner_tx_hash:
|
|
|
|
|
* @setting: the #NMSettingTeam
|
|
|
|
|
*
|
|
|
|
|
* Returns: the number of elements in txhash
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
guint
|
|
|
|
|
nm_setting_team_get_num_runner_tx_hash (NMSettingTeam *setting)
|
|
|
|
|
{
|
|
|
|
|
NMSettingTeamPrivate *priv = NM_SETTING_TEAM_GET_PRIVATE (setting);
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_TEAM (setting), 0);
|
|
|
|
|
|
|
|
|
|
return priv->runner_tx_hash ? priv->runner_tx_hash->len : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_team_get_runner_tx_hash
|
|
|
|
|
* @setting: the #NMSettingTeam
|
|
|
|
|
* @idx: index number of the txhash element to return
|
|
|
|
|
*
|
|
|
|
|
* Returns: the txhash element at index @idx
|
|
|
|
|
*
|
2017-11-10 12:15:39 +01:00
|
|
|
* Since: 1.12
|
2017-10-12 12:02:06 +02:00
|
|
|
**/
|
|
|
|
|
const char *
|
2017-12-06 23:15:07 +01:00
|
|
|
nm_setting_team_get_runner_tx_hash (NMSettingTeam *setting, guint idx)
|
2017-10-12 12:02:06 +02:00
|
|
|
{
|
|
|
|
|
NMSettingTeamPrivate *priv = NM_SETTING_TEAM_GET_PRIVATE (setting);
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_TEAM (setting), NULL);
|
2017-12-06 23:15:07 +01:00
|
|
|
g_return_val_if_fail (idx < priv->runner_tx_hash->len, NULL);
|
2017-10-12 12:02:06 +02:00
|
|
|
|
|
|
|
|
return priv->runner_tx_hash->pdata[idx];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_team_remove_runner_tx_hash:
|
|
|
|
|
* @setting: the #NMSettingTeam
|
|
|
|
|
* @idx: index number of the element to remove from txhash
|
|
|
|
|
*
|
|
|
|
|
* Removes the txhash element at index @idx.
|
|
|
|
|
*
|
2017-11-10 12:15:39 +01:00
|
|
|
* Since: 1.12
|
2017-10-12 12:02:06 +02:00
|
|
|
**/
|
|
|
|
|
void
|
2017-12-06 23:15:07 +01:00
|
|
|
nm_setting_team_remove_runner_tx_hash (NMSettingTeam *setting, guint idx)
|
2017-10-12 12:02:06 +02:00
|
|
|
{
|
|
|
|
|
NMSettingTeamPrivate *priv = NM_SETTING_TEAM_GET_PRIVATE (setting);
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_SETTING_TEAM (setting));
|
2017-12-06 23:15:07 +01:00
|
|
|
g_return_if_fail (idx < priv->runner_tx_hash->len);
|
2017-10-12 12:02:06 +02:00
|
|
|
|
|
|
|
|
g_ptr_array_remove_index (priv->runner_tx_hash, idx);
|
|
|
|
|
g_object_notify (G_OBJECT (setting), NM_SETTING_TEAM_RUNNER_TX_HASH);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_team_add_runner_tx_hash:
|
|
|
|
|
* @setting: the #NMSettingTeam
|
|
|
|
|
* @txhash: the element to add to txhash
|
|
|
|
|
*
|
|
|
|
|
* Adds a new txhash element to the setting.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the txhash element was added; %FALSE if the element
|
|
|
|
|
* was already knnown.
|
|
|
|
|
*
|
2017-11-10 12:15:39 +01:00
|
|
|
* Since: 1.12
|
2017-10-12 12:02:06 +02:00
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_setting_team_add_runner_tx_hash (NMSettingTeam *setting, const char *txhash)
|
|
|
|
|
{
|
|
|
|
|
NMSettingTeamPrivate *priv = NM_SETTING_TEAM_GET_PRIVATE (setting);
|
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_TEAM (setting), FALSE);
|
|
|
|
|
g_return_val_if_fail (txhash != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (txhash[0] != '\0', FALSE);
|
|
|
|
|
|
|
|
|
|
if (!priv->runner_tx_hash)
|
|
|
|
|
priv->runner_tx_hash = g_ptr_array_new_with_free_func (g_free);
|
|
|
|
|
for (i = 0; i < priv->runner_tx_hash->len; i++) {
|
|
|
|
|
if (nm_streq (txhash, priv->runner_tx_hash->pdata[i]))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_ptr_array_add (priv->runner_tx_hash, g_strdup (txhash));
|
|
|
|
|
g_object_notify (G_OBJECT (setting), NM_SETTING_TEAM_RUNNER_TX_HASH);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-06 15:47:32 +01:00
|
|
|
/**
|
|
|
|
|
* nm_setting_team_get_num_link_watchers:
|
|
|
|
|
* @setting: the #NMSettingTeam
|
|
|
|
|
*
|
|
|
|
|
* Returns: the number of configured link watchers
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
guint
|
|
|
|
|
nm_setting_team_get_num_link_watchers (NMSettingTeam *setting)
|
|
|
|
|
{
|
|
|
|
|
NMSettingTeamPrivate *priv = NM_SETTING_TEAM_GET_PRIVATE (setting);
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_TEAM (setting), 0);
|
|
|
|
|
|
|
|
|
|
return priv->link_watchers->len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_team_get_link_watcher:
|
|
|
|
|
* @setting: the #NMSettingTeam
|
|
|
|
|
* @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_get_link_watcher (NMSettingTeam *setting, guint idx)
|
|
|
|
|
{
|
|
|
|
|
NMSettingTeamPrivate *priv = NM_SETTING_TEAM_GET_PRIVATE (setting);
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_TEAM (setting), NULL);
|
|
|
|
|
g_return_val_if_fail (idx < priv->link_watchers->len, NULL);
|
|
|
|
|
|
|
|
|
|
return priv->link_watchers->pdata[idx];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_team_add_link_watcher:
|
|
|
|
|
* @setting: the #NMSettingTeam
|
|
|
|
|
* @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_add_link_watcher (NMSettingTeam *setting,
|
|
|
|
|
NMTeamLinkWatcher *link_watcher)
|
|
|
|
|
{
|
|
|
|
|
NMSettingTeamPrivate *priv = NM_SETTING_TEAM_GET_PRIVATE (setting);
|
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_TEAM (setting), FALSE);
|
|
|
|
|
g_return_val_if_fail (link_watcher != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < priv->link_watchers->len; i++) {
|
|
|
|
|
if (nm_team_link_watcher_equal (priv->link_watchers->pdata[i], link_watcher))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_ptr_array_add (priv->link_watchers, nm_team_link_watcher_dup (link_watcher));
|
|
|
|
|
g_object_notify (G_OBJECT (setting), NM_SETTING_TEAM_LINK_WATCHERS);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_team_remove_link_watcher:
|
|
|
|
|
* @setting: the #NMSettingTeam
|
|
|
|
|
* @idx: index number of the link watcher to remove
|
|
|
|
|
*
|
|
|
|
|
* Removes the link watcher at index #idx.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
nm_setting_team_remove_link_watcher (NMSettingTeam *setting, guint idx)
|
|
|
|
|
{
|
|
|
|
|
NMSettingTeamPrivate *priv = NM_SETTING_TEAM_GET_PRIVATE (setting);
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_SETTING_TEAM (setting));
|
|
|
|
|
g_return_if_fail (idx < priv->link_watchers->len);
|
|
|
|
|
|
|
|
|
|
g_ptr_array_remove_index (priv->link_watchers, idx);
|
|
|
|
|
g_object_notify (G_OBJECT (setting), NM_SETTING_TEAM_LINK_WATCHERS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_team_remove_link_watcher_by_value:
|
|
|
|
|
* @setting: the #NMSettingTeam
|
|
|
|
|
* @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_remove_link_watcher_by_value (NMSettingTeam *setting,
|
|
|
|
|
NMTeamLinkWatcher *link_watcher)
|
|
|
|
|
{
|
|
|
|
|
NMSettingTeamPrivate *priv = NM_SETTING_TEAM_GET_PRIVATE (setting);
|
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_TEAM (setting), FALSE);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < priv->link_watchers->len; i++) {
|
|
|
|
|
if (nm_team_link_watcher_equal (priv->link_watchers->pdata[i], link_watcher)) {
|
|
|
|
|
g_ptr_array_remove_index (priv->link_watchers, i);
|
|
|
|
|
g_object_notify (G_OBJECT (setting), NM_SETTING_TEAM_LINK_WATCHERS);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_team_clear_link_watchers:
|
|
|
|
|
* @setting: the #NMSettingTeam
|
|
|
|
|
*
|
|
|
|
|
* Removes all configured link watchers.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
nm_setting_team_clear_link_watchers (NMSettingTeam *setting) {
|
|
|
|
|
NMSettingTeamPrivate *priv = NM_SETTING_TEAM_GET_PRIVATE (setting);
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_SETTING_TEAM (setting));
|
|
|
|
|
|
2018-05-28 15:31:11 +02:00
|
|
|
if (priv->link_watchers->len != 0) {
|
|
|
|
|
g_ptr_array_set_size (priv->link_watchers, 0);
|
|
|
|
|
g_object_notify (G_OBJECT (setting), NM_SETTING_TEAM_LINK_WATCHERS);
|
|
|
|
|
}
|
2017-11-06 15:47:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GVariant *
|
|
|
|
|
team_link_watchers_to_dbus (const GValue *prop_value)
|
|
|
|
|
{
|
|
|
|
|
return _nm_utils_team_link_watchers_to_variant (g_value_get_boxed (prop_value));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
team_link_watchers_from_dbus (GVariant *dbus_value,
|
|
|
|
|
GValue *prop_value)
|
|
|
|
|
{
|
|
|
|
|
g_value_take_boxed (prop_value, _nm_utils_team_link_watchers_from_variant (dbus_value));
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
static gboolean
|
2014-10-21 22:30:31 -04:00
|
|
|
verify (NMSetting *setting, NMConnection *connection, GError **error)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
2016-03-11 13:17:24 +01:00
|
|
|
NMSettingTeamPrivate *priv = NM_SETTING_TEAM_GET_PRIVATE (setting);
|
2017-11-06 15:47:32 +01:00
|
|
|
guint i;
|
2016-03-11 13:17:24 +01:00
|
|
|
|
|
|
|
|
if (!_nm_connection_verify_required_interface_name (connection, error))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (priv->config) {
|
2016-09-23 11:16:48 +02:00
|
|
|
if (strlen (priv->config) > 1*1024*1024) {
|
|
|
|
|
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("team config exceeds size limit"));
|
|
|
|
|
g_prefix_error (error,
|
|
|
|
|
"%s.%s: ",
|
|
|
|
|
NM_SETTING_TEAM_SETTING_NAME,
|
|
|
|
|
NM_SETTING_TEAM_CONFIG);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-23 10:30:50 +02:00
|
|
|
if (!nm_utils_is_json_object (priv->config, error)) {
|
2016-03-11 13:17:24 +01:00
|
|
|
g_prefix_error (error,
|
|
|
|
|
"%s.%s: ",
|
|
|
|
|
NM_SETTING_TEAM_SETTING_NAME,
|
|
|
|
|
NM_SETTING_TEAM_CONFIG);
|
2016-08-30 15:22:04 +02:00
|
|
|
/* We treat an empty string as no config for compatibility. */
|
|
|
|
|
return *priv->config ? FALSE : NM_SETTING_VERIFY_NORMALIZABLE;
|
2016-03-11 13:17:24 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-12 12:02:06 +02:00
|
|
|
if ( priv->runner
|
|
|
|
|
&& g_ascii_strcasecmp (priv->runner, NM_SETTING_TEAM_RUNNER_BROADCAST)
|
|
|
|
|
&& g_ascii_strcasecmp (priv->runner, NM_SETTING_TEAM_RUNNER_ROUNDROBIN)
|
2018-02-05 15:24:36 +01:00
|
|
|
&& g_ascii_strcasecmp (priv->runner, NM_SETTING_TEAM_RUNNER_RANDOM)
|
2017-10-12 12:02:06 +02:00
|
|
|
&& g_ascii_strcasecmp (priv->runner, NM_SETTING_TEAM_RUNNER_ACTIVEBACKUP)
|
|
|
|
|
&& g_ascii_strcasecmp (priv->runner, NM_SETTING_TEAM_RUNNER_LOADBALANCE)
|
|
|
|
|
&& g_ascii_strcasecmp (priv->runner, NM_SETTING_TEAM_RUNNER_LACP)) {
|
|
|
|
|
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_SETTING,
|
|
|
|
|
_("invalid runner \"%s\""), priv->runner);
|
|
|
|
|
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", nm_setting_get_name (setting), NM_SETTING_TEAM_RUNNER);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-06 15:47:32 +01:00
|
|
|
/* Validate link watchers */
|
|
|
|
|
for (i = 0; i < priv->link_watchers->len; i++) {
|
|
|
|
|
NMTeamLinkWatcher *link_watcher = priv->link_watchers->pdata[i];
|
|
|
|
|
const char *name = nm_team_link_watcher_get_name (link_watcher);
|
|
|
|
|
|
|
|
|
|
if (!name) {
|
|
|
|
|
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_MISSING_SETTING,
|
|
|
|
|
_("missing link watcher name"));
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", nm_setting_get_name (setting),
|
|
|
|
|
NM_SETTING_TEAM_LINK_WATCHERS);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
if (!NM_IN_STRSET (name,
|
|
|
|
|
NM_TEAM_LINK_WATCHER_ETHTOOL,
|
|
|
|
|
NM_TEAM_LINK_WATCHER_ARP_PING,
|
|
|
|
|
NM_TEAM_LINK_WATCHER_NSNA_PING)) {
|
|
|
|
|
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_SETTING,
|
|
|
|
|
_("unknown link watcher \"%s\""), name);
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", nm_setting_get_name (setting),
|
|
|
|
|
NM_SETTING_TEAM_LINK_WATCHERS);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (NM_IN_STRSET (name,
|
|
|
|
|
NM_TEAM_LINK_WATCHER_ARP_PING,
|
|
|
|
|
NM_TEAM_LINK_WATCHER_NSNA_PING)
|
|
|
|
|
&& !nm_team_link_watcher_get_target_host (link_watcher)) {
|
|
|
|
|
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_MISSING_SETTING,
|
|
|
|
|
_("missing target host"));
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", nm_setting_get_name (setting),
|
|
|
|
|
NM_SETTING_TEAM_LINK_WATCHERS);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
if (nm_streq (name, NM_TEAM_LINK_WATCHER_ARP_PING)
|
|
|
|
|
&& !nm_team_link_watcher_get_source_host (link_watcher)) {
|
|
|
|
|
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_MISSING_SETTING,
|
|
|
|
|
_("missing source address"));
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", nm_setting_get_name (setting),
|
|
|
|
|
NM_SETTING_TEAM_LINK_WATCHERS);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-08-30 16:37:54 +02:00
|
|
|
/* NOTE: normalizable/normalizable-errors must appear at the end with decreasing severity.
|
|
|
|
|
* Take care to properly order statements with priv->config above. */
|
|
|
|
|
|
2016-03-11 13:17:24 +01:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
compare_property (NMSetting *setting,
|
|
|
|
|
NMSetting *other,
|
|
|
|
|
const GParamSpec *prop_spec,
|
|
|
|
|
NMSettingCompareFlags flags)
|
|
|
|
|
{
|
2017-11-06 15:47:32 +01:00
|
|
|
NMSettingTeamPrivate *a_priv, *b_priv;
|
libnm/trivial: cleanup variable names in settings' class-init functions
- Don't use @parent_class name. This local variable (and @object_class) is
the class instance up-cast to the pointer types of the parents. The point
here is not that it is the direct parent. The point is, that it's the
NMSettingClass type.
Also, it can only be used inconsistently, in face of NMSettingIP4Config,
who's parent type is NMSettingIPConfig. Clearly, inside
nm-setting-ip4-config.c we wouldn't want to use the "parent_class"
name. Consistently rename @parent_class to @setting_class.
- Also rename the pointer to the own class to @klass. "setting_class" is also the
wrong name for that, because the right name would be something like
"setting_6lowpan_class".
However, "klass" is preferred over the latter, because we commonly create new
GObject implementations by copying an existing one. Generic names like "klass"
and "self" inside a type implementation make that simpler.
- drop useless comments like
/* virtual functions */
/* Properties */
It's better to logically and visually structure the code, and avoid trival
remarks about that. They only end up being used inconsistently. If you
even need a stronger visual separator, then an 80 char /****/ line
should be preferred.
2018-07-28 10:43:21 +02:00
|
|
|
NMSettingClass *setting_class;
|
2017-11-06 15:47:32 +01:00
|
|
|
guint i, j;
|
2016-03-11 13:17:24 +01:00
|
|
|
|
2016-05-26 18:29:50 +02:00
|
|
|
/* 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.
|
|
|
|
|
*/
|
|
|
|
|
if ( NM_FLAGS_HAS (flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)
|
|
|
|
|
&& nm_streq0 (prop_spec->name, NM_SETTING_TEAM_CONFIG)) {
|
2016-03-11 13:17:24 +01:00
|
|
|
return _nm_utils_team_config_equal (NM_SETTING_TEAM_GET_PRIVATE (setting)->config,
|
|
|
|
|
NM_SETTING_TEAM_GET_PRIVATE (other)->config,
|
|
|
|
|
FALSE);
|
|
|
|
|
}
|
2017-11-06 15:47:32 +01:00
|
|
|
if (nm_streq0 (prop_spec->name, NM_SETTING_TEAM_LINK_WATCHERS)) {
|
|
|
|
|
a_priv = NM_SETTING_TEAM_GET_PRIVATE (setting);
|
|
|
|
|
b_priv = NM_SETTING_TEAM_GET_PRIVATE (other);
|
|
|
|
|
|
|
|
|
|
if (a_priv->link_watchers->len != b_priv->link_watchers->len)
|
|
|
|
|
return FALSE;
|
|
|
|
|
for (i = 0; i < a_priv->link_watchers->len; i++) {
|
|
|
|
|
for (j = 0; j < b_priv->link_watchers->len; j++) {
|
|
|
|
|
if (nm_team_link_watcher_equal (a_priv->link_watchers->pdata[i],
|
|
|
|
|
b_priv->link_watchers->pdata[j])) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (j == b_priv->link_watchers->len)
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2016-03-11 13:17:24 +01:00
|
|
|
|
libnm/trivial: cleanup variable names in settings' class-init functions
- Don't use @parent_class name. This local variable (and @object_class) is
the class instance up-cast to the pointer types of the parents. The point
here is not that it is the direct parent. The point is, that it's the
NMSettingClass type.
Also, it can only be used inconsistently, in face of NMSettingIP4Config,
who's parent type is NMSettingIPConfig. Clearly, inside
nm-setting-ip4-config.c we wouldn't want to use the "parent_class"
name. Consistently rename @parent_class to @setting_class.
- Also rename the pointer to the own class to @klass. "setting_class" is also the
wrong name for that, because the right name would be something like
"setting_6lowpan_class".
However, "klass" is preferred over the latter, because we commonly create new
GObject implementations by copying an existing one. Generic names like "klass"
and "self" inside a type implementation make that simpler.
- drop useless comments like
/* virtual functions */
/* Properties */
It's better to logically and visually structure the code, and avoid trival
remarks about that. They only end up being used inconsistently. If you
even need a stronger visual separator, then an 80 char /****/ line
should be preferred.
2018-07-28 10:43:21 +02:00
|
|
|
setting_class = NM_SETTING_CLASS (nm_setting_team_parent_class);
|
|
|
|
|
return setting_class->compare_property (setting, other, prop_spec, flags);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_setting_team_init (NMSettingTeam *setting)
|
|
|
|
|
{
|
2017-10-12 12:02:06 +02:00
|
|
|
NMSettingTeamPrivate *priv = NM_SETTING_TEAM_GET_PRIVATE (setting);
|
|
|
|
|
|
|
|
|
|
priv->runner = g_strdup (NM_SETTING_TEAM_RUNNER_ROUNDROBIN);
|
2017-11-21 16:15:32 +01:00
|
|
|
priv->runner_tx_balancer_interval = -1;
|
|
|
|
|
priv->runner_sys_prio = -1;
|
|
|
|
|
priv->runner_min_ports = -1;
|
2017-11-06 15:47:32 +01:00
|
|
|
priv->link_watchers = g_ptr_array_new_with_free_func ((GDestroyNotify) nm_team_link_watcher_unref);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
finalize (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
NMSettingTeamPrivate *priv = NM_SETTING_TEAM_GET_PRIVATE (object);
|
|
|
|
|
|
|
|
|
|
g_free (priv->config);
|
2017-10-12 12:02:06 +02:00
|
|
|
g_free (priv->runner);
|
|
|
|
|
g_free (priv->runner_hwaddr_policy);
|
|
|
|
|
g_free (priv->runner_tx_balancer);
|
|
|
|
|
g_free (priv->runner_agg_select_policy);
|
2017-10-20 11:55:29 +02:00
|
|
|
if (priv->runner_tx_hash)
|
|
|
|
|
g_ptr_array_unref (priv->runner_tx_hash);
|
2017-11-06 15:47:32 +01:00
|
|
|
g_ptr_array_unref (priv->link_watchers);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (nm_setting_team_parent_class)->finalize (object);
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-08 18:10:27 +01:00
|
|
|
#define JSON_TO_VAL(typ, id) _nm_utils_json_extract_##typ (priv->config, _prop_to_keys[id], FALSE)
|
2017-10-20 11:55:29 +02:00
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
_align_team_properties (NMSettingTeam *setting)
|
|
|
|
|
{
|
|
|
|
|
NMSettingTeamPrivate *priv = NM_SETTING_TEAM_GET_PRIVATE (setting);
|
|
|
|
|
char **strv;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
priv->notify_peers_count = JSON_TO_VAL (int, PROP_NOTIFY_PEERS_COUNT);
|
|
|
|
|
priv->notify_peers_interval = JSON_TO_VAL (int, PROP_NOTIFY_PEERS_INTERVAL);
|
|
|
|
|
priv->mcast_rejoin_count = JSON_TO_VAL (int, PROP_MCAST_REJOIN_COUNT);
|
|
|
|
|
priv->mcast_rejoin_interval = JSON_TO_VAL (int, PROP_MCAST_REJOIN_INTERVAL);
|
|
|
|
|
priv->runner_tx_balancer_interval = JSON_TO_VAL (int, PROP_RUNNER_TX_BALANCER_INTERVAL);
|
|
|
|
|
priv->runner_sys_prio = JSON_TO_VAL (int, PROP_RUNNER_SYS_PRIO);
|
|
|
|
|
priv->runner_min_ports = JSON_TO_VAL (int, PROP_RUNNER_MIN_PORTS);
|
|
|
|
|
|
|
|
|
|
priv->runner_active = JSON_TO_VAL (boolean, PROP_RUNNER_ACTIVE);
|
|
|
|
|
priv->runner_fast_rate = JSON_TO_VAL (boolean, PROP_RUNNER_FAST_RATE);
|
|
|
|
|
|
|
|
|
|
g_free (priv->runner);
|
|
|
|
|
g_free (priv->runner_hwaddr_policy);
|
|
|
|
|
g_free (priv->runner_tx_balancer);
|
|
|
|
|
g_free (priv->runner_agg_select_policy);
|
|
|
|
|
priv->runner = JSON_TO_VAL (string, PROP_RUNNER);
|
|
|
|
|
priv->runner_hwaddr_policy = JSON_TO_VAL (string, PROP_RUNNER_HWADDR_POLICY);
|
|
|
|
|
priv->runner_tx_balancer = JSON_TO_VAL (string, PROP_RUNNER_TX_BALANCER);
|
|
|
|
|
priv->runner_agg_select_policy = JSON_TO_VAL (string, PROP_RUNNER_AGG_SELECT_POLICY);
|
|
|
|
|
|
|
|
|
|
if (priv->runner_tx_hash) {
|
|
|
|
|
g_ptr_array_unref (priv->runner_tx_hash);
|
|
|
|
|
priv->runner_tx_hash = NULL;
|
|
|
|
|
}
|
|
|
|
|
strv = JSON_TO_VAL (strv, PROP_RUNNER_TX_HASH);
|
|
|
|
|
if (strv) {
|
|
|
|
|
for (i = 0; strv[i]; i++)
|
|
|
|
|
nm_setting_team_add_runner_tx_hash (setting, strv[i]);
|
|
|
|
|
g_strfreev (strv);
|
|
|
|
|
}
|
2017-11-12 00:08:03 +01:00
|
|
|
|
|
|
|
|
g_ptr_array_unref (priv->link_watchers);
|
|
|
|
|
priv->link_watchers = JSON_TO_VAL (ptr_array, PROP_LINK_WATCHERS);
|
2017-10-20 11:55:29 +02:00
|
|
|
}
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
static void
|
|
|
|
|
set_property (GObject *object, guint prop_id,
|
|
|
|
|
const GValue *value, GParamSpec *pspec)
|
|
|
|
|
{
|
2017-10-20 11:55:29 +02:00
|
|
|
NMSettingTeam *setting = NM_SETTING_TEAM (object);
|
2014-07-24 08:53:33 -04:00
|
|
|
NMSettingTeamPrivate *priv = NM_SETTING_TEAM_GET_PRIVATE (object);
|
2017-10-20 11:55:29 +02:00
|
|
|
const GValue *align_value = NULL;
|
|
|
|
|
gboolean align_config = FALSE;
|
|
|
|
|
char **strv;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
|
case PROP_CONFIG:
|
|
|
|
|
g_free (priv->config);
|
|
|
|
|
priv->config = g_value_dup_string (value);
|
2017-10-20 11:55:29 +02:00
|
|
|
_align_team_properties (setting);
|
2014-07-24 08:53:33 -04:00
|
|
|
break;
|
2017-10-12 12:02:06 +02:00
|
|
|
case PROP_NOTIFY_PEERS_COUNT:
|
2017-10-20 11:55:29 +02:00
|
|
|
if (priv->notify_peers_count == g_value_get_int (value))
|
|
|
|
|
break;
|
|
|
|
|
priv->notify_peers_count = g_value_get_int (value);
|
2017-11-21 16:15:32 +01:00
|
|
|
align_value = value;
|
2017-10-20 11:55:29 +02:00
|
|
|
align_config = TRUE;
|
2017-10-12 12:02:06 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_NOTIFY_PEERS_INTERVAL:
|
2017-10-20 11:55:29 +02:00
|
|
|
if (priv->notify_peers_interval == g_value_get_int (value))
|
|
|
|
|
break;
|
|
|
|
|
priv->notify_peers_interval = g_value_get_int (value);
|
2017-11-21 16:15:32 +01:00
|
|
|
align_value = value;
|
2017-10-20 11:55:29 +02:00
|
|
|
align_config = TRUE;
|
2017-10-12 12:02:06 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_MCAST_REJOIN_COUNT:
|
2017-10-20 11:55:29 +02:00
|
|
|
if (priv->mcast_rejoin_count == g_value_get_int (value))
|
|
|
|
|
break;
|
|
|
|
|
priv->mcast_rejoin_count = g_value_get_int (value);
|
2017-11-21 16:15:32 +01:00
|
|
|
align_value = value;
|
2017-10-20 11:55:29 +02:00
|
|
|
align_config = TRUE;
|
2017-10-12 12:02:06 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_MCAST_REJOIN_INTERVAL:
|
2017-10-20 11:55:29 +02:00
|
|
|
if (priv->mcast_rejoin_interval == g_value_get_int (value))
|
|
|
|
|
break;
|
|
|
|
|
priv->mcast_rejoin_interval = g_value_get_int (value);
|
2017-11-21 16:15:32 +01:00
|
|
|
align_value = value;
|
2017-10-20 11:55:29 +02:00
|
|
|
align_config = TRUE;
|
2017-10-12 12:02:06 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_RUNNER:
|
2017-11-21 16:15:32 +01:00
|
|
|
if ( !g_value_get_string (value)
|
|
|
|
|
|| nm_streq (priv->runner, g_value_get_string (value)))
|
|
|
|
|
break;
|
2017-10-12 12:02:06 +02:00
|
|
|
g_free (priv->runner);
|
|
|
|
|
priv->runner = g_value_dup_string (value);
|
2017-11-21 16:15:32 +01:00
|
|
|
_nm_utils_json_append_gvalue (&priv->config, _prop_to_keys[prop_id], value);
|
|
|
|
|
_align_team_properties (setting);
|
2017-10-12 12:02:06 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_RUNNER_HWADDR_POLICY:
|
2017-11-21 16:15:32 +01:00
|
|
|
if (nm_streq0 (priv->runner_hwaddr_policy, g_value_get_string (value)))
|
|
|
|
|
break;
|
2017-10-20 11:55:29 +02:00
|
|
|
g_free (priv->runner_hwaddr_policy);
|
|
|
|
|
priv->runner_hwaddr_policy = g_value_dup_string (value);
|
2017-11-21 16:15:32 +01:00
|
|
|
align_value = value;
|
2017-10-20 11:55:29 +02:00
|
|
|
align_config = TRUE;
|
2017-10-12 12:02:06 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_RUNNER_TX_HASH:
|
2017-10-20 11:55:29 +02:00
|
|
|
if (priv->runner_tx_hash)
|
|
|
|
|
g_ptr_array_unref (priv->runner_tx_hash);
|
|
|
|
|
strv = g_value_get_boxed (value);
|
|
|
|
|
if (strv && strv[0]) {
|
|
|
|
|
priv->runner_tx_hash = _nm_utils_strv_to_ptrarray (strv);
|
|
|
|
|
align_value = value;
|
|
|
|
|
} else
|
|
|
|
|
priv->runner_tx_hash = NULL;
|
|
|
|
|
align_config = TRUE;
|
2017-10-12 12:02:06 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_RUNNER_TX_BALANCER:
|
2017-11-21 16:15:32 +01:00
|
|
|
if (nm_streq0 (priv->runner_tx_balancer, g_value_get_string (value)))
|
|
|
|
|
break;
|
2017-10-20 11:55:29 +02:00
|
|
|
g_free (priv->runner_tx_balancer);
|
|
|
|
|
priv->runner_tx_balancer = g_value_dup_string (value);
|
2017-11-21 16:15:32 +01:00
|
|
|
align_value = value;
|
2017-10-20 11:55:29 +02:00
|
|
|
align_config = TRUE;
|
2017-10-12 12:02:06 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_RUNNER_TX_BALANCER_INTERVAL:
|
2017-10-20 11:55:29 +02:00
|
|
|
if (priv->runner_tx_balancer_interval == g_value_get_int (value))
|
|
|
|
|
break;
|
|
|
|
|
priv->runner_tx_balancer_interval = g_value_get_int (value);
|
2017-11-21 16:15:32 +01:00
|
|
|
align_value = value;
|
2017-10-20 11:55:29 +02:00
|
|
|
align_config = TRUE;
|
2017-10-12 12:02:06 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_RUNNER_ACTIVE:
|
2017-10-20 11:55:29 +02:00
|
|
|
if (priv->runner_active == g_value_get_boolean (value))
|
|
|
|
|
break;
|
|
|
|
|
priv->runner_active = g_value_get_boolean (value);
|
2017-11-21 16:15:32 +01:00
|
|
|
align_value = value;
|
2017-10-20 11:55:29 +02:00
|
|
|
align_config = TRUE;
|
2017-10-12 12:02:06 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_RUNNER_FAST_RATE:
|
2017-10-20 11:55:29 +02:00
|
|
|
if (priv->runner_fast_rate == g_value_get_boolean (value))
|
|
|
|
|
break;
|
|
|
|
|
priv->runner_fast_rate = g_value_get_boolean (value);
|
2017-11-21 16:15:32 +01:00
|
|
|
align_value = value;
|
2017-10-20 11:55:29 +02:00
|
|
|
align_config = TRUE;
|
2017-10-12 12:02:06 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_RUNNER_SYS_PRIO:
|
2017-10-20 11:55:29 +02:00
|
|
|
if (priv->runner_sys_prio == g_value_get_int (value))
|
|
|
|
|
break;
|
|
|
|
|
priv->runner_sys_prio = g_value_get_int (value);
|
2017-11-21 16:15:32 +01:00
|
|
|
align_value = value;
|
2017-10-20 11:55:29 +02:00
|
|
|
align_config = TRUE;
|
2017-10-12 12:02:06 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_RUNNER_MIN_PORTS:
|
2017-10-20 11:55:29 +02:00
|
|
|
if (priv->runner_min_ports == g_value_get_int (value))
|
|
|
|
|
break;
|
|
|
|
|
priv->runner_min_ports = g_value_get_int (value);
|
2017-11-21 16:15:32 +01:00
|
|
|
align_value = value;
|
2017-10-20 11:55:29 +02:00
|
|
|
align_config = TRUE;
|
2017-10-12 12:02:06 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_RUNNER_AGG_SELECT_POLICY:
|
2017-11-21 16:15:32 +01:00
|
|
|
if (nm_streq0 (priv->runner_agg_select_policy, g_value_get_string (value)))
|
|
|
|
|
break;
|
2017-10-20 11:55:29 +02:00
|
|
|
g_free (priv->runner_agg_select_policy);
|
|
|
|
|
priv->runner_agg_select_policy = g_value_dup_string (value);
|
2017-11-21 16:15:32 +01:00
|
|
|
align_value = value;
|
2017-10-20 11:55:29 +02:00
|
|
|
align_config = TRUE;
|
2017-10-12 12:02:06 +02:00
|
|
|
break;
|
2017-11-06 15:47:32 +01:00
|
|
|
case PROP_LINK_WATCHERS:
|
|
|
|
|
g_ptr_array_unref (priv->link_watchers);
|
|
|
|
|
priv->link_watchers = _nm_utils_copy_array (g_value_get_boxed (value),
|
|
|
|
|
(NMUtilsCopyFunc) nm_team_link_watcher_dup,
|
|
|
|
|
(GDestroyNotify) nm_team_link_watcher_unref);
|
2017-11-10 19:25:13 +01:00
|
|
|
if (priv->link_watchers->len)
|
|
|
|
|
align_value = value;
|
|
|
|
|
align_config = TRUE;
|
2017-11-06 15:47:32 +01:00
|
|
|
break;
|
2014-07-24 08:53:33 -04:00
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2017-10-20 11:55:29 +02:00
|
|
|
|
2018-01-19 11:52:57 +01:00
|
|
|
if (align_config) {
|
2017-10-20 11:55:29 +02:00
|
|
|
_nm_utils_json_append_gvalue (&priv->config, _prop_to_keys[prop_id], align_value);
|
2018-01-19 11:52:57 +01:00
|
|
|
_align_team_properties (setting);
|
|
|
|
|
}
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
get_property (GObject *object, guint prop_id,
|
|
|
|
|
GValue *value, GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
NMSettingTeam *setting = NM_SETTING_TEAM (object);
|
2017-10-12 12:02:06 +02:00
|
|
|
NMSettingTeamPrivate *priv = NM_SETTING_TEAM_GET_PRIVATE (setting);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
|
case PROP_CONFIG:
|
|
|
|
|
g_value_set_string (value, nm_setting_team_get_config (setting));
|
|
|
|
|
break;
|
2017-10-12 12:02:06 +02:00
|
|
|
case PROP_NOTIFY_PEERS_COUNT:
|
|
|
|
|
g_value_set_int (value, priv->notify_peers_count);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_NOTIFY_PEERS_INTERVAL:
|
|
|
|
|
g_value_set_int (value, priv->notify_peers_interval);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_MCAST_REJOIN_COUNT:
|
|
|
|
|
g_value_set_int (value, priv->mcast_rejoin_count);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_MCAST_REJOIN_INTERVAL:
|
|
|
|
|
g_value_set_int (value, priv->mcast_rejoin_interval);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_RUNNER:
|
|
|
|
|
g_value_set_string (value, nm_setting_team_get_runner (setting));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_RUNNER_HWADDR_POLICY:
|
|
|
|
|
g_value_set_string (value, nm_setting_team_get_runner_hwaddr_policy (setting));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_RUNNER_TX_HASH:
|
|
|
|
|
g_value_take_boxed (value, priv->runner_tx_hash ?
|
|
|
|
|
_nm_utils_ptrarray_to_strv (priv->runner_tx_hash): NULL);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_RUNNER_TX_BALANCER:
|
|
|
|
|
g_value_set_string (value, nm_setting_team_get_runner_tx_balancer (setting));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_RUNNER_TX_BALANCER_INTERVAL:
|
|
|
|
|
g_value_set_int (value, priv->runner_tx_balancer_interval);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_RUNNER_ACTIVE:
|
|
|
|
|
g_value_set_boolean (value, nm_setting_team_get_runner_active (setting));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_RUNNER_FAST_RATE:
|
|
|
|
|
g_value_set_boolean (value, nm_setting_team_get_runner_fast_rate (setting));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_RUNNER_SYS_PRIO:
|
|
|
|
|
g_value_set_int (value, priv->runner_sys_prio);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_RUNNER_MIN_PORTS:
|
|
|
|
|
g_value_set_int (value, priv->runner_min_ports);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_RUNNER_AGG_SELECT_POLICY:
|
|
|
|
|
g_value_set_string (value, nm_setting_team_get_runner_agg_select_policy (setting));
|
|
|
|
|
break;
|
2017-11-06 15:47:32 +01:00
|
|
|
case PROP_LINK_WATCHERS:
|
|
|
|
|
g_value_take_boxed (value, _nm_utils_copy_array (priv->link_watchers,
|
|
|
|
|
(NMUtilsCopyFunc) nm_team_link_watcher_dup,
|
|
|
|
|
(GDestroyNotify) nm_team_link_watcher_unref));
|
|
|
|
|
break;
|
2014-07-24 08:53:33 -04:00
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
libnm/trivial: cleanup variable names in settings' class-init functions
- Don't use @parent_class name. This local variable (and @object_class) is
the class instance up-cast to the pointer types of the parents. The point
here is not that it is the direct parent. The point is, that it's the
NMSettingClass type.
Also, it can only be used inconsistently, in face of NMSettingIP4Config,
who's parent type is NMSettingIPConfig. Clearly, inside
nm-setting-ip4-config.c we wouldn't want to use the "parent_class"
name. Consistently rename @parent_class to @setting_class.
- Also rename the pointer to the own class to @klass. "setting_class" is also the
wrong name for that, because the right name would be something like
"setting_6lowpan_class".
However, "klass" is preferred over the latter, because we commonly create new
GObject implementations by copying an existing one. Generic names like "klass"
and "self" inside a type implementation make that simpler.
- drop useless comments like
/* virtual functions */
/* Properties */
It's better to logically and visually structure the code, and avoid trival
remarks about that. They only end up being used inconsistently. If you
even need a stronger visual separator, then an 80 char /****/ line
should be preferred.
2018-07-28 10:43:21 +02:00
|
|
|
nm_setting_team_class_init (NMSettingTeamClass *klass)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
libnm/trivial: cleanup variable names in settings' class-init functions
- Don't use @parent_class name. This local variable (and @object_class) is
the class instance up-cast to the pointer types of the parents. The point
here is not that it is the direct parent. The point is, that it's the
NMSettingClass type.
Also, it can only be used inconsistently, in face of NMSettingIP4Config,
who's parent type is NMSettingIPConfig. Clearly, inside
nm-setting-ip4-config.c we wouldn't want to use the "parent_class"
name. Consistently rename @parent_class to @setting_class.
- Also rename the pointer to the own class to @klass. "setting_class" is also the
wrong name for that, because the right name would be something like
"setting_6lowpan_class".
However, "klass" is preferred over the latter, because we commonly create new
GObject implementations by copying an existing one. Generic names like "klass"
and "self" inside a type implementation make that simpler.
- drop useless comments like
/* virtual functions */
/* Properties */
It's better to logically and visually structure the code, and avoid trival
remarks about that. They only end up being used inconsistently. If you
even need a stronger visual separator, then an 80 char /****/ line
should be preferred.
2018-07-28 10:43:21 +02:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
NMSettingClass *setting_class = NM_SETTING_CLASS (klass);
|
libnm: rework setting metadata for property handling
NMSetting internally already tracked a list of all proper GObject properties
and D-Bus-only properties.
Rework the tracking of the list, so that:
- instead of attaching the data to the GType of the setting via
g_type_set_qdata(), it is tracked in a static array indexed by
NMMetaSettingType. This allows to find the setting-data by simple
pointer arithmetic, instead of taking a look and iterating (like
g_type_set_qdata() does).
Note, that this is still thread safe, because the static table entry is
initialized in the class-init function with _nm_setting_class_commit().
And it only accessed by following a NMSettingClass instance, thus
the class constructor already ran (maybe not for all setting classes,
but for the particular one that we look up).
I think this makes initialization of the metadata simpler to
understand.
Previously, in a first phase each class would attach the metadata
to the GType as setting_property_overrides_quark(). Then during
nm_setting_class_ensure_properties() it would merge them and
set as setting_properties_quark(). Now, during the first phase,
we only incrementally build a properties_override GArray, which
we finally hand over during nm_setting_class_commit().
- sort the property infos by name and do binary search.
Also expose this meta data types as internal API in nm-setting-private.h.
While not accessed yet, it can prove beneficial, to have direct (internal)
access to these structures.
Also, rename NMSettingProperty to NMSettInfoProperty to use a distinct
naming scheme. We already have 40+ subclasses of NMSetting that are called
NMSetting*. Likewise, NMMetaSetting* is heavily used already. So, choose a
new, distinct name.
2018-07-28 15:26:03 +02:00
|
|
|
GArray *properties_override = _nm_sett_info_property_override_create_array ();
|
2014-07-24 08:53:33 -04:00
|
|
|
|
libnm/trivial: cleanup variable names in settings' class-init functions
- Don't use @parent_class name. This local variable (and @object_class) is
the class instance up-cast to the pointer types of the parents. The point
here is not that it is the direct parent. The point is, that it's the
NMSettingClass type.
Also, it can only be used inconsistently, in face of NMSettingIP4Config,
who's parent type is NMSettingIPConfig. Clearly, inside
nm-setting-ip4-config.c we wouldn't want to use the "parent_class"
name. Consistently rename @parent_class to @setting_class.
- Also rename the pointer to the own class to @klass. "setting_class" is also the
wrong name for that, because the right name would be something like
"setting_6lowpan_class".
However, "klass" is preferred over the latter, because we commonly create new
GObject implementations by copying an existing one. Generic names like "klass"
and "self" inside a type implementation make that simpler.
- drop useless comments like
/* virtual functions */
/* Properties */
It's better to logically and visually structure the code, and avoid trival
remarks about that. They only end up being used inconsistently. If you
even need a stronger visual separator, then an 80 char /****/ line
should be preferred.
2018-07-28 10:43:21 +02:00
|
|
|
g_type_class_add_private (klass, sizeof (NMSettingTeamPrivate));
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2016-03-11 13:17:24 +01:00
|
|
|
object_class->set_property = set_property;
|
|
|
|
|
object_class->get_property = get_property;
|
|
|
|
|
object_class->finalize = finalize;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
libnm/trivial: cleanup variable names in settings' class-init functions
- Don't use @parent_class name. This local variable (and @object_class) is
the class instance up-cast to the pointer types of the parents. The point
here is not that it is the direct parent. The point is, that it's the
NMSettingClass type.
Also, it can only be used inconsistently, in face of NMSettingIP4Config,
who's parent type is NMSettingIPConfig. Clearly, inside
nm-setting-ip4-config.c we wouldn't want to use the "parent_class"
name. Consistently rename @parent_class to @setting_class.
- Also rename the pointer to the own class to @klass. "setting_class" is also the
wrong name for that, because the right name would be something like
"setting_6lowpan_class".
However, "klass" is preferred over the latter, because we commonly create new
GObject implementations by copying an existing one. Generic names like "klass"
and "self" inside a type implementation make that simpler.
- drop useless comments like
/* virtual functions */
/* Properties */
It's better to logically and visually structure the code, and avoid trival
remarks about that. They only end up being used inconsistently. If you
even need a stronger visual separator, then an 80 char /****/ line
should be preferred.
2018-07-28 10:43:21 +02:00
|
|
|
setting_class->compare_property = compare_property;
|
|
|
|
|
setting_class->verify = verify;
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
/**
|
|
|
|
|
* NMSettingTeam:config:
|
|
|
|
|
*
|
|
|
|
|
* The JSON configuration for the team network interface. 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.
|
|
|
|
|
**/
|
libnm, libnm-util: move settings doc generation to libnm-core
Move the settings/plugins doc generation from libnm-util to
libnm-core, since libnm-util isn't being updated for all new
properties.
With this commit, the keyfile and ifcfg-rh documentation is basically
unchanged, except that deprecated properties are now gone, and new
properties have been added, and the sections are in a different order.
(generate-plugin-docs.pl just outputs the settings in Makefile order,
and they were unsorted in libnm-util, but are sorted in libnm-core).
The settings documentation used for nm-settings.5, the D-Bus API docs,
and the nmcli help is changed a bit more at this point, and mostly for
the worse, since the libnm-core setting properties don't match up with
the D-Bus API as well as the libnm-util ones do. To be fixed...
(I also removed the "plugins docs" line in each plugin docs comment
block while moving them, since those blocks will be used for more than
just plugins soon, and it's sort of obvious anyway.)
2014-10-28 09:58:25 -04:00
|
|
|
/* ---ifcfg-rh---
|
|
|
|
|
* property: config
|
|
|
|
|
* variable: TEAM_CONFIG
|
|
|
|
|
* description: Team configuration in JSON. See man teamd.conf for details.
|
|
|
|
|
* ---end---
|
|
|
|
|
*/
|
2014-07-24 08:53:33 -04:00
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_CONFIG,
|
|
|
|
|
g_param_spec_string (NM_SETTING_TEAM_CONFIG, "", "",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
NM_SETTING_PARAM_INFERRABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
2014-08-04 19:57:20 -04:00
|
|
|
|
2017-10-12 12:02:06 +02:00
|
|
|
/**
|
|
|
|
|
* NMSettingTeam:notify-peers-count:
|
|
|
|
|
*
|
|
|
|
|
* Corresponds to the teamd notify_peers.count.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_NOTIFY_PEERS_COUNT,
|
|
|
|
|
g_param_spec_int (NM_SETTING_TEAM_NOTIFY_PEERS_COUNT, "", "",
|
|
|
|
|
G_MININT32, G_MAXINT32, 0,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingTeam:notify-peers-interval:
|
|
|
|
|
*
|
|
|
|
|
* Corresponds to the teamd notify_peers.interval.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_NOTIFY_PEERS_INTERVAL,
|
|
|
|
|
g_param_spec_int (NM_SETTING_TEAM_NOTIFY_PEERS_INTERVAL, "", "",
|
|
|
|
|
G_MININT32, G_MAXINT32, 0,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingTeam:mcast-rejoin-count:
|
|
|
|
|
*
|
|
|
|
|
* Corresponds to the teamd mcast_rejoin.count.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_MCAST_REJOIN_COUNT,
|
|
|
|
|
g_param_spec_int (NM_SETTING_TEAM_MCAST_REJOIN_COUNT, "", "",
|
|
|
|
|
G_MININT32, G_MAXINT32, 0,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingTeam:mcast-rejoin-interval:
|
|
|
|
|
*
|
|
|
|
|
* Corresponds to the teamd mcast_rejoin.interval.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_MCAST_REJOIN_INTERVAL,
|
|
|
|
|
g_param_spec_int (NM_SETTING_TEAM_MCAST_REJOIN_INTERVAL, "", "",
|
|
|
|
|
G_MININT32, G_MAXINT32, 0,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingTeam:runner:
|
|
|
|
|
*
|
|
|
|
|
* Corresponds to the teamd runner.name.
|
|
|
|
|
* Permitted values are: "roundrobin", "broadcast", "activebackup",
|
2018-06-15 15:05:04 +02:00
|
|
|
* "loadbalance", "lacp", "random".
|
2018-01-12 14:05:24 +01:00
|
|
|
* When setting the runner, all the properties specific to the runner
|
|
|
|
|
* will be reset to the default value; all the properties specific to
|
|
|
|
|
* other runners will be set to an empty value (or if not possible to
|
|
|
|
|
* a default value).
|
2017-10-12 12:02:06 +02:00
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_RUNNER,
|
|
|
|
|
g_param_spec_string (NM_SETTING_TEAM_RUNNER, "", "",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingTeam:runner-hwaddr-policy:
|
|
|
|
|
*
|
|
|
|
|
* Corresponds to the teamd runner.hwaddr_policy.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_RUNNER_HWADDR_POLICY,
|
|
|
|
|
g_param_spec_string (NM_SETTING_TEAM_RUNNER_HWADDR_POLICY, "", "",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingTeam:runner-tx-hash:
|
|
|
|
|
*
|
|
|
|
|
* Corresponds to the teamd runner.tx_hash.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_RUNNER_TX_HASH,
|
|
|
|
|
g_param_spec_boxed (NM_SETTING_TEAM_RUNNER_TX_HASH, "", "",
|
|
|
|
|
G_TYPE_STRV,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
NM_SETTING_PARAM_INFERRABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingTeam:runner-tx-balancer:
|
|
|
|
|
*
|
|
|
|
|
* Corresponds to the teamd runner.tx_balancer.name.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_RUNNER_TX_BALANCER,
|
|
|
|
|
g_param_spec_string (NM_SETTING_TEAM_RUNNER_TX_BALANCER, "", "",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingTeam:runner-tx-balancer-interval:
|
|
|
|
|
*
|
|
|
|
|
* Corresponds to the teamd runner.tx_balancer.interval.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_RUNNER_TX_BALANCER_INTERVAL,
|
|
|
|
|
g_param_spec_int (NM_SETTING_TEAM_RUNNER_TX_BALANCER_INTERVAL, "", "",
|
|
|
|
|
G_MININT32, G_MAXINT32, 0,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingTeam:runner-active:
|
|
|
|
|
*
|
|
|
|
|
* Corresponds to the teamd runner.active.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_RUNNER_ACTIVE,
|
|
|
|
|
g_param_spec_boolean (NM_SETTING_TEAM_RUNNER_ACTIVE, "", "",
|
|
|
|
|
FALSE,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingTeam:runner-fast-rate:
|
|
|
|
|
*
|
|
|
|
|
* Corresponds to the teamd runner.fast_rate.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_RUNNER_FAST_RATE,
|
|
|
|
|
g_param_spec_boolean (NM_SETTING_TEAM_RUNNER_FAST_RATE, "", "",
|
|
|
|
|
FALSE,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingTeam:runner-sys-prio:
|
|
|
|
|
*
|
|
|
|
|
* Corresponds to the teamd runner.sys_prio.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_RUNNER_SYS_PRIO,
|
|
|
|
|
g_param_spec_int (NM_SETTING_TEAM_RUNNER_SYS_PRIO, "", "",
|
|
|
|
|
G_MININT32, G_MAXINT32, 0,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingTeam:runner-min-ports:
|
|
|
|
|
*
|
|
|
|
|
* Corresponds to the teamd runner.min_ports.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_RUNNER_MIN_PORTS,
|
|
|
|
|
g_param_spec_int (NM_SETTING_TEAM_RUNNER_MIN_PORTS, "", "",
|
|
|
|
|
G_MININT32, G_MAXINT32, 0,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingTeam:runner-agg-select-policy:
|
|
|
|
|
*
|
|
|
|
|
* Corresponds to the teamd runner.agg_select_policy.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_RUNNER_AGG_SELECT_POLICY,
|
|
|
|
|
g_param_spec_string (NM_SETTING_TEAM_RUNNER_AGG_SELECT_POLICY, "", "",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
2017-11-06 15:47:32 +01:00
|
|
|
/**
|
2018-03-24 15:18:21 +00:00
|
|
|
* NMSettingTeam:link-watchers: (type GPtrArray(NMTeamLinkWatcher))
|
2017-11-06 15:47:32 +01:00
|
|
|
*
|
|
|
|
|
* 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-incative', 'send-always'. See teamd.conf man for more details.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_LINK_WATCHERS,
|
|
|
|
|
g_param_spec_boxed (NM_SETTING_TEAM_LINK_WATCHERS, "", "",
|
|
|
|
|
G_TYPE_PTR_ARRAY,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
libnm: rework setting metadata for property handling
NMSetting internally already tracked a list of all proper GObject properties
and D-Bus-only properties.
Rework the tracking of the list, so that:
- instead of attaching the data to the GType of the setting via
g_type_set_qdata(), it is tracked in a static array indexed by
NMMetaSettingType. This allows to find the setting-data by simple
pointer arithmetic, instead of taking a look and iterating (like
g_type_set_qdata() does).
Note, that this is still thread safe, because the static table entry is
initialized in the class-init function with _nm_setting_class_commit().
And it only accessed by following a NMSettingClass instance, thus
the class constructor already ran (maybe not for all setting classes,
but for the particular one that we look up).
I think this makes initialization of the metadata simpler to
understand.
Previously, in a first phase each class would attach the metadata
to the GType as setting_property_overrides_quark(). Then during
nm_setting_class_ensure_properties() it would merge them and
set as setting_properties_quark(). Now, during the first phase,
we only incrementally build a properties_override GArray, which
we finally hand over during nm_setting_class_commit().
- sort the property infos by name and do binary search.
Also expose this meta data types as internal API in nm-setting-private.h.
While not accessed yet, it can prove beneficial, to have direct (internal)
access to these structures.
Also, rename NMSettingProperty to NMSettInfoProperty to use a distinct
naming scheme. We already have 40+ subclasses of NMSetting that are called
NMSetting*. Likewise, NMMetaSetting* is heavily used already. So, choose a
new, distinct name.
2018-07-28 15:26:03 +02:00
|
|
|
|
|
|
|
|
_properties_override_add_transform (properties_override,
|
|
|
|
|
g_object_class_find_property (G_OBJECT_CLASS (setting_class),
|
|
|
|
|
NM_SETTING_TEAM_LINK_WATCHERS),
|
|
|
|
|
G_VARIANT_TYPE ("aa{sv}"),
|
|
|
|
|
team_link_watchers_to_dbus,
|
|
|
|
|
team_link_watchers_from_dbus);
|
2017-11-06 15:47:32 +01:00
|
|
|
|
2014-11-16 15:36:18 -05:00
|
|
|
/* ---dbus---
|
|
|
|
|
* property: interface-name
|
|
|
|
|
* format: string
|
|
|
|
|
* description: Deprecated in favor of connection.interface-name, but can
|
|
|
|
|
* be used for backward-compatibility with older daemons, to set the
|
|
|
|
|
* team's interface name.
|
|
|
|
|
* ---end---
|
|
|
|
|
*/
|
libnm: rework setting metadata for property handling
NMSetting internally already tracked a list of all proper GObject properties
and D-Bus-only properties.
Rework the tracking of the list, so that:
- instead of attaching the data to the GType of the setting via
g_type_set_qdata(), it is tracked in a static array indexed by
NMMetaSettingType. This allows to find the setting-data by simple
pointer arithmetic, instead of taking a look and iterating (like
g_type_set_qdata() does).
Note, that this is still thread safe, because the static table entry is
initialized in the class-init function with _nm_setting_class_commit().
And it only accessed by following a NMSettingClass instance, thus
the class constructor already ran (maybe not for all setting classes,
but for the particular one that we look up).
I think this makes initialization of the metadata simpler to
understand.
Previously, in a first phase each class would attach the metadata
to the GType as setting_property_overrides_quark(). Then during
nm_setting_class_ensure_properties() it would merge them and
set as setting_properties_quark(). Now, during the first phase,
we only incrementally build a properties_override GArray, which
we finally hand over during nm_setting_class_commit().
- sort the property infos by name and do binary search.
Also expose this meta data types as internal API in nm-setting-private.h.
While not accessed yet, it can prove beneficial, to have direct (internal)
access to these structures.
Also, rename NMSettingProperty to NMSettInfoProperty to use a distinct
naming scheme. We already have 40+ subclasses of NMSetting that are called
NMSetting*. Likewise, NMMetaSetting* is heavily used already. So, choose a
new, distinct name.
2018-07-28 15:26:03 +02:00
|
|
|
_properties_override_add_dbus_only (properties_override,
|
|
|
|
|
"interface-name",
|
|
|
|
|
G_VARIANT_TYPE_STRING,
|
|
|
|
|
_nm_setting_get_deprecated_virtual_interface_name,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
_nm_setting_class_commit_full (setting_class, NM_META_SETTING_TYPE_TEAM,
|
|
|
|
|
NULL, properties_override);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|