diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2011-12-24 13:03:46 -0500 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2011-12-24 13:49:04 -0500 |
commit | 81378f728fe560e175fb2e8fd33206793567e896 (patch) | |
tree | 9b64245afa92a9790c9df00067250ed625c5156e | |
parent | 3f1e6d3fd37bd4f25e5b19f1c7ca21850426c33f (diff) |
netfilter: ctnetlink: fix return value of ctnetlink_get_expect()
This fixes one bogus error that is returned to user-space:
libnetfilter_conntrack/utils# ./expect_get
TEST: get expectation (-1)(Unknown error 18446744073709551504)
This patch includes the correct handling for EAGAIN (nfnetlink
uses this error value to restart the operation after module
auto-loading).
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r-- | net/netfilter/nf_conntrack_netlink.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index ef21b221f036..3d7ea7af76fc 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c | |||
@@ -1869,25 +1869,30 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb, | |||
1869 | 1869 | ||
1870 | err = -ENOMEM; | 1870 | err = -ENOMEM; |
1871 | skb2 = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); | 1871 | skb2 = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); |
1872 | if (skb2 == NULL) | 1872 | if (skb2 == NULL) { |
1873 | nf_ct_expect_put(exp); | ||
1873 | goto out; | 1874 | goto out; |
1875 | } | ||
1874 | 1876 | ||
1875 | rcu_read_lock(); | 1877 | rcu_read_lock(); |
1876 | err = ctnetlink_exp_fill_info(skb2, NETLINK_CB(skb).pid, | 1878 | err = ctnetlink_exp_fill_info(skb2, NETLINK_CB(skb).pid, |
1877 | nlh->nlmsg_seq, IPCTNL_MSG_EXP_NEW, exp); | 1879 | nlh->nlmsg_seq, IPCTNL_MSG_EXP_NEW, exp); |
1878 | rcu_read_unlock(); | 1880 | rcu_read_unlock(); |
1881 | nf_ct_expect_put(exp); | ||
1879 | if (err <= 0) | 1882 | if (err <= 0) |
1880 | goto free; | 1883 | goto free; |
1881 | 1884 | ||
1882 | nf_ct_expect_put(exp); | 1885 | err = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT); |
1886 | if (err < 0) | ||
1887 | goto out; | ||
1883 | 1888 | ||
1884 | return netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT); | 1889 | return 0; |
1885 | 1890 | ||
1886 | free: | 1891 | free: |
1887 | kfree_skb(skb2); | 1892 | kfree_skb(skb2); |
1888 | out: | 1893 | out: |
1889 | nf_ct_expect_put(exp); | 1894 | /* this avoids a loop in nfnetlink. */ |
1890 | return err; | 1895 | return err == -EAGAIN ? -ENOBUFS : err; |
1891 | } | 1896 | } |
1892 | 1897 | ||
1893 | static int | 1898 | static int |