]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
mnl: Improve error checking in mnl_nft_event_listener()
authorPhil Sutter <phil@nwl.cc>
Wed, 24 Oct 2018 16:05:55 +0000 (18:05 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 24 Oct 2018 18:08:24 +0000 (20:08 +0200)
When trying to adjust receive buffer size, the second call to
setsockopt() was not error-checked.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/mnl.c

index 2be8ca14e50da783eeb3be3fe8b8be91bf561341..0d9b7ffc85c764475c8d51238f8eb67697f68d19 100644 (file)
--- a/src/mnl.c
+++ b/src/mnl.c
@@ -1425,8 +1425,11 @@ int mnl_nft_event_listener(struct mnl_socket *nf_sock, unsigned int debug_mask,
                 */
                ret = setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &bufsiz,
                                 sizeof(socklen_t));
-               nft_print(octx, "# Cannot set up netlink socket buffer size to %u bytes, falling back to %u bytes\n",
-                         NFTABLES_NLEVENT_BUFSIZ, 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);
        }
 
        while (1) {