summaryrefslogtreecommitdiff
path: root/libnm-core/nm-setting-team.c
Commit message (Collapse)AuthorAgeFilesLines
* libnm/team: preserve unset priv->runner_tx_hash in _align_team_properties()th/libnm-team-fixesThomas Haller2019-03-241-1/+1
| | | | | There is a difference between an unset JSON array element and an empty one. Don't loose that information.
* libnm/team: check for changes to team:runner-tx-hash in _align_team_properties()Thomas Haller2019-03-241-7/+17
| | | | | We will need to emit property changed signals. For that we need to know whether the property changes. Compare it.
* libnm/team: add function to compare list of link-watchersThomas Haller2019-03-241-21/+35
|
* libnm/team: minor coding style cleanupThomas Haller2019-03-241-16/+16
|
* libnm/team: fix crash with nm_setting_team_remove_runner_tx_hash_by_value() ↵Thomas Haller2019-03-241-6/+7
| | | | having no runner_tx_hash array
* all: drop unnecessary includes of <errno.h> and <string.h>Thomas Haller2019-02-121-1/+0
| | | | | "nm-macros-interal.h" already includes <errno.h> and <string.h>. No need to include it everywhere else too.
* libnm: avoid "-Wmissing-braces" warning for teams _prop_to_keys arrayThomas Haller2019-02-081-19/+16
| | | | | | | | | | | [1/384] Compiling C object 'libnm-core/2b1af02@@nm-core@sta/nm-setting-team.c.o'. ../libnm-core/nm-setting-team.c:649:77: warning: missing braces around initializer [-Wmissing-braces] static const _NMUtilsTeamPropertyKeys _prop_to_keys[_PROPERTY_ENUMS_LAST] = { ^ [PROP_CONFIG] = { NULL, NULL, NULL, 0 }, { } And use designated initializers.
* libnm-core: fix team link-watcher struct layoutBeniamino Galvani2019-01-281-1/+1
| | | | | | | | | | As the comment above the union says, structs in the union must have the same layout of arp_ping. 'vlanid' is in the wrong place and breaks that. Fixes: f44c793f6cd89c3e84e83872478daf286821ed64 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/110
* libnm-core: reorder code in settingsThomas Haller2019-01-151-125/+132
| | | | | | | | | | Order the code in our common way. No other changes. - ensure to include the main header first (directly after "nm-default.h"). - reorder function definitions: get_property(), set_property(), *_init(), *_new(), finalize(), *_class_init().
* libnm-core: cleanup NMSetting's class initializationThomas Haller2019-01-151-112/+94
| | | | | | | Unify the coding style for class-init functions in libnm-core. Also make use of obj_properties, NM_GOBJECT_PROPERTIES_DEFINE(), and _notify().
* libnm: rework compare_property() implementation for NMSettingThomas Haller2019-01-111-27/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | NMSetting's compare_property() has and had two callers: nm_setting_compare() and nm_setting_diff(). compare_property() accepts a NMSettingCompareFlags argument, but at the same time, both callers have another complex (and inconsistent!) set of pre-checks for shortcuting the call of compare_property(): should_compare_prop(). Merge should_compare_prop() into compare_property(). This way, nm_setting_compare() and nm_setting_diff() has less additional code, and are simpler to follow. Especially nm_setting_compare() is now trivial. And nm_setting_diff() is still complicated, but not related to the question how the property compares or whether it should be compared at all. If you want to know whether it should be compared, all you need to do now is follow NMSettingClass.compare_property(). This changes function pointer NMSettingClass.compare_property(), which is public API. However, no user can actually use this (and shall not!), because _nm_setting_class_commit_full() etc. is private API. A user outside of libnm-core cannot create his/her own subclasses of NMSetting, and never could in the past. So, this API/ABI change doesn't matter.
* libnm: implement nm_team_link_watcher_new_arp_ping() based on ↵Thomas Haller2018-12-121-54/+47
| | | | | | | | | | | nm_team_link_watcher_new_arp_ping2() nm_team_link_watcher_new_arp_ping2() is the more powerful variant of nm_team_link_watcher_new_arp_ping(). It can do everything the new variant can, and more. Hence, v1 should be implemented based on v2. This way, validating and constructing the watcher is all done in one place, not split in two places.
* team: add support for 'vlanid' link-watchers propertyPatrick Talbert2018-12-121-6/+80
| | | | | | | | | | Add support for the teaming arp_ping link watcher 'vlanid' property. Signed-off-by: Patrick Talbert <ptalbert@redhat.com> [thaller@redhat.com: minor fixes to original patch] https://bugzilla.redhat.com/show_bug.cgi?id=1652931
* libnm-core: fix other int comparisons in team settingBeniamino Galvani2018-10-081-7/+7
| | | | | | I forgot to update them when applying commit 72b454177121. Fixes: 72b45417712186b0247ba5a69e42d54a27763fb0
* libnm-core: fix int comparisons in team settingThomas Haller2018-10-071-2/+2
|
* Fix typosRafael Fontenelle2018-09-301-1/+1
| | | | | | | https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/21 [thaller@redhat.com: fix generated clients/common/settings-docs.h.in file and fix wrong change in src/systemd/src/libsystemd/sd-event/sd-event.c]
* docs: misc. typos pt2luz.paz2018-09-171-2/+2
| | | | | | | | | | | | | | | | | | | | | Remainder of typos found using `codespell -q 3 --skip="./shared,./src/systemd,*.po" -I ../NetworkManager-word-whitelist.txt` whereby whitelist consists of: ``` ans busses cace cna conexant crasher iff liftime creat nd sav technik uint ``` https://github.com/NetworkManager/NetworkManager/pull/205
* libnm: rework setting metadata for property handlingThomas Haller2018-08-101-10/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* libnm: use NMMetaSettingInfo for tracking setting priorityThomas Haller2018-08-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* libnm/trivial: cleanup variable names in settings' class-init functionsThomas Haller2018-08-101-14/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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.
* libnm-core: don't emit signal when clearing lists already emptyBeniamino Galvani2018-07-111-2/+4
| | | | | If the property is a list and it is already empty, we should not emit a signal when it gets cleared.
* all: don't use gchar/gshort/gint/glong but C typesThomas Haller2018-07-111-22/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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[@]}"
* libnm: avoid constructor function for registering NMSetting typesThomas Haller2018-07-011-1/+0
| | | | | | | | | | constructor functions are ugly, because code is running before main() starts. Instead, as the registration code for NMSetting types is insid the GType constructor, we just need to ensure at the right place, that the GType was created. The right place here is _register_settings_ensure_inited(), because that is called before we need the registration information.
* man: add 'random' to the allowed values of team.runnerFrancesco Giudici2018-06-151-1/+1
| | | | https://bugzilla.redhat.com/show_bug.cgi?id=1543832
* all: remove consecutive empty linesBeniamino Galvani2018-04-301-1/+0
| | | | | | | Normalize coding style by removing consecutive empty lines from C sources and headers. https://github.com/NetworkManager/NetworkManager/pull/108
* gobject-introspection: made several fixes to the annotationsCorentin Noël2018-03-261-2/+1
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=794658
* all: replace non-leading tabs with spacesThomas Haller2018-02-071-1/+1
| | | | | | We commonly only allow tabs at the beginning of a line, not afterwards. The reason for this style is so that the code looks formated right with tabstop=4 and tabstop=8.
* libnm-core: team: add support to runner "random"fg/team-random-runner-rh1538699Francesco Giudici2018-02-051-0/+1
| | | | https://bugzilla.redhat.com/show_bug.cgi?id=1538699
* libnm-core: ensure alignment of team.config and other team propertiesFrancesco Giudici2018-01-221-1/+3
| | | | https://bugzilla.redhat.com/show_bug.cgi?id=1533830
* libnm-core: update team.runner descriptionFrancesco Giudici2018-01-121-0/+4
| | | | https://bugzilla.redhat.com/show_bug.cgi?id=1533799
* libnm: fix checking argument in nm_team_link_watcher_new_arp_ping()Thomas Haller2017-12-121-1/+1
| | | | | | Found by coverity. Fixes: 6c93e32212f9901e882d5a9ca221d037162bc740
* libnm: don't use g_strsplit_set() to search string for invalid charactersThomas Haller2017-12-081-9/+3
|
* libnm-core: team: change tx-hash APIs idx type from int to guintFrancesco Giudici2017-12-081-4/+4
|
* libnm-core: team: rework defaults management on runner propertiesFrancesco Giudici2017-12-081-44/+30
| | | | | | | | | | | | till now when no explicit value was set on a property, the default value for that property was returned, also if the property was not applicable to the selected runner. Fix this, showing default values for properties only when relevant and showing instead -1 or null when the property is not relevant for the selected runner. Moreover, reset all the properties but the link-watchers when the team.runner is changed: this is required to clean up the properties unrelated to the new runner and start with the runner-specific defaults.
* libnm-core: team: use the correct name for teamd property 'balancing_interval'Francesco Giudici2017-12-081-1/+1
| | | | | | | the teamd 'runner.tx_balancer.balancing_interval' property was wrongly set and searched as 'runner.tx_balancer.interval'. Fixed. Fixes: fc3b7d61e29a56106a0ecb55deb7fcdcf7d9b691
* libnm-core: synchronize team.link_watchers when team.config is set.Francesco Giudici2017-12-081-0/+3
|
* libnm-core: synchronize team.config when team.link_watchers is set.Francesco Giudici2017-12-081-0/+3
|
* libnm-core: team: expose the new link-watchers propertyFrancesco Giudici2017-12-081-0/+258
| | | | | It will allow explicit configuration of link-watchers in the team configuration.
* libnm-core: team: add NMTeamLinkWatcher boxed typeFrancesco Giudici2017-12-081-0/+527
| | | | | | Team allows to specify multiple link watchers for each link. Define a link watcher object in order to allow to specify multiple ones for each Team configuration.
* libnm-core: fix "Since" notation in team and team-port settings.Francesco Giudici2017-11-101-17/+17
| | | | | | | Not "Since 1.12" but "Since: 1.12". Fixes: 9715969b77300f47478b58482375dcd07dba1e85 Fixes: 1c99d379eb7ef1947beb4176a9611e404d1b220f
* libnm-core: enforce team and team-port defaultsfg/team_abstraction_rh1398925Francesco Giudici2017-11-091-20/+29
| | | | Rework a bit the way default values are check, set and aligned.
* libnm-core: enforce team config and properties alignmentFrancesco Giudici2017-11-091-2/+159
| | | | Ensure .config is aligned when an explicit team property is set and vice versa.
* libnm-core: add explicit team properties to NMSettingTeamFrancesco Giudici2017-11-091-0/+656
|
* libnm-core: remove duplicate include of "nm-utils-private.h"Francesco Giudici2017-10-131-1/+0
|
* libnm: use enum for setting prioritiesThomas Haller2017-06-071-1/+1
|
* libnm: reject too large team-config JSONThomas Haller2016-09-271-0/+10
|
* libnm: expose nm_utils_is_json_object() utility functionThomas Haller2016-09-271-1/+1
| | | | | | | | | Since we possibly already link against libjansson, we can also expose some helper utils which allows nmcli to do basic validation of JSON without requiring to duplicate the effort of using libjansson. Also, tighten up the cecks to ensure that we have a JSON object at hand. We are really interested in that and not of arrays or literals.
* libnm: restore verify() comments in team/team-port settingsBeniamino Galvani2016-08-301-0/+3
| | | | | Restore the comments removed in commit a524091966afb884cdb8db48067d5599a685a8eb.
* Revert "libnm-core/team: normalize invalid config to NULL"Beniamino Galvani2016-08-301-10/+2
| | | | | | | It's better to fail the validation of any invalid configuration instead of silently ignoring it. This reverts commit 476810c29016d569ac3885542a6c91e7af8a7f6d.
* libnm-core/team: normalize invalid config to NULLThomas Haller2016-08-241-2/+10
| | | | | | | | | | | | | A user may very well have connections on disk with bogus json. Such connections may have failed to activate before, but rejecting them now as invalid means that we stop loading them from disk. That is, they disappear after upgrade. Instead of doing that, also accept invalid json (beside "") and normalize/coerce it to NULL. https://bugzilla.redhat.com/show_bug.cgi?id=1366300 (cherry picked from commit 476810c29016d569ac3885542a6c91e7af8a7f6d)