Commit graph

26234 commits

Author SHA1 Message Date
Yuri Chornoivan
4e33f8cd89
all: fix minor typos
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/565
2020-07-07 11:33:46 +02:00
Thomas Haller
4c52c69d66
nettools: reimport nettools' n-dhcp4
git subtree pull --prefix shared/n-dhcp4/ git@github.com:nettools/n-dhcp4.git master --squash
2020-07-07 11:15:26 +02:00
Thomas Haller
082aab5452 Squashed 'shared/n-dhcp4/' changes from 6876b73ec113..5aeb53d149b4
5aeb53d149b4 client: use jrand48 instead of mrand48_r

git-subtree-dir: shared/n-dhcp4
git-subtree-split: 5aeb53d149b4a6108cae49c73c2308a7c5d52175
2020-07-07 11:14:46 +02:00
Thomas Haller
b9e458b184
shared: add NM_N_ELEMENTS() macro 2020-07-06 14:11:23 +02:00
Thomas Haller
d407c1271c
shared: move NM_SET_OUT() to "nm-std-aux.h" 2020-07-06 14:11:22 +02:00
Thomas Haller
220825836a
shared: move nm_utils_get_next_realloc_size() to nm-std-aux 2020-07-06 14:11:22 +02:00
Thomas Haller
19613016e2
shared: add "nm-std-aux/nm-std-utils.[hc]"
General purpose utilities for nm-std-aux. Contrary to
"nm-std-aux.h", this is not header only.
2020-07-06 14:11:22 +02:00
Thomas Haller
b109d63376
shared: add min/max macros to "nm-std-aux.h" 2020-07-06 11:45:37 +02:00
Thomas Haller
5361317f68
shared: add macros for declaration attribute to "nm-std-aux.h" 2020-07-06 11:45:37 +02:00
Thomas Haller
030d68aef7
shared: add nm_assert() to "nm-std-aux.h"
Having assertion macros that are disabled by default, is not
only useful for our glib code, but should also be available
for nm-std-aux. Move the macros.
2020-07-06 11:45:37 +02:00
Thomas Haller
5dd923cd86
shared: add "nm-std-aux/nm-std-aux.h" header
"nm-std-aux" is an utility library that has no glib depdencency. That
is the difference to "nm-glib-aux".
2020-07-06 11:10:43 +02:00
Beniamino Galvani
15492e6c50 ovs: merge branch 'bg/ovs-mac-pt2'
https://bugzilla.redhat.com/show_bug.cgi?id=1852106
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/557
2020-07-06 09:45:33 +02:00
Beniamino Galvani
77b6ce7d04 device: don't reset the MAC without ifindex
nm_device_cleanup() can be called when the device no longer has an
ifindex. In such case, don't try to reset the MAC address as that
would lead to an assertion failure.
2020-07-06 09:44:16 +02:00
Beniamino Galvani
47ec3d14d4 ovs: also set cloned MAC address via netlink
We already set the MAC of OVS interfaces in the ovsdb. Unfortunately,
vswitchd doesn't create the interface with the given MAC from the
beginning, but first creates it with a random MAC and then changes it.

This causes a race condition: as soon as NM sees the new link, it
starts IP configuration on it and (possibly later) vswitchd will
change the MAC.

To avoid this, also set the desired MAC via netlink before starting IP
configuration.

https://bugzilla.redhat.com/show_bug.cgi?id=1852106
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/483
2020-07-06 09:44:16 +02:00
Beniamino Galvani
5d4c8521a3 ovs: set MAC address on the bridge for local interfaces
When a user creates a ovs-interface with the same name of the parent
ovs-bridge, openvswitch considers the interface as the "local
interface" [1] and assigns the MAC address of the bridge to the
interface [2].

This is confusing for users, as the cloned MAC property is ignored in
some cases, depending on the ovs-interface name.

Instead, detect when the interface is local and set the MAC from the
ovs-interface connection in the bridge table.

[1] https://github.com/openvswitch/ovs/blob/v2.13.0/vswitchd/vswitch.xml#L2546
[2] https://github.com/openvswitch/ovs/blob/v2.13.0/vswitchd/bridge.c#L4744
2020-07-06 09:44:16 +02:00
Beniamino Galvani
fbac6217b1 initrd: merge branch 'bg/initrd-bootif'
https://bugzilla.redhat.com/show_bug.cgi?id=1853277
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/562
2020-07-03 22:10:35 +02:00
Beniamino Galvani
5fa97d7796 initrd: write the hostname to stdout with --stdout
Don't try to open /run/NetworkManager/initrd when called with
--stdout, but instead write the hostname to the standard output.

Fixes: ff70adf873 ('initrd: save hostname to a file in /run')
2020-07-03 22:08:22 +02:00
Beniamino Galvani
3023c70e4e initrd: fix generating default BOOTIF= connection
There is a bug when parsing a BOOTIF= without any existing
connection. The generated connection doesn't have wired setting and
later we try to access it:

 # nm-initrd-generator --stdout -- BOOTIF=01-50-50-00-9f-21-21
  (nm-initrd-generator:1546): libnm-CRITICAL **: ((libnm-core/nm-setting-wired.c:205)): assertion '<dropped>' failed
  (nm-initrd-generator:1546): GLib-GObject-CRITICAL **: g_object_set: assertion 'G_IS_OBJECT (object)' failed

