diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2011-12-30 20:32:26 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2012-01-01 16:36:08 +0100 |
commit | 3ab0b245aa550ea4670d096092ca8e8d5e14ac89 (patch) | |
tree | c676525f070f4400d562953ed4ca681cd12da4d9 | |
parent | b236916a68d923acff15787b5439d7d684c17ae5 (diff) | |
download | linux-3.10-3ab0b245aa550ea4670d096092ca8e8d5e14ac89.tar.gz linux-3.10-3ab0b245aa550ea4670d096092ca8e8d5e14ac89.tar.bz2 linux-3.10-3ab0b245aa550ea4670d096092ca8e8d5e14ac89.zip |
netfilter: nfnetlink_acct: fix nfnl_acct_get operation
The get operation was not sending the message that was built to
user-space. This patch also includes the appropriate handling for
the return value of netlink_unicast().
Moreover, fix error codes on error (for example, for non-existing
entry was uncorrect).
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r-- | net/netfilter/nfnetlink_acct.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/net/netfilter/nfnetlink_acct.c b/net/netfilter/nfnetlink_acct.c index 362ab6ca3dc..11ba013e47f 100644 --- a/net/netfilter/nfnetlink_acct.c +++ b/net/netfilter/nfnetlink_acct.c @@ -166,7 +166,7 @@ static int nfnl_acct_get(struct sock *nfnl, struct sk_buff *skb, const struct nlmsghdr *nlh, const struct nlattr * const tb[]) { - int ret = 0; + int ret = -ENOENT; struct nf_acct *cur; char *acct_name; @@ -186,17 +186,26 @@ nfnl_acct_get(struct sock *nfnl, struct sk_buff *skb, continue; skb2 = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); - if (skb2 == NULL) + if (skb2 == NULL) { + ret = -ENOMEM; break; + } ret = nfnl_acct_fill_info(skb2, NETLINK_CB(skb).pid, nlh->nlmsg_seq, NFNL_MSG_TYPE(nlh->nlmsg_type), NFNL_MSG_ACCT_NEW, cur); - if (ret <= 0) + if (ret <= 0) { kfree_skb(skb2); + break; + } + ret = netlink_unicast(nfnl, skb2, NETLINK_CB(skb).pid, + MSG_DONTWAIT); + if (ret > 0) + ret = 0; - break; + /* this avoids a loop in nfnetlink. */ + return ret == -EAGAIN ? -ENOBUFS : ret; } return ret; } |