Skip to contentSkip to conversation

listing: only display wanted chain

PATCH In review Eric Leblond 3 participants 3 messages Nov 18, 2013 – Nov 19, 2013 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 listing: only display wanted chain

When specifying a chain to list, all created chains were displayed with a void content:

 # nft list chain filter
 table ip filter {
  	chain input {
  	}
  	chain new {
  		 counter packets 17971 bytes 2380637 accept
  		 counter packets 0 bytes 0 accept
  	}
  }

With the attached patch, only the asked chain is displayed:

  # nft list chain filter
  table ip filter {
  	chain new {
  		 counter packets 17971 bytes 2380637 accept # handle 36
  		 counter packets 0 bytes 0 accept # handle 40
  	}
  }
---
 src/netlink.c | 4 ++++
 1 file changed, 4 insertions(+)
src/netlink.c +4 -0
index a62c357..15cba79 100644
@@ -544,6 +544,10 @@ static int list_chain_cb(struct nft_chain *nlc, void *arg)
 	    strcmp(nft_chain_attr_get_str(nlc, NFT_CHAIN_ATTR_TABLE), h->table) != 0)
 		return 0;
 
+	if (h->chain &&
+	    strcmp(nft_chain_attr_get_str(nlc, NFT_CHAIN_ATTR_NAME), h->chain) != 0)
+		return 0;
+
 	chain = chain_alloc(nft_chain_attr_get_str(nlc, NFT_CHAIN_ATTR_NAME));
 	chain->handle.family =
 		nft_chain_attr_get_u32(nlc, NFT_CHAIN_ATTR_FAMILY);
Signature · 1 line
1.8.4.3
#1 lore raw
Quoted 24 lines · Eric Leblond

When specifying a chain to list, all created chains were displayed with a void content:

 # nft list chain filter
 table ip filter {
        chain input {
        }
        chain new {
                 counter packets 17971 bytes 2380637 accept
                 counter packets 0 bytes 0 accept
        }

}

With the attached patch, only the asked chain is displayed:

  # nft list chain filter
  table ip filter {
        chain new {
                 counter packets 17971 bytes 2380637 accept # handle 36
                 counter packets 0 bytes 0 accept # handle 40
        }
  }
Quoted 1 line

Hi all,

I've been testing this patch and works fine for me. I think the old behaviour was a bit odd.

Thanks Eric.

Signature · 5 lines
Arturo Borrero González
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
In reply to Eric Leblond
Quoted 16 lines · Eric Leblond

When specifying a chain to list, all created chains were displayed with a void content:

 # nft list chain filter
 table ip filter {
  	chain input {
  	}
  	chain new {
  		 counter packets 17971 bytes 2380637 accept
  		 counter packets 0 bytes 0 accept
  	}
  }

With the attached patch, only the asked chain is displayed:

Quoted 7 lines
  # nft list chain filter
  table ip filter {
  	chain new {
  		 counter packets 17971 bytes 2380637 accept # handle 36
  		 counter packets 0 bytes 0 accept # handle 40
  	}
  }

Also applied, thanks.