Commit Graph

25044 Commits

Author SHA1 Message Date
Antonio Cardace
15a8595575 nmcli: remove interface length check in nmcli
nmcli should not perform checks on the interface name length,
this kind of operations should only be performed by the NetworkManager
daemon and not be duplicated inside cli applications.
2020-02-17 15:27:35 +01:00
Antonio Cardace
0cac094c93 nm-device-factory: remove ifname check as it prevents activating OVS connections 2020-02-17 15:27:35 +01:00
Antonio Cardace
9e27252c27 nm-dhcp-client: use nm_assert() to check ifname
so that it gets compiled out in production builds, this check is
carried out anyway when the connection is created.
2020-02-17 15:27:35 +01:00
Thomas Haller
439ac7f7c2 license: add Michael to RELICENSE.md
https://mail.gnome.org/archives/networkmanager-list/2020-February/msg00012.html
2020-02-17 15:23:56 +01:00
Thomas Haller
04bb97d4c1 libnm: move nm_setting_ip6_config_get_ra_timeout() to "libnm_1_22_8" symbol version
nm_setting_ip6_config_get_ra_timeout() was backported to nm-1-22 branch, and
will be released as 1.22.8. As such, on the stable branch the symbol will be
placed in a separate symbol version ("libnm_1_22_8").

To support the upgrade path from 1.22.8+ to 1.23+, we want this symbol
also present on master.

At that point, we don't need to duplicate the symbol. Just add the same linker
symbol version also to master.
2020-02-17 15:18:58 +01:00
Thomas Haller
3719c0fe84 all: merge branch 'th/ra-timeout-2'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/414
2020-02-17 14:45:39 +01:00
Thomas Haller
cab8b857ca device: more unify handling of DHCP data for IPv4/IPv6 (client, config, state_sigid, was_active)
At this point, just move the fields in their respective address-family
specific structure. We don't use it generically yet, but instead always
explicitly select IPv4 or IPv6. But this would allow to access those
fields by address-family in the future.
2020-02-17 14:45:09 +01:00
Thomas Haller
0c52c18b56 device: unify handling of grace-period for DHCPv4 and DHCPv6 (2) 2020-02-17 14:45:09 +01:00
Thomas Haller
49b4fce2d3 device: unify handling of grace-period for DHCPv4 and DHCPv6 (1)
Often, the code paths for IPv4 and IPv6 are very similar. We should try
to unify those code paths. The main advantage of doing that, is that
we don't unintentionally end up doing different things. And of course,
it removes duplicate code.

In a first step, unify handling of the grace timeout for DHCPv4 and
DHCPv6.
2020-02-17 14:45:09 +01:00
Thomas Haller
eae862e385 shared: add LOGD_DHCP_from_addr_family() helper 2020-02-17 14:45:09 +01:00
Thomas Haller
4c993f6bbb all: merge branch 'th/ra-timeout'
https://bugzilla.redhat.com/show_bug.cgi?id=1801158

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/414
2020-02-17 14:44:17 +01:00
Thomas Haller
9dde86d02c ndisc: implement "ipv6.ra-timeout" property 2020-02-17 14:43:13 +01:00
Thomas Haller
10f0253f2e ndisc: rename NM_NDISC_RA_TIMEOUT signal to NM_NDISC_RA_TIMEOUT_SIGNAL
We will add a property NM_NDISC_RA_TIMEOUT for which this name is better
suited. The problem is really that our convention for object properties
and signals defines have no prefix to indicate whether it's a property
or a signal.

Rename.
2020-02-17 14:43:13 +01:00
Thomas Haller
b2e30b3c9a ndisc: improve logging message with nm_ndisc_start() and minor cleanup 2020-02-17 14:43:13 +01:00
Thomas Haller
de4aeb34e3 libnm,cli,ifcfg-rh: add ipv6.ra-timeout configuration option 2020-02-17 14:43:13 +01:00
Thomas Haller
0d8f55a1cb cli: add support for "ipv6.dhcp-timeout" property
It was internally supported, but not by nmcli.
2020-02-17 14:43:13 +01:00
Thomas Haller
843c546b84 ifcfg-rh: belatedly add support for "ipv6.dhcp-timeout" setting 2020-02-17 14:43:13 +01:00
Thomas Haller
9b82d29f5f ifcfg-rh: fix potential crash with variadic argument make_ip6_setting()
It is undefined behavior and can lead to crashes or memory corruption.
In practice, this only had an issue on Big Endian systems.

