Commit graph

27747 commits

Author SHA1 Message Date
Thomas Haller
8f2ca652d9
build: make path to polkit-agent-helper-1 binary configurable
Add new configure option to set the path to "polkit-agent-helper-1".

The path cannot be obtained from pkg-config and `pkg-config
--variable=prefix polkit-agent-1` is not good enough.

On Fedora, the path is "/usr/lib/polkit-1/polkit-agent-helper-1".
On Debian Buster, the path is "/usr/lib/policykit-1/polkit-agent-helper-1"
On Debian Sid, the path is "/usr/libexec/polkit-agent-helper-1" (but
currently it is also symlinked from "/usr/lib/policykit-1/polkit-agent-helper-1".

(cherry picked from commit 801c41a11c)
2021-02-12 11:36:36 +01:00
Thomas Haller
4e11b182a0
release: bump version to 1.29.90 (1.30-rc1) 2021-02-11 16:41:29 +01:00
Andrew Zaborowski
190ed7b2c9
iwd: Fix agent DBus method parameter types
The object path DBus type wasn't being used correctly in the parameters
signatures, fix them.
2021-02-11 16:34:09 +01:00
Andrew Zaborowski
c8b283b818
settings: Fix REASON_CLEAR_DEFAULT_WIRED comment typos 2021-02-11 16:34:08 +01:00
Thomas Haller
5ca018c0db
lldp/tests: try workaround failure with ioctl(TUNSETIFF)
On copr build, it seems possible that the ioctl fails with

  ERROR: src/core/devices/tests/test-lldp - Bail out! NetworkManager:ERROR:src/core/devices/tests/test-lldp.c:823:_test_recv_fixture_setup: assertion failed (errno == 0): (1 == 0)

(1 is EPERM). Unclear why this happens. But as it only affects the
test setup, retry a few times.
2021-02-11 16:04:46 +01:00
Thomas Haller
a21fdd4237
dhcp: merge branch 'th/dhcp-nettools-lease-parse'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/750
2021-02-11 14:43:45 +01:00
Thomas Haller
4b874019ad
dhcp: downgrade logging messages for DHCP to <debug>
Granted, for debugging this information is useful. However, to actually
debug an issue thoroughly, level=TRACE is anyway required. There is simply
no way how we can log useful debug information and not flood logging
messages for regular use.

For example, logging the DHCP lease options can easily print 30 lines.
And this, every time you get a lease update (e.g. every 30 minutes) and
for every interface that does DHCP.

It's simply too verbose. Downgrade the logging level.

Yes, now our default <info> level is even less useful to understand what
is going on. But the majority of time, users don't care so not spamming
the log is more important.

However, we still log the DHCP event (and the IP address) with <info>
level.
2021-02-11 14:33:32 +01:00
Thomas Haller
24abf13239
dhcp: binary search in nm_dhcp_option_find()
Let's use binary search.

Test patch:

    diff --git a/src/core/dhcp/tests/test-dhcp-utils.c b/src/core/dhcp/tests/test-dhcp-utils.c
    index 9b54e2cd0228..007993341672 100644
    --- a/src/core/dhcp/tests/test-dhcp-utils.c
    +++ b/src/core/dhcp/tests/test-dhcp-utils.c
    @@ -788,6 +788,24 @@ NMTST_DEFINE();
     int
     main(int argc, char **argv)
     {
    +    int i;
    +    guint idx;
    +    guint c;
    +
    +    idx = 0;
    +    c = 0;
    +    for (i = 0; i < 1000000; i++) {
    +        const guint option = _nm_dhcp_option_dhcp4_options[idx % G_N_ELEMENTS(_nm_dhcp_option_dhcp4_options)].option_num;
    +
    +        idx += 2010055757;
    +
    +        if (nm_dhcp_option_find(AF_INET, option)->name)
    +            c++;
    +    }
    +    g_print(">%u\n", c);
    +
    +    return 0;
    +
         nmtst_init_assert_logging(&argc, &argv, "WARN", "DEFAULT");

         g_test_add_func("/dhcp/generic-options", test_generic_options);

Build:

  CFLAGS='-O2' ./autogen.sh --with-more-asserts=0
  make -j 10 src/core/dhcp/tests/test-dhcp-utils && \
    src/core/dhcp/tests/test-dhcp-utils && \
    perf stat -r 200 -B src/core/dhcp/tests/test-dhcp-utils

Before:

 Performance counter stats for 'src/core/dhcp/tests/test-dhcp-utils' (200 runs):

             82.83 msec task-clock:u              #    0.994 CPUs utilized            ( +-  0.21% )
                 0      context-switches:u        #    0.000 K/sec
                 0      cpu-migrations:u          #    0.000 K/sec
               579      page-faults:u             #    0.007 M/sec                    ( +-  0.03% )
       264,676,245      cycles:u                  #    3.195 GHz                      ( +-  0.06% )
       544,792,266      instructions:u            #    2.06  insn per cycle           ( +-  0.00% )
       151,624,848      branches:u                # 1830.472 M/sec                    ( +-  0.00% )
         1,083,780      branch-misses:u           #    0.71% of all branches          ( +-  0.01% )

          0.083328 +- 0.000178 seconds time elapsed  ( +-  0.21% )

After:

 Performance counter stats for 'src/core/dhcp/tests/test-dhcp-utils' (200 runs):

             39.21 msec task-clock:u              #    0.987 CPUs utilized            ( +-  0.57% )
                 0      context-switches:u        #    0.000 K/sec
                 0      cpu-migrations:u          #    0.000 K/sec
               579      page-faults:u             #    0.015 M/sec                    ( +-  0.03% )
       115,396,123      cycles:u                  #    2.943 GHz                      ( +-  0.23% )
       137,664,630      instructions:u            #    1.19  insn per cycle           ( +-  0.00% )
        25,866,025      branches:u                #  659.597 M/sec                    ( +-  0.00% )
         1,919,616      branch-misses:u           #    7.42% of all branches          ( +-  0.12% )

          0.039717 +- 0.000227 seconds time elapsed  ( +-  0.57% )
2021-02-11 13:00:18 +01:00
Thomas Haller
1cbe926c20
dhcp: rework DHCP options to not carry around option array
Previously, we would pass around the list of options. However,

- that isn't too nice to read. Also, usually when we want to treat
  IP address families generically, then we have an addr_family argument.
  Having to first resolve the addr_family to another set of variables
  is inconvenient.

- the option array itself doesn't have enough information. For example,
  we don't know how many elements there are, we don't know which address
  family it is (unless we compare it to one of the two well known
  lists).
  For example, I'd like to do a binary search for the option. But that's
  not immediately possible, because the length is unknown.

- in practice, there are only two address families: AF_INET and
  AF_INET6. It is extremely unlikely that we will require a third
  DHCP options list, and even if we had that, the addr_family argument
  still abstracts them nicely.
  We also don't need two different lists for one DHCP type. While that
  would currently be possible (and afterwards not anymore), it would
  be wrong to do.

- also add a new accessor nm_dhcp_option_find() to find the NMDhcpOption
  instance by option number.
2021-02-11 12:26:18 +01:00
Thomas Haller
53f137af6e
dhcp/nettools: accept any number of trailing NULs in string options
https://tools.ietf.org/html/rfc2132#section-2 says:

   Options containing NVT ASCII data SHOULD NOT include a trailing NULL;
   however, the receiver of such options MUST be prepared to delete trailing
   nulls if they exist.

It speaks in plurals.
2021-02-11 09:23:20 +01:00
Thomas Haller
3b8882b978
dhcp/nettools: use NMStrBuf in lease_save() 2021-02-11 09:23:19 +01:00
Thomas Haller
4707cf5fab
dhcp/nettools: cleanup lease_parse_search_domains() 2021-02-11 09:23:19 +01:00
Thomas Haller
8366fd87b9
dhcp/nettools: make data pointer const 2021-02-11 09:23:18 +01:00
Thomas Haller
ce72563a8c
dhcp/nettools: cleanup nm_dhcp_lease_data_parse_search_list() 2021-02-11 09:23:17 +01:00
Thomas Haller
6e0d2e5850
dhcp/nettools: move nm_dhcp_lease_data_parse_search_list() to nm-dhcp-utils.c 2021-02-11 09:23:16 +01:00
Thomas Haller
67dd25a396
shared,dhcp: add _nm_utils_ip4_get_default_prefix0() helper 2021-02-11 09:23:15 +01:00
Thomas Haller
94e474fa62
dhcp/nettools: cleanup lease_parse_routes() 2021-02-11 09:23:15 +01:00
Thomas Haller
2be43d79f7
dhcp/nettools: refactor parsing of DHCP lease (ntps) 2021-02-11 09:23:14 +01:00
Thomas Haller
f986d409f9
dhcp/nettools: cleanup lease_parse_address_list() 2021-02-11 09:23:14 +01:00
Thomas Haller
30911a305f
dhcp/nettools: cleanup lease_parse_address() 2021-02-11 09:23:13 +01:00
Thomas Haller
58b3b7ec3c
dhcp/nettools: refactor parsing of DHCP lease (server-id)
No change in behavior.
2021-02-11 09:23:12 +01:00
Thomas Haller
6850e3640e
dhcp/nettools: refactor parsing of DHCP lease (broadcast)
No change in behavior.
2021-02-11 09:23:12 +01:00
Thomas Haller
a24b7287d8
dhcp/nettools: validate domain-name option (15) differently 2021-02-11 09:23:12 +01:00
Thomas Haller
94c6f3c14e
dhcp/nettools: refactor parsing of DHCP lease (domain-name)
No change in behavior.
2021-02-11 09:23:11 +01:00
Thomas Haller
6c8a9e8bd6
dhcp/nettools: validate nis-domain option (40) differently
Previously, we would check that all characters are ASCII. But we would
also accept NUL characters (and truncate on the first NUL).

Now:

- reject any NUL characters inside the string (except trailing NUL).

- accept all characters, and if necessary backslash-encode non UTF-8.
2021-02-11 09:23:11 +01:00
Thomas Haller
0c93bff179
dhcp/nettools: refactor parsing of DHCP lease (nis-domain) 2021-02-11 09:23:10 +01:00
Thomas Haller
0ef37431cf
dhcp/nettools: validate root-path option (17) to not contain any NUL characters
And make it UTF-8 (by backslash escaping).
2021-02-11 09:23:10 +01:00
Thomas Haller
f2885cdf02
dhcp/nettools: refactor parsing of DHCP lease (root-path) 2021-02-11 09:23:10 +01:00
Thomas Haller
eb16cb6563
dhcp/nettools: validate proxy-autodiscovery option (252) to not contain any NUL characters 2021-02-11 09:23:09 +01:00
Thomas Haller
8f7a2a1ea0
dhcp/nettools: refactor parsing of DHCP lease (wpad) 2021-02-11 09:23:09 +01:00
Thomas Haller
784932550c
dhcp/nettools: validate and normalize Host Name Option (12)
The hostname is in the end a string, which means it must be in a known,
sensible encoding (UTF-8). Previously, we would not ensure the encoding,
nor that the hostname was valid.

Fix that. Follow what systemd does with lease_parse_domain().

See-also: https://tools.ietf.org/html/rfc2132#section-3.14
2021-02-11 09:23:09 +01:00
Thomas Haller
67110d1711
dhcp/nettools: refactor parsing of DHCP lease (hostname) 2021-02-11 09:23:08 +01:00
Thomas Haller
89773b8739
dhcp/nettools: refactor parsing of DHCP lease (metered) 2021-02-11 09:23:08 +01:00
Thomas Haller
de14a376ff
dhcp/nettools: refactor parsing of DHCP lease (mtu) 2021-02-11 09:23:08 +01:00
Thomas Haller
fc83acbd99
dhcp: add nm_dhcp_option_add_option_in_addr() helper 2021-02-11 09:23:07 +01:00
Thomas Haller
41634d5199
dhcp: add nm_dhcp_option_add_option_utf8safe_escape() helper 2021-02-11 09:23:07 +01:00
Thomas Haller
f0a9268718
dhcp: require options argument for nm_dhcp_option_add_option()
It's not clear why the option argument would be optional.
Also, it's not optional for nm_dhcp_option_take_option().

Add an nm_assert() to catch such wrong uses.
2021-02-11 09:23:07 +01:00
Thomas Haller
1e15ea9dd5
systemd: add nm_sd_dns_name_normalize() accessor 2021-02-11 09:23:07 +01:00
Thomas Haller
e12e4ef849
shared: return NMStrBuf instance from nm_str_buf_reset()
it can be useful for chaining, and it costs nothing to do this
on an inline function.
2021-02-11 09:23:07 +01:00
Thomas Haller
edc7c7204c
shared: remove "str" argument from nm_str_buf_reset()
NMStrBuf's API is all about convenience. When you reset the buffer,
is it convenient to immediately append a new string?

It seems not. Make nm_str_buf_reset() simpler by doing only one thing.
2021-02-11 09:23:06 +01:00
Thomas Haller
04e824a256
NEWS: update 2021-02-11 08:48:51 +01:00
Thomas Haller
d27ce97195
cloud-setup: merge branch 'th/cloud-setup-fix-replace-addr'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/747
2021-02-10 19:25:18 +01:00
Thomas Haller
d0552e00d0
cloud-setup/tests: add test for nmcs_setting_ip_replace_ipv4_addresses() 2021-02-10 18:35:13 +01:00
Thomas Haller
7e8809a9c5
cloud-setup/tests: add unit test for nm-cloud-setup 2021-02-10 18:23:44 +01:00
Thomas Haller
bbd36be44a
cloud-setup: fix replacing IPv4 addresses during update
If previously the profile would track two addresses ("10.116.1.130/24",
"10.116.1.65/24"), and during an update the second address was removed
(leaving "10.116.1.130/24"), then the addresses of the profile were
wrongly not changed.

The effect is that removing a secondary IP address might not take
effect.

Fix that.

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

Fixes: 69f048bf0c ('cloud-setup: add tool for automatic IP configuration in cloud')
2021-02-10 18:23:44 +01:00
Thomas Haller
94a75c8cd6
cloud-setup: build intermediate library "libnm-cloud-setup-core.a"
Next we'll add unit tests, hence we need to link against the code
but we don't want to compile it twice.
2021-02-10 18:23:44 +01:00
Thomas Haller
8d6bd2f6c0
shared/tests: add nmtst_rand_perm_strv() helper 2021-02-10 18:23:44 +01:00
Thomas Haller
826d4fd7a9
shared/tests: add nmtst_ip_address_new() helper 2021-02-10 18:23:44 +01:00
Thomas Haller
dfddab88ac
gitignore: ignore *.a files 2021-02-10 18:23:43 +01:00
Yuri Chornoivan
d24ad0a202
po: update Ukrainian (uk) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/749
2021-02-10 17:52:06 +01:00