Fix this.

https://bugzilla.redhat.com/show_bug.cgi?id=1853277

Fixes: 25a2b6e14f ('initrd: rework command line parsing')
2020-07-03 22:08:22 +02:00
Beniamino Galvani
79f70bf5d6 initrd: fix generation of MTU and cloned-mac-address for masters
Setting a MTU or a cloned MAC for bonds/bridges/teams fails with:

 # nm-initrd-generator -- bond=bond0:eno1,eno2:mode=802.3ad
    ip=192.168.1.5::192.168.1.254:255.255.255.0:MyServer:bond0:none::01:02:03:04:05:06
    bootdev=bond0 nameserver=192.168.1.1

 <warn> cmdline-reader: 'bond' does not support setting cloned-mac-address

Fix this.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/460
2020-07-03 22:02:34 +02:00
Thomas Haller
b2f03544a7
ndisc/tests: fix assertion in "test-ndisc-fake.c"
First I wanted to fix

  test:ERROR:../src/ndisc/tests/test-ndisc-fake.c:373:test_preference_changed_cb: assertion failed (_a->timestamp == (data->timestamp1 + 3)): (9 == 10)

but that leads to a different failure:

  test:ERROR:../src/ndisc/tests/test-ndisc-fake.c:375:test_preference_changed_cb: assertion failed (_a->lifetime == (9)): (10 == 9)

Instead, the start and end times must match exact (in their duration),
we only allow them to be shifted by up to one second.

Fixes: 8209095ee1 ('ndisc/tests: relax the assertion in "test-ndisc-fake.c"')
2020-07-03 19:29:46 +02:00
Thomas Haller
4af93f848d
cloud-setup: fix invalid assertion in nm_http_client_get_finish()
Fixes: 53bdd81800 ('cloud-setup: ensure that nm_http_client_get_finish() always returns success or error')
2020-07-03 19:03:32 +02:00
Thomas Haller
2a1e621704
cli: suppress "(unknown)" output in terse mode for device properties HWADDR and DRIVER
$ nmcli -f GENERAL.HWADDR device show ovsport0
  GENERAL.HWADDR: (unknown)

but:

  $ nmcli -f GENERAL.HWADDR --terse device show ovsport0
  GENERAL.HWADDR:

This is an API change of nmcli.
2020-07-03 11:40:11 +02:00
Thomas Haller
05a84be550
cli: add nmc_meta_generic_get_str_i18n_null() helper 2020-07-03 11:37:45 +02:00
Sayed Shah
7337ab8959
all: fix typo in man pages
There should be a comma after 'Otherwise' and 'Currently'.

https://bugzilla.redhat.com/show_bug.cgi?id=1852452

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/560
2020-07-03 10:48:04 +02:00
Thomas Haller
66e2d8c38a
cloud-setup: merge branch 'th/cloud-setup-various'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/553
2020-07-03 10:41:46 +02:00
Thomas Haller
9702f79db6
cloud-setup: don't check redundant error results from nm_http_client_poll_get_finish()
nm_http_client_poll_get_finish() can only either succeed (returning TRUE
and setting no GError), or failing (returning FALSE and setting GError).

