Commit graph

20753 commits

Author SHA1 Message Date
Thomas Haller
cd0bd8a2ee connectivity/trivial: rename socket argument in multi_socket_cb() callback
"s" might be a good name for a temporary string.

But here it's really a file descriptor. Call it "fd".
2018-07-24 15:38:23 +02:00
Thomas Haller
a24f118a1f connectivity/trivial: rename local functions to avoid "curl" prefix
Since this is "C" there are not namespaces and libraries commonly choose
a particular name prefix for their symbols.

In case of libcurl, that is "curl_".

We should avoid using the same name prefix, and choose something distinct.
2018-07-24 15:02:58 +02:00
Thomas Haller
a6f51fffa1 device: merge branch 'th/not-available-reason'
https://github.com/NetworkManager/NetworkManager/pull/163
2018-07-24 09:44:18 +02:00
Thomas Haller
3000ade72a core: improve error message when activating profile
Before:

    $ nmcli connection up my-wired
    Error: Connection activation failed: No suitable device found for this connection.

After:

    $ nmcli connection up my-wired
    Error: Connection activation failed: No suitable device found for this connection (device eth0 not available because device has no carrier).

This relies on nm_manager_get_best_device_for_connection() giving a
suitable error. That is however a bit complicated, because if no
suitable device is found, it's not immediately clear what is the
exact reason. E.g. if you try to activate a Wi-Fi profile, the
failure reason

    "SSID is not visible"

is better than

    "Wi-Fi profile cannot activate on ethernet device".

This is controlled by carefully setting the failure codes
NM_UTILS_ERROR_CONNECTION_AVAILABLE_* to indicate an absolute
relevance of the failure. And subsequently, by selecting the failure
with the highest relevance. This might still need some improvements,
for example by reordering checks (so that more relevant failures
are handled first) and tweaking the error relevance.
2018-07-24 09:39:09 +02:00
Thomas Haller
e9f6bb0bbb core: improve error message when activating profile on device
Before:

    $ nmcli connection up my-wired ifname eth0
    Error: Connection activation failed: Connection 'my-wired' is not available on the device eth0 at this time.

After:

    $ nmcli connection up my-wired ifname eth0
    Error: Connection activation failed: Connection 'my-wired' is not available on device eth0 because device has no carrier
2018-07-24 09:39:09 +02:00
Thomas Haller
7bad40109e core: return error reason from nm_manager_get_best_device_for_connection()
Still unused, but will be used to give a better failure reason when
no device is found.

The difficulty here is to select the failure message from the most appropriate
device. This might still need some tweaking by setting the error codes accordingly
and re-ordering checks so that failure cares that are more accurate are handled
first.
2018-07-24 09:39:09 +02:00
Thomas Haller
33a88ca566 core: give better error reason why device is incompatible with profile
Note the special error codes  NM_UTILS_ERROR_CONNECTION_AVAILABLE_*.
This will be used to determine, whether the profile is fundamentally
incompatible with the device, or whether just some other properties
mismatch. That information will be importand during a plain `nmcli
connection up`, where NetworkManager searches all devices for a device
to activate. If no device is found (and multiple errors happened),
we want to show the error that is most likely relevant for the user.

Also note, how NMDevice's check_connection_compatible() uses the new
class field "device_class->connection_type_check_compatible" to simplify
checks for compatible profiles.

The error reason is still unused.
2018-07-24 09:39:09 +02:00
Thomas Haller
570e1fa75b core: give better error reason why device is unavailable
The error reason is still unused.
2018-07-24 09:39:09 +02:00
Thomas Haller
246b747540 shared: add special error codes to NM_UTILS_ERROR
Will be used next.
2018-07-24 09:39:09 +02:00
Thomas Haller
2ce4167967 device: replace NM_DEVICE_CLASS_DECLARE_TYPES() macro by explicit initialization
It seems to me the NM_DEVICE_CLASS_DECLARE_TYPES() macro confuses more
than helping. Let's explicitly initialize the two fields, albeit with
another helper macro NM_DEVICE_DEFINE_LINK_TYPES() to get the list of
link-types right.

For consistency, also leave nop-lines like

  device_class->connection_type_supported = NULL;
  device_class->link_types = NM_DEVICE_DEFINE_LINK_TYPES ();

because all NMDevice class init methods should have this same
boiler plate code and to make it explicit that this is intended.
And there are only 3 occurences where this actually comes into play.
2018-07-24 09:39:09 +02:00
Thomas Haller
c9883b85a2 device: also use NM_DEVICE_CLASS_DECLARE_TYPES() for types without link-types
NMDeviceOvsPort and NMDeviceOvsInterface don't have an underlying link-type from platform.
Still use NM_DEVICE_CLASS_DECLARE_TYPES() macro, for consistancy reasons.

This requires to extend NM_DEVICE_CLASS_DECLARE_TYPES() macro, to support
a variadic argument list with zero link-types.
2018-07-24 09:39:09 +02:00
Thomas Haller
87a60c4596 device: use NM_DEVICE_CLASS_DECLARE_TYPES() to set connection_type_supported of device class
the macro already does it just fine. Use it.
2018-07-24 09:39:09 +02:00
Thomas Haller
0cbf2c8c2a device: wrap NM_DEVICE_CLASS_DECLARE_TYPES() macro with do-while block 2018-07-24 09:39:09 +02:00
Thomas Haller
b9ae79c273 device/trivial: rename NMDeviceClass.connection_type to connection_type_supported
The term "connection_type" is overused. Give it a more distinct name.
2018-07-24 09:39:09 +02:00
Thomas Haller
0b8e1fd971 core/trival: rename nm_device_match_hwaddr() function to nm_device_match_parent_hwaddr()
This name is better, because it compares the MAC address of the device's
parent.
2018-07-24 09:39:09 +02:00
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