Commit graph

29099 commits

Author SHA1 Message Date
Thomas Haller
e2bd2f3f91
tui: fix order of includes in "nmt-page-bond-port.c"
Headers should be included in a particular order. See the CONTRIBUTING
file.
2021-08-26 23:05:12 +02:00
Gris Ge
9958510f28
bond: add support of queue_id of bond port
Introduced `NMSettingBondPort` to hold the new setting class with single
property `NM_SETTING_BOND_PORT_QUEUE_ID`.

For dbus interface, please use `bond-port` as setting name and
`queue-id` as property name.

Unit test cases for ifcfg reader and writer included.

Signed-off-by: Gris Ge <fge@redhat.com>

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/952
2021-08-26 23:04:31 +02:00
Thomas Haller
3a39ce6a99
checkpatch: encourage g_snprintf() over snprintf()
The only reason is consistency. The majority of times we
do use g_snprintf(). As there are no strong reasons to
prefer one over the other, prefer the one that use use
most of the time.
2021-08-26 14:59:53 +02:00
Thomas Haller
27427bad90
CONTRIBUTING: explain order of includes of header files 2021-08-26 14:50:16 +02:00
Thomas Haller
83ee8bd82a
core: sort includes in "src/core/nm-manager.c"
This will be linked by CONTRIBUTING.md file as an example how to do it.
Sorting includes by name is a sensible default-choice, so do it.
2021-08-26 14:43:32 +02:00
Thomas Haller
727bea99b6
CONTRIBUTING: explain which version of clang-format to use 2021-08-26 14:23:17 +02:00
Thomas Haller
101a7cb56d
tests: improve documentation how to generate files for "/test-client.py" 2021-08-26 13:47:04 +02:00
Thomas Haller
beeff19f6c
libnm: cleanup nm_utils_check_virtual_device_compatibility() 2021-08-25 08:19:57 +02:00
Christian Glombek
9c2d835e5c
libnm: allow addition of wireless connections to bonds in nm_utils_check_virtual_device_compatibility()
https://gitlab.gnome.org/GNOME/network-manager-applet/-/issues/140

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/969
2021-08-25 08:19:01 +02:00
Wen Liang
012158f53e platform: merge branch 'liangwen12year:perma_hw_addr'
https://bugzilla.redhat.com/show_bug.cgi?id=1987286

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/673

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/961
2021-08-24 16:54:32 -04:00
Wen Liang
6da4464154 platform: track kernel support for IFLA_PERM_ADDRESS
Track whether kernel supports netlink API IFLA_PERM_ADDRESS. To use the
platform cache preferably if kernel supports IFLA_PERM_ADDRESS. To fall
back to the old ethtool call directly if kernel does not support
IFLA_PERM_ADDRESS.

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/673

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/961

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-08-24 16:16:27 -04:00
Wen Liang
60bad3a41e
platform: obtain l_perm_address via netlink or lookup via ethtool
Add and call the new `nm_platform_link_get_permanent_address()` to
obtain `l_perm_address` via netlink or lookup via ethtool if kernel
does not expose the `IFLA_PERM_ADDRESS`.

And call the new `nm_platform_link_get_permanent_address()` in the unit
tests.

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

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-08-24 21:04:22 +02:00
Wen Liang
2b70e02ef5
platform: rename nm_platform_link_get_permanent_address()
Rename `nm_platform_link_get_permanent_address()`, `link_get_permanent_address()` to
`nm_platform_link_get_permanent_address_ethtool()`, `link_get_permanent_address_ethtool()`.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-08-24 21:04:21 +02:00
Wen Liang
1605fa460d
platform: update nm_platform_link_get_permanent_address() to accept NMPLinkAddress argument
Replace the arguments "buf+length" of
`nm_platform_link_get_permanent_address()` with "NMPLinkAddress *out_addr"

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-08-24 21:04:21 +02:00
Wen Liang
585257509f
platform: add l_perm_address in NMPlatformLink and parse it from netlink
Add `l_perm_address` in `NMPlatformLink` and add it to
`nm_platform_link_to_string`, `nm_platform_link_hash_update`,
`nm_platform_link_cmp` functions, and parse it from netlink.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-08-24 21:04:20 +02:00
Thomas Haller
db13b93563
ifcfg-rh: fail nms_ifcfg_rh_writer_write_connection() without filename/dir
No actual caller should use the API without providing either a filename
or the directory name. I don't think this can actually happen, hence
fail and assert in that case.
2021-08-24 13:45:10 +02:00
Thomas Haller
1fa105eaef
ifcfg-rh: fix updating ifcfg file if file on disk is no longer present
Have an ifcfg file loaded in NetworkManager, then move/remove the file and try
to modify it. That will fail with:

  "failed to update connection: Could not read file '/etc/sysconfig/network-scripts/ifcfg-eth0': No such file or directory"

