All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Victor Stinner <victor.stinner@inl.fr>
Cc: netfilter-devel@lists.netfilter.org
Subject: Re: Bugfix: libnetfilter_conntrack getter and setter
Date: Fri, 05 Jan 2007 15:45:20 +0100	[thread overview]
Message-ID: <459E6480.1010806@netfilter.org> (raw)
In-Reply-To: <200701041103.39580.victor.stinner@inl.fr>

[-- Attachment #1: Type: text/plain, Size: 1323 bytes --]

Hi,

Victor Stinner wrote:
> Libnetfilter_conntrack getters and setters of new API are not complete:
>  * it's not possible to set counter attributes value

Because of ctnetlink, the kernel part of this whole thing, doesn't
support this. Anyway, as you pointed out below, I can't see how this
could be useful.

>  * it's not possible to set or read 'use' and 'id' attributes value

The 'use' attribute must be possible to be get, but not set. I'll commit
the patch for the getter mangled, I prefer dropping the 'id' support
since it's planned to be removed.

> 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.

OK, I think that the patch attached should be enough.

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

I prefer doing nothing and documenting this issue, perhaps doing some
kind of warning or assertion, although that would be too much I think.
Moreover, the error thing would pollute the code with tons of error
checkings in the set operations.

Thanks again Victor.

-- 
The dawn of the fourth age of Linux firewalling is coming; a time of
great struggle and heroic deeds -- J.Kadlecsik got inspired by J.Morris

[-- Attachment #2: x --]
[-- Type: text/plain, Size: 1527 bytes --]

Index: src/conntrack/api.c
===================================================================
--- src/conntrack/api.c	(revisión: 6716)
+++ src/conntrack/api.c	(copia de trabajo)
@@ -185,6 +185,12 @@
  * @ct: pointer to a valid conntrack
  * @type: attribute type
  * @value: pointer to the attribute value
+ *
+ * Note that certain attributes are unsettable:
+ * 	- ATTR_USE
+ * 	- ATTR_ID
+ * 	- ATTR_*_COUNTER_*
+ * The call of this function for such attributes do nothing.
  */
 void nfct_set_attr(struct nf_conntrack *ct,
 		   const enum nf_conntrack_attr type, 
@@ -196,8 +202,10 @@
 	if (type >= ATTR_MAX)
 		return;
 
-	set_attr_array[type](ct, value);
-	set_bit(type, ct->set);
+	if (set_attr_array[type]) {
+		set_attr_array[type](ct, value);
+		set_bit(type, ct->set);
+	}
 }
 
 /**
Index: src/conntrack/getter.c
===================================================================
--- src/conntrack/getter.c	(revisión: 6716)
+++ src/conntrack/getter.c	(copia de trabajo)
@@ -162,6 +162,11 @@
 	return &ct->status;
 }
 
+static const void *get_attr_use(const struct nf_conntrack *ct)
+{
+	return &ct->use;
+}
+
 get_attr get_attr_array[] = {
 	[ATTR_ORIG_IPV4_SRC]		= get_attr_orig_ipv4_src,
 	[ATTR_ORIG_IPV4_DST] 		= get_attr_orig_ipv4_dst,
@@ -193,5 +198,6 @@
 	[ATTR_ORIG_COUNTER_BYTES]	= get_attr_orig_counter_bytes,
 	[ATTR_REPL_COUNTER_PACKETS]	= get_attr_repl_counter_packets,
 	[ATTR_REPL_COUNTER_BYTES]	= get_attr_repl_counter_bytes,
+	[ATTR_USE]			= get_attr_use,
 	[ATTR_STATUS]			= get_attr_status,
 };

  reply	other threads:[~2007-01-05 14:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-04 10:03 Bugfix: libnetfilter_conntrack getter and setter Victor Stinner
2007-01-05 14:45 ` Pablo Neira Ayuso [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-01-03 18:42 Victor Stinner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=459E6480.1010806@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=netfilter-devel@lists.netfilter.org \
    --cc=victor.stinner@inl.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.