Checking for both is redundant and unnecessary.
2020-07-03 10:34:29 +02:00
Thomas Haller
53bdd81800
cloud-setup: ensure that nm_http_client_get_finish() always returns success or error 2020-07-03 10:34:29 +02:00
Thomas Haller
eb2dfa9b41
cloud-setup: always report success or an GError from nm_http_client_poll_get_finish()/nmcs_utils_poll_finish()
Since commit 3bd30f6064 ('nmcs: add error message when a HTTP request times
out'), the case where polling returns %FALSE without an error is no
longer possible. This is preferable, because it follows a consistent
API where a function clearly fails or succeeds.

So, checking for the error code and the returned boolean is redundant and
unnecessary.
2020-07-03 10:34:29 +02:00
Thomas Haller
ceb75f8ab4
cloud-setup: remove debugging message from _poll_cancelled_cb() 2020-07-03 10:34:28 +02:00
Thomas Haller
2fbc8717ca
cloud-setup: use stack allocated buffer for temporary strings in "nmcs-provider-gcp.c"
The maximum length of these strings is known and small. Use
a buffer on the stack for them.
2020-07-03 10:34:28 +02:00
Thomas Haller
3d61b28941
cloud-setup: don't use a GString in loop in _get_net_ifaces_list_cb()
nm_utils_parse_next_line() operates on the response buffer obtained
from NMHttpClient. We own this buffer, and we also can rely on the fact
that the buffer has a trailing NUL byte after the data.

There is no need to copy the string to a GString, just use it directly.
2020-07-03 10:34:28 +02:00
Thomas Haller
62aec7acd3
cloud-setup: don't use a GString in _get_config_ips_list_cb()
nm_utils_parse_next_line() operates on the response buffer obtained
from NMHttpClient. We own this buffer, and we also can rely on the fact
that the buffer has a trailing NUL byte after the data.

There is no need to clone the string to a GString, just use it directly.
2020-07-03 10:34:28 +02:00
Thomas Haller
c9c54709b8
cloud-setup: use NMStrBuf in NMHttpClient to track response 2020-07-03 10:34:27 +02:00
Thomas Haller
39733352d6
cloud-setup: use NMStrBuf in nmcs_utils_uri_build_concat_v() 2020-07-03 10:34:27 +02:00
Thomas Haller
4f542384c3
cloud-setup: use nm_utils_parse_next_line() in _get_config_metadata_ready_check()
nm_utils_parse_next_line() has more flexible handling of line endings
(for example, also accpting "\0", "\r", "\r\n"). Use it.
2020-07-03 10:34:27 +02:00
Thomas Haller
e2bd722358
shared: refactor nm_utils_parse_next_line() and add tests
- add unit test for nm_utils_parse_next_line()

- as line delimiter also accept "\r\n" and "\r" (beside "\n", "\0" and
  EOF).

- fix returning lines with embedded "\0" characters. The line ends
  on the first "\n" or "\0", whatever comes first. The code before
  didn't ensure that with:

     line_end = memchr (line_start, '\n', *inout_len);
     if (!line_end)
         line_end = memchr (line_start, '\0', *inout_len);
2020-07-03 10:34:27 +02:00
Thomas Haller
e7357419cd
shared: add nm_str_buf_finalize_to_gbytes() helper 2020-07-03 10:34:26 +02:00
Thomas Haller
befd971b45
cloud-setup: assert that NMHttpClient returns NUL terminated buffer
The behavior is documented at various places, so this assert is less
to actually assert it, but as making this condition obvious to the
reader of the code.
2020-07-03 10:34:26 +02:00
Thomas Haller
e3bbd267c3
cloud-setup: add gtk-doc comment for nm_http_client_get_finish()
NMHttpClient guarantees that the returned response is %NUL terminated after the
returned length of the buffer. That guarantee is important and should be documented.
2020-07-03 10:34:26 +02:00
Thomas Haller
460afe6d50
cloud-setup: fix allocating buffer for GetConfigMetadataMac in _get_config_metadata_ready_check()
It's not a severe issue, because the GetConfigMetadataData struct is
larger than GetConfigMetadataMac.

Fixes: 69f048bf0c ('cloud-setup: add tool for automatic IP configuration in cloud')
2020-07-03 10:34:26 +02:00
Thomas Haller
8209095ee1
ndisc/tests: relax the assertion in "test-ndisc-fake.c"
test:ERROR:../src/ndisc/tests/test-ndisc-fake.c:373:test_preference_changed_cb: assertion failed (_a->timestamp == (data->timestamp1 + 3)): (9 == 10)
2020-07-03 10:34:15 +02:00
Beniamino Galvani
2c50438987 device: restart DHCP only for devices that are active or activating
do_sleep_wake() tries to restart DHCP for all devices, even ones that
are disconnecting. When a device is disconnecting, it still has a DHCP
client instance but we shouldn't restart it because it makes no sense;
and especially, the device could be already removed.

https://bugzilla.redhat.com/show_bug.cgi?id=1852612
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/561
2020-07-03 09:31:35 +02:00
Thomas Haller
9fa59c156b
gitlab-ci: check "examples/python/gi/nm-wg-set" with black 2020-07-02 17:44:29 +02:00
Thomas Haller
38b7556c65
build: check "examples/python/gi/nm-wg-set" with black 2020-07-02 17:44:21 +02:00
Thomas Haller
1acd64b7a2
examples: run python black on "examples/python/gi/nm-wg-set"
black by default only considers files that have a ".py" extension.
2020-07-02 17:37:12 +02:00
Thomas Haller
3b896cc642
ndisc/tests: make assertion checks a macro and not a function in test-ndisc-fake
By having it a function, the assertion failure does not show the line
number of the origin. Make them a macro, so that we see where exactly it
failed.
2020-07-02 16:28:49 +02:00
Beniamino Galvani
76baf6e0ba wifi: merge branch 'bg/ap-isolation'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/469
2020-07-01 17:47:53 +02:00
Beniamino Galvani
4db4801038 supplicant,device: support AP isolation
Support setting the ApIsolate property of the supplicant interface
during association and resetting it to zero during disconnection.
2020-07-01 17:36:20 +02:00
Beniamino Galvani
dbfe219d5b all: add ap-isolation property to wifi setting
Add a new 'ap-isolation' property to the wifi setting, useful to
prevent communication between wireless clients.
2020-07-01 17:36:20 +02:00
Beniamino Galvani
47817a576c ifcfg-rh: add generic shvar getter and setter for ternary variables 2020-07-01 17:36:20 +02:00