Commit graph

726 commits

Author SHA1 Message Date
luz.paz 58510ed566 docs: misc. typos pt2
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
2018-09-17 11:26:13 +02:00
Thomas Haller 070e4e392e autoptr: add missing autoptr cleanup functions
(cherry picked from commit c1b647d54f)
2018-09-14 17:07:27 +02:00
Thomas Haller fe866fbeb3 libnm: drop API nm_connection_get_setting_{6lowpan,sriov,wpan}()
Note that NMSettingEthtool and NMSettingMatch don't have such
functions either.

We have API

  nm_connection_get_setting (NMConnection *, GType)
  nm_connection_get_setting_by_name (NMConnection *, const char *)

which can be used generically, meaning: the requested setting type
is an argument to the function. That is generally more useful and
flexible.

Don't add API which duplicates existing functionality and is (arguably)
inferiour. Drop it now. This is an ABI/API break for the current development
cycle where the 1.14.0 API is still unstable. Indeed it's already after
1.14-rc1, which is ugly. But it's also unlikely that somebody already uses
this API/ABI and is badly impacted by this change.

Note that nm_connection_get_setting() and nm_connection_get_setting_by_name()
are slightly inconvenient in C still, because they usually require a cast.
We should fix that by changing the return type to "void *". Such
a change may be possibly any time without breaking API/ABI (almost, it'd
be an API change when taking a function pointer without casting).

(cherry picked from commit a10156f516)
2018-09-14 16:30:51 +02:00
Beniamino Galvani e83c31bbe0 libnm-core: add connection.llmnr property 2018-09-06 09:07:41 +02:00
Thomas Haller b232508707 shared: add nm-secret-utils.h helper
We already had nm_free_secret() to clear the secret out
of a NUL terminated string. That works well for secrets
which are strings, it can be used with a cleanup attribute
(nm_auto_free_secret) and as a cleanup function for a
GBytes.

However, it does not work for secrets which are binary.
For those, we must also track the length of the allocated
data and clear it.

Add two new structs NMSecretPtr and NMSecretBuf to help
with that.
2018-09-04 07:38:30 +02:00
Thomas Haller 1b448aeb30 all: use nm_utils_gbytes_equal_mem() 2018-08-30 11:17:09 +02:00
Lubomir Rintel bd3472fb82 vpn-service-plugin: cancel the connect timer on has_ipv4=has_ipv6=false
NetworkManager considers a connection w/o L3 configuration fine and connected.
Don't make VPN plugins commit suicide in such case.
2018-08-23 17:15:38 +02:00
Beniamino Galvani 9b9dce9486 all: add 'match' setting
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.
2018-08-11 09:41:07 +02:00
Thomas Haller df30651b89 libnm, cli, ifcfg-rh: add NMSettingEthtool setting
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.
2018-08-10 10:38:19 +02:00
Thomas Haller 55ae69233d all: add connection.multi-connect property for wildcard profiles
Add a new option that allows to activate a profile multiple times
(at the same time). Previoulsy, all profiles were implicitly
NM_SETTING_CONNECTION_MULTI_CONNECT_SINGLE, meaning, that activating
a profile that is already active will deactivate it first.

This will make more sense, as we also add more match-options how
profiles can be restricted to particular devices. We already have
connection.type, connection.interface-name, and (ethernet|wifi).mac-address
to restrict a profile to particular devices. For example, it is however
not possible to specify a wildcard like "eth*" to match a profile to
a set of devices by interface-name. That is another missing feature,
and once we extend the matching capabilities, it makes more sense to
activate a profile multiple times.

See also https://bugzilla.redhat.com/show_bug.cgi?id=997998, which
previously changed that a connection is restricted to a single activation
at a time. This work relaxes that again.

This only adds the new property, it is not used nor implemented yet.

https://bugzilla.redhat.com/show_bug.cgi?id=1555012
2018-08-08 11:24:29 +02:00
Thomas Haller 93ce88a2fa libnm: fix leak for NMDeviceWireGuard's public_key 2018-08-06 08:34:27 +02:00
Javier Arteaga 1427719116 libnm: introduce NMDeviceWireGuard 2018-08-06 08:34:27 +02:00
Javier Arteaga 54df43ed52 core: introduce NMDeviceWireGuard
For now, the device only exposes partial link status (not including
peers). It cannot create new links.
2018-08-06 08:34:27 +02:00
Thomas Haller 86841df368 libnm/docs: don't document NM_SETTING_NAME property
NM_SETTING_NAME is a special property that only has relevance
to libnm. It is inherited by all NMSetting instances. It is
read-only, and it has no corresponding value on D-Bus or nmcli.

