Been working on a patch for dhcp6c. I have gotten to the point where I can collect all the information needed in one place and easily parsable by a script:
grep "prefix allocated" /var/log/dhcpd.log
Mar 23 17:04:09 pfSense dhcp6c[70335]: prefix allocated 2001:db8:4000::/64 iaid=0 ifname=vmx2
Mar 23 17:04:09 pfSense dhcp6c[70335]: prefix allocated 2001:db8:4001::/64 iaid=1 floating=true
Mar 23 17:04:09 pfSense dhcp6c[70335]: prefix allocated 2001:db8:4002::/64 iaid=2 floating=true
Mar 23 17:04:09 pfSense dhcp6c[70335]: prefix allocated 2001:db8:4003::/64 iaid=3 floating=true
Mar 23 17:04:09 pfSense dhcp6c[70335]: prefix allocated 2001:db8:4005::/64 iaid=4 floating=true
Mar 23 17:04:09 pfSense dhcp6c[70335]: prefix allocated 2001:db8:4006::/64 iaid=5 floating=true
Mar 23 17:04:09 pfSense dhcp6c[70335]: prefix allocated 2001:db8:4007::/64 iaid=6 floating=true
Patch is below. Pretty sure it can be optimized further. If any expert in C happens to know why I can't seem to use struct ia *ia's copy of ia->conf->iaid that would save me having to pass the dhcp6_ia struct. I get: prefixconf.c:231:6: error: incomplete definition of type 'struct ia'
diff --git a/dhcp6c_ia.c b/dhcp6c_ia.c
index 9f9ca84..473fc58 100644
--- a/dhcp6c_ia.c
+++ b/dhcp6c_ia.c
@@ -152,7 +152,7 @@ update_ia(iatype, ialist, ifp, serverid, authparam)
case DHCP6_LISTVAL_PREFIX6:
/* add or update the prefix */
iapdc = (struct iapd_conf *)iac;
- if (update_prefix(ia, &siav->val_prefix6,
+ if (update_prefix(ia, &iav->val_ia, &siav->val_prefix6,
&iapdc->iapd_pif_list, ifp, &ia->ctl,
callback)) {
d_printf(LOG_NOTICE, FNAME,
diff --git a/prefixconf.c b/prefixconf.c
index bbb4d6e..582f192 100644
--- a/prefixconf.c
+++ b/prefixconf.c
@@ -119,8 +119,9 @@ extern struct dhcp6_timer *client6_timo __P((void *));
static int pd_ifaddrconf __P((ifaddrconf_cmd_t, struct dhcp6_ifprefix *ifpfx));
int
-update_prefix(ia, pinfo, pifc, dhcpifp, ctlp, callback)
+update_prefix(ia, iinfo, pinfo, pifc, dhcpifp, ctlp, callback)
struct ia *ia;
+ struct dhcp6_ia *iinfo;
struct dhcp6_prefix *pinfo;
struct pifc_list *pifc;
struct dhcp6_if *dhcpifp;
@@ -197,6 +198,7 @@ update_prefix(ia, pinfo, pifc, dhcpifp, ctlp, callback)
in6addr2str(&pinfo->addr, 0), pinfo->plen,
pinfo->pltime, pinfo->vltime);
+ int allocated = 0;
/* update prefix interfaces if necessary */
if (sp->prefix.vltime != 0 && spcreate) {
for (pif = TAILQ_FIRST(iac_pd->pifc_head); pif;
@@ -215,10 +217,21 @@ update_prefix(ia, pinfo, pifc, dhcpifp, ctlp, callback)
continue;
}
+ allocated = 1;
+ d_printf(LOG_INFO, FNAME, "prefix allocated %s/%d iaid=%u ifname=%s",
+ in6addr2str(&pinfo->addr, 0), pinfo->plen,
+ iinfo->iaid,
+ pif->ifname);
add_ifprefix(sp, pinfo, pif);
}
}
+ if (allocated == 0) {
+ d_printf(LOG_INFO, FNAME, "prefix allocated %s/%d iaid=%u floating=true",
+ in6addr2str(&pinfo->addr, 0), pinfo->plen,
+ iinfo->iaid);
+ }
+
/*
* If the new vltime is 0, this prefix immediately expires.
* Otherwise, set up or update the associated timer.
diff --git a/prefixconf.h b/prefixconf.h
index dcff695..3dd5986 100644
--- a/prefixconf.h
+++ b/prefixconf.h
@@ -32,7 +32,7 @@
typedef enum { PREFIX6S_ACTIVE, PREFIX6S_RENEW,
PREFIX6S_REBIND} prefix6state_t;
-extern int update_prefix __P((struct ia *, struct dhcp6_prefix *,
+extern int update_prefix __P((struct ia *, struct dhcp6_ia *, struct dhcp6_prefix *,
struct pifc_list *, struct dhcp6_if *, struct iactl **,
void (*)__P((struct ia *))));
extern int prefix6_add __P((struct dhcp6_if *, struct dhcp6_prefix *,
Next steps for me will be looking at adding a custom DHCPv6 server configuration file field to the UI, like can be done for the interface DHCPv6 client configuration.