Skip to contentSkip to conversation

Bugfix: libnetfilter_conntrack getter and setter

PATCH Victor Stinner 1 participant 1 message Jan 3, 2007 netfilter

lore
Share & tools
lore
#0 lore raw

Hi,

Libnetfilter_conntrack getters and setters of new API are not complete:
* it's not possible to set counter attributes value
* it's not possible to set or read 'use' and 'id' attributes value

I can understand that setting counter values is not very useful, but trying to set them would lead to a crash (call NULL function). Same problem when trying to read use/id attribute value.

I attached two patches to fix that.

---

An alternative for nfct_set_attr() is to do nothing if the getter in NULL (and set an error?).

Victor Stinner aka haypo
http://hachoir.org/

conntrack/getter.c +13 -1
Index: src/conntrack/getter.c
===================================================================
@@ -157,6 +157,16 @@
 	return &ct->counters[__DIR_REPL].bytes;
 }
 
+static const void *get_attr_use(const struct nf_conntrack *ct)
+{
+	return &ct->use;
+}
+
+static const void *get_attr_id(const struct nf_conntrack *ct)
+{
+	return &ct->id;
+}
+
 static const void *get_attr_status(const struct nf_conntrack *ct)
 {
 	return &ct->status;
@@ -190,8 +200,10 @@
 	[ATTR_TIMEOUT]			= get_attr_timeout,
 	[ATTR_MARK]			= get_attr_mark,
 	[ATTR_ORIG_COUNTER_PACKETS] 	= get_attr_orig_counter_packets,
-	[ATTR_ORIG_COUNTER_BYTES]	= get_attr_orig_counter_bytes,
 	[ATTR_REPL_COUNTER_PACKETS]	= get_attr_repl_counter_packets,
+	[ATTR_ORIG_COUNTER_BYTES]	= get_attr_orig_counter_bytes,
 	[ATTR_REPL_COUNTER_BYTES]	= get_attr_repl_counter_bytes,
+	[ATTR_USE]			= get_attr_use,
+	[ATTR_ID]			= get_attr_id,
 	[ATTR_STATUS]			= get_attr_status,
 };
conntrack/setter.c +63 -27

100 lines not on this page · raw message