That is not right.

If the user didn't move/remove the file but merely modified it, NetworkManager
would silently overwrite it. There is no reason why move/remove should behave
differently and not just write a completely fresh file.

The reason why NetworkManager first loads the file before writing, is to
preserve comments and unrecognized shell variables. This is a certain effort
to play nice with users editing the file. It's not essential to load the file
first and a failure to do so should not result in a failure.

And of course, keyfile writer doesn't behave like this either.

This bug exists since 2009, but let's not add a "Fixes" comment for
commit 1974b257e0 ('ifcfg-rh: begin adding write support'), because
it seems not right to backport this patch to all the old releases.
2021-08-24 13:45:06 +02:00
Thomas Haller
f9c096ba84
all: merge branch 'cathay4t:ensure_setting'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/964
2021-08-20 22:17:23 +02:00
Thomas Haller
8ed17ded7b
libnm-core: drop unnecessary cast from _nm_connection_ensure_setting() 2021-08-20 22:16:40 +02:00
Thomas Haller
650922eeaa
tui: fix order of includes 2021-08-20 22:16:36 +02:00
Gris Ge
e69c5e4bab
libnm: Use _nm_connection_ensure_setting()
Use `_nm_connection_ensure_setting()` to eliminate the
duplicated codes. This function will retrieve the specific setting from
connection, if not found, create new one and attach to the connection.

Signed-off-by: Gris Ge <fge@redhat.com>
2021-08-20 19:02:23 +02:00
Gris Ge
c265096d66
libnm-core-aux-intern: Add helper function _nm_connection_ensure_setting()
Introduce internal function `_nm_connection_ensure_setting()` to
`libnm-core-aux-intern` and add specified setting to connection if not
found.

