Blame SOURCES/0020-netlink-reset-mnl_socket-field-in-struct-nft_ctx-on-.patch

34625f
From c8b6092b4fec23b823695c0c9b10325f9c33150c Mon Sep 17 00:00:00 2001
34625f
From: Pablo Neira Ayuso <pablo@netfilter.org>
34625f
Date: Mon, 22 Oct 2018 21:20:44 +0200
34625f
Subject: [PATCH] netlink: reset mnl_socket field in struct nft_ctx on EINTR
34625f
34625f
Otherwise we keep using the old netlink socket if we hit EINTR.
34625f
34625f
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
34625f
(cherry picked from commit d7ef1e206bd9b36607dddcf337fada11d743b61f)
34625f
34625f
Conflicts:
34625f
	include/netlink.h
34625f
-> Missing upstream commit 0562beb6544d3 ("src: get rid of netlink_genid_get()")
34625f
34625f
Signed-off-by: Phil Sutter <psutter@redhat.com>
34625f
---
34625f
 include/netlink.h | 2 +-
34625f
 src/netlink.c     | 4 ++--
34625f
 src/rule.c        | 3 +--
34625f
 3 files changed, 4 insertions(+), 5 deletions(-)
34625f
34625f
diff --git a/include/netlink.h b/include/netlink.h
34625f
index 31465ff16822e..894bf6fc98487 100644
34625f
--- a/include/netlink.h
34625f
+++ b/include/netlink.h
34625f
@@ -191,7 +191,7 @@ extern void netlink_dump_obj(struct nftnl_obj *nlo, struct netlink_ctx *ctx);
34625f
 extern int netlink_batch_send(struct netlink_ctx *ctx, struct list_head *err_list);
34625f
 
34625f
 extern uint16_t netlink_genid_get(struct netlink_ctx *ctx);
34625f
-extern void netlink_restart(struct mnl_socket *nf_sock);
34625f
+extern struct mnl_socket *netlink_restart(struct mnl_socket *nf_sock);
34625f
 #define netlink_abi_error()	\
34625f
 	__netlink_abi_error(__FILE__, __LINE__, strerror(errno));
34625f
 extern void __noreturn __netlink_abi_error(const char *file, int line, const char *reason);
34625f
diff --git a/src/netlink.c b/src/netlink.c
34625f
index e16eb504fdef8..c178be3c9ee26 100644
34625f
--- a/src/netlink.c
34625f
+++ b/src/netlink.c
34625f
@@ -73,10 +73,10 @@ void netlink_close_sock(struct mnl_socket *nf_sock)
34625f
 		mnl_socket_close(nf_sock);
34625f
 }
34625f
 
34625f
-void netlink_restart(struct mnl_socket *nf_sock)
34625f
+struct mnl_socket *netlink_restart(struct mnl_socket *nf_sock)
34625f
 {
34625f
 	netlink_close_sock(nf_sock);
34625f
-	nf_sock = netlink_open_sock();
34625f
+	return netlink_open_sock();
34625f
 }
34625f
 
34625f
 uint16_t netlink_genid_get(struct netlink_ctx *ctx)
34625f
diff --git a/src/rule.c b/src/rule.c
34625f
index 6acfa3ac1695c..47b0d30cbed18 100644
34625f
--- a/src/rule.c
34625f
+++ b/src/rule.c
34625f
@@ -161,7 +161,6 @@ int cache_update(struct nft_ctx *nft, enum cmd_ops cmd, struct list_head *msgs)
34625f
 		.msgs		= msgs,
34625f
 		.nft		= nft,
34625f
 	};
34625f
-	struct mnl_socket *nf_sock = nft->nf_sock;
34625f
 	struct nft_cache *cache = &nft->cache;
34625f
 
34625f
 replay:
34625f
@@ -176,7 +175,7 @@ replay:
34625f
 	if (ret < 0) {
34625f
 		cache_release(cache);
34625f
 		if (errno == EINTR) {
34625f
-			netlink_restart(nf_sock);
34625f
+			nft->nf_sock = netlink_restart(nft->nf_sock);
34625f
 			goto replay;
34625f
 		}
34625f
 		return -1;
34625f
-- 
34625f
2.19.0
34625f