{"id":808613,"url":"http://patchwork.ozlabs.org/api/patches/808613/?format=json","web_url":"http://patchwork.ozlabs.org/project/netfilter-devel/patch/1504260847-5408-3-git-send-email-pablo@netfilter.org/","project":{"id":26,"url":"http://patchwork.ozlabs.org/api/projects/26/?format=json","name":"Netfilter Development","link_name":"netfilter-devel","list_id":"netfilter-devel.vger.kernel.org","list_email":"netfilter-devel@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<1504260847-5408-3-git-send-email-pablo@netfilter.org>","list_archive_url":null,"date":"2017-09-01T10:14:07","name":"[nft,3/3] src: add nft_ctx_netlink_init()","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"59d69cf91df884f8f2c3ec6da2a556473f9dfbbc","submitter":{"id":1315,"url":"http://patchwork.ozlabs.org/api/people/1315/?format=json","name":"Pablo Neira Ayuso","email":"pablo@netfilter.org"},"delegate":{"id":6139,"url":"http://patchwork.ozlabs.org/api/users/6139/?format=json","username":"pablo","first_name":"Pablo","last_name":"Neira","email":"pablo@netfilter.org"},"mbox":"http://patchwork.ozlabs.org/project/netfilter-devel/patch/1504260847-5408-3-git-send-email-pablo@netfilter.org/mbox/","series":[{"id":988,"url":"http://patchwork.ozlabs.org/api/series/988/?format=json","web_url":"http://patchwork.ozlabs.org/project/netfilter-devel/list/?series=988","date":"2017-09-01T10:14:05","name":"[nft,1/3] src: move nf_sock into nft_ctx structure","version":1,"mbox":"http://patchwork.ozlabs.org/series/988/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/808613/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/808613/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netfilter-devel-owner@vger.kernel.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netfilter-devel-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xkFTV28J9z9t2x\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  1 Sep 2017 20:14:22 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751868AbdIAKOV (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tFri, 1 Sep 2017 06:14:21 -0400","from mail.us.es ([193.147.175.20]:34346 \"EHLO mail.us.es\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1751730AbdIAKOU (ORCPT <rfc822; netfilter-devel@vger.kernel.org>);\n\tFri, 1 Sep 2017 06:14:20 -0400","from antivirus1-rhel7.int (unknown [192.168.2.11])\n\tby mail.us.es (Postfix) with ESMTP id 97CCF190F86\n\tfor <netfilter-devel@vger.kernel.org>;\n\tFri,  1 Sep 2017 12:13:55 +0200 (CEST)","from antivirus1-rhel7.int (localhost [127.0.0.1])\n\tby antivirus1-rhel7.int (Postfix) with ESMTP id 89940909BB\n\tfor <netfilter-devel@vger.kernel.org>;\n\tFri,  1 Sep 2017 12:13:55 +0200 (CEST)","by antivirus1-rhel7.int (Postfix, from userid 99)\n\tid 88F55909B1; Fri,  1 Sep 2017 12:13:55 +0200 (CEST)","from antivirus1-rhel7.int (localhost [127.0.0.1])\n\tby antivirus1-rhel7.int (Postfix) with ESMTP id 55C57B502D;\n\tFri,  1 Sep 2017 12:13:53 +0200 (CEST)","from 192.168.1.97 (192.168.1.97) by antivirus1-rhel7.int\n\t(F-Secure/fsigk_smtp/550/antivirus1-rhel7.int); \n\tFri, 01 Sep 2017 12:13:53 +0200 (CEST)","from salvia.here (129.166.216.87.static.jazztel.es\n\t[87.216.166.129]) (Authenticated sender: pneira@us.es)\n\tby entrada.int (Postfix) with ESMTPA id F21444265A24;\n\tFri,  1 Sep 2017 12:13:52 +0200 (CEST)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.1 (2015-04-28) on\n\tantivirus1-rhel7.int","X-Spam-Level":"","X-Spam-Status":"No, score=-108.2 required=7.5 tests=ALL_TRUSTED,BAYES_50,\n\tSMTPAUTH_US2,USER_IN_WHITELIST autolearn=disabled version=3.4.1","X-Virus-Status":"clean(F-Secure/fsigk_smtp/550/antivirus1-rhel7.int)","X-SMTPAUTHUS":"auth mail.us.es","From":"Pablo Neira Ayuso <pablo@netfilter.org>","To":"netfilter-devel@vger.kernel.org","Cc":"phil@nwl.cc, eric@regit.org","Subject":"[PATCH nft 3/3] src: add nft_ctx_netlink_init()","Date":"Fri,  1 Sep 2017 12:14:07 +0200","Message-Id":"<1504260847-5408-3-git-send-email-pablo@netfilter.org>","X-Mailer":"git-send-email 2.1.4","In-Reply-To":"<1504260847-5408-1-git-send-email-pablo@netfilter.org>","References":"<1504260847-5408-1-git-send-email-pablo@netfilter.org>","X-Virus-Scanned":"ClamAV using ClamSMTP","Sender":"netfilter-devel-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netfilter-devel.vger.kernel.org>","X-Mailing-List":"netfilter-devel@vger.kernel.org"},"content":"Add these two new functions to set up netlink sockets in the global\ncontext structure.\n\nSigned-off-by: Pablo Neira Ayuso <pablo@netfilter.org>\n---\n src/main.c | 12 ++++++++++--\n 1 file changed, 10 insertions(+), 2 deletions(-)","diff":"diff --git a/src/main.c b/src/main.c\nindex a891832ec5d6..fce9bfeca100 100644\n--- a/src/main.c\n+++ b/src/main.c\n@@ -298,12 +298,20 @@ static struct nft_ctx *nft_ctx_new(void)\n \n static void nft_ctx_free(const struct nft_ctx *ctx)\n {\n+\tif (ctx->nf_sock)\n+\t\tnetlink_close_sock(ctx->nf_sock);\n+\n \tiface_cache_release();\n \tcache_release(&nft->cache);\n \txfree(ctx);\n \tnft_exit();\n }\n \n+static void nft_ctx_netlink_init(struct nft_ctx *ctx)\n+{\n+\tctx->nf_sock = netlink_open_sock();\n+}\n+\n static int nft_run_cmd_from_buffer(struct nft_ctx *nft,\n \t\t\t\t   char *buf, size_t buflen)\n {\n@@ -361,7 +369,8 @@ int main(int argc, char * const *argv)\n \n \tnft = nft_ctx_new();\n \n-\tnft->nf_sock = netlink_open_sock();\n+\tnft_ctx_netlink_init(nft);\n+\n \twhile (1) {\n \t\tval = getopt_long(argc, argv, OPTSTRING, options, NULL);\n \t\tif (val == -1)\n@@ -472,7 +481,6 @@ int main(int argc, char * const *argv)\n \t}\n \n \txfree(buf);\n-\tnetlink_close_sock(nft->nf_sock);\n \tnft_ctx_free(nft);\n \n \treturn rc;\n","prefixes":["nft","3/3"]}