Skip to contentSkip to conversation

Fix all set output from list/save when set with counters in use.

PATCH Superseded Sergey Popovich 2 participants 4 messages Nov 7, 2013 – Nov 13, 2013 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 Fix all set output from list/save when set with counters in use.

Using upstream version with counters support we have following output when listing all sets currently configured:
--------------------------------------------------

 # ipset create test-1 hash:ip
 # ipset create test-2 hash:ip counters
 # ipset add test-2 192.0.2.1/32
 # ipset create test-3 hash:ip
 # ipset add test-3 192.0.2.1/32
 # ipset list
 Name: test-1
 Type: hash:ip
 Revision: 2
 Header: family inet hashsize 1024 maxelem 65536
 Size in memory: 16504
 References: 0
 Members:

Name: test-2
Type: hash:ip
Revision: 2
Header: family inet hashsize 1024 maxelem 65536 counters Size in memory: 16616
References: 0
Members:
192.0.2.1 packets 0 bytes 0

Name: test-3
Type: hash:ip
Revision: 2
Header: family inet hashsize 1024 maxelem 65536 counters Size in memory: 16520
References: 0
Members:
192.0.2.1 packets 0 bytes 0

Set test-3 created without counters, but displayed as with counters present.

Restricting output to list only test-3 set we have:
---------------------------------------------------

  # ipset list test-3
  Name: test-3
  Type: hash:ip
  Revision: 2
  Header: family inet hashsize 1024 maxelem 65536
  Size in memory: 16520
  References: 0
  Members:
  192.0.2.1

So test-3 set created correctly without counters support, but in all sets listing it displayed as such one with counters.

It seems with commit 5a6021823aa0da24b83f8d03f46ad4202f149fa3 (Support counters in the ipset library) we fogot to add counter options flags to IPSET_CREATE_FLAGS and IPSET_ADT_FLAGS defines to clear these flags when preparing output in callback_list() from lib/session.c.

---
 include/libipset/data.h |    6 ++++++
 1 file changed, 6 insertions(+)
include/libipset/data.h +6 -0
index b6e75e8..fded8bd 100644
@@ -90,6 +90,9 @@ enum ipset_opt {
 	| IPSET_FLAG(IPSET_OPT_PROBES)	\
 	| IPSET_FLAG(IPSET_OPT_RESIZE)	\
 	| IPSET_FLAG(IPSET_OPT_SIZE)	\
+	| IPSET_FLAG(IPSET_OPT_COUNTERS)\
+	| IPSET_FLAG(IPSET_OPT_PACKETS)	\
+	| IPSET_FLAG(IPSET_OPT_BYTES)	\
 	| IPSET_FLAG(IPSET_OPT_CREATE_COMMENT))
 
 #define IPSET_ADT_FLAGS			\
@@ -110,6 +113,9 @@ enum ipset_opt {
 	| IPSET_FLAG(IPSET_OPT_BEFORE) \
 	| IPSET_FLAG(IPSET_OPT_PHYSDEV) \
 	| IPSET_FLAG(IPSET_OPT_NOMATCH) \
+	| IPSET_FLAG(IPSET_OPT_COUNTERS)\
+	| IPSET_FLAG(IPSET_OPT_PACKETS)	\
+	| IPSET_FLAG(IPSET_OPT_BYTES)	\
 	| IPSET_FLAG(IPSET_OPT_ADT_COMMENT))
 
 struct ipset_data;
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 70 lines · Sergey Popovich

Using upstream version with counters support we have following output when listing all sets currently configured:
--------------------------------------------------

 # ipset create test-1 hash:ip
 # ipset create test-2 hash:ip counters
 # ipset add test-2 192.0.2.1/32
 # ipset create test-3 hash:ip
 # ipset add test-3 192.0.2.1/32
 # ipset list
 Name: test-1
 Type: hash:ip
 Revision: 2
 Header: family inet hashsize 1024 maxelem 65536
 Size in memory: 16504
 References: 0
 Members:

Name: test-2
Type: hash:ip
Revision: 2
Header: family inet hashsize 1024 maxelem 65536 counters Size in memory: 16616
References: 0
Members:
192.0.2.1 packets 0 bytes 0

Name: test-3
Type: hash:ip
Revision: 2
Header: family inet hashsize 1024 maxelem 65536 counters Size in memory: 16520
References: 0
Members:
192.0.2.1 packets 0 bytes 0

Set test-3 created without counters, but displayed as with counters present.

