netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Cc: Giuseppe Longo <giuseppelng@gmail.com>, netfilter-devel@vger.kernel.org
Subject: Re: [xtables-arptables PATCH v2 3/5] nft: nft_xtables_config_load() called only in nft_init()
Date: Wed, 24 Jul 2013 12:56:38 +0200	[thread overview]
Message-ID: <20130724105638.GA17248@localhost> (raw)
In-Reply-To: <51EFA01B.30907@linux.intel.com>

Hi,

On Wed, Jul 24, 2013 at 12:36:27PM +0300, Tomasz Bursztyka wrote:
> Hi Pablo,
> 
> >>+int nft_init(struct nft_handle *h, struct builtin_table *t,
> >>>+	     const char *filename)
> >                          ^^^^^^^^
> >
> >why do we need this new parameter?
> >
> >The optional /etc/xtables.conf file should contain the definition for
> >all the families, that includes IPv4, IPv6, bridge and ARP.
> 
> My mistake, I advised that. Imho, it's not relevant to load
> everything for all families if the user is using only
> xtables-iptables for instance.
> 
> Then ok, let's have one file, but we could make a change in
> nft_xtables_config_load() so it would load only the tables of the
> current family.
> It's a quick fix to do actually.

Yes, that's the way to go.

> >>>  {
> >>>  	h->nl = mnl_socket_open(NETLINK_NETFILTER);
> >>>  	if (h->nl == NULL) {
> >>>@@ -388,6 +389,16 @@ int nft_init(struct nft_handle *h, struct builtin_table *t)
> >>>  	h->portid = mnl_socket_get_portid(h->nl);
> >>>  	h->tables = t;
> >>>  >+	/* If built-in chains don't exist for this table, create
> >>them */
> >>>+	if (nft_xtables_config_load(h, filename, 0) < 0) {
> >>>+		int i;
> >>>+
> >>>+		if (h->tables != NULL) {
> >>>+			for (i=0; i<TABLES_MAX; i++)
> >>>+				nft_chain_builtin_init(h, h->tables[i].name,
> >>>+						       NULL, NF_ACCEPT);
> >>>+		}
> >>>+	}
> >
> >I don't see what we get by moving nft_xtables_config_load here.
> 
> Why not calling this at only one unique place instead of multiple ones?
> You need to call that anyway currently as soon as you list/change
> the rule set.
> It's relevant to move that here, makes code clearer.

OK, but there are other chunks in this patch that are unclear to me:

@@ -1100,6 +1100,11 @@  int do_commandx(struct nft_handle *h, int
argc, char *argv[], char **table)
        if (h->ops == NULL)
                xtables_error(PARAMETER_PROBLEM, "Unknown family");
 
+       if (h->tables == NULL) {
+                if (nft_init(h, tables, XTABLES_CONFIG_DEFAULT) < 0)
+                        xtables_error(OTHER_PROBLEM, "Could not initialize nftables layer.");
+        }
+
        h->ops->post_parse(command, &cs, &args);
 
        if (command == CMD_REPLACE &&

By looking at patch 1, h->tables always point to some array of tables,
so that should always evaluates true.

Please, resolve all open issue and get back to me with a patch for
this if you think the time is worth to discuss this small
refactorization.

Thanks.

  reply	other threads:[~2013-07-24 10:56 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-23 16:11 [xtables-arptables PATCH v2 0/5] nft changes for xtables-arptables Giuseppe Longo
2013-07-23 16:12 ` [xtables-arptables PATCH v2 1/5] nft: add builtin_table pointer Giuseppe Longo
2013-07-24  8:50   ` Pablo Neira Ayuso
2013-07-23 16:12 ` [xtables-arptables PATCH v2 2/5] nft: search builtin tables via nft_handle tables pointer Giuseppe Longo
2013-07-24  8:51   ` Pablo Neira Ayuso
2013-07-23 16:12 ` [xtables-arptables PATCH v2 3/5] nft: nft_xtables_config_load() called only in nft_init() Giuseppe Longo
2013-07-24  8:56   ` Pablo Neira Ayuso
2013-07-24  9:36     ` Tomasz Bursztyka
2013-07-24 10:56       ` Pablo Neira Ayuso [this message]
2013-07-24 11:14         ` Tomasz Bursztyka
2013-07-24 11:55           ` Pablo Neira Ayuso
2013-07-24  9:01   ` Pablo Neira Ayuso
2013-07-23 16:12 ` [xtables-arptables PATCH v2 4/5] nft: make functions public Giuseppe Longo
2013-07-23 16:13 ` [xtables-arptables PATCH v2 5/5] nft: replace args.family Giuseppe Longo
2013-07-24  8:58   ` Pablo Neira Ayuso
2013-07-24  9:40     ` Tomasz Bursztyka
2013-07-23 16:16 ` [xtables-arptables PATCH v2 0/5] nft changes for xtables-arptables Tomasz Bursztyka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130724105638.GA17248@localhost \
    --to=pablo@netfilter.org \
    --cc=giuseppelng@gmail.com \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=tomasz.bursztyka@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).