Skip to content

Commit

Permalink
Review fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pawsten committed Sep 28, 2023
1 parent ae4f0fd commit 6a1b063
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions libebpfdiscovery/src/IpAddressChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static void logErrorFromErrno(std::string_view prefix) {
std::cout << prefix << ": " << strerror(errno) << "\n";
}

static int sendIpAddrRequest(int fd, sockaddr_nl* sa, int domain) {
static int sendIpAddrRequest(int fd, sockaddr_nl* dst, int domain) {
std::array<char, BUFFLEN> buf{};

nlmsghdr* nl;
Expand All @@ -44,7 +44,7 @@ static int sendIpAddrRequest(int fd, sockaddr_nl* sa, int domain) {
ifa->ifa_family = domain; // ipv4 or ipv6

iovec iov = {nl, nl->nlmsg_len};
msghdr msg = {sa, sizeof(*sa), &iov, 1, NULL, 0, 0};
msghdr msg = {dst, sizeof(*dst), &iov, 1, NULL, 0, 0};

return sendmsg(fd, &msg, 0);
}
Expand All @@ -62,7 +62,7 @@ static void addNetlinkMsg(nlmsghdr* nh, int type, const void* data, int dataLen)
memcpy(RTA_DATA(rta), data, dataLen);
}

static int sendBridgesRequest(int fd, sockaddr_nl* sa, int domain) {
static int sendBridgesRequest(int fd, sockaddr_nl* dst, int domain) {
struct {
struct nlmsghdr n;
struct ifinfomsg i;
Expand All @@ -84,20 +84,20 @@ static int sendBridgesRequest(int fd, sockaddr_nl* sa, int domain) {
linkinfo->rta_len = (int)((char*)&r.n + NLMSG_ALIGN(r.n.nlmsg_len) - (char*)linkinfo);

iovec iov = {&r.n, r.n.nlmsg_len};
msghdr msg = {sa, sizeof(*sa), &iov, 1, NULL, 0, 0};
msghdr msg = {dst, sizeof(*dst), &iov, 1, NULL, 0, 0};

return sendmsg(fd, &msg, 0);
}


static int receive(int fd, sockaddr_nl* sa, void* buf, size_t len) {
static int receive(int fd, sockaddr_nl* dst, void* buf, size_t len) {
iovec iov;
msghdr msg {};
iov.iov_base = buf;
iov.iov_len = len;

msg.msg_name = sa;
msg.msg_namelen = sizeof(*sa);
msg.msg_name = dst;
msg.msg_namelen = sizeof(*dst);
msg.msg_iov = &iov;
msg.msg_iovlen = 1;

Expand Down Expand Up @@ -206,7 +206,6 @@ static bool handleNetlink(S send, P parse, int domain) {
}

nlMsgType = parseNlMsg(buf.data(), len, parse);

} while (nlMsgType != NLMSG_DONE && nlMsgType != NLMSG_ERROR);

return true;
Expand Down

0 comments on commit 6a1b063

Please sign in to comment.