Fixes: fdbf4ae5e6 ('ifcfg-rh: add IPV4_DHCP_TIMEOUT key for ipv4.dhcp-timeout property')
2020-02-17 14:43:13 +01:00
Thomas Haller
d06092acbd ifcfg-rh: inline unnecessary function write_ip6_setting_dhcp_hostname()
If a function is only called once, it may not help to simplify the code
but make it more complicated. It would only simplify the code, if it
had a clear, distinct purpose. That isn't the case here. Also, the
IPv4 writer doesn't have such a function either. Drop and inline it.
2020-02-17 14:43:13 +01:00
Thomas Haller
4c101f36ec device: don't schedule grace timeout if dhcp-timeout is infinity
It feels wrong to schedule a timeout with G_MAXUINT32, if we actually
disabled the timeout. Of course, in practice there should be little
difference.
2020-02-17 14:43:13 +01:00
Thomas Haller
be4129bb2d device/trivial: rename get_dhcp_timeout() virtual function to have a unique name
This is C, we have almost no IDE support. And ctags/cscope is much more
helpful if we use unique names.

Don't use the get_dhcp_timeout() name, because that is already used in
"src/devices/nm-device.c" already. Rename.
2020-02-17 14:43:12 +01:00
Thomas Haller
e34db042af libnm/doc: explain values for dhcp-timeout setting 2020-02-17 14:43:12 +01:00
Beniamino Galvani
e127a82370 Revert "manager: drop devices_inited field in NManagerPrivate for devices_inited_id"
After this change the startup-complete event is reached too early,
even before priv->devices_inited_id is initialized.

This reverts commit d50856b5c6.
2020-02-17 13:30:35 +01:00
Thomas Haller
b2d3ba33a7 license: merge branch 'th/fix-lgpl-license-violations' (part 1)
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/390
2020-02-16 15:59:46 +01:00
Thomas Haller
6963ecf0d1 license: relicense "libnm-core/nm-errors.h" under LGPL-2.1+
$ git shortlog -n -s a3e75f3294 -- libnm-core/nm-errors.h
      11    Dan Winship
       5    Thomas Haller
       2    Beniamino Galvani

Note that the header also contains code that was copied from other
files. However, that code originates from libnm itself (and thus was
already LGPL licensed).

All contributors agreed to the relicensing according to "RELICENSE.md".
2020-02-16 15:55:55 +01:00
Thomas Haller
2dde55203b license: relicense "shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h" under LGPL-2.1+
$ git shortlog -n -s a3e75f3294 -- shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h src/systemd/sd-adapt-core/nm-sd-adapt-core.c src/systemd/sd-adapt/nm-sd-adapt.'[hc]' src/systemd/nm-sd-adapt.'[hc]' src/dhcp-manager/systemd-dhcp/nm-sd-adapt.'[hc]'
      46    Thomas Haller
       7    Beniamino Galvani
       3    Lubomir Rintel
       2    Dan Williams
       2    Dan Winship
       1    Glenn Washburn
       1    Jiří Klimeš

Note that the contribution to the file by Glenn was removed in
commit e27b15c00d ('all: remove CLOCK_BOOTTIME defintions'), so
it is no longer relevant.

All other contributors agreed to the relicensing according to "RELICENSE.md".
2020-02-16 15:45:08 +01:00
Thomas Haller
46da89cb54 license: relicense "shared/nm-utils/nm-vpn-editor-plugin-call.h" under LGPL-2.1+
$ git shortlog -n -s a3e75f3294 -- shared/nm-utils/nm-vpn-editor-plugin-call.h shared/nm-vpn-editor-plugin-call.h
       5    Thomas Haller

All contributors agreed to the relicensing according to "RELICENSE.md".
2020-02-16 15:41:49 +01:00
Thomas Haller
3eef0cf387 license: relicense "shared/nm-libnm-core-intern-aux/nm-auth-subject.[hc]" under LGPL-2.1+
$ git shortlog -n -s a3e75f3294 -- shared/nm-libnm-core-intern/nm-auth-subject.'[hc]' src/nm-auth-subject.'[hc]'
      28    Thomas Haller
       7    Dan Winship
       1    Beniamino Galvani
       1    Dan Williams
       1    Jiří Klimeš

