summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* settings: use delegation instead of inheritance for NMSettingsConnection and ↵th/settings-connection-delegateThomas Haller2018-08-226-138/+122
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NMConnection NMConnection is an interface, which is both implemented by NMSimpleConnection (libnm-core), NMSettingsConnection (src) and NMRemoteConnection (libnm). NMSettingsConnection does a lot of things 1) it is an NMDBusObject and exports the API of a connection profile on D-Bus 2) it interacts with NMSettings and contains functionality for tracking the profiles. 3) it is the base-class of types like NMSKeyfileConnection and NMIfcfgConnection. These determine how to persist the profile on disk. 4) it implements NMConnection interface, to itself track the settings of the profile. 3) and 4) would be better implemented via delegation than inheritance. Don't let NMSettingsConnection implemente the NMConnection interface. Instead, it references now a NMSimpleConnection instance, to which it delegates for keeping the actual profiles. Advantages: - by delegating, there is a clearer separation of what NMSettingsConnection does. For example, in C we often required casts from NMSettingsConnection to NMConnection. NMConnection is a very trivial object with very little logic. When we have a NMConnection instance at hand, it's good to know that it is *only* that simple. - NMConnection is implemented as an interface and we create NMSimpleConnection instances whenever we need a real instance. In GLib, interfaces have a performance overhead, that we needlessly pay all the time. With this change, we could compile a version of libnm-core for the daemon, where NMConnection is not an interface but a GObject implementation akin to NMSimpleConnection. - In the previous implementation, we cannot do copy-on-write. For example, when NMDevice needs a snapshot of the activated profile as applied-connection, all it can do is clone the NMSettingsConnection as a NMSimpleConnection. Likewise, when we get a NMConnection instance and want to keep a reference to it, we cannot do that, because we never know who also references and modifies the instance. By separating NMSettingsConnection we could have NMConnection immutable and copy-on-write, to avoid all unnecessary clones.
* device: refactor setting parent in device's update_connection()Thomas Haller2018-08-227-104/+63
| | | | | | | | | | | | | | | Add a helper function nm_device_parent_find_for_connection() to unify implementations of setting the parent in update_connection(). There is some change in behavior, in particular for nm-device-vlan.c, which no longer compares the link information from platform. But update_connection() is anyway a very questionable concept, only used for external device (which itself, is questionable). Meaning, update_connection() is a hack not science, and it's not at all clear what the correct behavior is. Also, note how vlan's implementation differs from all others. Why? Should we always resort to also check the information from platform? Either way, one of the two approaches should be used consistently.
* wifi: merge branch 'th/wifi-gbytes-ssid'Thomas Haller2018-08-2227-340/+662
|\ | | | | | | https://github.com/NetworkManager/NetworkManager/pull/182
| * wifi: refactor nm_wifi_ap_set_ssid() to accept GBytesThomas Haller2018-08-224-34/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | - have two variants of functions to set the SSID of an access point: one that passes SSID as GBytes, and one that passes it as plain data with length. Accepting a GBytes allows to share the immutable GBytes instance. - both functions now also support clearing the SSID. In nm_wifi_ap_update_from_properties(), if the GVariant specifies a "SSID", we always update the access point. We already support chaging the SSID, so why not support changing it to *no* SSID (hidden).
| * wifi: don't use GBytesArray for NMWifiAP's ssidThomas Haller2018-08-2211-152/+179
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GBytes makes more sense, because it's immutable. Also, since at other places we use GBytes, having different types is combersome and requires needless conversions. Also: - avoid nm_utils_escape_ssid() instead of _nm_utils_ssid_to_string(). We use nm_utils_escape_ssid() when we want to log the SSID. However, it does not escape newlines, which is bad. - also no longer use nm_utils_same_ssid(). Since it no longer treated trailing NUL special, it is not different from g_bytes_equal(). - also, don't use nm_utils_ssid_to_utf8() for logging anymore. For logging, _nm_utils_ssid_escape_utf8safe() is better because it is loss-less escaping which can be unambigously reverted.
| * wifi: don't ignore trailing NUL byte when comparing SSIDThomas Haller2018-08-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | nm_utils_same_ssid() has a comment * Earlier versions of the Linux kernel added a NULL byte to the end of the * SSID to enable easy printing of the SSID on the console or in a terminal, * but this behavior was problematic (SSIDs are simply byte arrays, not strings) * and thus was changed. This function compensates for that behavior at the * cost of some compatibility with odd SSIDs that may legitimately have trailing * NULLs, even though that is functionally pointless. and the functionality was introduced by commit ccb13f0bdd0c8ac3ee85dd0a6064c9bc545585f1. There was only place left that calls nm_utils_same_ssid(). I really don't think this is the right approach, nor is it clear that this is still necessary. Also, it seems to only matter with WEXT, and we should not have such an ugly hack in all cases.
| * shared: add nm_utils_buf_utf8safe_escape() utilThomas Haller2018-08-223-73/+345
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We already have nm_utils_str_utf8safe_escape() to convert a NUL termianted string to an UTF-8 string. nm_utils_str_utf8safe_escape() operates under the assumption, that the input strig is already valid UTF-8 and returns the input string verbatim. That way, in the common expected cases, the string just looks like a regular UTF-8 string. However, in case there are invalid UTF-8 sequences (or a backslash escape characters), the function will use backslash escaping to encode the input string as a valid UTF-8 sequence. Note that the escaped sequence, can be reverted to the original non-UTF-8 string via unescape. An example, where this is useful are file names or interface names. Which are not in a defined encoding, but NUL terminated and commonly ASCII or UTF-8 encoded. Extend this, to also handle not NUL terminated buffers. The same applies, except that the process cannot be reverted via g_strcompress() -- because the NUL character cannot be unescaped. This will be useful to escape a Wi-Fi SSID. Commonly we expect the SSID to be in UTF-8/ASCII encoding and we want to print it verbatim. Only if that is not the case, we fallback to backslash escaping. However, the orginal value can be fully recovered via unescape(). The difference between an SSID and a filename is, that the former can contain '\0' bytes.
| * wifi: use GBytes for ssids scan listThomas Haller2018-08-223-34/+27
| | | | | | | | | | | | | | | | | | Use GBytes instead of GBytesArray. GBytes is immutable and can be shared. It is also the type that we natively get from nm_setting_wireless_get_ssid(). This way we avoid some conversions.
| * device: avoid intermediary GByteArray when creating DUID GBytesThomas Haller2018-08-221-13/+13
| | | | | | | | Creating it directly is simple enough.
| * dhcp/trivial: add fixme comments to nm_dhcp_dhclient_unescape_duid()Thomas Haller2018-08-221-0/+7
| |
| * all: avoid useless cast of g_free() to GDestroyNotifyThomas Haller2018-08-225-7/+7
| |
| * wifi: use GBytes instead of GBytesArray for tracking blobs in supplicantThomas Haller2018-08-222-15/+6
| |
| * wifi/olpc: fix setting SSID for OLPC mesh in complete_connection()Thomas Haller2018-08-221-5/+4
| | | | | | | | NM_SETTING_OLPC_MESH_SSID is of type GBytes, not GByteArray.
| * platform: drop unused virtual function NMPlatformClass.wifi_get_ssid()Thomas Haller2018-08-222-8/+0
| |
| * libnm: replace _nm_utils_bytes_to_dbus() with nm_utils_gbytes_get_variant_ay()Thomas Haller2018-08-223-19/+1
| |
| * shared: add nm_utils_gbytes_to_variant_ay() utilThomas Haller2018-08-222-0/+21
|/
* po: update German translationChristian K2018-08-211-2354/+3112
| | | | https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/9
* po: fix a typo in fr translationLubomir Rintel2018-08-201-1/+1
| | | | https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/5
* platform: if AF_INET6 is not available, don't warnLubomir Rintel2018-08-202-1/+5
| | | | | | | | | These should be logged on DEBUG level: <warn> platform-linux: do-change-link[2]: failure changing link: failure 97 (Address family not supported by protocol) <warn> device (wlo1): failed to enable userspace IPv6LL address handling (unspecified) https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/10
* ip4-config: fix a typoLubomir Rintel2018-08-196-6/+6
| | | | (cherry picked from commit 0550003ef0b71cd4342519c06d8bc3c92b4f64ea)
* po/ja: translations from the Red Hat translatorsLubomir Rintel2018-08-191-2308/+2586
| | | | (cherry picked from commit 7af38dc4fc802e4f897aeeb1532ca9099a2c5333)
* build: fix meson build with -Dppp=falseBeniamino Galvani2018-08-151-1/+3
| | | | | | | | meson.build:897:15: ERROR: Unknown variable "pppd_plugin_dir". Fixes: a75ab799e4f6b9c5d6f298ad7c1899ae21726a48 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/7
* po: update Brazilian Portuguese translationRafael Fontenelle2018-08-151-3323/+4594
| | | | https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/3
* device: cope with devices' failure to provide reason for incompatibilityLubomir Rintel2018-08-141-0/+1
| | | | | Pretty sure we get this right now, but if we don't let's fail more sensibly.
* wifi: provide reasons for connection incompatibilityLubomir Rintel2018-08-141-7/+28
| | | | | | The callers assume that we set an error on returning FALSE. Mostly copied from the IWD implementation.
* iwd: improve error messagesLubomir Rintel2018-08-141-3/+3
| | | | Fix errors, typoes and ambiguities.
* release: bump version to 1.13.3 (development)1.13.3-devThomas Haller2018-08-132-2/+2
|
* release: update NEWSThomas Haller2018-08-131-0/+3
|
* utils/test: don't assert on debug level messagesLubomir Rintel2018-08-111-2/+3
| | | | | They come and go in GLib core for all sorts of purposes. Don't let that break our tests.
* merge: branch 'bg/wildcard-match-rh1555012'Beniamino Galvani2018-08-1128-91/+866
|\ | | | | | | | | https://bugzilla.redhat.com/show_bug.cgi?id=1555012 https://github.com/NetworkManager/NetworkManager/pull/181
| * device: support match.interface-nameBeniamino Galvani2018-08-113-4/+47
| | | | | | | | | | Add support for matching a connection with the new match.interface-name property.
| * ifcfg-rh: add support for 'match' settingBeniamino Galvani2018-08-115-1/+140
| |
| * all: add 'match' settingBeniamino Galvani2018-08-1114-0/+462
| | | | | | | | | | | | | | Add a new 'match' setting containing properties to match a connection to devices. At the moment only the interface-name property is present and, contrary to connection.interface-name, it allows the use of wildcards.
| * shared: add @allow_escaping argument to @nm_utils_strsplit_setBeniamino Galvani2018-08-119-84/+108
| |
| * libnm-core: remove wrong annotation in NMSettingIPConfigBeniamino Galvani2018-08-111-2/+0
| |
| * shared: add space escape functionsBeniamino Galvani2018-08-113-0/+109
|/
* all/ethtool: merge branch 'th/ethtool-options-rh1335409-1'Thomas Haller2018-08-1096-1951/+5049
|\ | | | | | | | | | | | | | | Add support for setting offload features (akin to ethtool's -K|--offload|--feature). https://bugzilla.redhat.com/show_bug.cgi?id=1335409 https://github.com/NetworkManager/NetworkManager/pull/179
| * all/ethtool: add support for all currently supported kernel featuresThomas Haller2018-08-106-49/+322
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As of upstream kernel v4.18-rc8. Note that we name the features like they are called in ethtool's ioctl API ETH_SS_FEATURES. Except, for features like "tx-gro", which ethtool utility aliases as "gro". So, for those features where ethtool has a built-in, alternative name, we prefer the alias. And again, note that a few aliases of ethtool utility ("sg", "tso", "tx") actually affect more than one underlying kernel feature. Note that 3 kernel features which are announced via ETH_SS_FEATURES are explicitly exluded because kernel marks them as "never_changed": #define NETIF_F_NEVER_CHANGE (NETIF_F_VLAN_CHALLENGED | \ NETIF_F_LLTX | NETIF_F_NETNS_LOCAL)
| * cli: hide ethtool options form `nmcli connection show "$PROFILE"` outputThomas Haller2018-08-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We will add a large number of offload features. That means, the output of `nmcli connection show "$PROFILE"` would be very verbose, in case the profile has a [ethtool] option. Since this is newly added API, don't do that. Don't show ethtool properties that are left unset. A minor problem here is, that it becomes no longer obvious which properties exist. We should however counter that by documentation. Also, one could do: $ nmcli connection modify "$PROFILE" ethtool.xxx x Error: invalid property 'xxx': 'xxx' not among [feature-gro, feature-gso, feature-lro, feature-ntuple, feature-rx, feature-rxhash, feature-rxvlan, feature-sg, feature-tso, feature-tx, feature-txvlan, feature-tx-tcp6-segmentation, feature-tx-tcp-segmentation]. Likewise, bash completion still works as one would expect. $ nmcli --complete-args connection modify "$PROFILE" ethtool. ethtool.feature-gro ethtool.feature-gso ethtool.feature-lro [...] Note the output of $ nmcli -f ethtool.feature-gro connection show "$PROFILE" gives now nothing (if there is an ethtool section, but not this particular feature). Maybe this shouldn't be like that. On the other hand, specifying a connection setting that doesn't exist also gives no output: $ nmcli -f bond connection show "$PROFILE" So, maybe this behavior is fine.
| * cli: add functionality to hide properties from outputThomas Haller2018-08-102-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Historically, nmcli printed all fields during operations like `nmcli connection show "$PROFILE"`. As we supported more and more options, this resulted in a verbose output, of most properties just being the default values. To counter that, we added the '-overview' option. When given, it would hide options that are set at their default. This option was not the default, to preserve established behavior. However, for new options, we can afford to hide them. Add a mechanism, that property getters can mark their value to be hidden. At the moment, there is no way to show these properties. However, we could add a '-verbose' option, with the opposite meaning of '-overview'. Anyway, that does not seem necessary at the moment. Hiding properties from output is only acceptable for new properties (otherwise we badly change behavior), and if the properties are set at their default values (otherwise, we hide important information).
| * device: implement setting ethtool offload featuresThomas Haller2018-08-101-0/+87
| |
| * platform/ethtool: add code to get/set offload features via ethtoolThomas Haller2018-08-1010-26/+599
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also, add two more features "tx-tcp-segmentation" and "tx-tcp6-segmentation". There are two reasons for that: - systemd-networkd supports setting these two features, so lets support them too (apparently they are important enough for networkd). - these two features are already implicitly covered by "tso". Like for the "ethtool" program, "tso" is an alias for several actual features. By adding two features that are already also covered by an alias (which sets multiple kernel names at once), we showcase how aliases for the same feature can coexist. In particular, note how setting "tso on tx-tcp6-segmentation off" will behave as one would expect: all 4 tso features covered by the alias are enabled, except that particular one.
| * platform/mii: use SocketHandle also for nmp_utils_mii_supports_carrier_detect()Thomas Haller2018-08-101-16/+12
| | | | | | | | | | | | There is little difference in practice because there is only one caller. Still re-use the SocketHandle also for mii. If only, to make it clear that SocketHandle is not only suitable for ethtool, but also mii.
| * platform/ethtool: add SocketHandle to reuse socket for ethtool requestsThomas Haller2018-08-101-83/+131
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, each call to ethtool_get() would resolve the ifindex and create a new socket for the ethtool request. This is partly done, because ethtool only supports making requests by name. Since interfaces can be renamed, this is inherrently racy. So, we want to fetch the latest name shortly before making the request. Some functions like nmp_utils_ethtool_supports_vlans() require multiple ioctls. And next, we will introduce more ethtool functions, that make an even larger number of individual requests. Add a simple SocketHandle struct, to create the socket once and reuse it for multiple requests. This is still entirely internal API in "nm-platform-utils.c".
| * platform/ethtool: split functions for ETHTOOL_GSTRINGSThomas Haller2018-08-101-33/+69
| | | | | | | | | | | | | | ethtool_get_stringset() will be used later, independently. Also, don't trust and ensure that the block of strings returned by ETHTOOL_GSTRINGS are NUL terminated.
| * shared: add NM_DIV_ROUND_UP() helper macroThomas Haller2018-08-101-0/+8
| | | | | | | | Inspired by ethtool's DIV_ROUND_UP() and systemd's DIV_ROUND_UP().
| * libnm, cli, ifcfg-rh: add NMSettingEthtool settingThomas Haller2018-08-1029-91/+1241
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Note that in NetworkManager API (D-Bus, libnm, and nmcli), the features are called "feature-xyz". The "feature-" prefix is used, because NMSettingEthtool possibly will gain support for options that are not only -K|--offload|--features, for example -C|--coalesce. The "xzy" suffix is either how ethtool utility calls the feature ("tso", "rx"). Or, if ethtool utility specifies no alias for that feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation"). If possible, we prefer ethtool utility's naming. Also note, how the features "feature-sg", "feature-tso", and "feature-tx" actually refer to multiple underlying kernel features at once. This too follows what ethtool utility does. The functionality is not yet implemented server-side.
| * libnm: add generic-data for implementing NMSettingThomas Haller2018-08-105-96/+708
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new way how NMSetting subclasses can be implemented. Currently, most NMSetting implementations realize all their properties via GObject properties. That has some downsides: - the biggest one, is the large effort to add new properties. Most of them are implemented on a one-by-one basis and they come with additional API (like native getter functions). It makes it cumbersome to add more properties. - for certain properties, it's hard to encode them entirely in a GObject property. That results in unusable API like NM_SETTING_IP_CONFIG_ADDRESSES, NM_SETTING_BOND_OPTIONS, NM_SETTING_USER_DATA. These complex valued properties only exist, because we currently always need GObject properties to even implement simple functionality. For example, nm_setting_duplicate() is entirely implemented via nm_setting_enumerate_values(), which can only iterate GObject properies. There is no reason why this is necessary. Note also how nmcli badly handles bond options and VPN data. That is only a shortcoming of nmcli and wouldn't need to be that way. But it happend, because we didn't keep an open mind that settings might be more than just accessing GObject properties. - a major point of NMSetting is to convert to/from a GVariant from the D-Bus API. As NMSetting needs to squeeze all values into the static GObject structure, there is no place to encode invalid or unknown properties. Optimally, _nm_setting_new_from_dbus() does not loose any information and a subsequent _nm_setting_to_dbus() can restore the original variant. That is interesting, because we want that an older libnm client can talk to a newer NetworkManager version. The client needs to handle unknown properties gracefully to stay forward compatible. However, it also should not just drop the properties on the floor. Note however, optimally we want that nm_setting_verify() still can reject settings that have such unknown/invalid values. So, it should be possible to create an NMSetting instance without error or loosing information. But verify() should be usable to identify such settings as invalid. They also have a few upsides. - libnm is heavily oriented around GObject. So, we generate our nm-settings manual based on the gtk-doc. Note however, how we fail to generate a useful manual for bond.options. Also note, that there is no reason we couldn't generate great documentation, even if the properties are not GObject properties. - GObject properties do give some functionality like meta-data, data binding and notification. However, the meta-data is not sufficient on its own. Note how keyfile and nmcli need extensive descriptor tables on top of GObject properties, to make this useful. Note how GObject notifications for NMSetting instances are usually not useful, aside for data binding like nmtui does. Also note how NMSettingBond already follows a different paradigm than using GObject properties. Nowdays, NMSettingBond is considered a mistake (related bug rh#1032808). Many ideas of NMSettingBond are flawed, like exposing an inferiour API that reduces everything to a string hash. Also, it only implemented the options hash inside NMSettingBond. That means, if we would consider this a good style, we would have to duplicate this approach in each new setting implementation. Add a new style to track data for NMSetting subclasses. It keeps an internal hash table with all GVariant properies. Also, the functionality is hooked into NMSetting base class, so all future subclasses that follow this way, can benefit from this. This approach has a few similiarties with NMSettingBond, but avoids its flaws. With this, we also no longer need GObject properties (if we would also implement generating useful documentation based on non-gkt-doc). They may be added as accessors if they are useful, but there is no need for them. Also, handling the properties as a hash of variants invites for a more generic approach when handling them. While we still could add accessors that operate on a one-by-one bases, this leads to a more generic usage where we apply common functionality to a set of properties. Also, this is for the moment entirely internal and an implementation detail. It's entirely up to the NMSetting subclass to make use of this new style. Also, there are little hooks for the subclass available. If they turn out to be necessary, they might be added. However, for the moment, the functionality is restricted to what is useful and necessary.
| * libnm: rework setting metadata for property handlingThomas Haller2018-08-1046-540/+810
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/keyfile: use NMMetaSettingInfo for indexing keyfile vtableThomas Haller2018-08-101-49/+63
| | | | | | | | | | | | | | | | | | | | | | | | We have NMMetaSettingType enum, which is an enum of all setting types. We also have an efficient way to get the enum (and its NMMetaSettingInfo) from an NMSetting, setting-name and GType. No longer maintain the vtable for keyfile by "setting-name". Instead, index it by NMMetaSettingType enum. That way, we get efficient lookup, and don't need to duplicate the functionality of finding the vtable entry for a setting.