Commit Graph

27758 Commits

Author SHA1 Message Date
Thomas Haller
c7fa8d0a16 platform: downgrade severity of message for failure to create NMPNetns
Under restricted permissions (like inside a podman container) opening
"/proc/self/ns/net" fails with Permission denied. Consequently we cannot
create our bottom NMPNetns instance. That is mostly fine, however we
would log an error message with severity <error>.

Note that test "src/core/platform/tests/test-platform-general" asserts
that no <warn> and <error> messages get logged. Hence, the test will
fail.

That is undesirable. Downgrade the message to <debug> so that the test
passes. Also, it's not clear that this error message is useful here.
Being unable to open a netns fd is fine and not necessarily an error
condition.

(cherry picked from commit 0213300dce)
2021-02-15 21:18:06 +01:00
Thomas Haller
f6c07c39e4 platform: reorder code in _netns_stack_get_impl()
We should always register the GArray stack with pthread
for cleanup the thread local storage. Do that first, before
creating the NMPNetns instance at the bottom of the stack.

(cherry picked from commit f9636080ac)
2021-02-15 21:18:05 +01:00
Thomas Haller
4113e93b3b platform/tests: skip tests if "unshare(CLONE_NEWNET|CLONE_NEWNS)" fails
Inside a podman container (without `--priviledged`) we don't have
permissions for "unshare(CLONE_NEWNET|CLONE_NEWNS)".

It's not useful to fail tests in environments where they cannot run.
Skip them.

(cherry picked from commit ecdbb1ab84)
2021-02-15 21:18:04 +01:00
Thomas Haller
67b0deffac tests: add "/bin:/sbin" to "$PATH" for unit tests
We call `tc` from iproute2, which commonly is at "/sbin/tc".
That might not be in the "$PATH" of a regular user, and consequently
we fail to run the test.

Work around that by always adding "/bin" and "/sbin" to the $PATH.

(cherry picked from commit f591aa41c6)
2021-02-15 14:03:20 +01:00
Thomas Haller
a18155fc23 shared: refactor nm_assert() for NMRefString
- also check consistency of the string.

- disable more expensive check unless running with NM_MORE_ASSERTS>10.

(cherry picked from commit ac1c66eb34)
2021-02-15 10:24:34 +01:00
Thomas Haller
4a50d5a448 libnm: add assertion in _dbus_handle_properties_changed()
(cherry picked from commit 3ceec9c6ac)
2021-02-15 10:24:33 +01:00
Thomas Haller
9832ddd1ec libnm: merge branch 'th/nmclient-fix'
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=982613
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/662

(cherry picked from commit d8214144d2)
2021-02-15 09:49:49 +01:00
Thomas Haller
1db2314a73 libnm: fix tracking object state in NMClient cache
NMClient has a NMLDBusObject instance for each D-Bus object
that it sees. This object can be in different states, like that we
already saw it on D-Bus or that it is only referred to by another
property. Due to a bug, we would wrongly not update the state and
trigger an assertion.

Reproduce with python-dbusmock (commit e89e28bf1bc0254a1eb71b71cf68ef7a97d11e5b)
by running `pytest -v -s tests/test_networkmanager.py -k test_one_wifi_with_accesspoints`.
With LIBNM_CLIENT_DEBUG we get:

>>> libnm-dbus[96085]: <trace> [6464.06459] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/Devices/mock_WiFi2]: properties-changed: properties changed for interface org.freedesktop.NetworkManager.Device { {'ActiveConnection': <objectpath '/org/freedesktop/NetworkManager/ActiveConnection/0'>} }
    libnm-dbus[96085]: <trace> [6464.06459] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/Devices/mock_WiFi2]: properties-changed: set property org.freedesktop.NetworkManager.Device.ActiveConnection
    libnm-dbus[96085]: <trace> [6464.06459] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/Devices/mock_WiFi2]: changed-type 0x01 linked
    libnm-dbus[96085]: <trace> [6464.06459] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/Devices/mock_WiFi2]: changed-type 0x01 consumed
>>> libnm-dbus[96085]: <trace> [6464.06459] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/ActiveConnection/0]: set D-Bus object state watched-only
    libnm-dbus[96085]: <trace> [6464.06459] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/Devices/mock_WiFi2]: changed-type 0x02 linked
    libnm-dbus[96085]: <trace> [6464.06459] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager]: changed-type 0x02 linked
    libnm-dbus[96085]: <trace> [6464.06459] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/Devices/mock_WiFi2]: changed-type 0x02 consumed
