File dhcpv6-1.0.22-correct-DUID-time-generation-and-save-server-DUID.patch of Package dhcpv6
From eacc7053019158c8193426a662ceaf3fbb02f057 Mon Sep 17 00:00:00 2001
From: David Cantrell <dcantrell@redhat.com>
Date: Tue, 16 Sep 2008 09:49:28 -1000
Subject: [PATCH] Correct DUID time generation and save server DUID.
Make sure DUID time generation is since 01-Jan-2008 (the IPv6
epoch, I guess).
We call save_duid() from dhcp6c, but we were not for dhcp6s, so
make sure we do that.
---
src/common.c | 2 +-
src/dhcp6s.c | 7 +++++++
2 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/src/common.c b/src/common.c
index e4616d7..4566ad4 100644
--- a/src/common.c
+++ b/src/common.c
@@ -833,7 +833,7 @@ int get_duid(const char *idfile, const char *ifname, struct duid *duid) {
dp = (struct dhcp6_duid_type1 *) duid->duid_id;
dp->dh6duid1_type = htons(1); /* type 1 */
dp->dh6duid1_hwtype = htons(hwtype);
- t64 = (u_int64_t) (time(NULL));
+ t64 = (u_int64_t) (time(NULL) - 946684800);
dp->dh6duid1_time = htonl((u_long) (t64 & 0xffffffff));
memcpy((void *) (dp + 1), tmpbuf, (len - sizeof(*dp)));
diff --git a/src/dhcp6s.c b/src/dhcp6s.c
index f7faeb5..ecf07e4 100644
--- a/src/dhcp6s.c
+++ b/src/dhcp6s.c
@@ -403,6 +403,9 @@ void server6_init() {
dhcpv6_dprintf(LOG_ERR, "%s" "failed to get a DUID", FNAME);
exit(1);
}
+ if (save_duid(DUID_FILE, device[0], &server_duid)) {
+ dhcpv6_dprintf(LOG_ERR, "%s" "failed to save server ID", FNAME);
+ }
} else {
/* all the interfaces join multicast group */
ifc.ifc_len = sizeof(buff);
@@ -437,6 +440,10 @@ void server6_init() {
FNAME);
exit(1);
}
+ if (save_duid(DUID_FILE, ifr->ifr_name, &server_duid)) {
+ dhcpv6_dprintf(LOG_ERR, "%s" "failed to save server ID",
+ FNAME);
+ }
}
ifinit(ifr->ifr_name);
num_device += 1;
--
1.6.4.2