dhcp/0013-DHCPv6-over-PPP-support-626514.patch
Petr Šabata 5da03fab07 RHEL 9.0.0 Alpha bootstrap
The content of this branch was automatically imported from Fedora ELN
with the following as its source:
https://src.fedoraproject.org/rpms/dhcp#8c5f5bc2cd759f3ad6cfbbfcbd13e93adb16bab3
2020-10-14 23:37:14 +02:00

177 lines
5.9 KiB
Diff

From 234747fbfd6c6429619ba843713d5b39fb4a513d Mon Sep 17 00:00:00 2001
From: Pavel Zhukov <pzhukov@redhat.com>
Date: Thu, 21 Feb 2019 10:33:06 +0100
Subject: [PATCH 13/26] DHCPv6 over PPP support (#626514)
Cc: pzhukov@redhat.com
---
client/dhc6.c | 3 ++-
client/dhclient.c | 17 ++++++++++++++---
common/bpf.c | 16 ++++++++++++++++
common/lpf.c | 16 ++++++++++++++++
includes/dhcp.h | 2 ++
includes/dhcpd.h | 2 +-
server/dhcpv6.c | 3 +++
7 files changed, 54 insertions(+), 5 deletions(-)
diff --git a/client/dhc6.c b/client/dhc6.c
index 16a0838..3171828 100644
--- a/client/dhc6.c
+++ b/client/dhc6.c
@@ -5744,7 +5744,8 @@ make_client6_options(struct client_state *client, struct option_state **op,
*/
if ((oc = lookup_option(&dhcpv6_universe, *op,
D6O_CLIENTID)) == NULL) {
- if (!option_cache(&oc, &default_duid, NULL, clientid_option,
+ if (default_duid.len == 0 ||
+ !option_cache(&oc, &default_duid, NULL, clientid_option,
MDL))
log_fatal("Failure assembling a DUID.");
diff --git a/client/dhclient.c b/client/dhclient.c
index 5d3f5bc..301132c 100644
--- a/client/dhclient.c
+++ b/client/dhclient.c
@@ -1202,8 +1202,8 @@ main(int argc, char **argv) {
if (default_duid.buffer != NULL)
data_string_forget(&default_duid, MDL);
- form_duid(&default_duid, MDL);
- write_duid(&default_duid);
+ if (form_duid(&default_duid, MDL) == ISC_R_SUCCESS)
+ write_duid(&default_duid);
}
}
@@ -3956,7 +3956,7 @@ write_options(struct client_state *client, struct option_state *options,
* is not how it is intended. Upcoming rearchitecting the client should
* address this "one daemon model."
*/
-void
+isc_result_t
form_duid(struct data_string *duid, const char *file, int line)
{
struct interface_info *ip;
@@ -3969,6 +3969,15 @@ form_duid(struct data_string *duid, const char *file, int line)
if (ip == NULL)
log_fatal("Impossible condition at %s:%d.", MDL);
+ while (ip && ip->hw_address.hbuf[0] == HTYPE_RESERVED) {
+ /* Try the other interfaces */
+ log_debug("Cannot form default DUID from interface %s.", ip->name);
+ ip = ip->next;
+ }
+ if (ip == NULL) {
+ return ISC_R_UNEXPECTED;
+ }
+
if ((ip->hw_address.hlen == 0) ||
(ip->hw_address.hlen > sizeof(ip->hw_address.hbuf)))
log_fatal("Impossible hardware address length at %s:%d.", MDL);
@@ -4014,6 +4023,8 @@ form_duid(struct data_string *duid, const char *file, int line)
log_info("Created duid %s.", str);
dfree(str, MDL);
}
+
+ return ISC_R_SUCCESS;
}
/* Write the default DUID to the lease store. */
diff --git a/common/bpf.c b/common/bpf.c
index 67b6d64..ffbd09a 100644
--- a/common/bpf.c
+++ b/common/bpf.c
@@ -650,6 +650,22 @@ get_hw_addr(const char *name, struct hardware *hw) {
memcpy(&hw->hbuf[1], LLADDR(sa), sa->sdl_alen);
break;
#endif /* IFT_FDDI */
+#if defined(IFT_PPP)
+ case IFT_PPP:
+ if (local_family != AF_INET6)
+ log_fatal("Unsupported device type %d for \"%s\"",
+ sa->sdl_type, name);
+ hw->hlen = 0;
+ hw->hbuf[0] = HTYPE_RESERVED;
+ /* 0xdeadbeef should never occur on the wire,
+ * and is a signature that something went wrong.
+ */
+ hw->hbuf[1] = 0xde;
+ hw->hbuf[2] = 0xad;
+ hw->hbuf[3] = 0xbe;
+ hw->hbuf[4] = 0xef;
+ break;
+#endif
default:
log_fatal("Unsupported device type %d for \"%s\"",
sa->sdl_type, name);
diff --git a/common/lpf.c b/common/lpf.c
index 82a279b..b0ed01c 100644
--- a/common/lpf.c
+++ b/common/lpf.c
@@ -563,6 +563,22 @@ get_hw_addr(const char *name, struct hardware *hw) {
hw->hbuf[0] = HTYPE_FDDI;
memcpy(&hw->hbuf[1], sa->sa_data, 6);
break;
+#if defined(ARPHRD_PPP)
+ case ARPHRD_PPP:
+ if (local_family != AF_INET6)
+ log_fatal("Unsupported device type %d for \"%s\"",
+ sa->sa_family, name);
+ hw->hlen = 0;
+ hw->hbuf[0] = HTYPE_RESERVED;
+ /* 0xdeadbeef should never occur on the wire,
+ * and is a signature that something went wrong.
+ */
+ hw->hbuf[1] = 0xde;
+ hw->hbuf[2] = 0xad;
+ hw->hbuf[3] = 0xbe;
+ hw->hbuf[4] = 0xef;
+ break;
+#endif
default:
log_fatal("Unsupported device type %ld for \"%s\"",
(long int)sa->sa_family, name);
diff --git a/includes/dhcp.h b/includes/dhcp.h
index 95bf539..4cc547a 100644
--- a/includes/dhcp.h
+++ b/includes/dhcp.h
@@ -80,6 +80,8 @@ struct dhcp_packet {
* is no standard for this so we
* just steal a type */
+#define HTYPE_RESERVED 0 /* RFC 5494 */
+
/* Magic cookie validating dhcp options field (and bootp vendor
extensions field). */
#define DHCP_OPTIONS_COOKIE "\143\202\123\143"
diff --git a/includes/dhcpd.h b/includes/dhcpd.h
index 2ac39ae..faa9251 100644
--- a/includes/dhcpd.h
+++ b/includes/dhcpd.h
@@ -3051,7 +3051,7 @@ void client_dns_remove(struct client_state *client, struct iaddr *addr);
void dhcpv4_client_assignments(void);
void dhcpv6_client_assignments(void);
-void form_duid(struct data_string *duid, const char *file, int line);
+isc_result_t form_duid(struct data_string *duid, const char *file, int line);
void dhcp4o6_start(void);
diff --git a/server/dhcpv6.c b/server/dhcpv6.c
index a7110f9..c5ce7e8 100644
--- a/server/dhcpv6.c
+++ b/server/dhcpv6.c
@@ -482,6 +482,9 @@ generate_new_server_duid(void) {
if (p->hw_address.hlen > 0) {
break;
}
+ if (p->next == NULL && p->hw_address.hbuf[0] == HTYPE_RESERVED) {
+ log_error("Can not generate DUID from interfaces which do not have hardware addresses, please configure server-duid!");
+ }
}
if (p == NULL) {
return ISC_R_UNEXPECTED;
--
2.14.5