netns xfrm: add struct xfrm_policy::xp_net
[safe/jmp/linux-2.6] / net / key / af_key.c
index 362fe31..036315d 100644 (file)
@@ -1122,7 +1122,7 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct sadb_msg *hdr,
             (key->sadb_key_bits+7) / 8 > key->sadb_key_len * sizeof(uint64_t)))
                return ERR_PTR(-EINVAL);
 
-       x = xfrm_state_alloc();
+       x = xfrm_state_alloc(&init_net);
        if (x == NULL)
                return ERR_PTR(-ENOBUFS);
 
@@ -1411,7 +1411,7 @@ static int pfkey_acquire(struct sock *sk, struct sk_buff *skb, struct sadb_msg *
        spin_lock_bh(&x->lock);
        if (x->km.state == XFRM_STATE_ACQ) {
                x->km.state = XFRM_STATE_ERROR;
-               wake_up(&km_waitq);
+               wake_up(&init_net.xfrm.km_waitq);
        }
        spin_unlock_bh(&x->lock);
        xfrm_state_put(x);
@@ -2075,7 +2075,6 @@ static int pfkey_xfrm_policy2msg(struct sk_buff *skb, struct xfrm_policy *xp, in
                        req_size += socklen * 2;
                } else {
                        size -= 2*socklen;
-                       socklen = 0;
                }
                rq = (void*)skb_put(skb, req_size);
                pol->sadb_x_policy_len += req_size/8;
@@ -2175,7 +2174,7 @@ static int pfkey_spdadd(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
        if (!pol->sadb_x_policy_dir || pol->sadb_x_policy_dir >= IPSEC_DIR_MAX)
                return -EINVAL;
 
-       xp = xfrm_policy_alloc(GFP_KERNEL);
+       xp = xfrm_policy_alloc(&init_net, GFP_KERNEL);
        if (xp == NULL)
                return -ENOBUFS;
 
@@ -2341,6 +2340,7 @@ static int pfkey_spddelete(struct sock *sk, struct sk_buff *skb, struct sadb_msg
 
        c.seq = hdr->sadb_msg_seq;
        c.pid = hdr->sadb_msg_pid;
+       c.data.byid = 0;
        c.event = XFRM_MSG_DELPOLICY;
        km_policy_notify(xp, pol->sadb_x_policy_dir-1, &c);
 
@@ -3141,7 +3141,7 @@ static struct xfrm_policy *pfkey_compile_policy(struct sock *sk, int opt,
            (!pol->sadb_x_policy_dir || pol->sadb_x_policy_dir > IPSEC_DIR_OUTBOUND))
                return NULL;
 
-       xp = xfrm_policy_alloc(GFP_ATOMIC);
+       xp = xfrm_policy_alloc(&init_net, GFP_ATOMIC);
        if (xp == NULL) {
                *dir = -ENOBUFS;
                return NULL;
@@ -3188,6 +3188,7 @@ static struct xfrm_policy *pfkey_compile_policy(struct sock *sk, int opt,
        return xp;
 
 out:
+       xp->walk.dead = 1;
        xfrm_policy_destroy(xp);
        return NULL;
 }