提交 dd5b6ce6 编写于 作者: P Pablo Neira Ayuso 提交者: Patrick McHardy

nefilter: nfnetlink: add nfnetlink_set_err and use it in ctnetlink

This patch adds nfnetlink_set_err() to propagate the error to netlink
broadcast listener in case of memory allocation errors in the
message building.
Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: NPatrick McHardy <kaber@trash.net>
上级 17625274
...@@ -76,6 +76,7 @@ extern int nfnetlink_subsys_unregister(const struct nfnetlink_subsystem *n); ...@@ -76,6 +76,7 @@ extern int nfnetlink_subsys_unregister(const struct nfnetlink_subsystem *n);
extern int nfnetlink_has_listeners(unsigned int group); extern int nfnetlink_has_listeners(unsigned int group);
extern int nfnetlink_send(struct sk_buff *skb, u32 pid, unsigned group, extern int nfnetlink_send(struct sk_buff *skb, u32 pid, unsigned group,
int echo); int echo);
extern void nfnetlink_set_err(u32 pid, u32 group, int error);
extern int nfnetlink_unicast(struct sk_buff *skb, u_int32_t pid, int flags); extern int nfnetlink_unicast(struct sk_buff *skb, u_int32_t pid, int flags);
extern void nfnl_lock(void); extern void nfnl_lock(void);
......
...@@ -518,6 +518,7 @@ static int ctnetlink_conntrack_event(struct notifier_block *this, ...@@ -518,6 +518,7 @@ static int ctnetlink_conntrack_event(struct notifier_block *this,
nla_put_failure: nla_put_failure:
rcu_read_unlock(); rcu_read_unlock();
nlmsg_failure: nlmsg_failure:
nfnetlink_set_err(0, group, -ENOBUFS);
kfree_skb(skb); kfree_skb(skb);
return NOTIFY_DONE; return NOTIFY_DONE;
} }
...@@ -1514,6 +1515,7 @@ static int ctnetlink_expect_event(struct notifier_block *this, ...@@ -1514,6 +1515,7 @@ static int ctnetlink_expect_event(struct notifier_block *this,
nla_put_failure: nla_put_failure:
rcu_read_unlock(); rcu_read_unlock();
nlmsg_failure: nlmsg_failure:
nfnetlink_set_err(0, 0, -ENOBUFS);
kfree_skb(skb); kfree_skb(skb);
return NOTIFY_DONE; return NOTIFY_DONE;
} }
......
...@@ -113,6 +113,12 @@ int nfnetlink_send(struct sk_buff *skb, u32 pid, unsigned group, int echo) ...@@ -113,6 +113,12 @@ int nfnetlink_send(struct sk_buff *skb, u32 pid, unsigned group, int echo)
} }
EXPORT_SYMBOL_GPL(nfnetlink_send); EXPORT_SYMBOL_GPL(nfnetlink_send);
void nfnetlink_set_err(u32 pid, u32 group, int error)
{
netlink_set_err(nfnl, pid, group, error);
}
EXPORT_SYMBOL_GPL(nfnetlink_set_err);
int nfnetlink_unicast(struct sk_buff *skb, u_int32_t pid, int flags) int nfnetlink_unicast(struct sk_buff *skb, u_int32_t pid, int flags)
{ {
return netlink_unicast(nfnl, skb, pid, flags); return netlink_unicast(nfnl, skb, pid, flags);
......
...@@ -1106,6 +1106,7 @@ void netlink_set_err(struct sock *ssk, u32 pid, u32 group, int code) ...@@ -1106,6 +1106,7 @@ void netlink_set_err(struct sock *ssk, u32 pid, u32 group, int code)
read_unlock(&nl_table_lock); read_unlock(&nl_table_lock);
} }
EXPORT_SYMBOL(netlink_set_err);
/* must be called with netlink table grabbed */ /* must be called with netlink table grabbed */
static void netlink_update_socket_mc(struct netlink_sock *nlk, static void netlink_update_socket_mc(struct netlink_sock *nlk,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册