[PATCH nft,v2 2/7] mnl: mnl_set_rcvbuffer() skips buffer size update if it is too small

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Check for existing buffer size, if this is larger than the requested new
buffer size, skip the buffer size update.

Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
---
 src/mnl.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/mnl.c b/src/mnl.c
index 288a887df097..a84a6a609333 100644
--- a/src/mnl.c
+++ b/src/mnl.c
@@ -235,8 +235,15 @@ static void mnl_set_sndbuffer(const struct mnl_socket *nl,
 
 static int mnl_set_rcvbuffer(const struct mnl_socket *nl, size_t bufsiz)
 {
+	size_t cur_bufsiz;
+	socklen_t len;
 	int ret;
 
+	ret = getsockopt(mnl_socket_get_fd(nl), SOL_SOCKET, SO_RCVBUF,
+			 &cur_bufsiz, &len);
+	if (cur_bufsiz > bufsiz)
+		return 0;
+
 	ret = setsockopt(mnl_socket_get_fd(nl), SOL_SOCKET, SO_RCVBUFFORCE,
 			 &bufsiz, sizeof(socklen_t));
 	if (ret < 0) {
-- 
2.11.0




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux