{"id":809384,"url":"http://patchwork.ozlabs.org/api/1.2/patches/809384/?format=json","web_url":"http://patchwork.ozlabs.org/project/netfilter-devel/patch/1504477589-12045-5-git-send-email-pablo@netfilter.org/","project":{"id":26,"url":"http://patchwork.ozlabs.org/api/1.2/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":"<1504477589-12045-5-git-send-email-pablo@netfilter.org>","list_archive_url":null,"date":"2017-09-03T22:25:46","name":"[04/47] netfilter: nf_tables: Attach process info to NFT_MSG_NEWGEN notifications","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"aa9a0e03de70cd95597d7d6bf9b4e99a3978b8f0","submitter":{"id":1315,"url":"http://patchwork.ozlabs.org/api/1.2/people/1315/?format=json","name":"Pablo Neira Ayuso","email":"pablo@netfilter.org"},"delegate":{"id":6139,"url":"http://patchwork.ozlabs.org/api/1.2/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/1504477589-12045-5-git-send-email-pablo@netfilter.org/mbox/","series":[{"id":1280,"url":"http://patchwork.ozlabs.org/api/1.2/series/1280/?format=json","web_url":"http://patchwork.ozlabs.org/project/netfilter-devel/list/?series=1280","date":"2017-09-03T22:25:42","name":"[01/47] netfilter: expect: add to hash table after expect init","version":1,"mbox":"http://patchwork.ozlabs.org/series/1280/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/809384/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/809384/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 3xlnfQ5qBlz9s06\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon,  4 Sep 2017 08:27:26 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1753221AbdICW10 (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tSun, 3 Sep 2017 18:27:26 -0400","from mail.us.es ([193.147.175.20]:50794 \"EHLO mail.us.es\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1753050AbdICW0l (ORCPT <rfc822; netfilter-devel@vger.kernel.org>);\n\tSun, 3 Sep 2017 18:26:41 -0400","from antivirus1-rhel7.int (unknown [192.168.2.11])\n\tby mail.us.es (Postfix) with ESMTP id 946EB190F61\n\tfor <netfilter-devel@vger.kernel.org>;\n\tMon,  4 Sep 2017 00:26:14 +0200 (CEST)","from antivirus1-rhel7.int (localhost [127.0.0.1])\n\tby antivirus1-rhel7.int (Postfix) with ESMTP id 7FBFCB502E\n\tfor <netfilter-devel@vger.kernel.org>;\n\tMon,  4 Sep 2017 00:26:14 +0200 (CEST)","by antivirus1-rhel7.int (Postfix, from userid 99)\n\tid 756A3B502C; Mon,  4 Sep 2017 00:26:14 +0200 (CEST)","from antivirus1-rhel7.int (localhost [127.0.0.1])\n\tby antivirus1-rhel7.int (Postfix) with ESMTP id 70909B5027;\n\tMon,  4 Sep 2017 00:26:12 +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\tMon, 04 Sep 2017 00:26:12 +0200 (CEST)","from salvia.here (unknown [31.4.193.113])\n\t(Authenticated sender: pneira@us.es)\n\tby entrada.int (Postfix) with ESMTPA id 22C854265A22;\n\tMon,  4 Sep 2017 00:26:12 +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":"davem@davemloft.net, netdev@vger.kernel.org","Subject":"[PATCH 04/47] netfilter: nf_tables: Attach process info to\n\tNFT_MSG_NEWGEN notifications","Date":"Mon,  4 Sep 2017 00:25:46 +0200","Message-Id":"<1504477589-12045-5-git-send-email-pablo@netfilter.org>","X-Mailer":"git-send-email 2.1.4","In-Reply-To":"<1504477589-12045-1-git-send-email-pablo@netfilter.org>","References":"<1504477589-12045-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":"From: Phil Sutter <phil@nwl.cc>\n\nThis is helpful for 'nft monitor' to track which process caused a given\nchange to the ruleset.\n\nSigned-off-by: Phil Sutter <phil@nwl.cc>\nSigned-off-by: Pablo Neira Ayuso <pablo@netfilter.org>\n---\n include/uapi/linux/netfilter/nf_tables.h | 2 ++\n net/netfilter/nf_tables_api.c            | 5 ++++-\n 2 files changed, 6 insertions(+), 1 deletion(-)","diff":"diff --git a/include/uapi/linux/netfilter/nf_tables.h b/include/uapi/linux/netfilter/nf_tables.h\nindex 683f6f88fcac..6f0a950e21c3 100644\n--- a/include/uapi/linux/netfilter/nf_tables.h\n+++ b/include/uapi/linux/netfilter/nf_tables.h\n@@ -1221,6 +1221,8 @@ enum nft_objref_attributes {\n enum nft_gen_attributes {\n \tNFTA_GEN_UNSPEC,\n \tNFTA_GEN_ID,\n+\tNFTA_GEN_PROC_PID,\n+\tNFTA_GEN_PROC_NAME,\n \t__NFTA_GEN_MAX\n };\n #define NFTA_GEN_MAX\t\t(__NFTA_GEN_MAX - 1)\ndiff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c\nindex 7fbf0070aba1..b77ad0813564 100644\n--- a/net/netfilter/nf_tables_api.c\n+++ b/net/netfilter/nf_tables_api.c\n@@ -4657,6 +4657,7 @@ static int nf_tables_fill_gen_info(struct sk_buff *skb, struct net *net,\n {\n \tstruct nlmsghdr *nlh;\n \tstruct nfgenmsg *nfmsg;\n+\tchar buf[TASK_COMM_LEN];\n \tint event = nfnl_msg_type(NFNL_SUBSYS_NFTABLES, NFT_MSG_NEWGEN);\n \n \tnlh = nlmsg_put(skb, portid, seq, event, sizeof(struct nfgenmsg), 0);\n@@ -4668,7 +4669,9 @@ static int nf_tables_fill_gen_info(struct sk_buff *skb, struct net *net,\n \tnfmsg->version\t\t= NFNETLINK_V0;\n \tnfmsg->res_id\t\t= htons(net->nft.base_seq & 0xffff);\n \n-\tif (nla_put_be32(skb, NFTA_GEN_ID, htonl(net->nft.base_seq)))\n+\tif (nla_put_be32(skb, NFTA_GEN_ID, htonl(net->nft.base_seq)) ||\n+\t    nla_put_be32(skb, NFTA_GEN_PROC_PID, htonl(task_pid_nr(current))) ||\n+\t    nla_put_string(skb, NFTA_GEN_PROC_NAME, get_task_comm(buf, current)))\n \t\tgoto nla_put_failure;\n \n \tnlmsg_end(skb, nlh);\n","prefixes":["04/47"]}