All contributors agreed to the relicensing according to "RELICENSE.md".
2020-02-16 15:41:44 +01:00
Thomas Haller
fee50e17b2 license: relicense "shared/nm-glib-aux/nm-jansson.h" under LGPL-2.1+
$ git shortlog -n -s a3e75f3294 -- shared/nm-glib-aux/nm-jansson.h shared/nm-utils/nm-jansson.h
       7    Thomas Haller
       1    Lubomir Rintel
       1    Beniamino Galvani
       1    Francesco Giudici

All contributors agreed to the relicensing according to "RELICENSE.md".
2020-02-16 15:41:40 +01:00
Thomas Haller
e70ce4042c license: relicense "shared/nm-glib-aux/nm-glib.h" under LGPL-2.1+
$ git shortlog -n -s a3e75f3294 -- shared/nm-glib-aux/nm-glib.h shared/nm-utils/nm-glib.h shared/nm-glib.h include/nm-glib.h include/nm-glib-compat.h
      35    Thomas Haller
      12    Dan Winship
       5    Dan Williams
       3    Lubomir Rintel
       2    Beniamino Galvani
       1    Jan Kantert
       1    Thomas Bechtold

The last two contributions by Thomas and Jan are no longer present in any
form, because they were for an older version of glib which is no longer
supported. All other contributors agree to the licences change according
to "RELICENSE.md" file.
2020-02-16 15:41:36 +01:00
Thomas Haller
146743ecff license: "Red Hat, Inc." agreement in RELICENSE.md
A large part of the copyright on NetworkManager belongs to Red Hat, Inc.
I talked with legal team (Scott Peterson), and they agree with the
relicensing of NetworkManager code under LGPL-2.1+ code.

On Red Hat's behalf, I hereby mark the agreement to the license change.
2020-02-16 15:12:22 +01:00
Thomas Haller
3ceb7bf099 libnm/doc: fix example for MULTI_CONNECT ifcfg-rh setting 2020-02-14 13:25:37 +01:00
Thomas Haller
d50856b5c6 manager: drop devices_inited field in NManagerPrivate for devices_inited_id
It is redundant. Drop it.

Also, we don't need to cancel and reschedule the idle source in
nm_manager_start(). First of all, it really shouldn't be pending.
Second, contrary to a timer, when an idle source is already pending,
then the pending one will run at the right time.
2020-02-14 11:56:44 +01:00
Thomas Haller
de62da297e all: drop explicit casts from _GET_PRIVATE() macro calls
The _GET_PRIVATE() macros are all implemented based on
_NM_GET_PRIVATE(). That macro tries to be more type safe and uses
_Generic() to do the right thing. Explicitly casting is not only
unnecessary, it defeats these (static) type checks.

Don't do that.
2020-02-14 11:04:46 +01:00
Thomas Haller
d165787b54 device/trivial: add FIXME comment about simplifying deactivate_async() 2020-02-14 10:10:26 +01:00
Thomas Haller
ecddb4c29b supplicant: merge branch 'th/supplicant-cleanup-2'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/411
2020-02-14 09:49:42 +01:00
Thomas Haller
f0bc4aa525 device: move supplicant_timeout_id into supplicant struct in NMDeviceEthernetPrivate
The supplicant struct is there to group related variables.

Move supplicant_timeout_id there.
2020-02-14 09:48:37 +01:00
Thomas Haller
c23c2e2f94 device: reorder fields in NMDeviceEthernetPrivate struct 2020-02-14 09:48:37 +01:00
Thomas Haller
098c0d5092 device: inline "struct Supplicant" to where it is used 2020-02-14 09:48:37 +01:00
Thomas Haller
984e94f01d supplicant: expose nm_supplicant_driver_to_string() helper function
Will be useful later.
2020-02-14 09:48:37 +01:00
Thomas Haller
d36df06c24 shared: don't require callback argument to nm_dbus_connection_call_set()
It's fine to call propery-set without caring about the result.
2020-02-14 09:48:37 +01:00
Thomas Haller
02c95a2d3d all: merge branch 'th/define-fcn-macros-cleanup'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/413
2020-02-14 09:45:08 +01:00
Thomas Haller
829f8e8314 shared: drop compat implementation for G_DEFINE_QUARK()
For one, we by now require glib >= 2.34.0, so this is not used.