Signed-off-by: Gris Ge <fge@redhat.com>
2021-08-20 19:02:23 +02:00
Beniamino Galvani
bbb7eb1767 8021x: request PINs for PKCS#11 certs unless explicitly not-required
Commit df0dc912cc ('8021x: don't request secrets if they are empty
and system owned') changed the setting so that NM doesn't request the
PIN for PKCS#11 certificates and keys when the password property has
NM_SETTING_SECRET_FLAG_NONE. From the commit message:

    Empty secrets are fine. In particular, for PKCS#11 it means that
    protected authentication path is used (the secrets are obtained
    on-demand from the pinpad).

This change breaks the scenario in which PINs are stored in the
connection, as the setting indicates that no secrets are required, and
thus PINs are not sent to the supplicant.

If the PIN is entered through a pinpad, users should set the secret
flags as 'not-required'.

This reverts commit df0dc912cc ('8021x: don't request secrets if
they are empty and system owned').

https://bugzilla.redhat.com/show_bug.cgi?id=1992829
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/965
2021-08-20 18:09:48 +02:00
Thomas Haller
c8d80f332d
contrib/makerepo: fix detection of centpkg for git+ssh:// remotes 2021-08-20 11:43:33 +02:00
Thomas Haller
ea49b50651
all: add some README.md files describing the purpose of our sources 2021-08-19 17:51:11 +02:00
Thomas Haller
2f3c2647d2
nmcli/docs: fix address order in ipv46.addresses documentation for man nm-settings-nmcli
For IPv4, the order is not like for IPv6. Of course not.

Fixes: 7aa4ad0fa2 ('nmcli/docs: better describe ipv[46].addresses in `man nm-settings-nmcli`')
2021-08-19 14:00:03 +02:00
Thomas Haller
c380893dc6
platform: fix capturing addresses from platform for assuming after restart
Commit c631aa48f0 ('platform: capture NMIP[46]Config from platform
with correct (reversed) order of IP addresses') changed this for IPv6
and IPv4, but it's not correct for IPv4.

For IPv6, later `ip addr add` calls adds a new primary address, which
is also listed in `ip addr show` first. Hence, as NMIP6Config tracks
addresses in increasing priority, while NMPlatform tracks them as
exposed by kernel, the order when appending addresses form platform
to NMIP6Config must be reversed.

That is not the case for IPv4. For IPv4, later `ip addr add` calls
add a secondary IP address. Also, in `ip addr show` output they are
appended. Consequently, IPv4 addresses are tracked by NMPlatform with
decreasing priority (in the reverse order than for IPv6).

Fix constructing the NMIP4Config by fixing the address order. This is
important, because during restart devices get assumed and our code would
configure the order of addresses as it finds them.

Fixes: c631aa48f0 ('platform: capture NMIP[46]Config from platform with correct (reversed) order of IP addresses')
2021-08-19 13:48:22 +02:00
Thomas Haller
b08eef9d38
ifcfg: merge branch 'th/ifcfg-ipv6-disabled-fix'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/962
2021-08-19 09:02:25 +02:00
Thomas Haller
8733d22343
ifcfg: read/write full IPv6 settings also for method ignore/disabled
Do "bother" to read/write settings.

For the umpteenth time, it's not up to the reader/writer to decide
what properties are valid for a profile or which makes sense.

Only nm_connection_verify() can decide that. For example nm_connection_verify()
has no problem with ipv6.method=disabled while also setting ipv6.addr-gen-mode.
We cannot just shortcut the parsing/writing.

The reader only ignores addresses, dns and dns-searches, so that we don't start
parsing invalid files, where the setting would have been ignore
previously.

In particular,

   echo "DEVICE=eth0" > /etc/sysconfig/network-scripts/ifcfg-xxx
   nmcli connection load /etc/sysconfig/network-scripts/ifcfg-xxx
   nmcli -f ipv6.method,ipv6.addr-gen-mode connection show /etc/sysconfig/network-scripts/ifcfg-xxx

needs to show eui64 addr-gen-mode.
2021-08-19 08:54:54 +02:00
Thomas Haller
7de4322d51
ifcfg: don't let write_ip[46]_setting() fail 2021-08-19 08:54:54 +02:00
Thomas Haller
00f63074d6
ifcfg: don't limit parsing DNS elements to 10 entries
It's not the task of the ifcfg reader to pre-normalize profiles
to truncate the DNS server list. It's only nm_connection_verify()'s
task to indicate what is valid and what not.

Increase the number to something excessive. Note that the parsing
scales with O(n^2). So don't have it totally unbounded and have an
overall limit (of 10000 entries).
2021-08-19 08:54:40 +02:00
Thomas Haller
1abf512831
ifcfg: fix crash due to not setting error on failure to parse DNS
Fixes: c2ad294290 ('ifcfg-rh: fix error handing in some functions that expect error != NULL')
2021-08-17 20:07:34 +02:00
Thomas Haller
02832b03ee
ifcfg/tests: fix evaluating environment variable to regenerate test files
Fixes: 1ae6719cf1 ('ifcfg-rh/tests: evalute environment for $NMTST_IFCFG_RH_UPDATE_EXPECTED only once')
2021-08-17 20:05:25 +02:00
Thomas Haller
f76af50df3
core: merge branch 'th/fix-addr-order-on-assume'
https://bugzilla.redhat.com/show_bug.cgi?id=1988751

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/963
2021-08-17 19:56:39 +02:00
Thomas Haller
7aa4ad0fa2
nmcli/docs: better describe ipv[46].addresses in man nm-settings-nmcli 2021-08-17 19:56:39 +02:00
Thomas Haller
c631aa48f0
platform: capture NMIP[46]Config from platform with correct (reversed) order of IP addresses
Fix the order of IP addresses when assuming devices (service restart).

The order of IP addresses matters to kernel for selection of source IP
address.

If all other properties are equal ([1]), for IPv6, the address added *last*
will be preferred. That is the address you see *first*` in `ip -6 addr show`.
NMPlatform also preserves that order, so the address *first* is the most
important one.

On the other hand, in a connection profile, `ipv6.addresses` lists
addresses in increasing priority (the last address is the primary one).
That is for compatibility with initscripts, which iterates over the
list of addresses and calls `ip addr add` (meaning, the last address
will be added last and is thus preferred by kernel).

As the priority order in the profile is reversed, also the priority
order in NMIP[46]Config is reversed. Fix creating an NMIP[46]Config
instance from platform addresses to honor the priority.

This has real consequences. When restarting NetworkManager, the interface
stays up with the addresses configured in the right order. After
restart, the device gets assumed, which means that the NMIP[46]Config
instance from the connection is not yet set, only the config from the
platform gets synchronized. Previously the order was wrong, so during
restart the order of IP addresses was reverted.

[1] https://access.redhat.com/solutions/189153

https://bugzilla.redhat.com/show_bug.cgi?id=1988751
2021-08-17 19:56:39 +02:00
Thomas Haller
9c99c948fd
platform: add nmp_cache_iter_for_each_reverse() helper 2021-08-17 19:56:38 +02:00
Thomas Haller
53070705b0
glib-aux: clear iterator in nm_dedup_multi_iter_{next,prev}() at the end
It seems slightly nicer not to leave a dangling pointer at the
end of the iteration. Then you could do something like

    nm_dedup_multi_iter_init(&iter, head_entry);
    while (nm_dedup_multi_iter_next(&iter)) {

        if (some_condition())
            break;
    }
    if (!iter.current)
        printf("iterated to the end\n");

As nm_dedup_multi_iter_next() and nm_dedup_multi_iter_init() are inline
functions, the compiler should even be able to see that the initial
setting becomes unnecessary (the field will be initialized by the
first nm_dedup_multi_iter_next()). Likewise, the final clearing
of the field might also be optimized away at the end of the iteration
(if, as in the common case, the iterator is not accessed afterwards).
2021-08-17 19:56:38 +02:00
Thomas Haller
57a519cc03
glib-aux: add nm_dedup_multi_iter_init_reverse() to iterate in reverse order 2021-08-17 19:56:38 +02:00
Ana Cabral
bdaf82ed19 nm-initrd-generator: Merge branch 'al/initrdgenerator-ethtool-docs'
- remove duplex option 

- include man entry for rd.ethtool options

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

!960
2021-08-17 17:51:58 +00:00
Ana Cabral
44a5bdabe9 nm-initrd-generator: include man entry for rd.ethtool options 2021-08-17 12:32:54 -03:00
Ana Cabral
750d35a6e3 nm-initrd-generator: remove duplex option 2021-08-17 12:00:37 -03:00
Javier Sánchez Parra
b0f5b1d97a
tui: add WireGuard support to nmtui
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/736
2021-08-17 14:10:12 +02:00
Thomas Haller
5d0d8f9e3a
platform/netlink: merge branch 'th/netlink-policy-cleanup'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/959
2021-08-17 13:22:12 +02:00
Thomas Haller
76bcd78710
platform/netlink: use appropriate integer types in nla_policy 2021-08-17 13:18:08 +02:00
Thomas Haller
57d626c182
platform/netlink: rework static check in _nl_static_assert_tb() to use _Generic()
Depending on sizeof(policy) to be sizeof(NULL) is not a good check
whether the macro argument may be NULL. That is, because the size
of the policy array might accidentally be the same as the size of
a pointer. Use _Generic() instead.
2021-08-17 13:18:07 +02:00
Thomas Haller
fa745181dc
platform/netlink: drop unused NLA_NUL_STRING type
Kernel implemente NLA_NUL_STRING type, but we don't implement
exactly the same type checks. Drop NLA_NUL_STRING and use a plain
NLA_STRING instead.
2021-08-17 13:18:07 +02:00
Thomas Haller
f7635c9ffe
platform/netlink: use switch for type check in validate_nla() 2021-08-17 13:18:07 +02:00
Thomas Haller
68a5d1cfe5
platform/netlink: refactor handling length in validate_nla() 2021-08-17 13:18:07 +02:00
Thomas Haller
6f1274caea
platform/netlink: return uint16_t type from nla_len()
nla_len() cannot return anything larger or smaller than range uint16_t.
Change the return type of nla_len().
2021-08-17 13:18:07 +02:00