All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
To: netfilter-devel@vger.kernel.org
Cc: pablo@netfilter.org
Subject: [nft PATCH 2/2] monitor: fix how rules with intervals are printed
Date: Mon, 14 Jul 2014 13:56:52 +0200	[thread overview]
Message-ID: <20140714115651.10384.23718.stgit@nfdev.cica.es> (raw)
In-Reply-To: <20140714115646.10384.69637.stgit@nfdev.cica.es>

Previous to this patch, if we add a rule like this:
 nft add rule filter test ip saddr { 1.1.1.1-2.2.2.2 }

The monitor operation output shows:
 add rule ip filter test ip saddr { 0.0.0.0, 1.1.1.1, 2.2.2.3}

The fix suggested by Pablo is to call interval_map_decompose().

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
---
 src/netlink.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/netlink.c b/src/netlink.c
index 1a5d07b..83a13c3 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -1723,6 +1723,12 @@ out:
 	return MNL_CB_OK;
 }
 
+static void rule_map_decompose_cb(struct set *s, void *data)
+{
+	if (s->flags & NFT_SET_INTERVAL)
+		interval_map_decompose(s->init);
+}
+
 static int netlink_events_rule_cb(const struct nlmsghdr *nlh, int type,
 				  struct netlink_mon_handler *monh)
 {
@@ -1743,6 +1749,7 @@ static int netlink_events_rule_cb(const struct nlmsghdr *nlh, int type,
 
 		if (type == NFT_MSG_NEWRULE) {
 			r = netlink_delinearize_rule(monh->ctx, nlr);
+			nlr_for_each_set(nlr, rule_map_decompose_cb, NULL);
 
 			printf("add rule %s %s %s", family, table, chain);
 			rule_print(r);


  reply	other threads:[~2014-07-14 11:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-14 11:56 [nft PATCH 1/2] netlink: monitor: add a helper function to handle sets referenced by a rule Arturo Borrero Gonzalez
2014-07-14 11:56 ` Arturo Borrero Gonzalez [this message]
2014-07-21 12:21   ` [nft PATCH 2/2] monitor: fix how rules with intervals are printed Pablo Neira Ayuso
2014-07-21 12:21 ` [nft PATCH 1/2] netlink: monitor: add a helper function to handle sets referenced by a rule Pablo Neira Ayuso

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=20140714115651.10384.23718.stgit@nfdev.cica.es \
    --to=arturo.borrero.glez@gmail.com \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.