summaryrefslogtreecommitdiffstats
path: root/src/if.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2018-03-19 15:39:05 +0000
committerRoy Marples <roy@marples.name>2018-03-19 15:39:05 +0000
commit1437db1d25f09c5235ed792bd278ee3f0f17dd65 (patch)
treedecb2c14336f00dff8f505e394e099ec8a2c40ba /src/if.c
parent81edfe77f1ab8c5e9d5761fda73506d2a28710fb (diff)
downloaddhcpcd-1437db1d25f09c5235ed792bd278ee3f0f17dd65.tar.xz
link: detect buffer overflow / desync and relearn interface state
It's possible for the internal kernel buffer that reports network events to overflow. On Linux and NetBSD* this is handled by ENOBUFS being returned by recv(2). On OpenBSD there is a special route(4) message RTM_DESYNC. All other OS's don't seem to report this error, so dhcpcd cannot detect it. * I will commit a patch to NetBSD soon for this and will request a pullup to NetBSD-8.
Diffstat (limited to 'src/if.c')
-rw-r--r--src/if.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/if.c b/src/if.c
index e3641ac6..208da245 100644
--- a/src/if.c
+++ b/src/if.c
@@ -191,6 +191,21 @@ if_hasconf(struct dhcpcd_ctx *ctx, const char *ifname)
}
void
+if_markaddrsstale(struct if_head *ifs)
+{
+ struct interface *ifp;
+
+ TAILQ_FOREACH(ifp, ifs, next) {
+#ifdef INET
+ ipv4_markaddrsstale(ifp);
+#endif
+#ifdef INET6
+ ipv6_markaddrsstale(ifp, 0);
+#endif
+ }
+}
+
+void
if_learnaddrs(struct dhcpcd_ctx *ctx, struct if_head *ifs,
struct ifaddrs **ifaddrs)
{
@@ -268,6 +283,21 @@ if_learnaddrs(struct dhcpcd_ctx *ctx, struct if_head *ifs,
*ifaddrs = NULL;
}
+void
+if_deletestaleaddrs(struct if_head *ifs)
+{
+ struct interface *ifp;
+
+ TAILQ_FOREACH(ifp, ifs, next) {
+#ifdef INET
+ ipv4_deletestaleaddrs(ifp);
+#endif
+#ifdef INET6
+ ipv6_deletestaleaddrs(ifp);
+#endif
+ }
+}
+
bool
if_valid_hwaddr(const uint8_t *hwaddr, size_t hwlen)
{