Skip to contentSkip to conversation

mnl: bogus error when running monitor mode

PATCH In review Pablo Neira Ayuso 2 participants 3 messages Jun 5, 2019 – Jun 7, 2019 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 mnl: bogus error when running monitor mode

Fix bogus error message:

 # nft monitor
 Cannot set up netlink socket buffer size to 16777216 bytes, falling back to 16777216 bytes
Fixes bcf60fb819bf ("mnl: add mnl_set_rcvbuffer() and use it")
---
 src/mnl.c | 2 --
 1 file changed, 2 deletions(-)
src/mnl.c +0 -2
index c0df2c941d88..a7693ef1de30 100644
@@ -1433,8 +1433,6 @@ int mnl_nft_event_listener(struct mnl_socket *nf_sock, unsigned int debug_mask,
 
 	ret = mnl_set_rcvbuffer(nf_sock, bufsiz);
 	if (ret < 0)
-		nft_print(octx, "# Cannot increase netlink socket buffer size, expect message loss\n");
-	else
 		nft_print(octx, "# Cannot set up netlink socket buffer size to %u bytes, falling back to %u bytes\n",
 			  NFTABLES_NLEVENT_BUFSIZ, bufsiz);
 
Signature · 1 line
2.11.0
reviewer
#1 lore raw
Quoted 16 lines · Pablo Neira Ayuso

Fix bogus error message:

 # nft monitor
 Cannot set up netlink socket buffer size to 16777216 bytes, falling back to 16777216 bytes
Fixes bcf60fb819bf ("mnl: add mnl_set_rcvbuffer() and use it")
---
 src/mnl.c | 2 --
 1 file changed, 2 deletions(-)
src/mnl.c +0 -0
index c0df2c941d88..a7693ef1de30 100644

src/mnl.c int mnl_nft_event_listener(struct mnl_socket *nf_sock, unsigned int debug_mask, · line 1437

Quoted 7 lines
src/mnl.c +0 -2
@@ -1433,8 +1433,6 @@ int mnl_nft_event_listener(struct mnl_socket *nf_sock, unsigned int debug_mask,
 
 	ret = mnl_set_rcvbuffer(nf_sock, bufsiz);
 	if (ret < 0)
-		nft_print(octx, "# Cannot increase netlink socket buffer size, expect message loss\n");
-	else
 		nft_print(octx, "# Cannot set up netlink socket buffer size to %u bytes, falling back to %u bytes\n",
 			  NFTABLES_NLEVENT_BUFSIZ, bufsiz);

This error message is not correct: If mnl_set_rcvbuffer() returned non-zero, both setsockopt() calls failed. The removed message would be more appropriate for that situation.

BTW: While being at it, maybe s/socket buffer/socket receive buffer/?

Cheers, Phil

author maintainer
#2 lore raw
Quoted 18 lines · Phil Sutter
Quoted 17 lines · Pablo Neira Ayuso

Fix bogus error message:

 # nft monitor
 Cannot set up netlink socket buffer size to 16777216 bytes, falling back to 16777216 bytes
Fixes bcf60fb819bf ("mnl: add mnl_set_rcvbuffer() and use it")
---
 src/mnl.c | 2 --
 1 file changed, 2 deletions(-)
src/mnl.c +0 -0
index c0df2c941d88..a7693ef1de30 100644
@@ -1433,8 +1433,6 @@ int mnl_nft_event_listener(struct mnl_socket *nf_sock, unsigned int debug_mask,
 
Quoted 10 lines

src/mnl.c int mnl_nft_event_listener(struct mnl_socket *nf_sock, unsigned int debug_mask, · line 1437

Quoted 6 lines
src/mnl.c +0 -2
 	ret = mnl_set_rcvbuffer(nf_sock, bufsiz);
 	if (ret < 0)
-		nft_print(octx, "# Cannot increase netlink socket buffer size, expect message loss\n");
-	else
 		nft_print(octx, "# Cannot set up netlink socket buffer size to %u bytes, falling back to %u bytes\n",
 			  NFTABLES_NLEVENT_BUFSIZ, bufsiz);

This error message is not correct: If mnl_set_rcvbuffer() returned non-zero, both setsockopt() calls failed. The removed message would be more appropriate for that situation.

setsockopt() should not fail, I think. So this is unlikely to show up.

events are unreliable anyway, no matter if buffer is set or not.

Quoted 1 line

BTW: While being at it, maybe s/socket buffer/socket receive buffer/?

Yes I can update this.

Thanks for reviewing.