Skip to content

Commit

Permalink
check recv err and improve send error message
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers committed Dec 16, 2024
1 parent 18ccbb5 commit 93fed4a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/net/linux/addrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ int net_netlink_addrs(net_ifaddr_h *ifh, void *arg)

if (send(sock, &req, req.nlh.nlmsg_len, 0) < 0) {
err = errno;
DEBUG_WARNING("sendto failed %m\n", err);
DEBUG_WARNING("GETLINK send failed %m\n", err);
goto out;
}

Expand All @@ -174,6 +174,12 @@ int net_netlink_addrs(net_ifaddr_h *ifh, void *arg)
break;
}

if (len < 0) {
err = errno;
DEBUG_WARNING("GETLINK recv failed %m\n", err);
goto out;
}

/* GETADDR */
memset(&req, 0, sizeof(req));
req.nlh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg));
Expand All @@ -182,7 +188,7 @@ int net_netlink_addrs(net_ifaddr_h *ifh, void *arg)

if (send(sock, &req, req.nlh.nlmsg_len, 0) < 0) {
err = errno;
DEBUG_WARNING("sendto failed %m\n", err);
DEBUG_WARNING("GETADDR send failed %m\n", err);
goto out;
}

Expand All @@ -192,6 +198,11 @@ int net_netlink_addrs(net_ifaddr_h *ifh, void *arg)
break;
}

if (len < 0) {
err = errno;
DEBUG_WARNING("GETADDR recv failed %m\n", err);
}

out:
close(sock);

Expand Down

0 comments on commit 93fed4a

Please sign in to comment.