Commit 463191c2 authored by David S. Miller's avatar David S. Miller

[IPSEC]: Make xfrm_user key manager return proper errors.

parent 8a568f5b
......@@ -110,8 +110,8 @@ extern int init_netlink(void);
extern struct sock *netlink_kernel_create(int unit, void (*input)(struct sock *sk, int len));
extern void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err);
extern int netlink_unicast(struct sock *ssk, struct sk_buff *skb, __u32 pid, int nonblock);
extern void netlink_broadcast(struct sock *ssk, struct sk_buff *skb, __u32 pid,
__u32 group, int allocation);
extern int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, __u32 pid,
__u32 group, int allocation);
extern void netlink_set_err(struct sock *ssk, __u32 pid, __u32 group, int code);
extern int netlink_register_notifier(struct notifier_block *nb);
extern int netlink_unregister_notifier(struct notifier_block *nb);
......
......@@ -910,9 +910,8 @@ static int xfrm_send_notify(struct xfrm_state *x, int hard)
BUG();
NETLINK_CB(skb).dst_groups = XFRMGRP_EXPIRE;
netlink_broadcast(xfrm_nl, skb, 0, XFRMGRP_EXPIRE, GFP_ATOMIC);
return 0;
return netlink_broadcast(xfrm_nl, skb, 0, XFRMGRP_EXPIRE, GFP_ATOMIC);
}
/* XXX Make this xfrm_state.c:xfrm_get_acqseq() */
......@@ -971,9 +970,8 @@ static int xfrm_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *xt,
BUG();
NETLINK_CB(skb).dst_groups = XFRMGRP_ACQUIRE;
netlink_broadcast(xfrm_nl, skb, 0, XFRMGRP_ACQUIRE, GFP_ATOMIC);
return 0;
return netlink_broadcast(xfrm_nl, skb, 0, XFRMGRP_ACQUIRE, GFP_ATOMIC);
}
/* User gives us xfrm_user_policy_info followed by an array of 0
......
......@@ -503,13 +503,13 @@ static __inline__ int netlink_broadcast_deliver(struct sock *sk, struct sk_buff
return -1;
}
void netlink_broadcast(struct sock *ssk, struct sk_buff *skb, u32 pid,
u32 group, int allocation)
int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, u32 pid,
u32 group, int allocation)
{
struct sock *sk;
struct sk_buff *skb2 = NULL;
int protocol = ssk->protocol;
int failure = 0;
int failure = 0, delivered = 0;
/* While we sleep in clone, do not allow to change socket list */
......@@ -544,8 +544,10 @@ void netlink_broadcast(struct sock *ssk, struct sk_buff *skb, u32 pid,
failure = 1;
} else if (netlink_broadcast_deliver(sk, skb2)) {
netlink_overrun(sk);
} else
} else {
delivered = 1;
skb2 = NULL;
}
sock_put(sk);
}
......@@ -554,6 +556,12 @@ void netlink_broadcast(struct sock *ssk, struct sk_buff *skb, u32 pid,
if (skb2)
kfree_skb(skb2);
kfree_skb(skb);
if (delivered)
return 0;
if (failure)
return -ENOBUFS;
return -ESRCH;
}
void netlink_set_err(struct sock *ssk, u32 pid, u32 group, int code)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment