Browse Source

add missing patches

Signed-off-by: Toshaan Bharvani <toshaan@powerel.org>
master
Toshaan Bharvani 1 year ago
parent
commit
cf22488fc9
  1. 82
      SOURCES/1004-n-dhcp4-discard-NAKs-from-other-servers-rhbz2067122.patch
  2. 1994
      SOURCES/1005-fix-dhcp-loses-lease-when-restarting-rhbz2094715.patch
  3. 309
      SOURCES/1006-dhcp-routes-src-rh2094778.patch
  4. 48
      SOURCES/1007-platform-workaround-for-preserving-ipv6-address-rhbz2094715.patch
  5. 31
      SOURCES/readme-ifcfg-rh.txt

82
SOURCES/1004-n-dhcp4-discard-NAKs-from-other-servers-rhbz2067122.patch

@ -0,0 +1,82 @@ @@ -0,0 +1,82 @@
From 118561e284ff7f28421b19530d4471075b89645c Mon Sep 17 00:00:00 2001
From: Beniamino Galvani <bgalvani@redhat.com>
Date: Thu, 10 Mar 2022 12:07:49 +0100
Subject: [PATCH] n-dhcp4: discard NAKs from other servers in SELECTING

I got a report of a scenario where multiple servers reply to a REQUEST
in SELECTING, and all servers send NAKs except the one which sent the
offer, which replies with a ACK. In that scenario, n-dhcp4 is not able
to obtain a lease because it restarts from INIT as soon as the first
NAK is received. For comparison, dhclient can get a lease because it
ignores all NAKs in SELECTING.

Arguably, the network is misconfigured there, but it would be great if
n-dhcp4 could still work in such scenario.

According to RFC 2131, ACK and NAK messages from server must contain a
server-id option. The RFC doesn't explicitly say that the client
should check the option, but I think it's a reasonable thing to do, at
least for NAKs.

This patch stores the server-id of the REQUEST in SELECTING, and
compares it with the server-id from NAKs, to discard other servers'
replies.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1144
---
src/n-dhcp4/src/n-dhcp4-c-connection.c | 19 +++++++++++++++++++
src/n-dhcp4/src/n-dhcp4-private.h | 1 +
2 files changed, 20 insertions(+)

