Re: [nft PATCH v2] expression: print sets and maps in pretty format

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 26, 2017 at 11:05:55AM +0200, Arturo Borrero Gonzalez wrote:
> Print elements per line instead of all in a single line.
> The elements which can be 'short' are printed 5 per line,
> and others, like IPv4 addresses are printed 2 per line.
> 
> Example:
> 
> % nft list ruleset -nnn
> table ip t {
> 	set s {
> 		type inet_service
> 		elements = { 1, 2, 3, 4, 10,
> 			     432, 433, 434, 435, 436,
> 			     437, 438, 439, 440, 441,
> 			     442, 443, 444, 445, 446,
> 			     447, 448, 449, 450, 12345 }
> 	}
> 
> 	map m {
> 		type inet_service . iface_index : verdict
> 		elements = { 123 . "lo" : accept,
> 			     1234 . "lo" : accept,
> 			     12345 . "lo" : accept,
> 			     12346 . "lo" : accept,
> 			     12347 . "lo" : accept }
> 	}
> 
> 	set s3 {
> 		type ipv4_addr
> 		elements = { 1.1.1.1, 2.2.2.2,
> 			     3.3.3.3 }
> 	}
> }
> 
> NOTE: some testcases require updates because the output change.

I think this is a good starting point.

We can probably make a simple calculation based on the maximum length
of the string datatype, ie. strlen("255.255.255.255"), then use the
number of columns available and make a good guess on how much we can
fit in. It would still be something approximate.

Anyway, this can be refined later on.

Would you send me a v3 including the test updates? I ran them very
often here and I don't want to see them broken :).

Thanks!
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux