diff mbox

[conntrack-tools,2/2] conntrack: add connlabel format attribute

Message ID 1372022618-12312-2-git-send-email-fw@strlen.de
State Superseded
Headers show

Commit Message

Florian Westphal June 23, 2013, 9:23 p.m. UTC
Signed-off-by: Florian Westphal <fw@strlen.de>
---
 Note: Modifying labels isn't supported yet with this patch.

 conntrack.8     | 4 +++-
 src/conntrack.c | 9 +++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/conntrack.8 b/conntrack.8
index a411fd4..7dbb3a4 100644
--- a/conntrack.8
+++ b/conntrack.8
@@ -88,11 +88,13 @@  Show the in-kernel connection tracking system statistics.
 Atomically zero counters after reading them.  This option is only valid in
 combination with the "-L, --dump" command options.
 .TP
-.BI "-o, --output [extended,xml,timestamp,id,ktimestamp] "
+.BI "-o, --output [extended,xml,timestamp,id,ktimestamp,connlabels] "
 Display output in a certain format. With the extended output option, this tool
 displays the layer 3 information. With ktimestamp, it displays the in-kernel
 timestamp available since 2.6.38 (you can enable it via echo 1 >
 /proc/sys/net/netfilter/nf_conntrack_timestamp).
+The connlabels output option tells conntrack to show the names of labels that
+might be present.
 .TP
 .BI "-e, --event-mask " "[ALL|NEW|UPDATES|DESTROY][,...]"
 Set the bitmask of events that are to be generated by the in-kernel ctnetlink
diff --git a/src/conntrack.c b/src/conntrack.c
index d4e79de..80bb1ff 100644
--- a/src/conntrack.c
+++ b/src/conntrack.c
@@ -731,6 +731,7 @@  enum {
 	_O_TMS	= (1 << 2),
 	_O_ID	= (1 << 3),
 	_O_KTMS	= (1 << 4),
+	_O_CL	= (1 << 5),
 };
 
 enum {
@@ -749,8 +750,8 @@  static struct parse_parameter {
 	  { IPS_ASSURED, IPS_SEEN_REPLY, 0, IPS_FIXED_TIMEOUT, IPS_EXPECTED} },
 	{ {"ALL", "NEW", "UPDATES", "DESTROY"}, 4,
 	  { CT_EVENT_F_ALL, CT_EVENT_F_NEW, CT_EVENT_F_UPD, CT_EVENT_F_DEL } },
-	{ {"xml", "extended", "timestamp", "id", "ktimestamp"}, 5, 
-	  { _O_XML, _O_EXT, _O_TMS, _O_ID, _O_KTMS },
+	{ {"xml", "extended", "timestamp", "id", "ktimestamp", "connlabels", }, 6, 
+	  { _O_XML, _O_EXT, _O_TMS, _O_ID, _O_KTMS, _O_CL },
 	},
 };
 
@@ -1149,6 +1150,8 @@  static int event_cb(enum nf_conntrack_msg_type type,
 		op_flags |= NFCT_OF_TIMESTAMP;
 	if (output_mask & _O_ID)
 		op_flags |= NFCT_OF_ID;
+	if (output_mask & _O_CL)
+		op_flags |= NFCT_OF_CONNLABELS;
 
 	nfct_snprintf(buf, sizeof(buf), ct, type, op_type, op_flags);
 
@@ -1193,6 +1196,8 @@  static int dump_cb(enum nf_conntrack_msg_type type,
 		op_flags |= NFCT_OF_TIMESTAMP;
 	if (output_mask & _O_ID)
 		op_flags |= NFCT_OF_ID;
+	if (output_mask & _O_CL)
+		op_flags |= NFCT_OF_CONNLABELS;
 
 	nfct_snprintf(buf, sizeof(buf), ct, NFCT_T_UNKNOWN, op_type, op_flags);
 	printf("%s\n", buf);