From: Roy Marples Date: Mon, 5 Sep 2016 22:48:08 +0000 (+0000) Subject: More iovec array fixes. X-Git-Tag: v6.11.4~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df46ce682bd37e947e42f695151998cc0ec91b76;p=thirdparty%2Fdhcpcd.git More iovec array fixes. --- diff --git a/if-linux.c b/if-linux.c index 564d0bac..75b3f434 100644 --- a/if-linux.c +++ b/if-linux.c @@ -94,7 +94,7 @@ int if_getssid_wext(const char *ifname, uint8_t *ssid); struct priv { int route_fd; uint32_t route_pid; - struct iovec link_iov[1]; + struct iovec sndrcv_iov[1]; }; /* Broadcast address for IPoIB */ @@ -310,7 +310,7 @@ if_closesockets_os(struct dhcpcd_ctx *ctx) if (ctx->priv != NULL) { priv = (struct priv *)ctx->priv; - free(priv->link_iov[0].iov_base); + free(priv->sndrcv_iov[0].iov_base); close(priv->route_fd); } } @@ -854,10 +854,8 @@ link_netlink(struct dhcpcd_ctx *ctx, struct interface *ifp, int if_handlelink(struct dhcpcd_ctx *ctx) { - struct priv *priv; - priv = (struct priv *)ctx->priv; - return get_netlink(ctx, priv->link_iov, NULL, + return get_netlink(ctx, ctx->iov, NULL, ctx->link_fd, MSG_DONTWAIT, &link_netlink); } @@ -868,7 +866,7 @@ send_netlink(struct dhcpcd_ctx *ctx, struct interface *ifp, { int s, r; struct sockaddr_nl snl; - struct iovec iov; + struct iovec iov[1]; struct msghdr msg; memset(&snl, 0, sizeof(snl)); @@ -888,16 +886,19 @@ send_netlink(struct dhcpcd_ctx *ctx, struct interface *ifp, msg.msg_name = &snl; msg.msg_namelen = sizeof(snl); memset(&iov, 0, sizeof(iov)); - iov.iov_base = hdr; - iov.iov_len = hdr->nlmsg_len; - msg.msg_iov = &iov; + iov[0].iov_base = hdr; + iov[0].iov_len = hdr->nlmsg_len; + msg.msg_iov = iov; msg.msg_iovlen = 1; /* Request a reply */ hdr->nlmsg_flags |= NLM_F_ACK; hdr->nlmsg_seq = (uint32_t)++ctx->seq; if (sendmsg(s, &msg, 0) != -1) { + struct priv *priv; + + priv = (struct priv *)ctx->priv; ctx->sseq = ctx->seq; - r = get_netlink(ctx, ctx->iov, ifp, s, 0, callback); + r = get_netlink(ctx, priv->sndrcv_iov, ifp, s, 0, callback); } else r = -1; if (protocol != NETLINK_ROUTE)