diff options
-rw-r--r-- | src/mnl.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -218,24 +218,24 @@ void mnl_err_list_free(struct mnl_err *err) xfree(err); } -static int nlbuffsiz; - static void mnl_set_sndbuffer(const struct mnl_socket *nl, struct nftnl_batch *batch) { + socklen_t len = sizeof(int); + int sndnlbuffsiz = 0; int newbuffsiz; - if (nftnl_batch_iovec_len(batch) * BATCH_PAGE_SIZE <= nlbuffsiz) - return; + getsockopt(mnl_socket_get_fd(nl), SOL_SOCKET, SO_SNDBUF, + &sndnlbuffsiz, &len); newbuffsiz = nftnl_batch_iovec_len(batch) * BATCH_PAGE_SIZE; + if (newbuffsiz <= sndnlbuffsiz) + return; /* Rise sender buffer length to avoid hitting -EMSGSIZE */ if (setsockopt(mnl_socket_get_fd(nl), SOL_SOCKET, SO_SNDBUFFORCE, &newbuffsiz, sizeof(socklen_t)) < 0) return; - - nlbuffsiz = newbuffsiz; } static unsigned int nlsndbufsiz; |