Commit Graph

21088 Commits

Author SHA1 Message Date
Thomas Haller
c3ab0ed60f device/trivial: rename parent-class variable in device class constructor
The majority of device implementations name their parent-class variable
"device_class". That also makes more sense as it is more consistant.
E.g. "parent" sounds like it's the direct parent, but that is not
the crucial point here. The crucial point at this place, is that we
access the NMDeviceClass typed pointer. Rename.
2018-07-24 09:39:09 +02:00
Thomas Haller
39f47e2f7e wwan/trivial: rename NMModemClass.check_connection_compatible() to use unique name
We also have NMDeviceClass.check_connection_compatible(). It is preferable
to use unique names, especially for the virtual function table. A reasonable
thing to do is grep for the function name to find all places that implement
this function. But if different classes use the same name, grep just
turns up annoying false positives.
2018-07-24 09:39:09 +02:00
Thomas Haller
0ee782d03e shared: add nm_utils_error_set*() helper macros
Add helper macros to type less.
2018-07-24 09:39:09 +02:00
Thomas Haller
0d3bb64008 shared: support zero arguments for NM_NARG() macro
It relies on the GCC extension ##__VA_ARGS__, but we
do that on various places already.

Also add a test.
2018-07-24 09:39:09 +02:00
Lubomir Rintel
159ff23268 dhcp/dhclient-utils: skip over dhclient.conf blocks
Extend the lame-ass dhclient.conf parser to ignore the blocks we can't
do anything useful about: alias{}, pseudo{} and even lease{}.

Note that there's still a lot of cases we can't handle without a
full-fledged dhclient.conf parser -- notably the files that don't use
line breaks to separate the statements.

That is probably okay -- the whole thing is probably mostly useless and
we shall ever bother only about cases that actually cause trouble.

https://github.com/NetworkManager/NetworkManager/pull/153
2018-07-23 12:33:51 +02:00
Lubomir Rintel
c40dbeb49a contrib/rpm: add RHEL connectivity checking package
https://github.com/NetworkManager/NetworkManager/pull/166
2018-07-23 12:30:25 +02:00
Lubomir Rintel
3f449654f7 contrib/rpm: use whitespace consistently
Double newline is used to visually separate sections.
2018-07-23 12:30:20 +02:00
Thomas Haller
91235ec2ba shared: merge branch 'th/merge-gsystem-local-alloc'
https://github.com/NetworkManager/NetworkManager/pull/169
2018-07-19 15:31:47 +02:00
Thomas Haller
196d7c8ca5 shared: use nm_auto() macro to define other nm_auto_* macros 2018-07-18 10:27:39 +02:00
Thomas Haller
d0b3702b37 shared: cleanup nm_auto implementations
- Reuse NM_AUTO_DEFINE*() where possible.
- Consistently name the cleanup functions for "nm_auto_xzy" as
  _nm_auto_xzy().
2018-07-18 10:21:27 +02:00
Thomas Haller
e9d9fc3fa0 shared/gsystem-local-alloc: merge "gsystem-local-alloc.h" into "nm-macros-shared.h"
We only have a certain granularity of how our headers in "shared/nm-utils"
can be used independently.

For example, it's not supported to use "nm-macros-internal.h" without
"gsystem-local-alloc.h". Likewise, you cannot use "nm-glib.h" directly,
you always get it together with "nm-macros-internal.h".

This is, we don't support to use certain headers entirely independently,
because usually you anyway want to use them together.

As such, no longer support "gsystem-local-alloc.h", but merge the
remainder into "nm-macros-internal.h". There is really no reason
to support arbitrary flexibility of including individual bits. You
want cleanup-macros? Include "nm-macros-internal.h".

Merge the headers.
2018-07-18 10:21:27 +02:00
Thomas Haller
c2245e3e5c shared/trivial: whitespace 2018-07-18 10:21:27 +02:00
Thomas Haller
a38782f378 shared/trivial: rename GS_DEFINE_CLEANUP_FUNCTION_*() macros
To be consistent with our other nm_auto* related functions.
2018-07-18 10:21:27 +02:00
Thomas Haller
904e8b8ca0 shared/gsystem-local-alloc: rename unused gs_* cleanup macros
These cleanup macros are unused by NetworkManager code. Note that
since "shared/nm-utils" is used by applet and VPN plugins, theoretically,
they could be used there. I didn't check that, but breaking API of
"shared/nm-utils" is fine (as long as we catch it with a compilation
error).

Historically, we use libgsystem's gsystem-local-alloc header and their
"gs_*" macros. However, they are not really our style and don't have
a nm-prefix (like the rest of our code). We keep the gs_ names, because
they are wildly used and because we wanted to keep gsystem-local-alloc
in sync with upstream (which is no longer the case).

Our own cleanup macros are always called "nm_auto_*". So, at least
for the unused "gs_*" macros, rename them to "nm_auto_*".

