From patchwork Tue Feb 11 16:36:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Bursztyka X-Patchwork-Id: 319331 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 5B4BB2C00B0 for ; Wed, 12 Feb 2014 03:37:02 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752559AbaBKQg6 (ORCPT ); Tue, 11 Feb 2014 11:36:58 -0500 Received: from mga11.intel.com ([192.55.52.93]:62651 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752524AbaBKQg5 (ORCPT ); Tue, 11 Feb 2014 11:36:57 -0500 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 11 Feb 2014 08:36:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.95,826,1384329600"; d="scan'208";a="479719178" Received: from davidllo-mobl.ger.corp.intel.com (HELO rd-190.ger.corp.intel.com) ([10.252.123.163]) by fmsmga002.fm.intel.com with ESMTP; 11 Feb 2014 08:36:55 -0800 From: Tomasz Bursztyka To: netfilter-devel@vger.kernel.org Cc: Tomasz Bursztyka Subject: [iptables (nft-compat) PATCH 2/5] nft: A builtin chain might be created when restoring Date: Tue, 11 Feb 2014 18:36:43 +0200 Message-Id: <1392136606-10339-3-git-send-email-tomasz.bursztyka@linux.intel.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1392136606-10339-1-git-send-email-tomasz.bursztyka@linux.intel.com> References: <1392136606-10339-1-git-send-email-tomasz.bursztyka@linux.intel.com> Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org nft_chain_set() is directly used in xtables-restore.c, however at that point no builtin chains have been created yet thus the need to request to build it relevantly. Signed-off-by: Tomasz Bursztyka --- iptables/nft.c | 1 + iptables/nft.h | 1 + iptables/xtables-restore.c | 1 + 3 files changed, 3 insertions(+) diff --git a/iptables/nft.c b/iptables/nft.c index 968fe8c..7031ede 100644 --- a/iptables/nft.c +++ b/iptables/nft.c @@ -744,6 +744,7 @@ __nft_chain_set(struct nft_handle *h, const char *table, } nlh = nft_chain_nlmsg_build_hdr(buf, NFT_MSG_NEWCHAIN, h->family, + h->restore ? NLM_F_ACK|NLM_F_CREATE : NLM_F_ACK, h->seq); nft_chain_nlmsg_build_payload(nlh, c); diff --git a/iptables/nft.h b/iptables/nft.h index 22af66e..8b64f8b 100644 --- a/iptables/nft.h +++ b/iptables/nft.h @@ -34,6 +34,7 @@ struct nft_handle { struct mnl_nlmsg_batch *batch; struct nft_family_ops *ops; struct builtin_table *tables; + bool restore; }; extern struct builtin_table xtables_ipv4[TABLES_MAX]; diff --git a/iptables/xtables-restore.c b/iptables/xtables-restore.c index 50d2935..0498abc 100644 --- a/iptables/xtables-restore.c +++ b/iptables/xtables-restore.c @@ -170,6 +170,7 @@ xtables_restore_main(int family, const char *progname, int argc, char *argv[]) { struct nft_handle h = { .family = family, + .restore = true, }; char buffer[10240]; int c;