All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: xfrm_add_sa_expire return codes
       [not found] <499d6ed30702261426r107fb555hd621418376f5c61c@mail.gmail.com>
@ 2007-02-26 22:48 ` David Miller
  2007-02-27  0:31   ` jamal
  0 siblings, 1 reply; 2+ messages in thread
From: David Miller @ 2007-02-26 22:48 UTC (permalink / raw)
  To: shpedoikal; +Cc: netdev, hadi

From: "Kent Yoder" <shpedoikal@gmail.com>
Date: Mon, 26 Feb 2007 16:26:41 -0600

>   I was browsing through the xfrm_user.c code and noticed that it
> appears that in xfrm_add_sa_expire, the only possible return codes are
> -ENOENT and -EINVAL.  Was this intentional, or is this a bug?

Please use netdev@vger.kernel.org for kernel networking
discussions, thanks.

Indeed, and the tabbing on the first "err = " assignment should
be a clue that some mistake might have been added.

It looks like the code has been like that from day one, I wonder
how Jamal tested this stuff :-)

I'm going to assume the intended logic, and fix it like this.
Jamal?

diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 2567453..924a2fe 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -1557,14 +1557,13 @@ static int xfrm_add_sa_expire(struct sk_buff *skb, struct nlmsghdr *nlh,
 	struct xfrm_usersa_info *p = &ue->state;
 
 	x = xfrm_state_lookup(&p->id.daddr, p->id.spi, p->id.proto, p->family);
-		err = -ENOENT;
 
+	err = -ENOENT;
 	if (x == NULL)
 		return err;
 
-	err = -EINVAL;
-
 	spin_lock_bh(&x->lock);
+	err = -EINVAL;
 	if (x->km.state != XFRM_STATE_VALID)
 		goto out;
 	km_state_expired(x, ue->hard, current->pid);
@@ -1574,6 +1573,7 @@ static int xfrm_add_sa_expire(struct sk_buff *skb, struct nlmsghdr *nlh,
 		xfrm_audit_log(NETLINK_CB(skb).loginuid, NETLINK_CB(skb).sid,
 			       AUDIT_MAC_IPSEC_DELSA, 1, NULL, x);
 	}
+	err = 0;
 out:
 	spin_unlock_bh(&x->lock);
 	xfrm_state_put(x);

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: xfrm_add_sa_expire return codes
  2007-02-26 22:48 ` xfrm_add_sa_expire return codes David Miller
@ 2007-02-27  0:31   ` jamal
  0 siblings, 0 replies; 2+ messages in thread
From: jamal @ 2007-02-27  0:31 UTC (permalink / raw)
  To: David Miller; +Cc: shpedoikal, netdev

On Mon, 2007-26-02 at 14:48 -0800, David Miller wrote:

> Indeed, and the tabbing on the first "err = " assignment should
> be a clue that some mistake might have been added.
> 
> It looks like the code has been like that from day one, I wonder
> how Jamal tested this stuff :-)
> 

I am asking myself the same question staring at that;-> 
Let me look at the test code tommorow and get back to you. I know my
test was "passing" ;->

> I'm going to assume the intended logic, and fix it like this.
> Jamal?
> 

Looks good - thanks Dave.

cheers,
jamal


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-02-27  0:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <499d6ed30702261426r107fb555hd621418376f5c61c@mail.gmail.com>
2007-02-26 22:48 ` xfrm_add_sa_expire return codes David Miller
2007-02-27  0:31   ` jamal

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.