Package: wide-dhcpv6 / 20080615-22

0007-Adding-ifid-option-to-the-dhcp6c.conf-prefix-interfa.patch Patch series | download
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
From: =?utf-8?q?Bj=C3=B8rn_Mork?= <bjorn@mork.no>
Date: Wed, 10 Nov 2010 07:41:55 +0100
Subject: Adding ifid option to the dhcp6c.conf prefix-interface statement
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit

This adds the ability to override the default EUI-64 address selection.
Useful for interfaces without a unique hardware address, or for creating
more userfriendly addresses in general.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Jeremie Corbier <jeremie@famille-corbier.net>
---
 cfparse.y     | 10 +++++++++-
 cftoken.l     |  1 +
 config.c      | 19 ++++++++++++++-----
 config.h      |  2 +-
 dhcp6c.conf.5 | 10 ++++++++++
 5 files changed, 35 insertions(+), 7 deletions(-)

diff --git a/cfparse.y b/cfparse.y
index c79d131..e83ecf7 100644
--- a/cfparse.y
+++ b/cfparse.y
@@ -104,7 +104,7 @@ static void cleanup_cflist __P((struct cf_list *));
 
 %token INTERFACE IFNAME
 %token PROFILE PROFILENAME
-%token PREFIX_INTERFACE SLA_ID SLA_LEN DUID_ID
+%token PREFIX_INTERFACE SLA_ID SLA_LEN IFID DUID_ID
 %token ID_ASSOC IA_PD IAID IA_NA
 %token ADDRESS
 %token REQUEST SEND ALLOW PREFERENCE
@@ -1056,6 +1056,14 @@ ifparam:
 			l->num = $2;
 			$$ = l;
 		}
+	|	IFID NUMBER EOS
+		{
+			struct cf_list *l;
+
+			MAKE_CFLIST(l, IFPARAM_IFID, NULL, NULL);
+			l->num = (u_int64_t)$2;
+			$$ = l;
+		}
 	;
 
 ianaconf_list:
diff --git a/cftoken.l b/cftoken.l
index 4c9ed10..6afda5f 100644
--- a/cftoken.l
+++ b/cftoken.l
@@ -240,6 +240,7 @@ ecl		\}
 <S_CNF>prefix-interface { DECHO; BEGIN S_IFACE; return (PREFIX_INTERFACE); }
 <S_CNF>sla-id { DECHO; return (SLA_ID); }
 <S_CNF>sla-len { DECHO; return (SLA_LEN); }
+<S_CNF>ifid { DECHO; return (IFID); }
 
 	/* duration */
 <S_CNF>infinity { DECHO; return (INFINITY); }
diff --git a/config.c b/config.c
index 23598fc..e04d6a5 100644
--- a/config.c
+++ b/config.c
@@ -471,6 +471,7 @@ add_pd_pif(iapdc, cfl0)
 {
 	struct cf_list *cfl;
 	struct prefix_ifconf *pif;
+	int i, use_default_ifid = 1;
 
 	/* duplication check */
 	for (pif = TAILQ_FIRST(&iapdc->iapd_pif_list); pif;
@@ -504,11 +505,6 @@ add_pd_pif(iapdc, cfl0)
 
 	pif->ifid_len = IFID_LEN_DEFAULT;
 	pif->sla_len = SLA_LEN_DEFAULT;
-	if (get_default_ifid(pif)) {
-		debug_printf(LOG_NOTICE, FNAME,
-		    "failed to get default IF ID for %s", pif->ifname);
-		goto bad;
-	}
 
 	for (cfl = cfl0->list; cfl; cfl = cfl->next) {
 		switch(cfl->type) {
@@ -524,6 +520,11 @@ add_pd_pif(iapdc, cfl0)
 				goto bad;
 			}
 			break;
+		case IFPARAM_IFID:
+			for (i = sizeof(pif->ifid) -1; i >= 0; i--)
+				pif->ifid[i] = (cfl->num >> 8*(sizeof(pif->ifid) - 1 - i)) & 0xff;
+			use_default_ifid = 0;
+			break;
 		default:
 			debug_printf(LOG_ERR, FNAME, "%s:%d internal error: "
 			    "invalid configuration",
@@ -532,6 +533,14 @@ add_pd_pif(iapdc, cfl0)
 		}
 	}
 
+	if (use_default_ifid) {
+		if (get_default_ifid(pif)) {
+			debug_printf(LOG_NOTICE, FNAME,
+			    "failed to get default IF ID for %s", pif->ifname);
+			goto bad;
+		}
+	}
+
 	TAILQ_INSERT_TAIL(&iapdc->iapd_pif_list, pif, link);
 	return (0);
 
diff --git a/config.h b/config.h
index ea8d17c..64ce9e8 100644
--- a/config.h
+++ b/config.h
@@ -266,7 +266,7 @@ enum { DECL_SEND, DECL_ALLOW, DECL_INFO_ONLY, DECL_REQUEST, DECL_DUID,
        DECL_PREFIX, DECL_PREFERENCE, DECL_SCRIPT, DECL_DELAYEDKEY,
        DECL_ADDRESS,
        DECL_RANGE, DECL_ADDRESSPOOL,
-       IFPARAM_SLA_ID, IFPARAM_SLA_LEN,
+       IFPARAM_SLA_ID, IFPARAM_SLA_LEN, IFPARAM_IFID,
        DHCPOPT_RAPID_COMMIT, DHCPOPT_AUTHINFO,
        DHCPOPT_DNS, DHCPOPT_DNSNAME,
        DHCPOPT_IA_PD, DHCPOPT_IA_NA, DHCPOPT_NTP,
diff --git a/dhcp6c.conf.5 b/dhcp6c.conf.5
index 3d5d25a..1c91d72 100644
--- a/dhcp6c.conf.5
+++ b/dhcp6c.conf.5
@@ -443,6 +443,16 @@ This statement specifies the length of the SLA ID in bits.
 must be a decimal number between 0 and 128.
 If the length is not specified by this statement,
 the default value 16 will be used.
+.It Xo
+.Ic ifid Ar ID
+;
+.Xc
+This statement specifies the interface id.
+.Ar ID
+must be a decimal integer.  It will be combined with the delegated
+prefix and the sla-id to form a complete interface address.  The
+default is to use the EUI-64 address of the
+.Ar interface .
 .El
 .El
 .\"