diff options
| author | Roy Marples <roy@marples.name> | 2019-03-14 00:17:26 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2019-03-14 00:17:26 +0000 |
| commit | 3e3ef397a1141157f29f104bb42b725cc31ae398 (patch) | |
| tree | 5a3d6d327a9fb39bd2e7e5d0c1424d68b738c9f9 /src/dhcpcd.c | |
| parent | 3ed3eb1c89f7267323d69e7a7922a771dc87fa2e (diff) | |
| download | dhcpcd-3e3ef397a1141157f29f104bb42b725cc31ae398.tar.xz | |
options: add link_rcvbuf variable
Sets SO_RCVBUF on the link socket to the designated size.
On a busy system this can be inflated to avoid buffer overflow.
However, dhcpcd *will* cope fine with overflow on NetBSD, OpenBSD
and Linux with a call to getifaddrs(3), but that might be too
heavy weight depending on the libc implementation as most
don't report address flags via this method.
Diffstat (limited to 'src/dhcpcd.c')
| -rw-r--r-- | src/dhcpcd.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/dhcpcd.c b/src/dhcpcd.c index f7927140..8986a9b4 100644 --- a/src/dhcpcd.c +++ b/src/dhcpcd.c @@ -1128,6 +1128,22 @@ dhcpcd_checkcarrier(void *arg) dhcpcd_handlecarrier(ifp->ctx, LINK_UNKNOWN, ifp->flags, ifp->name); } +#ifndef SMALL +static void +dhcpcd_setlinkrcvbuf(struct dhcpcd_ctx *ctx) +{ + socklen_t socklen; + + if (ctx->link_rcvbuf == 0) + return; + + socklen = sizeof(ctx->link_rcvbuf); + if (setsockopt(ctx->link_fd, SOL_SOCKET, + SO_RCVBUF, &ctx->link_rcvbuf, socklen) == -1) + logerr(__func__); +} +#endif + void dhcpcd_linkoverflow(struct dhcpcd_ctx *ctx) { @@ -1148,6 +1164,9 @@ dhcpcd_linkoverflow(struct dhcpcd_ctx *ctx) eloop_exit(ctx->eloop, EXIT_FAILURE); return; } +#ifndef SMALL + dhcpcd_setlinkrcvbuf(ctx); +#endif eloop_event_add(ctx->eloop, ctx->link_fd, dhcpcd_handlelink, ctx); /* Work out the current interfaces. */ @@ -1993,6 +2012,9 @@ printpidfile: logerr("%s: if_opensockets", __func__); goto exit_failure; } +#ifndef SMALL + dhcpcd_setlinkrcvbuf(&ctx); +#endif /* When running dhcpcd against a single interface, we need to retain * the old behaviour of waiting for an IP address */ |
