Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
network:linux: Fix netlink requests
Browse files Browse the repository at this point in the history
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
  • Loading branch information
ceolin committed Sep 10, 2015
1 parent 73565c6 commit 4d4ee81
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions src/lib/comms/sol-network-linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ _on_event(void *data, int nl_socket, unsigned int cond)
static void
_netlink_request(int event)
{
size_t n;
char buf[NLMSG_ALIGN(sizeof(struct nlmsghdr) + sizeof(struct rtgenmsg))] = { 0 };
struct iovec iov = { buf, sizeof(buf) };
struct sockaddr_nl snl = { .nl_family = AF_NETLINK };
Expand All @@ -290,9 +289,6 @@ _netlink_request(int event)
};
struct nlmsghdr *h;
struct rtgenmsg *rt;
char buffer_receive_back[4096]; /* Backing storage for next sol_buffer */
struct sol_buffer buffer_receive = SOL_BUFFER_INIT_FLAGS(buffer_receive_back,
sizeof(buffer_receive_back), SOL_BUFFER_FLAGS_MEMORY_NOT_OWNED);

h = (struct nlmsghdr *)buf;

Expand All @@ -308,22 +304,7 @@ _netlink_request(int event)
if (sendmsg(network->nl_socket, (struct msghdr *)&msg, 0) <= 0)
SOL_WRN("Failed on send message to get the links");

while ((sol_util_fill_buffer(network->nl_socket, &buffer_receive, buffer_receive.capacity)) > 0) {
n = buffer_receive.used;
for (h = buffer_receive.data; NLMSG_OK(h, n); h = NLMSG_NEXT(h, n)) {
if (h->nlmsg_type == NLMSG_DONE)
return;
if (h->nlmsg_type == NLMSG_ERROR) {
SOL_WRN("netlink error");
return;
}
if ((h->nlmsg_type == RTM_NEWLINK) || (h->nlmsg_type == RTM_DELLINK))
_on_link_event(h);
if ((h->nlmsg_type == RTM_NEWADDR) || (h->nlmsg_type == RTM_DELADDR))
_on_addr_event(h);
}
sol_buffer_reset(&buffer_receive);
}
_on_event(network, network->nl_socket, SOL_FD_FLAGS_IN);
}

SOL_API int
Expand Down

0 comments on commit 4d4ee81

Please sign in to comment.