diff options
| author | Roy Marples <roy@marples.name> | 2017-04-22 22:09:08 +0100 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2017-04-23 00:34:29 +0100 |
| commit | 9049f85750ecb4ae9ab50ccae401a5e0e2a1a230 (patch) | |
| tree | 3b94e98d07d8a25ac97ae8139a480832840956dc /src/dhcpcd.c | |
| parent | 9b04fabf77cdc6daff576c83d53c5833738d63d3 (diff) | |
| download | dhcpcd-9049f85750ecb4ae9ab50ccae401a5e0e2a1a230.tar.xz | |
Detect VLANID to use in IAID.
Summary:
This only works if the VLAN interface has already been setup prior
to starting dhcpcd.
Initial fix for T115.
Test Plan:
Configure a vlan interface.
Don't set any iaid in /etc/dhcpcd.conf.
Start dhcpcd, check VLANID is used for IAID.
Reviewers: sthen
Reviewed By: sthen
Tags: #dhcpcd
Differential Revision: https://dev.marples.name/D107
Diffstat (limited to 'src/dhcpcd.c')
| -rw-r--r-- | src/dhcpcd.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/dhcpcd.c b/src/dhcpcd.c index bc79610e..ac6c6ba9 100644 --- a/src/dhcpcd.c +++ b/src/dhcpcd.c @@ -477,6 +477,10 @@ configure_interface1(struct interface *ifp) * between reboots without persitent storage, * generating the IAID from the MAC address is the only * logical default. + * Saying that, if a VLANID has been specified then we + * can use that. It's possible that different interfaces + * can have the same VLANID, but this is no worse than + * generating the IAID from the duplicate MAC address. * * dhclient uses the last 4 bytes of the MAC address. * dibbler uses an increamenting counter. @@ -487,11 +491,18 @@ configure_interface1(struct interface *ifp) * dhcpcd-6.1.0 and earlier used the interface name, * falling back to interface index if name > 4. */ - if (ifp->hwlen >= sizeof(ifo->iaid)) + if (ifp->vlanid != 0) { + uint32_t vlanid; + + /* Maximal VLANID is 4095, so prefix with 0xff + * so we don't conflict with an interface index. */ + vlanid = htonl(ifp->vlanid | 0xff000000); + memcpy(ifo->iaid, &vlanid, sizeof(vlanid)); + } else if (ifp->hwlen >= sizeof(ifo->iaid)) { memcpy(ifo->iaid, ifp->hwaddr + ifp->hwlen - sizeof(ifo->iaid), sizeof(ifo->iaid)); - else { + } else { uint32_t len; len = (uint32_t)strlen(ifp->name); @@ -503,7 +514,7 @@ configure_interface1(struct interface *ifp) } else { /* IAID is the same size as a uint32_t */ len = htonl(ifp->index); - memcpy(ifo->iaid, &len, sizeof(len)); + memcpy(ifo->iaid, &len, sizeof(ifo->iaid)); } } ifo->options |= DHCPCD_IAID; |
