summaryrefslogtreecommitdiffstats
path: root/src/dhcpcd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2020-04-23 14:15:41 +0000
committerRoy Marples <roy@marples.name>2020-04-23 14:15:41 +0000
commitb18431f9b8feff00fdd9d71532c38723eaf9aad8 (patch)
treebc46aa14bf60a57da0ed5b6f923cd98741377555 /src/dhcpcd.c
parent3863f7bd6b991cc27ee29c764dab12b8902c61e4 (diff)
downloaddhcpcd-b18431f9b8feff00fdd9d71532c38723eaf9aad8.tar.xz
if: support changing hardware address type on Linux
Diffstat (limited to 'src/dhcpcd.c')
-rw-r--r--src/dhcpcd.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/dhcpcd.c b/src/dhcpcd.c
index 0059f47b..fa52fdfc 100644
--- a/src/dhcpcd.c
+++ b/src/dhcpcd.c
@@ -1208,17 +1208,12 @@ dhcpcd_linkoverflow(struct dhcpcd_ctx *ctx)
}
void
-dhcpcd_handlehwaddr(struct dhcpcd_ctx *ctx, const char *ifname,
- const void *hwaddr, uint8_t hwlen)
+dhcpcd_handlehwaddr(struct interface *ifp,
+ uint16_t hwtype, const void *hwaddr, uint8_t hwlen)
{
- struct interface *ifp;
char buf[sizeof(ifp->hwaddr) * 3];
- ifp = if_find(ctx->ifaces, ifname);
- if (ifp == NULL)
- return;
-
- if (!if_valid_hwaddr(hwaddr, hwlen))
+ if (hwaddr == NULL || !if_valid_hwaddr(hwaddr, hwlen))
hwlen = 0;
if (hwlen > sizeof(ifp->hwaddr)) {
@@ -1227,7 +1222,14 @@ dhcpcd_handlehwaddr(struct dhcpcd_ctx *ctx, const char *ifname,
return;
}
- if (ifp->hwlen == hwlen && memcmp(ifp->hwaddr, hwaddr, hwlen) == 0)
+ if (ifp->hwtype != hwtype) {
+ loginfox("%s: hardware address type changed from %d to %d",
+ ifp->name, ifp->hwtype, hwtype);
+ ifp->hwtype = hwtype;
+ }
+
+ if (ifp->hwlen == hwlen &&
+ (hwlen == 0 || memcmp(ifp->hwaddr, hwaddr, hwlen) == 0))
return;
loginfox("%s: new hardware address: %s", ifp->name,