Also, I think G_DEFINE_QUARK() is rather ugly because it constructs
the defined function name (so you cannot grep for it). We should use
NM_CACHED_QUARK_FCN() instead.
2020-02-13 17:17:07 +01:00
Thomas Haller
cd31437024 shared: drop _STATIC variant of macros that define functions
Several macros are used to define function. They had a "_STATIC" variant,
to define the function as static.

I think those macros should not try to abstract entirely what they do.
They should not accept the function scope as argument (or have two
variants per scope). This also because it might make sense to add
additional __attribute__(()) to the function. That only works, if
the macro does not pretend to *not* define a plain function.

Instead, embrace what the function does and let the users place the
function scope as they see fit.

This also follows what is already done with

    static NM_CACHED_QUARK_FCN ("autoconnect-root", autoconnect_root_quark)
2020-02-13 17:17:07 +01:00
Thomas Haller
17d9b852c8 shared: explicitly implement binary search in NM_UTILS_STRING_TABLE_LOOKUP_DEFINE*()
When looking at nm_utils_array_find_binary_search(), we see that binary
search really isn't complicated. In nm_utils_array_find_binary_search()
it looks complicated, because that is our general purpose function which
accepts arbitrary lists, uses an opaque compare function, accepts a user
data argument, and returns the insertion position.

This is unnecessary for the narrow purpose in NM_UTILS_STRING_TABLE_LOOKUP_DEFINE*().
When we inline the binary search, it can be simplified, and the remaining
parts is simple enough to prefer this duplication of binary search over
using our general purpose function.

Also, this gives the compiler more chance for optimization. For
example, we can use "unsigned" as index type instead of gssize, because
we know (at compile time), that this type will always be large enough
for our LIST. Also, we can directly call strcmp().

The result is that the macro's implementation is also fast in the best
case (where the needle is found with only one strcmp()) and in the cases
where there is a small number of items to search.
It thus alleviates concerns that using the macro might be slower than
an optimized implementation.

The binary size of the defined function increases slightly (from 112
bytes to 192 bytes, on x86_64, GCC, -O2). But according to my tests it
is slightly and measurably faster.
2020-02-13 14:49:45 +01:00
Thomas Haller
760551e3fc shared/tests: add test for NM_UTILS_STRING_TABLE_LOOKUP_DEFINE*() 2020-02-13 14:20:26 +01:00
Thomas Haller
5a731747c5 libnm: use NM_UTILS_STRING_TABLE_LOOKUP_DEFINE() to implement _nm_setting_bond_mode_from_string() 2020-02-13 10:46:34 +01:00
Thomas Haller
487141d4a8 shared: add entry_cmd argument to NM_UTILS_STRING_TABLE_LOOKUP_DEFINE*() macro
This extra argument allows to tweak whether to assert for the input argument name.
2020-02-13 10:46:34 +01:00
Antonio Cardace
904050dd2d nm-logging: fix stack-use-after-scope error detected by asan
asan error:

==6291==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7ffe6af12880 at pc 0x7fc8dd3321cd bp 0x7ffe6af11be0 sp 0x7ffe6af11388
READ of size 15 at 0x7ffe6af12880 thread T0
    #0 0x7fc8dd3321cc  (/lib64/libasan.so.5+0x4e1cc)
    #1 0x7fc8dcebcf29 in sd_journal_sendv ../src/journal/journal-send.c:226
    #2 0x74d834 in _nm_log_impl ../src/nm-logging.c:778
    #3 0x42485c in main ../src/main.c:379
    #4 0x7fc8dca1b1a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
    #5 0x427e3d in _start (/work/NetworkManager/build/src/NetworkManager+0x427e3d)

Address 0x7ffe6af12880 is located in stack of thread T0 at offset 736 in frame
    #0 0x74c26f in _nm_log_impl ../src/nm-logging.c:663

  This frame has 9 object(s):
    [48, 56) 's_log_domains' (line 744)
    [80, 88) 'l_log_domains' (line 745)
    [112, 128) 'tv' (line 666)
    [144, 168) 'args' (line 664)
    [208, 240) 'g_copy' (line 670)
    [272, 312) 'cur_log_state_copy' (line 669)
    [352, 392) 'iov_free_data' (line 730)
    [432, 672) 'iov_data' (line 728)
    [736, 1024) 's_log_domains_buf' (line 743) <== Memory access at offset 736 is inside this variable
2020-02-12 16:21:47 +01:00
Thomas Haller
8e636186c0 core: for WireGuard devices use a default dns-priority of 50 (like for VPNs) 2020-02-12 11:55:30 +01:00