Skip it during generate-setting-docs.py.

This also drops it from `man nm-settings`, where it doesn't belong.
2018-08-03 14:24:28 +02:00
Thomas Haller 4eeb4b1bdd all: avoid byte ordering issue for IP4Config's Nameservers/WinsServers on D-Bus
Some properties in NetworkManager's D-Bus API are IPv4 addresses
in network byte order (big endian). That is problematic.

It is no problem, when the NetworkManager client runs on the same
host. That is the case with libnm, which does not support to be used
remotely for the time being.

It is a problem for an application that wants to access the D-Bus
interface of NetworkManager remotely. Possibly, such an application
would be implemented in two layers:

 - one layer merely remotes D-Bus, without specific knowledge of
   NetworkManager's API.

 - a higher layer which accesses the remote D-Bus interface of NetworkManager.
   Preferably it does so in an agnostic way, regardless of whether it runs
   locally or remotely.

When using a D-Bus library, all accesses to 32 bit integers are in
native endianness (regardless of how the integer is actually encoded
on the lower layers). Likewise, D-Bus does not support annotating integer
types in non-native endianness. There is no way to annotate an integer
type "u" to be anything but native order.
That means, when remoting D-Bus at some point the endianness must be
corrected.
But by looking at the D-Bus introspection alone, it is not possible
to know which property need correction and which don't. One would need
to understand the meaning of the properties.

That makes it problematic, because the higher layer of the application,
which knows that the "Nameservers" property is supposed to be in network
order, might not easily know, whether it must correct for endianness.

Deprecate IP4Config properties that are only accessible with a particular
endianness, and add new properties that expose the same data in an
agnostic way.

Note that I added "WinsServerData" to be a plain "as", while
"NameserverData" is of type "aa{sv}". There is no particularly strong
reason for these choices, except that I could imagine that it could be
useful to expose additional information in the future about nameservers
(e.g. are they received via DHCP or manual configuration?). On the other
hand, WINS information likely won't get extended in the future.

Also note, libnm was not modified to use the new D-Bus fields. The
endianness issue is no problem for libnm, so there is little reason to
change it (at this point).

https://bugzilla.redhat.com/show_bug.cgi?id=1153559
https://bugzilla.redhat.com/show_bug.cgi?id=1584584
2018-08-01 14:27:20 +02:00
Lubomir Rintel e0a93ac1e5 libnm: add g_autoptr function for more types
Not sure why there missing, perhaps an oversight.
2018-07-26 12:26:18 +02:00
Lubomir Rintel 3e6e077114 libnm: add nm_device_ovs_*_get_slaves()
They were missing. Add them to the 1.12.2 node, because they've been
backported.

See-also: https://github.com/NetworkManager/NetworkManager/pull/172
2018-07-24 20:16:12 +02:00
Thomas Haller a75ab799e4 build: create "config-extra.h" header instead of passing directory variables via CFLAGS
1) the command line gets shorter. I frequently run `make V=1` to see
   the command line arguments for the compiler, and there is a lot
   of noise.

2) define each of these variables at one place. This makes it easy
   to verify that for all compilation units, a particular
   define has the same value. Previously that was not obvious or
   even not the case (see commit e5d1a71396
   and commit d63cf1ef2f).
   The point is to avoid redundancy.

3) not all compilation units need all defines. In fact, most modules
   would only need a few of these defines. We aimed to pass the necessary
   minium of defines to each compilation unit, but that was non-obvious
   to get right and often we set a define that wasn't used. See for example
   "src_settings_plugins_ibft_cppflags" which needlessly had "-DSYSCONFDIR".
   This question is now entirely avoided by just defining all variables in
   a header. We don't care to find the minimum, because every component
   gets anyway all defines from the header.

4) this also avoids the situation, where a module that previously did
   not use a particular define gets modified to require it. Previously,
   that would have required to identify the missing define, and add
   it to the CFLAGS of the complation unit. Since every compilation
   now includes "config-extra.h", all defines are available everywhere.