Don't drop them, despite they being unused. The reason is, that we should
make use of cleanup functions more eagerly. Dropping them now -- because
they are momentarily unused -- hampers using them in the future. We
often don't use the cleanup macros at places where I think we should,
so by dropping them, we hamper future use.
2018-07-18 10:21:27 +02:00
Thomas Haller
5513af2e14 shared/trivial: add comment to nm_auto_free
It's not obvious why we have "nm_auto_free" along "gs_free".
Explain it.

Also, define the cleanup function first, then the nm-auto macro.
2018-07-18 10:21:27 +02:00
Thomas Haller
1546db05bd shared/gsystem-local-alloc: remove unused "gs_fd_close" cleanup macro
Drop unused "gs_fd_close" macro, now that we no longer care about keeping
"gsystem-local-alloc.h" header in sync with (unmaintained) upstream.

Also, our own "nm_auto_close" macro should be preferred, because

 - it preserves errno

 - it uses nm_close(), which asserts against EBADF.
2018-07-18 10:21:27 +02:00
Thomas Haller
0814ed8080 shared/gsystem-local-alloc: fix gs_free_variant_iter/gs_local_variant_builder_unref
Wrong signature, but they are unused anyway.

Fixes: 98c71df8a3
2018-07-18 10:21:27 +02:00
Thomas Haller
2936203066 build: merge branch 'th/build-flags'
https://github.com/NetworkManager/NetworkManager/pull/167
2018-07-18 09:02:26 +02:00
Thomas Haller
9a08276756 systemd: revert local modification for -std=gnu89 compilation and missing __STDC_VERSION__
We used to build with -std=gnu89 so commit 1391bdfa61
added a local patch to systemd code to avoid compilation error due to
missing __STDC_VERSION__ define.

In the meantime, since commit ba2b2de3ad
and commit b9bc20f4da, we also use -std=gnu99
and thus __STDC_VERSION__ is defined.

Revert our local modification.
2018-07-17 17:50:20 +02:00
Thomas Haller
b9bc20f4da build: pass -std=gnu99 to compiler
With --enable-more-warnings, we already used -std=gnu99, see
commit ba2b2de3ad.

Compilation may behave differently depending on the selected
C standard that we choose. It seems wrong, with more-warnings,
to build against a C standard, while otherwise leaving it undefind.

Indeed, one might argue, that our build system should not use
such compiler specific options. At least, not without detecting
support for the compiler option during ./configure.

However:

- we already did this for --enable-more-warnings.

- we should not program against a theoretical compiler. In practice,
  only gcc and clang works to build NetworkManager. Both these compilers
  support this option, so there is no reason to not use it. If we ever
  come into the situation to support another compiler, adjusting -std=gnu99
  will be the smallest problem. Until that happens (and that's far from
  imminent), don't pretend to be portable to non-existing compilers and
  use the flag that in practice is available.

See-also: https://gcc.gnu.org/onlinedocs/gcc/Standards.html
2018-07-17 17:46:39 +02:00
Thomas Haller
00a523c4f3 build: cleanup CFLAGS for Makefile.am
Reduce duplication of CFLAGS.
2018-07-17 17:46:39 +02:00
Thomas Haller
b4e6cf60f3 travis: do out-of-tree build in travis
When developing, we usually do in-tree-builds, so that case is
already better tested in every-day usage. It makes sense for
travis to test the less-well-tested case: the out-of-tree
build with autotools.
2018-07-17 17:46:39 +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
Thomas Haller
1c2033301c hostname: drop define IFCFG_DIR which is only used once
Also, "src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-common.h"
already has a define IFCFG_DIR, but with a different value.
We shouldn't name different things the same.
2018-07-17 17:46:01 +02:00
Thomas Haller
cc12413c08 m4/trivial: fix indentation 2018-07-17 17:42:24 +02:00
Thomas Haller
3992856964 contrib/rpm: reorder BuildRequires in spec file
Move the BuildRequires related to basic C build environment to the
beginning. Also, avoid specifying multiple packages in one line.
2018-07-17 17:42:24 +02:00
Thomas Haller
e2f106354e contrib/rpm: add BuildRequires to gcc compiler for NetworkManager.spec
Fedora is removing gcc from the default build-root [1], hence
require it.

Actually, we already have a "BuildRequires: libtool", which has a
dependancy on gcc and we already got it implicitly. Just make it
explicit.

[1] https://fedoraproject.org/wiki/Changes/Remove_GCC_from_BuildRoot
2018-07-17 17:42:24 +02:00
Thomas Haller
31a0881f3c keyfile: use gs_unref_keyfile in nms_keyfile_reader_from_file() 2018-07-17 15:09:53 +02:00
Thomas Haller
e512cec770 platform: merge 'jbeta:wireguard-genl-family-lifetime'
https://github.com/NetworkManager/NetworkManager/pull/161
2018-07-13 17:37:24 +02:00
Jan Alexander Steffens (heftig)
21f955b4dd wifi/ifd: Allow D-Bus activation to launch iwd
iwd does not ship activation configuration yet; until then we simply
fail the way we already do.

https://bugzilla.gnome.org/show_bug.cgi?id=796805
2018-07-13 15:58:35 +02:00
Javier Arteaga
6ea0cd1300 platform: put wireguard_family_id in NMPObjectLink
Limit the lifetime of the cached genl family ID to the lifetime of the
interface so we correctly handle module reloads.

