[PATCH] XFRM: remove redundant parameter "int dir" in struct xfrm_mgr.acquire

Subsystems: networking [general], networking [ipsec], the rest

STALE5109d

4 messages, 3 authors, 2012-08-14 · open the first message on its own page

[PATCH] XFRM: remove redundant parameter "int dir" in struct xfrm_mgr.acquire

From: Fan Du <hidden>
Date: 2012-08-13 06:26:07

Sematically speaking, xfrm_mgr.acquire is called when kernel intends to ask
user space IKE daemon to negotiate SAs with peers. IOW the direction will
*always* be XFRM_POLICY_OUT, so remove int dir for clarity.

Signed-off-by: Fan Du <redacted>
---
 include/net/xfrm.h    |    2 +-
 net/key/af_key.c      |    4 ++--
 net/xfrm/xfrm_state.c |    2 +-
 net/xfrm/xfrm_user.c  |    4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 62b619e..5e1662d 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -571,7 +571,7 @@ struct xfrm_mgr {
 	struct list_head	list;
 	char			*id;
 	int			(*notify)(struct xfrm_state *x, const struct km_event *c);
-	int			(*acquire)(struct xfrm_state *x, struct xfrm_tmpl *, struct xfrm_policy *xp, int dir);
+	int			(*acquire)(struct xfrm_state *x, struct xfrm_tmpl *, struct xfrm_policy *xp);
 	struct xfrm_policy	*(*compile_policy)(struct sock *sk, int opt, u8 *data, int len, int *dir);
 	int			(*new_mapping)(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport);
 	int			(*notify_policy)(struct xfrm_policy *x, int dir, const struct km_event *c);
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 34e4185..ec7d161 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -3024,7 +3024,7 @@ static u32 get_acqseq(void)
 	return res;
 }
 
-static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_policy *xp, int dir)
+static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_policy *xp)
 {
 	struct sk_buff *skb;
 	struct sadb_msg *hdr;
@@ -3105,7 +3105,7 @@ static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct
 	pol->sadb_x_policy_len = sizeof(struct sadb_x_policy)/sizeof(uint64_t);
 	pol->sadb_x_policy_exttype = SADB_X_EXT_POLICY;
 	pol->sadb_x_policy_type = IPSEC_POLICY_IPSEC;
-	pol->sadb_x_policy_dir = dir+1;
+	pol->sadb_x_policy_dir = XFRM_POLICY_OUT + 1;
 	pol->sadb_x_policy_id = xp->index;
 
 	/* Set sadb_comb's. */
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 87cd0e4..7856c33 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -1700,7 +1700,7 @@ int km_query(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_policy *pol)
 
 	read_lock(&xfrm_km_lock);
 	list_for_each_entry(km, &xfrm_km_list, list) {
-		acqret = km->acquire(x, t, pol, XFRM_POLICY_OUT);
+		acqret = km->acquire(x, t, pol);
 		if (!acqret)
 			err = acqret;
 	}
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index e75d8e4..844e661 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -2605,7 +2605,7 @@ static int build_acquire(struct sk_buff *skb, struct xfrm_state *x,
 }
 
 static int xfrm_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *xt,
-			     struct xfrm_policy *xp, int dir)
+			     struct xfrm_policy *xp)
 {
 	struct net *net = xs_net(x);
 	struct sk_buff *skb;
@@ -2614,7 +2614,7 @@ static int xfrm_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *xt,
 	if (skb == NULL)
 		return -ENOMEM;
 
-	if (build_acquire(skb, x, xt, xp, dir) < 0)
+	if (build_acquire(skb, x, xt, xp, XFRM_POLICY_OUT) < 0)
 		BUG();
 
 	return nlmsg_multicast(net->xfrm.nlsk, skb, 0, XFRMNLGRP_ACQUIRE, GFP_ATOMIC);
-- 
1.7.1

Re: [PATCH] XFRM: remove redundant parameter "int dir" in struct xfrm_mgr.acquire

From: Steffen Klassert <steffen.klassert@secunet.com>
Date: 2012-08-13 07:08:44

On Mon, Aug 13, 2012 at 02:25:57PM +0800, Fan Du wrote:
quoted hunk
 
 static int xfrm_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *xt,
-			     struct xfrm_policy *xp, int dir)
+			     struct xfrm_policy *xp)
 {
 	struct net *net = xs_net(x);
 	struct sk_buff *skb;
@@ -2614,7 +2614,7 @@ static int xfrm_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *xt,
 	if (skb == NULL)
 		return -ENOMEM;
 
-	if (build_acquire(skb, x, xt, xp, dir) < 0)
+	if (build_acquire(skb, x, xt, xp, XFRM_POLICY_OUT) < 0)
 		BUG();
xfrm_send_acquire() is the only caller of build_acquire().
So if you remove the dir parameter from xfrm_send_acquire(),
you can remove it from build_acquire() too. 

Re: [PATCH] XFRM: remove redundant parameter "int dir" in struct xfrm_mgr.acquire

From: Fan Du <hidden>
Date: 2012-08-13 07:17:53


On 2012年08月13日 15:08, Steffen Klassert wrote:
On Mon, Aug 13, 2012 at 02:25:57PM +0800, Fan Du wrote:
quoted
  static int xfrm_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *xt,
-			     struct xfrm_policy *xp, int dir)
+			     struct xfrm_policy *xp)
  {
  	struct net *net = xs_net(x);
  	struct sk_buff *skb;
@@ -2614,7 +2614,7 @@ static int xfrm_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *xt,
  	if (skb == NULL)
  		return -ENOMEM;

-	if (build_acquire(skb, x, xt, xp, dir)<  0)
+	if (build_acquire(skb, x, xt, xp, XFRM_POLICY_OUT)<  0)
  		BUG();
xfrm_send_acquire() is the only caller of build_acquire().
So if you remove the dir parameter from xfrm_send_acquire(),
you can remove it from build_acquire() too.
Yep, looks like we can only remove "dir" at build_acquire, not into
copy_to_user_policy anymore :)

I will adopt your approach in v2 if Dave say *YES* about this patch.
thanks anyway.

-- 

Love each day!
--fan

Re: [PATCH] XFRM: remove redundant parameter "int dir" in struct xfrm_mgr.acquire

From: David Miller <davem@davemloft.net>
Date: 2012-08-14 21:57:00

From: Fan Du <redacted>
Date: Mon, 13 Aug 2012 15:23:09 +0800

On 2012年08月13日 15:08, Steffen Klassert wrote:
quoted
On Mon, Aug 13, 2012 at 02:25:57PM +0800, Fan Du wrote:
quoted
  static int xfrm_send_acquire(struct xfrm_state *x, struct xfrm_tmpl
  *xt,
-			     struct xfrm_policy *xp, int dir)
+			     struct xfrm_policy *xp)
  {
  	struct net *net = xs_net(x);
  	struct sk_buff *skb;
@@ -2614,7 +2614,7 @@ static int xfrm_send_acquire(struct xfrm_state
*x, struct xfrm_tmpl *xt,
  	if (skb == NULL)
  		return -ENOMEM;

-	if (build_acquire(skb, x, xt, xp, dir)<  0)
+	if (build_acquire(skb, x, xt, xp, XFRM_POLICY_OUT)<  0)
  		BUG();
xfrm_send_acquire() is the only caller of build_acquire().
So if you remove the dir parameter from xfrm_send_acquire(),
you can remove it from build_acquire() too.
Yep, looks like we can only remove "dir" at build_acquire, not into
copy_to_user_policy anymore :)

I will adopt your approach in v2 if Dave say *YES* about this patch.
thanks anyway.
Looks find to me.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help