summaryrefslogtreecommitdiffstats
path: root/source/n/dhcpcd/patches/dhcpcd.2fae4a113c3e736d585dd300ca6c8fddae300503.patch
blob: 8f6a0075aa235e5a6feced2f99f8f6ccafd58555 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
From 2fae4a113c3e736d585dd300ca6c8fddae300503 Mon Sep 17 00:00:00 2001
From: Roy Marples <roy@marples.name>
Date: Tue, 31 Aug 2021 10:57:44 +0100
Subject: [PATCH] DHCP6: Only send FQDN for SOLICIT, REQUEST, RENEW, or REBIND messages.

As per RFC 4704 section 5.
Fixes #44.
---
 src/dhcp6.c |   79 +++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 45 insertions(+), 34 deletions(-)

diff --git a/src/dhcp6.c b/src/dhcp6.c
index f355418..9c818b3 100644
--- a/src/dhcp6.c
+++ b/src/dhcp6.c
@@ -637,7 +637,7 @@ dhcp6_makemessage(struct interface *ifp)
 	uint8_t type;
 	uint16_t si_len, uni_len, n_options;
 	uint8_t *o_lenp;
-	struct if_options *ifo;
+	struct if_options *ifo = ifp->options;
 	const struct dhcp_opt *opt, *opt2;
 	const struct ipv6_addr *ap;
 	char hbuf[HOSTNAME_MAX_LEN + 1];
@@ -658,8 +658,50 @@ dhcp6_makemessage(struct interface *ifp)
 		state->send = NULL;
 	}
 
-	ifo = ifp->options;
-	fqdn = ifo->fqdn;
+	switch(state->state) {
+	case DH6S_INIT: /* FALLTHROUGH */
+	case DH6S_DISCOVER:
+		type = DHCP6_SOLICIT;
+		break;
+	case DH6S_REQUEST:
+		type = DHCP6_REQUEST;
+		break;
+	case DH6S_CONFIRM:
+		type = DHCP6_CONFIRM;
+		break;
+	case DH6S_REBIND:
+		type = DHCP6_REBIND;
+		break;
+	case DH6S_RENEW:
+		type = DHCP6_RENEW;
+		break;
+	case DH6S_INFORM:
+		type = DHCP6_INFORMATION_REQ;
+		break;
+	case DH6S_RELEASE:
+		type = DHCP6_RELEASE;
+		break;
+	case DH6S_DECLINE:
+		type = DHCP6_DECLINE;
+		break;
+	default:
+		errno = EINVAL;
+		return -1;
+	}
+
+	/* RFC 4704 Section 5 says we can only send FQDN for these
+	 * message types. */
+	switch(type) {
+	case DHCP6_SOLICIT:
+	case DHCP6_REQUEST:
+	case DHCP6_RENEW:
+	case DHCP6_REBIND:
+		fqdn = ifo->fqdn;
+		break;
+	default:
+		fqdn = FQDN_DISABLE;
+		break;
+	}
 
 	if (fqdn == FQDN_DISABLE && ifo->options & DHCPCD_HOSTNAME) {
 		/* We're sending the DHCPv4 hostname option, so send FQDN as
@@ -823,37 +865,6 @@ dhcp6_makemessage(struct interface *ifp)
 	}
 
 	switch(state->state) {
-	case DH6S_INIT: /* FALLTHROUGH */
-	case DH6S_DISCOVER:
-		type = DHCP6_SOLICIT;
-		break;
-	case DH6S_REQUEST:
-		type = DHCP6_REQUEST;
-		break;
-	case DH6S_CONFIRM:
-		type = DHCP6_CONFIRM;
-		break;
-	case DH6S_REBIND:
-		type = DHCP6_REBIND;
-		break;
-	case DH6S_RENEW:
-		type = DHCP6_RENEW;
-		break;
-	case DH6S_INFORM:
-		type = DHCP6_INFORMATION_REQ;
-		break;
-	case DH6S_RELEASE:
-		type = DHCP6_RELEASE;
-		break;
-	case DH6S_DECLINE:
-		type = DHCP6_DECLINE;
-		break;
-	default:
-		errno = EINVAL;
-		return -1;
-	}
-
-	switch(state->state) {
 	case DH6S_REQUEST: /* FALLTHROUGH */
 	case DH6S_RENEW:   /* FALLTHROUGH */
 	case DH6S_RELEASE:
-- 
1.7.1