https://github.com/NetworkManager/NetworkManager/pull/161
2018-07-13 10:38:42 +02:00
Javier Arteaga
6c3174f6e0 checkpatch: fix perldoc heading
The script does not actually emulate a serial modem (yet).

https://github.com/NetworkManager/NetworkManager/pull/165
2018-07-12 07:40:02 +02:00
Yuri Chornoivan
acb975043e po: update Ukrainian (uk) translation (bgo#796728)
https://bugzilla.gnome.org/show_bug.cgi?id=796728
2018-07-12 07:37:25 +02:00
Thomas Haller
9730961a02 tests/trivial: rename ip4_addr_ne32() to ip4_addr_be32() in test-networkmanager-service.py
The function is supposed to return the IPv4 address as 32 bit integer in
network byte order (bit endian). The ip4_addr_ne32() name is confusing,
because "ne" commonly stands for "native endianness".

Compare also "unaligned.h" and unaligned_read_ne32(), which also
stands for native endianness (host order), not network order (big
endian).

Rename.
2018-07-11 17:53:44 +02:00
Beniamino Galvani
260cded3d6 device: destroy pending acd-managers when the device disconnects
We previously kept any acd-manager running if the device was
disconnected. It was possible to trigger a crash by setting a long
dad-timeout and interrupting the activation request:

  nmcli con add type ethernet ifname eth0 con-name eth0+ ip4 1.2.3.4/32
  nmcli con mod eth0+ ipv4.dad-timeout 10000
  nmcli -w 2 con up eth0+
  nmcli con down eth0+

After this, the n-acd timer would fire after 10 seconds and try to
disconnect an already disconnected device, throwing the assertion:

  NetworkManager:ERROR:src/devices/nm-device.c:9845:
  activate_stage5_ip4_config_result: assertion failed: (req)

Fixes: 28f6e8b4d2
2018-07-11 17:27:11 +02:00
Thomas Haller
ca9981eb5d connectivity: downgrade verbosity of error logging
Such failures during connectivity checks, may happen frequently
and due to external causes. Don't log with error level to avoid
spamming the logfile.
2018-07-11 16:43:28 +02:00
Thomas Haller
98c71df8a3 shared/gsystem-local-alloc: strongly type gs_* cleanup functions
At various places, use the correct type for the pointer, this
allows the compiler to be more helpful.

For gs_free, gs_unref_object, and nm_auto_free, the pointer type is
of course still 'void *'.

This catches wrong uses like

   gs_strfreev char *wrong1 = NULL;
   gs_strfreev const char **wrong2 = NULL;
   gs_free_error GError **p_error = NULL;
   gs_unref_array GPtrArray *ptr_array = NULL;

Note that long time ago we copied "gsystem-local-alloc.h" header
from libgsystem library. Until now, we didn't apply any local
modification to this file, to keep it in sync with upstream.
However, upstream libgsystem is not maintained anymore, so there
is no reason to stay in sync with upstream.
2018-07-11 16:38:12 +02:00
Beniamino Galvani
7df4fc3849 merge: branch 'bg/sriov-vf-rh1555013'
Add support for changing SR-IOV VF settings.

https://bugzilla.redhat.com/show_bug.cgi?id=1555013
2018-07-11 16:29:55 +02:00
Beniamino Galvani
c02d1c488f ifcfg-rh: SR-IOV support 2018-07-11 16:16:22 +02:00
Beniamino Galvani
53c2951f61 device: configure SR-IOV 2018-07-11 16:16:22 +02:00
Beniamino Galvani
8720dd3df1 platform: add support for changing VF attributes 2018-07-11 16:16:22 +02:00
Beniamino Galvani
7df3333879 platform: allow setting drivers-autoprobe on SR-IOV PFs
It is possible to tell kernel not to automatically autoprobe drivers
for VFs. This is useful, for example, if the VF must be used by a VM.
2018-07-11 16:16:22 +02:00
Beniamino Galvani
a2f12994b7 cli: add support for configuring SR-IOV 2018-07-11 16:16:22 +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
Beniamino Galvani
507d078635 libnm-core: tc: fix indentation and typo 2018-07-11 16:16:22 +02:00
Beniamino Galvani
d3db846d95 ifcfg-rh: add missing NM-only annotations
Add the (+) annotation to NM-only variables.
2018-07-11 16:16:22 +02:00
Beniamino Galvani
a2846bd735 libnm-core: don't emit signal when clearing lists already empty
If the property is a list and it is already empty, we should not emit
a signal when it gets cleared.
2018-07-11 16:16:22 +02:00
Beniamino Galvani
347e0d8b5a ifcfg-rh: add @match_key_type argument to svGetKeys()
Add a @match_key_type to svGetKeys() to filter the keys to be returned.
2018-07-11 16:16:22 +02:00
Beniamino Galvani
d7382fbe93 nm-utils: add _nm_utils_format_variant_attributes_full() 2018-07-11 16:16:22 +02:00