diff --git a/src/n-dhcp4/src/n-dhcp4-c-connection.c b/src/n-dhcp4/src/n-dhcp4-c-connection.c
index 4aba97393d..2f660e3b30 100644
--- a/src/n-dhcp4/src/n-dhcp4-c-connection.c
+++ b/src/n-dhcp4/src/n-dhcp4-c-connection.c
@@ -705,6 +705,7 @@ int n_dhcp4_c_connection_select_new(NDhcp4CConnection *connection,
message->userdata.start_time = offer->userdata.start_time;
message->userdata.base_time = offer->userdata.base_time;
message->userdata.client_addr = client.s_addr;
+ message->userdata.server_id = server.s_addr;
n_dhcp4_incoming_get_xid(offer, &xid);
n_dhcp4_outgoing_set_xid(message, xid);
@@ -1224,6 +1225,24 @@ int n_dhcp4_c_connection_dispatch_io(NDhcp4CConnection *connection,
serv_addr, sizeof(serv_addr)));
}
+ if (type == N_DHCP4_MESSAGE_NAK &&
+ connection->request->userdata.server_id != INADDR_ANY) {
+ struct in_addr server;
+
+ r = n_dhcp4_incoming_query_server_identifier(message, &server);
+ if (r)
+ return N_DHCP4_E_AGAIN;
+
+ if (connection->request->userdata.server_id != server.s_addr) {
+ n_dhcp4_log(connection->log_queue,
+ LOG_DEBUG,
+ "discarded NAK with wrong server-id %s",
+ inet_ntop(AF_INET, &server,
+ serv_addr, sizeof(serv_addr)));
+ return N_DHCP4_E_AGAIN;
+ }
+ }
+
switch (type) {
case N_DHCP4_MESSAGE_OFFER:
case N_DHCP4_MESSAGE_ACK:
diff --git a/src/n-dhcp4/src/n-dhcp4-private.h b/src/n-dhcp4/src/n-dhcp4-private.h
index db7b24ff7d..191e946e70 100644
--- a/src/n-dhcp4/src/n-dhcp4-private.h
+++ b/src/n-dhcp4/src/n-dhcp4-private.h
@@ -202,6 +202,7 @@ struct NDhcp4Outgoing {
uint8_t type;
uint8_t message_type;
uint32_t client_addr;
+ uint32_t server_id;
uint64_t start_time;
uint64_t base_time;
uint64_t send_time;
--
2.35.1

1994
SOURCES/1005-fix-dhcp-loses-lease-when-restarting-rhbz2094715.patch

File diff suppressed because it is too large Load Diff

309
SOURCES/1006-dhcp-routes-src-rh2094778.patch

@ -0,0 +1,309 @@ @@ -0,0 +1,309 @@
From 3547c4d09a1d10b150a61bcbdc2418d750f7f616 Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Fri, 1 Apr 2022 08:39:56 +0200
Subject: [PATCH 1/2] dhcp: set "src" for DHCPv4 routes

Let's set the "src" (RTA_PREFSRC) of DHCP routes.
This helps with source address selection.

This can matter if the interface also has static addresses
configured.

Systemd-networkd also does this ([1], [2]).

[1] https://github.com/systemd/systemd/commit/ac2dce5f36bb8b1a877ff765e6a4dfde6bfb2d49
[2] https://github.com/systemd/systemd/blob/5b89bff55f45235f72d30d90fd489fe2247ad00d/src/network/networkd-dhcp4.c#L395

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1173
(cherry picked from commit 2dc7a3d9f9135959adf415405bdcb05a7387c1d4)
(cherry picked from commit 10b9e07bfc3ae044b35a7dc6559aa6a4583bd7e8)
(cherry picked from commit f2942d11a75e5fb0bda35f8b659d0643f1f418b2)
---
src/core/dhcp/nm-dhcp-nettools.c | 16 ++++++++++++----
src/core/dhcp/nm-dhcp-systemd.c | 4 +++-
src/core/dhcp/nm-dhcp-utils.c | 26 +++++++++++++++-----------
3 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/src/core/dhcp/nm-dhcp-nettools.c b/src/core/dhcp/nm-dhcp-nettools.c
index d7fbe3561599..769b0325f23d 100644
--- a/src/core/dhcp/nm-dhcp-nettools.c
+++ b/src/core/dhcp/nm-dhcp-nettools.c
@@ -154,6 +154,7 @@ static gboolean
lease_parse_address(NDhcp4ClientLease *lease,
NML3ConfigData *l3cd,
GHashTable *options,
+ in_addr_t *out_address,
GError **error)
{
struct in_addr a_address;
@@ -268,6 +269,8 @@ lease_parse_address(NDhcp4ClientLease *lease,
.preferred = a_lifetime,
}));
+ NM_SET_OUT(out_address, a_address.s_addr);
+
return TRUE;
}
@@ -326,6 +329,7 @@ lease_parse_address_list(NDhcp4ClientLease *lease,
static void
lease_parse_routes(NDhcp4ClientLease *lease,
NML3ConfigData *l3cd,
+ in_addr_t lease_address,
GHashTable *options,
NMStrBuf *sbuf)
{
@@ -373,10 +377,11 @@ lease_parse_routes(NDhcp4ClientLease *lease,
nm_l3_config_data_add_route_4(l3cd,
&((const NMPlatformIP4Route){
+ .rt_source = NM_IP_CONFIG_SOURCE_DHCP,
.network = dest,
.plen = plen,
.gateway = gateway,
- .rt_source = NM_IP_CONFIG_SOURCE_DHCP,
+ .pref_src = lease_address,
.table_any = TRUE,
.table_coerced = 0,
.metric_any = TRUE,
@@ -416,10 +421,11 @@ lease_parse_routes(NDhcp4ClientLease *lease,
nm_l3_config_data_add_route_4(l3cd,
&((const NMPlatformIP4Route){
+ .rt_source = NM_IP_CONFIG_SOURCE_DHCP,
.network = dest,
.plen = plen,
.gateway = gateway,
- .rt_source = NM_IP_CONFIG_SOURCE_DHCP,
+ .pref_src = lease_address,
.table_any = TRUE,
.table_coerced = 0,
.metric_any = TRUE,
@@ -464,6 +470,7 @@ lease_parse_routes(NDhcp4ClientLease *lease,
&((const NMPlatformIP4Route){
.rt_source = NM_IP_CONFIG_SOURCE_DHCP,
.gateway = gateway,
+ .pref_src = lease_address,
.table_any = TRUE,
.table_coerced = 0,
.metric_any = TRUE,
@@ -547,6 +554,7 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx,
const char *v_str;
guint16 v_u16;
in_addr_t v_inaddr;
+ in_addr_t lease_address;
struct in_addr v_inaddr_s;
int r;
@@ -556,7 +564,7 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx,
options = nm_dhcp_option_create_options_dict();
- if (!lease_parse_address(lease, l3cd, options, error))
+ if (!lease_parse_address(lease, l3cd, options, &lease_address, error))
return NULL;
r = n_dhcp4_client_lease_get_server_identifier(lease, &v_inaddr_s);
@@ -575,7 +583,7 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx,
v_inaddr);
}
- lease_parse_routes(lease, l3cd, options, &sbuf);
+ lease_parse_routes(lease, l3cd, lease_address, options, &sbuf);
lease_parse_address_list(lease, l3cd, NM_DHCP_OPTION_DHCP4_DOMAIN_NAME_SERVER, options, &sbuf);
diff --git a/src/core/dhcp/nm-dhcp-systemd.c b/src/core/dhcp/nm-dhcp-systemd.c
index 0884def35dc6..d17646154f67 100644
--- a/src/core/dhcp/nm-dhcp-systemd.c
+++ b/src/core/dhcp/nm-dhcp-systemd.c
@@ -309,10 +309,11 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx,
nm_l3_config_data_add_route_4(l3cd,
&((const NMPlatformIP4Route){
+ .rt_source = NM_IP_CONFIG_SOURCE_DHCP,
.network = network_net,
.plen = r_plen,
.gateway = r_gateway.s_addr,
- .rt_source = NM_IP_CONFIG_SOURCE_DHCP,
+ .pref_src = a_address.s_addr,
.metric_any = TRUE,
.metric = m,
.table_any = TRUE,
@@ -366,6 +367,7 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx,
&((const NMPlatformIP4Route){
.rt_source = NM_IP_CONFIG_SOURCE_DHCP,
.gateway = a_router[i].s_addr,
+ .pref_src = a_address.s_addr,
.table_any = TRUE,
.table_coerced = 0,
.metric_any = TRUE,
diff --git a/src/core/dhcp/nm-dhcp-utils.c b/src/core/dhcp/nm-dhcp-utils.c
index 4a138086b957..c71796f8bd9d 100644
--- a/src/core/dhcp/nm-dhcp-utils.c
+++ b/src/core/dhcp/nm-dhcp-utils.c
@@ -28,7 +28,8 @@ static gboolean
ip4_process_dhcpcd_rfc3442_routes(const char *iface,
const char *str,
NML3ConfigData *l3cd,
- guint32 *gwaddr)
+ in_addr_t address,
+ guint32 *out_gwaddr)
{
gs_free const char **routes = NULL;
const char **r;
@@ -79,7 +80,7 @@ ip4_process_dhcpcd_rfc3442_routes(const char *iface,
have_routes = TRUE;
if (rt_cidr == 0 && rt_addr == 0) {
/* FIXME: how to handle multiple routers? */
- *gwaddr = rt_route;
+ *out_gwaddr = rt_route;
} else {
_LOG2I(LOGD_DHCP4,
iface,
@@ -91,13 +92,13 @@ ip4_process_dhcpcd_rfc3442_routes(const char *iface,
nm_l3_config_data_add_route_4(
l3cd,
&((const NMPlatformIP4Route){
+ .rt_source = NM_IP_CONFIG_SOURCE_DHCP,
.network = nm_utils_ip4_address_clear_host_address(rt_addr, rt_cidr),
.plen = rt_cidr,
.gateway = rt_route,
- .rt_source = NM_IP_CONFIG_SOURCE_DHCP,
+ .pref_src = address,
.metric_any = TRUE,
.table_any = TRUE,
-
}));
}
}
@@ -158,7 +159,8 @@ static gboolean
ip4_process_dhclient_rfc3442_routes(const char *iface,
const char *str,
NML3ConfigData *l3cd,
- guint32 *gwaddr)
+ in_addr_t address,
+ guint32 *out_gwaddr)
{
gs_free const char **octets = NULL;
const char *const *o;
@@ -182,13 +184,14 @@ ip4_process_dhclient_rfc3442_routes(const char *iface,
have_routes = TRUE;
if (!route.plen) {
/* gateway passed as classless static route */
- *gwaddr = route.gateway;
+ *out_gwaddr = route.gateway;
} else {
char b1[INET_ADDRSTRLEN];
char b2[INET_ADDRSTRLEN];
/* normal route */
route.rt_source = NM_IP_CONFIG_SOURCE_DHCP;
+ route.pref_src = address;
route.table_any = TRUE;
route.table_coerced = 0;
route.metric_any = TRUE;
@@ -212,14 +215,15 @@ static gboolean
ip4_process_classless_routes(const char *iface,
GHashTable *options,
NML3ConfigData *l3cd,
- guint32 *gwaddr)
+ in_addr_t address,
+ guint32 *out_gwaddr)
{
const char *str, *p;
g_return_val_if_fail(options != NULL, FALSE);
g_return_val_if_fail(l3cd != NULL, FALSE);
- *gwaddr = 0;
+ *out_gwaddr = 0;
/* dhcpd/dhclient in Fedora has support for rfc3442 implemented using a
* slightly different format:
@@ -266,10 +270,10 @@ ip4_process_classless_routes(const char *iface,
if (strchr(str, '/')) {
/* dhcpcd format */
- return ip4_process_dhcpcd_rfc3442_routes(iface, str, l3cd, gwaddr);
+ return ip4_process_dhcpcd_rfc3442_routes(iface, str, l3cd, address, out_gwaddr);
}
- return ip4_process_dhclient_rfc3442_routes(iface, str, l3cd, gwaddr);
+ return ip4_process_dhclient_rfc3442_routes(iface, str, l3cd, address, out_gwaddr);
}
static void
@@ -422,7 +426,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx,
/* Routes: if the server returns classless static routes, we MUST ignore
* the 'static_routes' option.
*/
- if (!ip4_process_classless_routes(iface, options, l3cd, &gateway))
+ if (!ip4_process_classless_routes(iface, options, l3cd, address.address, &gateway))
process_classful_routes(iface, options, l3cd);
if (gateway) {
--
2.36.1


From ebfc7c2c58e6125346baf9b530e71b2571dc0c10 Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Wed, 13 Apr 2022 10:43:13 +0200
Subject: [PATCH 2/2] dhcp/dhclient: fix setting "src" attribute for certain
routes

Fixes: 2dc7a3d9f913 ('dhcp: set "src" for DHCPv4 routes')
(cherry picked from commit 197e73ac7c53556b32ff048c9720907be3217487)
(cherry picked from commit 0c6d242dc0b67b6269657acf33bf9d1f0830f0b4)
(cherry picked from commit b0a7dda2eae1493a3a285ed1d08178409266ba07)
---
src/core/dhcp/nm-dhcp-utils.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/core/dhcp/nm-dhcp-utils.c b/src/core/dhcp/nm-dhcp-utils.c
index c71796f8bd9d..35a2c6543759 100644
--- a/src/core/dhcp/nm-dhcp-utils.c
+++ b/src/core/dhcp/nm-dhcp-utils.c
@@ -277,7 +277,10 @@ ip4_process_classless_routes(const char *iface,
}
static void
-process_classful_routes(const char *iface, GHashTable *options, NML3ConfigData *l3cd)
+process_classful_routes(const char *iface,
+ GHashTable *options,
+ NML3ConfigData *l3cd,
+ in_addr_t address)
{
gs_free const char **searches = NULL;
const char **s;
@@ -325,6 +328,7 @@ process_classful_routes(const char *iface, GHashTable *options, NML3ConfigData *
route.plen = 32;
}
route.gateway = rt_route;
+ route.pref_src = address;
route.rt_source = NM_IP_CONFIG_SOURCE_DHCP;
route.table_any = TRUE;
route.table_coerced = 0;
@@ -427,7 +431,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx,
* the 'static_routes' option.
*/
if (!ip4_process_classless_routes(iface, options, l3cd, address.address, &gateway))
- process_classful_routes(iface, options, l3cd);
+ process_classful_routes(iface, options, l3cd, address.address);
if (gateway) {
_LOG2I(LOGD_DHCP4, iface, " gateway %s", _nm_utils_inet4_ntop(gateway, sbuf));
@@ -457,6 +461,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx,
const NMPlatformIP4Route r = {
.rt_source = NM_IP_CONFIG_SOURCE_DHCP,
.gateway = gateway,
+ .pref_src = address.address,
.table_any = TRUE,
.table_coerced = 0,
.metric_any = TRUE,
--
2.36.1

48
SOURCES/1007-platform-workaround-for-preserving-ipv6-address-rhbz2094715.patch

@ -0,0 +1,48 @@ @@ -0,0 +1,48 @@
From 43b27ab2c4735e35d84e6f5c90b8a79e23c05587 Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Thu, 9 Jun 2022 10:00:47 +0200
Subject: [PATCH 1/1] platform: workaround for preserving IPv6 address order

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/ ## 1021
---
src/libnm-platform/nm-platform.c | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/src/libnm-platform/nm-platform.c b/src/libnm-platform/nm-platform.c
index f264ed7a45b2..45534dd96a46 100644
--- a/src/libnm-platform/nm-platform.c
+++ b/src/libnm-platform/nm-platform.c
@@ -3978,11 +3978,26 @@ nm_platform_ip_address_sync(NMPlatform *self,
/* @plat_addresses for IPv6 must be sorted in decreasing priority order (highest priority addresses first).
* IPv4 are probably unsorted or sorted with lowest priority first, but their order doesn't matter because
* we check the "secondary" flag. */
- plat_addresses = nm_platform_lookup_clone(
- self,
- nmp_lookup_init_object(&lookup, NMP_OBJECT_TYPE_IP_ADDRESS(IS_IPv4), ifindex),
- NULL,
- NULL);
+ if (IS_IPv4) {
+ plat_addresses = nm_platform_lookup_clone(
+ self,
+ nmp_lookup_init_object(&lookup, NMP_OBJECT_TYPE_IP_ADDRESS(IS_IPv4), ifindex),
+ NULL,
+ NULL);
+ } else {
+ /* HACK: early 1.36 versions had a bug of not actually reordering the IPv6 addresses.
+ * This was fixed by commit cd4601802de5 ('platform: fix address order in
+ * nm_platform_ip_address_sync()').
+ *
+ * However, also in 1.36, the actually implemented order of IPv6 addresses is not
+ * the one we want ([1]). So disable the fix again, to not reorder IPv6 addresses.
+ *
+ * The effect is, that DHCPv6 addresses end up being preferred over SLAAC, because
+ * they get added later during activation. Of course, if any address gets added
+ * even later (like a new router appearing), then the order will be wrong again.
+ *
+ * [1] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1021 */
+ }
if (nm_g_ptr_array_len(plat_addresses) > 0) {
/* Delete addresses that interfere with our intended order. */
--
2.36.1

31
SOURCES/readme-ifcfg-rh.txt

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
NetworkManager stores new network profiles in keyfile format in the
/etc/NetworkManager/system-connections/ directory.

Previously, NetworkManager stored network profiles in ifcfg format
in this directory (/etc/sysconfig/network-scripts/). However, the ifcfg
format is deprecated. By default, NetworkManager no longer creates
new profiles in this format.

Connection profiles in keyfile format have many benefits. For example,
this format is INI file-based and can easily be parsed and generated.

Each section in NetworkManager keyfiles corresponds to a NetworkManager
setting name as described in the nm-settings(5) and nm-settings-keyfile(5)
man pages. Each key-value-pair in a section is one of the properties
listed in the settings specification of the man page.

If you still use network profiles in ifcfg format, consider migrating
them to keyfile format. To migrate all profiles at once, enter:

# nmcli connection migrate

This command migrates all profiles from ifcfg format to keyfile
format and stores them in /etc/NetworkManager/system-connections/.

Alternatively, to migrate only a specific profile, enter:

# nmcli connection migrate <profile_name|UUID|D-Bus_path>

For further details, see:
* nm-settings-keyfile(5)
* nmcli(1)
Loading…
Cancel
Save