Skip to contentSkip to conversation

segtree: add new segtree debugging option

PATCH In review Pablo Neira Ayuso 2 participants 5 messages Jan 15, 2014 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 segtree: add new segtree debugging option

Currently, nft displays the debugging information if it's compiled with --enable-debug (which seems a good idea) and when intervals are used in maps. Add a new option to enable debugging to segtree, so we only get this information when explicitly requested.

---
We need this in master to avoid inconditional display of the debugging information when --enable-debug is passed at configuration / compilation time. I'm aware this patch conflicts with next-3.14, that conflict should be easy to resolve.

 include/nftables.h |    1 +
 src/main.c         |    6 +++++-
 src/segtree.c      |   43 +++++++++++++++++++++++++++++++++----------
 3 files changed, 39 insertions(+), 11 deletions(-)
include/nftables.h +1 -0
index 12f3c49..f989161 100644
@@ -17,6 +17,7 @@ enum debug_level {
 	DEBUG_PARSER		= 0x2,
 	DEBUG_EVALUATION	= 0x4,
 	DEBUG_NETLINK		= 0x8,
+	DEBUG_SEGTREE		= 0x10,
 };
 
 #define INCLUDE_PATHS_MAX	16
src/main.c +5 -1
index e8be423..d78eea7 100644
@@ -111,7 +111,7 @@ static void show_help(const char *name)
 "  -a/--handle			Output rule handle.\n"
 "  -I/--includepath <directory>	Add <directory> to the paths searched for include files.\n"
 #ifdef DEBUG
-"  --debug <level [,level...]>	Specify debugging level (scanner, parser, eval, netlink, all)\n"
+"  --debug <level [,level...]>	Specify debugging level (scanner, parser, eval, netlink, segtree, all)\n"
 #endif
 "\n",
 	name);
@@ -139,6 +139,10 @@ static const struct {
 		.level		= DEBUG_NETLINK,
 	},
 	{
+		.name		= "segtree",
+		.level		= DEBUG_SEGTREE,
+	},
+	{
 		.name		= "all",
 		.level		= ~0,
 	},
src/segtree.c +33 -10

95 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 11 lines · Pablo Neira Ayuso

Currently, nft displays the debugging information if it's compiled with --enable-debug (which seems a good idea) and when intervals are used in maps. Add a new option to enable debugging to segtree, so we only get this information when explicitly requested.

---
We need this in master to avoid inconditional display of the debugging information when --enable-debug is passed at configuration / compilation time. I'm aware this patch conflicts with next-3.14, that conflict should be easy to resolve.

Looks good, thanks, I wanted to change this myself.

A few more things about debugging, some are easy, some might be a bit more work:

- we should use stdout for netlink rule debugging

- netlink rule debugging is very very verbose since it dumps the entire netlink message. I'd prefer to only have the netlink expressions ([meta load ...]) and have the netlink message as another option. It keeps scrolling everything off the screen.

- netlink message debugging colors break in less. We should check for isatty().

author maintainer
#2 lore raw
Quoted 6 lines · Patrick McHardy
Quoted 5 lines · Pablo Neira Ayuso

Currently, nft displays the debugging information if it's compiled with --enable-debug (which seems a good idea) and when intervals are used in maps. Add a new option to enable debugging to segtree, so we only get this information when explicitly requested.

Quoted 8 lines
Quoted 6 lines

---
We need this in master to avoid inconditional display of the debugging information when --enable-debug is passed at configuration / compilation time. I'm aware this patch conflicts with next-3.14, that conflict should be easy to resolve.

Looks good, thanks, I wanted to change this myself.

Just pushed it, thanks.

Quoted 4 lines

A few more things about debugging, some are easy, some might be a bit more work:

- we should use stdout for netlink rule debugging

OK, pushed another small patch for this.

Quoted 4 lines

- netlink rule debugging is very very verbose since it dumps the entire netlink message. I'd prefer to only have the netlink expressions ([meta load ...]) and have the netlink message as another option. It keeps scrolling everything off the screen.

Fine with me. I'd like to keep that there as option, it has helped me to debug some issues in the past. Will check this.

Quoted 2 lines

- netlink message debugging colors break in less. We should check for isatty().

less -R can interpret them here.

#3 lore raw
Quoted 30 lines · Pablo Neira Ayuso
Quoted 6 lines · Patrick McHardy
Quoted 5 lines · Pablo Neira Ayuso

Currently, nft displays the debugging information if it's compiled with --enable-debug (which seems a good idea) and when intervals are used in maps. Add a new option to enable debugging to segtree, so we only get this information when explicitly requested.

Quoted 8 lines
Quoted 6 lines

---
We need this in master to avoid inconditional display of the debugging information when --enable-debug is passed at configuration / compilation time. I'm aware this patch conflicts with next-3.14, that conflict should be easy to resolve.

Looks good, thanks, I wanted to change this myself.

Just pushed it, thanks.

Quoted 4 lines

A few more things about debugging, some are easy, some might be a bit more work:

- we should use stdout for netlink rule debugging

OK, pushed another small patch for this.

Quoted 4 lines

- netlink rule debugging is very very verbose since it dumps the entire netlink message. I'd prefer to only have the netlink expressions ([meta load ...]) and have the netlink message as another option. It keeps scrolling everything off the screen.

Quoted 7 lines

Fine with me. I'd like to keep that there as option, it has helped me to debug some issues in the past. Will check this.

Quoted 2 lines

- netlink message debugging colors break in less. We should check for isatty().

less -R can interpret them here.

Ok that's good enough for now, though I would usually rather surpress them completely. Still I'd suggest to use isatty() for redirections to files, bugtracker entries etc.

author maintainer
#4 lore raw
Quoted 34 lines · Patrick McHardy
Quoted 33 lines · Pablo Neira Ayuso
Quoted 6 lines · Patrick McHardy
Quoted 5 lines · Pablo Neira Ayuso

Currently, nft displays the debugging information if it's compiled with --enable-debug (which seems a good idea) and when intervals are used in maps. Add a new option to enable debugging to segtree, so we only get this information when explicitly requested.

Quoted 8 lines
Quoted 6 lines

---
We need this in master to avoid inconditional display of the debugging information when --enable-debug is passed at configuration / compilation time. I'm aware this patch conflicts with next-3.14, that conflict should be easy to resolve.

Looks good, thanks, I wanted to change this myself.

Just pushed it, thanks.

Quoted 4 lines

A few more things about debugging, some are easy, some might be a bit more work:

- we should use stdout for netlink rule debugging

OK, pushed another small patch for this.

Quoted 4 lines

- netlink rule debugging is very very verbose since it dumps the entire netlink message. I'd prefer to only have the netlink expressions ([meta load ...]) and have the netlink message as another option. It keeps scrolling everything off the screen.

Fine with me. I'd like to keep that there as option, it has helped me to debug some issues in the past. Will check this.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

- netlink message debugging colors break in less. We should check for isatty().

less -R can interpret them here.

Ok that's good enough for now, though I would usually rather surpress them completely. Still I'd suggest to use isatty() for redirections to files, bugtracker entries etc.

I'll add a new interface to libmnl that accepts flags to decide if we want colors or not. But it would take some time until distributors pack that new version of the library and I would like to avoid that. I'll add this to my notepad so we can revisit this later.