Restricting output to list only test-3 set we have:
---------------------------------------------------

  # ipset list test-3
  Name: test-3
  Type: hash:ip
  Revision: 2
  Header: family inet hashsize 1024 maxelem 65536
  Size in memory: 16520
  References: 0
  Members:
  192.0.2.1

So test-3 set created correctly without counters support, but in all sets listing it displayed as such one with counters.

It seems with commit 5a6021823aa0da24b83f8d03f46ad4202f149fa3 (Support counters in the ipset library) we fogot to add counter options flags to IPSET_CREATE_FLAGS and IPSET_ADT_FLAGS defines to clear these flags when preparing output in callback_list() from lib/session.c.

---
 include/libipset/data.h |    6 ++++++
 1 file changed, 6 insertions(+)
include/libipset/data.h +0 -0
index b6e75e8..fded8bd 100644

include/libipset/data.h enum ipset_opt { · line 96

Quoted 7 lines
include/libipset/data.h +3 -0
@@ -90,6 +90,9 @@ enum ipset_opt {
 	| IPSET_FLAG(IPSET_OPT_PROBES)	\
 	| IPSET_FLAG(IPSET_OPT_RESIZE)	\
 	| IPSET_FLAG(IPSET_OPT_SIZE)	\
+	| IPSET_FLAG(IPSET_OPT_COUNTERS)\
+	| IPSET_FLAG(IPSET_OPT_PACKETS)	\
+	| IPSET_FLAG(IPSET_OPT_BYTES)	\
 	| IPSET_FLAG(IPSET_OPT_CREATE_COMMENT))

There's no need to add IPSET_OPT_PACKETS and IPSET_OPT_BYTES to the CREATE option flags, and

include/libipset/data.h enum ipset_opt { · line 119

Quoted 9 lines
include/libipset/data.h +3 -0
 #define IPSET_ADT_FLAGS			\
@@ -110,6 +113,9 @@ enum ipset_opt {
 	| IPSET_FLAG(IPSET_OPT_BEFORE) \
 	| IPSET_FLAG(IPSET_OPT_PHYSDEV) \
 	| IPSET_FLAG(IPSET_OPT_NOMATCH) \
+	| IPSET_FLAG(IPSET_OPT_COUNTERS)\
+	| IPSET_FLAG(IPSET_OPT_PACKETS)	\
+	| IPSET_FLAG(IPSET_OPT_BYTES)	\
 	| IPSET_FLAG(IPSET_OPT_ADT_COMMENT))

similarly, IPSET_OPT_COUNTERS is not required at the ADT option flags.

Please resubmit the patch with these changes. Thanks.

Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics, Hungarian Academy of Sciences

          H-1525 Budapest 114, POB. 49, Hungary
#2 lore raw

PATCH v2 1/3 Fix all set output from list/save when set with counters in use.

In reply to Sergey Popovich

Using upstream version with counters support we have following output when listing all sets currently configured:
--------------------------------------------------

 # ipset create test-1 hash:ip
 # ipset create test-2 hash:ip counters
 # ipset add test-2 192.0.2.1/32
 # ipset create test-3 hash:ip
 # ipset add test-3 192.0.2.1/32
 # ipset list
 Name: test-1
 Type: hash:ip
 Revision: 2
 Header: family inet hashsize 1024 maxelem 65536
 Size in memory: 16504
 References: 0
 Members:

Name: test-2
Type: hash:ip
Revision: 2
Header: family inet hashsize 1024 maxelem 65536 counters Size in memory: 16616
References: 0
Members:
192.0.2.1 packets 0 bytes 0

Name: test-3
Type: hash:ip
Revision: 2
Header: family inet hashsize 1024 maxelem 65536 counters Size in memory: 16520
References: 0
Members:
192.0.2.1 packets 0 bytes 0

Set test-3 created without counters, but displayed as with counters present.

Restricting output to list only test-3 set we have:
---------------------------------------------------

  # ipset list test-3
  Name: test-3
  Type: hash:ip
  Revision: 2
  Header: family inet hashsize 1024 maxelem 65536
  Size in memory: 16520
  References: 0
  Members:
  192.0.2.1

So test-3 set created correctly without counters support, but in all sets listing it displayed as such one with counters.

It seems with commit 5a6021823aa0da24b83f8d03f46ad4202f149fa3 (Support counters in the ipset library) we fogot to add counter options flags to IPSET_CREATE_FLAGS and IPSET_ADT_FLAGS defines to clear these flags when preparing output in callback_list() from lib/session.c.

v2: Remove IPSET_OPT_BYTES, IPSET_PAKETS from CREATE and
IPSET_OPT_COUNTERS from ADT.

---
 include/libipset/data.h |    3 +++
 1 file changed, 3 insertions(+)
include/libipset/data.h +3 -0
index b6e75e8..cbf30cc 100644
@@ -90,6 +90,7 @@ enum ipset_opt {
 	| IPSET_FLAG(IPSET_OPT_PROBES)	\
 	| IPSET_FLAG(IPSET_OPT_RESIZE)	\
 	| IPSET_FLAG(IPSET_OPT_SIZE)	\
+	| IPSET_FLAG(IPSET_OPT_COUNTERS)\
 	| IPSET_FLAG(IPSET_OPT_CREATE_COMMENT))
 
 #define IPSET_ADT_FLAGS			\
@@ -110,6 +111,8 @@ enum ipset_opt {
 	| IPSET_FLAG(IPSET_OPT_BEFORE) \
 	| IPSET_FLAG(IPSET_OPT_PHYSDEV) \
 	| IPSET_FLAG(IPSET_OPT_NOMATCH) \
+	| IPSET_FLAG(IPSET_OPT_PACKETS)	\
+	| IPSET_FLAG(IPSET_OPT_BYTES)	\
 	| IPSET_FLAG(IPSET_OPT_ADT_COMMENT))
 
 struct ipset_data;
Signature · 1 line
1.7.10.4
#3 lore raw
Quoted 91 lines · Sergey Popovich

Using upstream version with counters support we have following output when listing all sets currently configured:
--------------------------------------------------

 # ipset create test-1 hash:ip
 # ipset create test-2 hash:ip counters
 # ipset add test-2 192.0.2.1/32
 # ipset create test-3 hash:ip
 # ipset add test-3 192.0.2.1/32
 # ipset list
 Name: test-1
 Type: hash:ip
 Revision: 2
 Header: family inet hashsize 1024 maxelem 65536
 Size in memory: 16504
 References: 0
 Members:

Name: test-2
Type: hash:ip
Revision: 2
Header: family inet hashsize 1024 maxelem 65536 counters Size in memory: 16616
References: 0
Members:
192.0.2.1 packets 0 bytes 0

Name: test-3
Type: hash:ip
Revision: 2
Header: family inet hashsize 1024 maxelem 65536 counters Size in memory: 16520
References: 0
Members:
192.0.2.1 packets 0 bytes 0

Set test-3 created without counters, but displayed as with counters present.

Restricting output to list only test-3 set we have:
---------------------------------------------------

  # ipset list test-3
  Name: test-3
  Type: hash:ip
  Revision: 2
  Header: family inet hashsize 1024 maxelem 65536
  Size in memory: 16520
  References: 0
  Members:
  192.0.2.1

So test-3 set created correctly without counters support, but in all sets listing it displayed as such one with counters.

It seems with commit 5a6021823aa0da24b83f8d03f46ad4202f149fa3 (Support counters in the ipset library) we fogot to add counter options flags to IPSET_CREATE_FLAGS and IPSET_ADT_FLAGS defines to clear these flags when preparing output in callback_list() from lib/session.c.

v2: Remove IPSET_OPT_BYTES, IPSET_PAKETS from CREATE and
IPSET_OPT_COUNTERS from ADT.

---
 include/libipset/data.h |    3 +++
 1 file changed, 3 insertions(+)
include/libipset/data.h +3 -0
index b6e75e8..cbf30cc 100644
@@ -90,6 +90,7 @@ enum ipset_opt {
 	| IPSET_FLAG(IPSET_OPT_PROBES)	\
 	| IPSET_FLAG(IPSET_OPT_RESIZE)	\
 	| IPSET_FLAG(IPSET_OPT_SIZE)	\
+	| IPSET_FLAG(IPSET_OPT_COUNTERS)\
 	| IPSET_FLAG(IPSET_OPT_CREATE_COMMENT))
 
 #define IPSET_ADT_FLAGS			\
@@ -110,6 +111,8 @@ enum ipset_opt {
 	| IPSET_FLAG(IPSET_OPT_BEFORE) \
 	| IPSET_FLAG(IPSET_OPT_PHYSDEV) \
 	| IPSET_FLAG(IPSET_OPT_NOMATCH) \
+	| IPSET_FLAG(IPSET_OPT_PACKETS)	\
+	| IPSET_FLAG(IPSET_OPT_BYTES)	\
 	| IPSET_FLAG(IPSET_OPT_ADT_COMMENT))
 
 struct ipset_data;
Signature · 1 line
1.7.10.4

Patch is applied, thanks.

Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics, Hungarian Academy of Sciences

          H-1525 Budapest 114, POB. 49, Hungary