>>> libnm-dbus[96085]: <error> [6464.06459] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/Devices/mock_WiFi2]: property ActiveConnection references /org/freedesktop/NetworkManager/ActiveConnection/0 but object is not present on D-Bus
    libnm-dbus[96085]: <trace> [6464.06459] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager]: changed-type 0x02 consumed
    libnm-dbus[96085]: <trace> [6464.06460] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/Devices/mock_WiFi2]: properties-changed: properties changed for interface org.freedesktop.NetworkManager.Device { {'State': <uint32 100>} }
    libnm-dbus[96085]: <trace> [6464.06460] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/Devices/mock_WiFi2]: properties-changed: set property org.freedesktop.NetworkManager.Device.State
    libnm-dbus[96085]: <trace> [6464.06460] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/Devices/mock_WiFi2]: changed-type 0x01 linked
    libnm-dbus[96085]: <trace> [6464.06460] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/Devices/mock_WiFi2]: changed-type 0x01 consumed
    libnm-dbus[96085]: <trace> [6464.06460] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/Devices/mock_WiFi2]: changed-type 0x02 linked
    libnm-dbus[96085]: <trace> [6464.06460] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager]: changed-type 0x02 linked
    libnm-dbus[96085]: <trace> [6464.06461] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/Devices/mock_WiFi2]: changed-type 0x02 consumed
    libnm-dbus[96085]: <trace> [6464.06461] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager]: changed-type 0x02 consumed
    libnm-dbus[96085]: <trace> [6464.06462] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/Devices/mock_WiFi2]: properties-changed: properties changed for interface org.freedesktop.NetworkManager.Device { {'StateReason': <(uint32 100, uint32 0)>} }
    libnm-dbus[96085]: <trace> [6464.06462] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/Devices/mock_WiFi2]: properties-changed: set property org.freedesktop.NetworkManager.Device.StateReason
    libnm-dbus[96085]: <trace> [6464.06462] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/Devices/mock_WiFi2]: changed-type 0x01 linked
    libnm-dbus[96085]: <trace> [6464.06462] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/Devices/mock_WiFi2]: changed-type 0x01 consumed
    libnm-dbus[96085]: <trace> [6464.06462] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/Devices/mock_WiFi2]: changed-type 0x02 linked
    libnm-dbus[96085]: <trace> [6464.06462] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager]: changed-type 0x02 linked
    libnm-dbus[96085]: <trace> [6464.06462] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/Devices/mock_WiFi2]: changed-type 0x02 consumed
    libnm-dbus[96085]: <trace> [6464.06462] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager]: changed-type 0x02 consumed
>>> libnm-dbus[96085]: <trace> [6464.06465] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/ActiveConnection/0]: interfaces-added: properties changed for interface org.freedesktop.NetworkManager.Connection.Active { {'Devices': <[objectpath '/org/freedesktop/NetworkManager/Devices/mock_WiFi2']>, 'Default6': <false>, 'Default': <true>, 'Type': <'802-11-wireless'>, 'Vpn': <false>, 'Connection': <objectpath '/org/freedesktop/NetworkManager/Settings/Mock_AP3'>, 'Master': <objectpath '/'>, 'SpecificObject': <objectpath '/org/freedesktop/NetworkManager/AccessPoint/Mock_AP3'>, 'Uuid': <'72757a57-8cb6-4052-a18f-4e2be4ba27d9'>, 'State': <uint32 2>, 'Id': <'AP_3'>} }
>>> here we lack "set D-Bus object state on-dbus"
    libnm-dbus[96085]: <trace> [6464.06465] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/ActiveConnection/0]: interfaces-added: set property org.freedesktop.NetworkManager.Connection.Active.Devices
    libnm-dbus[96085]: <trace> [6464.06465] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/ActiveConnection/0]: interfaces-added: set property org.freedesktop.NetworkManager.Connection.Active.Default6
    libnm-dbus[96085]: <trace> [6464.06465] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/ActiveConnection/0]: interfaces-added: set property org.freedesktop.NetworkManager.Connection.Active.Default
    libnm-dbus[96085]: <trace> [6464.06465] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/ActiveConnection/0]: interfaces-added: set property org.freedesktop.NetworkManager.Connection.Active.Type
    libnm-dbus[96085]: <trace> [6464.06465] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/ActiveConnection/0]: interfaces-added: set property org.freedesktop.NetworkManager.Connection.Active.Vpn
    libnm-dbus[96085]: <trace> [6464.06465] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/ActiveConnection/0]: interfaces-added: set property org.freedesktop.NetworkManager.Connection.Active.Connection
    libnm-dbus[96085]: <trace> [6464.06465] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/ActiveConnection/0]: interfaces-added: set property org.freedesktop.NetworkManager.Connection.Active.Master
    libnm-dbus[96085]: <trace> [6464.06465] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/ActiveConnection/0]: interfaces-added: set property org.freedesktop.NetworkManager.Connection.Active.SpecificObject
    libnm-dbus[96085]: <trace> [6464.06466] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/ActiveConnection/0]: interfaces-added: set property org.freedesktop.NetworkManager.Connection.Active.Uuid
    libnm-dbus[96085]: <trace> [6464.06466] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/ActiveConnection/0]: interfaces-added: set property org.freedesktop.NetworkManager.Connection.Active.State
    libnm-dbus[96085]: <trace> [6464.06466] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/ActiveConnection/0]: interfaces-added: set property org.freedesktop.NetworkManager.Connection.Active.Id
    libnm-dbus[96085]: <trace> [6464.06466] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/ActiveConnection/0]: changed-type 0x01 linked
    libnm-dbus[96085]: <trace> [6464.06466] nmclient[c9bf1eaa1f4b6c99]: [/org/freedesktop/NetworkManager/ActiveConnection/0]: changed-type 0x01 consumed
    Bail out! libnm:ERROR:libnm/nm-client.c:2863:_dbus_handle_obj_changed_dbus: assertion failed: (dbobj->obj_state >= NML_DBUS_OBJ_STATE_ON_DBUS)

