<!doctype html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<p style="" class="default-style"><span style="font-family: "courier new", courier;">Glenn Satchell <glenn.satchell@uniq.com.au> writes:</span><br></p>
<p style="" class="default-style"><span style="font-family: "courier new", courier;">> Have you tried 'send dhcp6.ia-prefix 60'.</span></p>
<p style="" class="default-style"><span style="font-family: "courier new", courier;">Yeah, I do not feel the love :)</span></p>
<p style="" class="default-style"><span style="font-family: "courier new", courier;">I have reviewed the source code in client/client.c and client/dhc6.c</span></p>
<p style="" class="default-style"><span style="font-family: "courier new", courier;">only reference to prefix_len_hint is (in dhclient.c, please excuse the crappy code formatting)</span></p>
<p class="default-style"><span style="font-family: "courier new", courier;">[...]<br></span><span style="font-family: "courier new", courier;">int prefix_len_hint = 0; <br></span><span style="font-family: "courier new", courier;">[...]<br></span><span style="font-family: "courier new", courier;">} else if (!strcmp(argv[i], "--prefix-len-hint")) {<br></span><span style="font-family: "courier new", courier;"> if (++i == argc) {</span><br><span style="font-family: "courier new", courier;"> usage(use_noarg, argv[i-1]);</span><br><span style="font-family: "courier new", courier;"> }<br></span><span style="font-family: "courier new", courier;"> errno = 0;</span><br><span style="font-family: "courier new", courier;"> prefix_len_hint = (int)strtol(argv[i], &s, 10);</span><br><span style="font-family: "courier new", courier;"> if (errno || (*s != '\0') || (prefix_len_hint < 0)) {</span><br><span style="font-family: "courier new", courier;"> usage("Invalid value for --prefix-len-hint: %s", </span><span style="font-family: "courier new", courier;">argv[i]);</span><br><span style="font-family: "courier new", courier;"> }</span><br></p>
<p class="default-style"><span style="font-family: "courier new", courier;"><br></span></p>
<p class="default-style"><span style="font-family: "courier new", courier;">This is in the section of code where the command-line options are interpreted.</span></p>
<p class="default-style"><span style="font-family: "courier new", courier;">There is an additional reference in dhc6.c, where the option is used:</span></p>
<p class="default-style"><span style="font-family: "courier new", courier;">extern int prefix_len_hint;<br>[...]<br></span></p>
<p class="default-style"><span style="font-family: "courier new", courier;">dhc6_bare_ia_xx(struct client_state *client, </span><span style="font-family: "courier new", courier;">struct data_string *packet, </span><span style="font-family: "courier new", courier;">int wanted, </span><span style="font-family: "courier new", courier;">u_int16_t ia_type)</span><br><span style="font-family: "courier new", courier;">{<br></span><span style="font-family: "courier new", courier;">[...]<br></span><span style="font-family: "courier new", courier;">/* figure out what type of option we are working with */</span><br></p>
<p class="default-style"><span style="font-family: "courier new", courier;"> switch (ia_type) {</span><br><span style="font-family: "courier new", courier;"> case D6O_IA_NA:</span><br><span style="font-family: "courier new", courier;"> type_string = "IA_NA";</span><br><span style="font-family: "courier new", courier;"> type_option = ia_na_option;</span><br><span style="font-family: "courier new", courier;"> len = IA_NA_OFFSET;</span><br><span style="font-family: "courier new", courier;"> break;</span><br><span style="font-family: "courier new", courier;"> case D6O_IA_TA:</span><br><span style="font-family: "courier new", courier;"> type_string = "IA_TA";</span><br><span style="font-family: "courier new", courier;"> type_option = ia_ta_option;</span><br><span style="font-family: "courier new", courier;"> len = IA_TA_OFFSET;</span><br><span style="font-family: "courier new", courier;"> break;</span><br><span style="font-family: "courier new", courier;"> case D6O_IA_PD:</span><br><span style="font-family: "courier new", courier;"> type_string = "IA_PD";</span><br><span style="font-family: "courier new", courier;"> type_option = ia_pd_option;</span><br><span style="font-family: "courier new", courier;"> len = IA_PD_OFFSET;</span><br><span style="font-family: "courier new", courier;"> if (prefix_len_hint > 0) {</span><br><span style="font-family: "courier new", courier;"> len += IASUBOPT_PD_LEN;</span><br><span style="font-family: "courier new", courier;"> }</span><br><span style="font-family: "courier new", courier;"> break;<br></span><span style="font-family: "courier new", courier;"> default:</span><br><span style="font-family: "courier new", courier;"> return (ISC_R_FAILURE);</span><br><span style="font-family: "courier new", courier;">}<br>[...]<br>if (ia_type == D6O_IA_PD && prefix_len_hint > 0) {<br> unsigned char *ptr = ia.buffer->data + IA_NA_OFFSET;<br> putUShort(ptr, D6O_IAPREFIX);<br> ptr += 2;<br> putUShort(ptr, IASUBOPT_PD_LEN);<br> ptr += 2;<br> putUChar(ptr + IASUBOPT_PD_PREFLEN_OFFSET, prefix_len_hint);<br> log_debug("XMT: | | X-- Request prefix ::/%u.", prefix_len_hint);<br>}<br></span><br></p>
<p class="default-style"><span style="font-family: "courier new", courier;">I did a quick recursive grep of every .c file in the source code</span></p>
<p class="default-style"><span style="font-family: "courier new", courier;">find ./ -name *.c -exec echo searching file {} \; -exec grep prefix_len_hint {} \;</span></p>
<p class="default-style"><span style="font-family: "courier new", courier;">and these are the only two places which reference that variable, so it isn't modified elsewhere by a subroutine in another library.</span></p>
<p class="default-style"><span style="font-family: "courier new", courier;">Your proposed hack seems to be the only solution, since it appears development on this software has pretty much ceased (4.4.2's tarballs were dated 2020 and 4.4.2-P1 contained only a security patch. If anyone who does development work on this product is monitoring the mailing list, adding an option to the configuration file, e.g.</span></p>
<p class="default-style"><font face="courier new, courier">request dhcp6.prefix-length 60</font></p>
<p class="default-style"><font face="courier new, courier">would be most helpful to people who have to provide a hint, use NetworkManager in their distribution, and do not want to have to implement/maintain a hack which could potentially break future updates (centos 8, for example, includes 4.3.6 of the dhclient by default).</font><span style="font-family: "courier new", courier;"></span></p>
<p class="default-style"><span style="font-family: "courier new", courier;">Based on your suggestion I implemented this script, and attempted to keep it a bit in line w/ Centos-isms (e.g. configuration stuff in /etc/sysconfig).</span></p>
<p class="default-style"><br></p>
<p class="default-style"><span style="font-family: "courier new", courier;">#! /bin/sh</span></p>
<p class="default-style"><span style="font-family: "courier new", courier;">. /etc/sysconfig/dhclient6</span></p>
<p class="default-style"><span style="font-family: "courier new", courier;">ADDL_OPTIONS=""</span></p>
<p class="default-style"><span style="font-family: "courier new", courier;">if [[ "$@" == *"-6"* && "$@" == *"-P"* ]]; then</span><br><span style="font-family: "courier new", courier;"> ADDL_OPTIONS="--prefix-len-hint $PREFIX_LEN_HINT"</span><br><span style="font-family: "courier new", courier;">fi</span></p>
<p class="default-style"><span style="font-family: "courier new", courier;">exec /sbin/dhclient.exe $ADDL_OPTIONS $@</span><br></p>
<p class="default-style"><span style="font-family: "courier new", courier;"><br></span></p>
<p class="default-style"><span style="font-family: "courier new", courier;">so I will only append the prefix length hint command-line parameter if I see this is a dhcpv6 invocation and prefix length delegation is enabled. the hint variable is in /etc/sysconfig/dhclient6:</span><span style="font-family: "courier new", courier;"></span></p>
<p class="default-style"><span style="font-family: "courier new", courier;">PREFIX_LEN_HINT=60</span></p>
<p class="default-style"><span style="font-family: "courier new", courier;"><br>This is of course less than ideal, since dhclient could require different additional options depending on the interface in question, but without getting into complex scripting to parse the command-line options passed and determine which are switches, options, and names of interfaces (and then look for, say, a /etc/sysconfig/dhclient6-interfacename.conf file for interface-specific options, it will have to do.<br><br>Thanks for your suggestion, I think it is the only option I have at the moment.</span></p>
</body>
</html>