netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: jamal <hadi@cyberus.ca>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: netdev@oss.sgi.com
Subject: Re: patch: policy update by id
Date: Wed, 27 Apr 2005 21:44:40 -0400	[thread overview]
Message-ID: <1114652680.7663.31.camel@localhost.localdomain> (raw)
In-Reply-To: <20050428012135.GA22950@gondor.apana.org.au>

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


I found a bug in the kernel that i initially thought was in "ip x p". 
If you specify an index when creating a new rule,  the kernel overrides
it regardless.
So i can now update by index with attached patch.

On Thu, 2005-28-04 at 11:21 +1000, Herbert Xu wrote:

> I see.  In that case you want to change your expression above
> so that the memcmp is never done if excl is off and the index
> is non-zero.

Hrm. Thinking... So you want to exclude the selector check if someone
updating ever specified the index? That may change things a little, no?
Give me a clever expression.

>   Otherwise this will result in non-deterministic
> behaviour as the result will change depending on whether the
> first hit is an index match or a selector match.
> 

I was trying to emulate the get/del. There if p->index is specified
it trumps the selector as a search key. 
 
> Actually, would it be so bad to check the policy->index for the
> add case? It does have a well-defined meaning there.

That may not be totally unreasonable depending on what you mean by 
"well defined meaning" ;->
If we want to ensure that theres a uniqueness of indices, then it makes
sense. i.e  noone should be able to add either a selector or index which
match what already is in the SPD (per direction and probably ifindex).
Is that what you mean?

cheers,
jamal

[-- Attachment #2: polid_p2 --]
[-- Type: text/plain, Size: 944 bytes --]

--- a/net/xfrm/xfrm_policy.c	2005/04/27 11:32:13	1.1
+++ b/net/xfrm/xfrm_policy.c	2005/04/28 01:22:42
@@ -345,7 +345,10 @@
 
 	write_lock_bh(&xfrm_policy_lock);
 	for (p = &xfrm_policy_list[dir]; (pol=*p)!=NULL;) {
-		if (!delpol && memcmp(&policy->selector, &pol->selector, sizeof(pol->selector)) == 0) {
+		if (!delpol && 
+		    ((!excl && policy->index && 
+		      (policy->index == pol->index)) || 
+		    (memcmp(&policy->selector, &pol->selector, sizeof(pol->selector)) == 0))) {
 			if (excl) {
 				write_unlock_bh(&xfrm_policy_lock);
 				return -EEXIST;
@@ -370,7 +373,9 @@
 	policy->next = *p;
 	*p = policy;
 	atomic_inc(&flow_cache_genid);
-	policy->index = delpol ? delpol->index : xfrm_gen_index(dir);
+	if (!policy->index)
+		policy->index = delpol ? delpol->index : xfrm_gen_index(dir);
+
 	policy->curlft.add_time = (unsigned long)xtime.tv_sec;
 	policy->curlft.use_time = 0;
 	if (!mod_timer(&policy->timer, jiffies + HZ))

  parent reply	other threads:[~2005-04-28  1:44 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-27 11:54 patch: policy update by id Jamal Hadi Salim
2005-04-27 12:18 ` Patrick McHardy
2005-04-27 12:28   ` Jamal Hadi Salim
2005-04-27 12:52     ` jamal
2005-04-27 12:24 ` jamal
2005-04-27 12:27   ` Jamal Hadi Salim
2005-04-27 23:39     ` Herbert Xu
2005-04-28  1:13       ` jamal
2005-04-28  1:21         ` Herbert Xu
2005-04-28  1:30           ` Herbert Xu
2005-04-28  1:52             ` jamal
2005-04-28  2:07               ` Herbert Xu
2005-04-28  2:20                 ` jamal
2005-04-28  2:22                   ` Herbert Xu
2005-04-28  2:29                     ` jamal
2005-04-28  2:43                 ` David S. Miller
2005-04-28  2:56                   ` Herbert Xu
2005-04-28  3:16                     ` jamal
2005-04-28  3:20                       ` Herbert Xu
2005-04-28 11:43                         ` Thomas Graf
2005-04-28 12:09                           ` Patrick McHardy
2005-04-28 12:33                             ` Thomas Graf
2005-04-28  3:09                   ` jamal
2005-04-28  1:44           ` jamal [this message]
2005-04-28  1:48             ` Herbert Xu
2005-04-28  1:59               ` jamal

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=1114652680.7663.31.camel@localhost.localdomain \
    --to=hadi@cyberus.ca \
    --cc=herbert@gondor.apana.org.au \
    --cc=netdev@oss.sgi.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).