Backtrace:

  #3  0x00007f0bd11173bf in g_assertion_message_expr
      (domain=domain@entry=0x7f0bd1576018 "libnm", file=file@entry=0x7f0bd1576006 "libnm/nm-client.c", line=line@entry=2863, func=func@entry=0x7f0bd157f1b0 <__func__.170> "_dbus_handle_obj_changed_dbus", expr=expr@entry=0x7f0bd157cba0 "dbobj->obj_state >= NML_DBUS_OBJ_STATE_ON_DBUS") at ../glib/gtestutils.c:2963
  #4  0x00007f0bd14959dd in _dbus_handle_obj_changed_dbus (self=self@entry=0x5612d4f5a130, log_context=<optimized out>) at libnm/nm-client.c:2863
  #5  0x00007f0bd1495c29 in _dbus_handle_changes (self=self@entry=0x5612d4f5a130, log_context=<optimized out>, allow_init_start_check_complete=allow_init_start_check_complete@entry=1)
      at libnm/nm-client.c:2909
  #6  0x00007f0bd1497e56 in _dbus_managed_objects_changed_cb
      (connection=<optimized out>, sender_name=<optimized out>, arg_object_path=<optimized out>, interface_name=<optimized out>, signal_name=<optimized out>, parameters=0x7f0bb800d720, user_data=0x5612d4f5a130) at libnm/nm-client.c:3172
  #7  0x00007f0bd132a8df in emit_signal_instance_in_idle_cb (data=data@entry=0x7f0bb8003700) at ../gio/gdbusconnection.c:3789
  #8  0x00007f0bd10f1b5b in g_idle_dispatch (source=source@entry=0x7f0bb8012260, callback=0x7f0bd132a860 <emit_signal_instance_in_idle_cb>, user_data=0x7f0bb8003700) at ../glib/gmain.c:5836
  #9  0x00007f0bd10f2a9f in g_main_dispatch (context=0x5612d4f4b630) at ../glib/gmain.c:3325
  #10 g_main_context_dispatch (context=0x5612d4f4b630) at ../glib/gmain.c:4043
  #11 0x00007f0bd1144a98 in g_main_context_iterate.constprop.0 (context=0x5612d4f4b630, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/gmain.c:4119
  #12 0x00007f0bd10f2163 in g_main_loop_run (loop=0x5612d4f4b720) at ../glib/gmain.c:4317
  #13 0x00005612d44b6543 in main (argc=7, argv=0x7fff4414f1d8) at clients/cli/nmcli.c:1036

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=982613
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/662

Fixes: ce0e898fb4 ('libnm: refactor caching of D-Bus objects in NMClient')
(cherry picked from commit e1e9abdf04)
2021-02-15 09:49:48 +01:00
Thomas Haller
9e743475b6 libnm: avoid assertion failure in _dbus_handle_properties_changed() for logging no properties
(cherry picked from commit 1f9622358a)
2021-02-15 09:49:48 +01:00
Thomas Haller
98b55a63c5 libnm: log PID in LIBNM_CLIENT_DEBUG debug logging
(cherry picked from commit 6da5fc59d8)
2021-02-15 09:49:48 +01:00
Andrew Zaborowski
210d2696a9 iwd: Fix the leaks in get_agent_request_network_path
Don't request new copies of strings from g_variant_get() to avoid
leaking memory as pointed out by Thomas Haller.

Fixes: dc0e31fb70 ('iwd: Add the wifi.iwd.autoconnect setting')
(cherry picked from commit 5ccb8ce17a)
2021-02-15 09:49:38 +01:00
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