Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-2.6
[sfrench/cifs-2.6.git] / net / netfilter / nf_conntrack_netlink.c
index c6439c77953c49cf705ac07fe758764d1cc82a9d..c523f0b8cee53bd9e304af4db77a4a474c44bcbe 100644 (file)
@@ -512,7 +512,7 @@ static int ctnetlink_conntrack_event(struct notifier_block *this,
 
        skb = ctnetlink_alloc_skb(tuple(ct, IP_CT_DIR_ORIGINAL), GFP_ATOMIC);
        if (!skb)
-               return NOTIFY_DONE;
+               goto errout;
 
        b = skb->tail;
 
@@ -591,8 +591,9 @@ static int ctnetlink_conntrack_event(struct notifier_block *this,
 nla_put_failure:
        rcu_read_unlock();
 nlmsg_failure:
-       nfnetlink_set_err(0, group, -ENOBUFS);
        kfree_skb(skb);
+errout:
+       nfnetlink_set_err(0, group, -ENOBUFS);
        return NOTIFY_DONE;
 }
 #endif /* CONFIG_NF_CONNTRACK_EVENTS */
@@ -987,7 +988,7 @@ ctnetlink_change_helper(struct nf_conn *ct, struct nlattr *cda[])
 {
        struct nf_conntrack_helper *helper;
        struct nf_conn_help *help = nfct_help(ct);
-       char *helpname;
+       char *helpname = NULL;
        int err;
 
        /* don't change helper of sibling connections */
@@ -1185,28 +1186,6 @@ ctnetlink_change_conntrack(struct nf_conn *ct, struct nlattr *cda[])
        return 0;
 }
 
-static inline void
-ctnetlink_event_report(struct nf_conn *ct, u32 pid, int report)
-{
-       unsigned int events = 0;
-
-       if (test_bit(IPS_EXPECTED_BIT, &ct->status))
-               events |= IPCT_RELATED;
-       else
-               events |= IPCT_NEW;
-
-       nf_conntrack_event_report(IPCT_STATUS |
-                                 IPCT_HELPER |
-                                 IPCT_REFRESH |
-                                 IPCT_PROTOINFO |
-                                 IPCT_NATSEQADJ |
-                                 IPCT_MARK |
-                                 events,
-                                 ct,
-                                 pid,
-                                 report);
-}
-
 static struct nf_conn *
 ctnetlink_create_conntrack(struct nlattr *cda[],
                           struct nf_conntrack_tuple *otuple,
@@ -1230,7 +1209,7 @@ ctnetlink_create_conntrack(struct nlattr *cda[],
 
        rcu_read_lock();
        if (cda[CTA_HELP]) {
-               char *helpname;
+               char *helpname = NULL;
  
                err = ctnetlink_parse_help(cda[CTA_HELP], &helpname);
                if (err < 0)
@@ -1372,6 +1351,7 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
                err = -ENOENT;
                if (nlh->nlmsg_flags & NLM_F_CREATE) {
                        struct nf_conn *ct;
+                       enum ip_conntrack_events events;
 
                        ct = ctnetlink_create_conntrack(cda, &otuple,
                                                        &rtuple, u3);
@@ -1382,9 +1362,18 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
                        err = 0;
                        nf_conntrack_get(&ct->ct_general);
                        spin_unlock_bh(&nf_conntrack_lock);
-                       ctnetlink_event_report(ct,
-                                              NETLINK_CB(skb).pid,
-                                              nlmsg_report(nlh));
+                       if (test_bit(IPS_EXPECTED_BIT, &ct->status))
+                               events = IPCT_RELATED;
+                       else
+                               events = IPCT_NEW;
+
+                       nf_conntrack_event_report(IPCT_STATUS |
+                                                 IPCT_HELPER |
+                                                 IPCT_PROTOINFO |
+                                                 IPCT_NATSEQADJ |
+                                                 IPCT_MARK | events,
+                                                 ct, NETLINK_CB(skb).pid,
+                                                 nlmsg_report(nlh));
                        nf_ct_put(ct);
                } else
                        spin_unlock_bh(&nf_conntrack_lock);
@@ -1403,9 +1392,13 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
                if (err == 0) {
                        nf_conntrack_get(&ct->ct_general);
                        spin_unlock_bh(&nf_conntrack_lock);
-                       ctnetlink_event_report(ct,
-                                              NETLINK_CB(skb).pid,
-                                              nlmsg_report(nlh));
+                       nf_conntrack_event_report(IPCT_STATUS |
+                                                 IPCT_HELPER |
+                                                 IPCT_PROTOINFO |
+                                                 IPCT_NATSEQADJ |
+                                                 IPCT_MARK,
+                                                 ct, NETLINK_CB(skb).pid,
+                                                 nlmsg_report(nlh));
                        nf_ct_put(ct);
                } else
                        spin_unlock_bh(&nf_conntrack_lock);
@@ -1564,7 +1557,7 @@ static int ctnetlink_expect_event(struct notifier_block *this,
 
        skb = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC);
        if (!skb)
-               return NOTIFY_DONE;
+               goto errout;
 
        b = skb->tail;
 
@@ -1589,8 +1582,9 @@ static int ctnetlink_expect_event(struct notifier_block *this,
 nla_put_failure:
        rcu_read_unlock();
 nlmsg_failure:
-       nfnetlink_set_err(0, 0, -ENOBUFS);
        kfree_skb(skb);
+errout:
+       nfnetlink_set_err(0, 0, -ENOBUFS);
        return NOTIFY_DONE;
 }
 #endif