]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
netlink: reset mnl_socket field in struct nft_ctx on EINTR
authorPablo Neira Ayuso <pablo@netfilter.org>
Mon, 22 Oct 2018 19:20:44 +0000 (21:20 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 22 Oct 2018 19:45:37 +0000 (21:45 +0200)
Otherwise we keep using the old netlink socket if we hit EINTR.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/netlink.h
src/netlink.c
src/rule.c

index b26ef459850037c92d4481f49b89d29fcfccde41..66e400d88f19a53c605811a4ccea01ceece6759d 100644 (file)
@@ -157,7 +157,7 @@ extern void netlink_dump_obj(struct nftnl_obj *nlo, struct netlink_ctx *ctx);
 
 extern int netlink_batch_send(struct netlink_ctx *ctx, struct list_head *err_list);
 
-extern void netlink_restart(struct mnl_socket *nf_sock);
+extern struct mnl_socket *netlink_restart(struct mnl_socket *nf_sock);
 #define netlink_abi_error()    \
        __netlink_abi_error(__FILE__, __LINE__, strerror(errno));
 extern void __noreturn __netlink_abi_error(const char *file, int line, const char *reason);
index 755949c965c3b7de86a2c3a2d491e06d1362cfef..403780ffdefb7b7ea2449de2caf9676f7ff19296 100644 (file)
@@ -73,10 +73,10 @@ void netlink_close_sock(struct mnl_socket *nf_sock)
                mnl_socket_close(nf_sock);
 }
 
-void netlink_restart(struct mnl_socket *nf_sock)
+struct mnl_socket *netlink_restart(struct mnl_socket *nf_sock)
 {
        netlink_close_sock(nf_sock);
-       nf_sock = netlink_open_sock();
+       return netlink_open_sock();
 }
 
 void __noreturn __netlink_abi_error(const char *file, int line,
index 9e24c35c85aeab8d41753deff7066aae6916212c..12ac1310034d909362f52d4fbd632a6547bfdfec 100644 (file)
@@ -229,7 +229,6 @@ int cache_update(struct nft_ctx *nft, enum cmd_ops cmd, struct list_head *msgs)
                .msgs           = msgs,
                .nft            = nft,
        };
-       struct mnl_socket *nf_sock = nft->nf_sock;
        struct nft_cache *cache = &nft->cache;
 
 replay:
@@ -244,7 +243,7 @@ replay:
        if (ret < 0) {
                cache_release(cache);
                if (errno == EINTR) {
-                       netlink_restart(nf_sock);
+                       nft->nf_sock = netlink_restart(nft->nf_sock);
                        goto replay;
                }
                return -1;