5) the fact that each define is now available in all compilation units
   could be perceived as a downside. But it isn't, because these defines
   should have a unique name and one specific value. Defining the same
   name with different values, or refer to the same value by different
   names is a bug, not a desirable feature. Since these defines should
   be unique accross the entire tree, there is no problem in providing
   them to every compilation unit.

6) the reason why we generate "config-extra.h" this way, instead of using
   AC_DEFINE() in configure.ac, is due to the particular handling of
   autoconf for directory variables. See [1].
   With meson, it would be trivial to put them into "config.h.meson".
   While that is not easy with autoconf, the "config-extra.h" workaround
   seems still preferable to me.

[1] https://www.gnu.org/software/autoconf/manual/autoconf-2.63/html_node/Installation-Directory-Variables.html
2018-07-17 17:46:39 +02:00
Beniamino Galvani a9b4532fa7 libnm-core: add SR-IOV setting
Add a setting containing SR-IOV parameters.
2018-07-11 16:16:22 +02:00
Beniamino Galvani d6483592b8 libnm: introduce NMTernary enum
Add a new enum that can be used where we need a boolean value that can
be overridden globally.
2018-07-11 16:16:22 +02:00
Thomas Haller e1c7a2b5d0 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 12:02:06 +02:00
Thomas Haller b41aa4bfde generate-setting-docs.py: remove unreachable code in get_default_value()
get_prop_type() cannot ever return "gchar", because it only returns
values from "dbus_type_name_map" or for enums it has the form

  "%s (%s)" % (pspec.value_type.name, prop_type)

Another reason why get_prop_type() cannot ever return a "char" type,
is because of what get_prop_type() does. get_prop_type() only returns
types based on the D-Bus type of the property, and on D-Bus there is
no fundamental type for a one-character string. There is either a
(UTF-8 encoded) string, or integer values of varying sizes. But in
terms of unicode, a 'char' type makes little sense on D-Bus. And neither
does it for get_prop_type().
2018-07-11 12:02:06 +02:00
Thomas Haller bc2367b83c generate-setting-docs.py: remove unused propxml argument from get_prop_type() 2018-07-11 08:16:40 +02:00
Lubomir Rintel 5f30a2b525 libnm: add accessors for ovs port/bridge slaves 2018-07-10 13:12:07 +02:00
Lubomir Rintel 889961f8b6 all/trivial: grammar fix 2018-07-10 13:12:02 +02:00
Beniamino Galvani f396826466 libnm: add (allow-none) annotations to nm_device_reapply()
The @connection argument can be NULL; add the (allow-none) annotation
otherwise calling the API with a NULL argument through GObject
introspection fails with:

 Argument 1 does not allow None as a value

Fixes: 278fd4fb0f
2018-07-04 14:01:53 +02:00
Thomas Haller b26efa5b68 libnm: fix missing symbols in libnm ABI
Also backport the ABI to 1.12.2 (and thus, don't bother
initially adding the API as libnm_1_14_0).
2018-06-30 12:29:35 +02:00
Thomas Haller 07c1e8c83c libnm: add missing symbols for 1.14 API
Fixes: c1bafea71831994b54d0d9f104005b08797d3e2d
2018-06-30 12:15:51 +02:00
Thomas Haller 4ad45b5944 libnm: fix symbol versioning for new symbols in 1.14 ABI
Fixes: 191c9c7f0d
2018-06-30 12:15:51 +02:00
Lubomir Rintel e53a7365ca docs: provide soft descriptions for NM{Simple,Remote}Connection
...and order them on more logical places in the libnm manual.
2018-06-28 20:38:52 +02:00
Lubomir Rintel 1491efa5d8 meson: run the check-export.sh in test phase
Targets not depended on by anything are not useful and likely never get run.
2018-06-28 20:38:52 +02:00
Lubomir Rintel d6c08691d9 libnm/meson: make generate_setting_docs depend on the typelib
Otherwise it would attempt to use a system-wide installed one, resulting
in sadness and misery.
2018-06-28 20:38:52 +02:00
Lubomir Rintel 21840f5321 meson: generate-setting-docs.py environment correctly
It's ugly, because meson doesnt' seem to provide any useful facilities for
dealing with environment variables. Not my fault.
2018-06-28 20:38:52 +02:00
Timothy Redaelli 9be0c3330d contrib/rpm: Use Open vSwitch instead of OpenVSwitch
The correct naming is Open vSwitch so use it instead of OpenVSwitch

[lkundrak@v3.sk: added some more cases of the same]

https://github.com/NetworkManager/NetworkManager/pull/150

Fixes: 830a5a14cb
2018-06-28 20:31:32 +02:00
Lubomir Rintel 3cd9322298 libnm: add support form 6LoWPAN devices 2018-06-26 16:21:55 +02:00
Lubomir Rintel b7173ad7a7 devices: add NMDevice6Lowpan 2018-06-26 16:21:55 +02:00
Lubomir Rintel 7c1f3650a1 core: add NMSetting6Lowpan 2018-06-26 16:21:55 +02:00
Lubomir Rintel a3baf1ca21 libnm: add support for WPAN devices 2018-06-26 16:21:55 +02:00
Lubomir Rintel 179909a4f2 devices: add NMDeviceWpan 2018-06-26 16:21:54 +02:00
Lubomir Rintel 8884b2cb5e core: add NMSettingWpan 2018-06-26 16:21:54 +02:00
Thomas Haller 9bc6ca96f6 libnm: fix leaking filename in NMRemoteConnection
Fixes: bd6fe17815
2018-06-21 16:06:41 +02:00
Lubomir Rintel 0132da1ddb libnm: add nm_utils_get_timestamp_msec() 2018-06-15 16:23:30 +02:00
Lubomir Rintel 07fd0502f6 wifi: expose LastScan as milliseconds not seconds
This doesn't wrap around in 68 years of uptime and is consistent with
o.fd.NM.Checkpoint.Created.
2018-06-15 16:23:30 +02:00
Lubomir Rintel 1c0aa397b3 libnm: correctly demarshall (u)int64 values 2018-06-15 16:23:30 +02:00
Thomas Haller 576cbb771a libnm: always return VPN connections's banner
It's not libnm's responsibility to hide the banner
depending on the VPN state. libnm should cache and expose
NetworkManager's state, and if the VPN connection has
a banner there, it should be returned.

The previous behavior was since ever in libnm, and in libnm-glib since
the banner was introduced in commit e5b834c1f9.
I think it's wrong if libnm tries too hard putting additional logic
on top of what is on D-Bus.
2018-06-15 11:56:04 +02:00
Simon Fels 58cdc7b550 libnm-core: add wake-on-wlan configuration items
Co-authored-by: Alfonso Sanchez-Beato <alfonso.sanchez-beato@canonical.com>
2018-06-15 09:46:26 +02:00
Beniamino Galvani bb20f2eb61 macsec: enable send-sci by default and make the option configurable
It is safer to enable send-sci by default because, at the cost of
8-byte overhead, it makes MACsec work over bridges (note that kernel
also enables it by default). While at it, also make the option
configurable.

https://bugzilla.redhat.com/show_bug.cgi?id=1588041
2018-06-14 15:13:11 +02:00
Lubomir Rintel c00e17578f wifi: expose the LastScan property
This is the time when the last Wi-Fi scan finished. It will help clients
decide whether the AP list is fresh enough.
2018-06-13 14:44:06 +02:00
Lubomir Rintel bd6fe17815 libnm/remote-connection: add filename property 2018-06-11 15:06:49 +02:00
Francesco Giudici 7a0b6b17bb libnm-core: add ipv6.dhcp-duid property
allow to specify the DUID to be used int the DHCPv6 client identifier
option: the dhcp-duid property accepts either a hex string or the
special values "lease", "llt", "ll", "stable-llt", "stable-ll" and
"stable-uuid".

"lease": give priority to the DUID available in the lease file if any,
         otherwise fallback to a global default dependant on the dhcp
         client used. This is the default and reflects how the DUID
         was managed previously.
"ll": enforce generation and use of LL type DUID based on the current
      hardware address.
"llt": enforce generation and use of LLT type DUID based on the current
       hardware address and a stable time field.
"stable-ll": enforce generation and use of LL type DUID based on a
             link layer address derived from the stable id.
"stable-llt": enforce generation and use of LLT type DUID based on
              a link layer address and a timestamp both derived from the
              stable id.
"stable-uuid": enforce generation and use of a UUID type DUID based on a
               uuid generated from the stable id.
2018-06-08 18:23:31 +02:00