[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANr6G5z3SYGo-f7OmKwncHFK0M01YkeWk2W9tPcQWX3LV5NEEA@mail.gmail.com>
Date: Mon, 19 Oct 2015 23:25:48 -0700
From: Joe Stringer <joestringer@...ira.com>
To: Florian Westphal <fw@...len.de>
Cc: netfilter-devel@...r.kernel.org,
Linux Netdev List <netdev@...r.kernel.org>,
Andy Zhou <azhou@...ira.com>
Subject: Re: [PATCH nf-next 4/4] netfilter: ipv6: avoid nf_iterate recursion
On 17 October 2015 at 13:14, Florian Westphal <fw@...len.de> wrote:
> @@ -606,19 +599,22 @@ struct sk_buff *nf_ct_frag6_gather(struct net *net, struct sk_buff *skb, u32 use
> spin_unlock_bh(&fq->q.lock);
> pr_debug("Can't insert skb to queue\n");
> inet_frag_put(&fq->q, &nf_frags);
> - return skb;
> + return -EINVAL;
> }
>
> + /* after queue has assumed skb ownership, only 0 or -EINPROGRESS
> + * must be returned.
> + */
> + ret = -EINPROGRESS;
> if (fq->q.flags == (INET_FRAG_FIRST_IN | INET_FRAG_LAST_IN) &&
> - fq->q.meat == fq->q.len) {
> - ret_skb = nf_ct_frag6_reasm(fq, skb, dev);
> - if (ret_skb == NULL)
> - pr_debug("Can't reassemble fragmented packets\n");
> - }
> + fq->q.meat == fq->q.len &&
> + nf_ct_frag6_reasm(fq, skb, dev))
> + ret = 0;
> +
> spin_unlock_bh(&fq->q.lock);
>
> inet_frag_put(&fq->q, &nf_frags);
> - return ret_skb;
> + return ret;
> }
> EXPORT_SYMBOL_GPL(nf_ct_frag6_gather);
Minor nit below, feel free to disregard if it misses some code style
guideline. The lock/unlock reads easier to me if the
unlocking/frag_put is grouped together, something like the following
incremental:
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c
b/net/ipv6/netfilter/nf_conntrack_reasm.c
index b87dd75967d0..edfd290792f5 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -596,10 +596,8 @@ int nf_ct_frag6_gather(struct net *net, struct
sk_buff *skb, u32 user)
spin_lock_bh(&fq->q.lock);
if (nf_ct_frag6_queue(fq, skb, fhdr, nhoff) < 0) {
- spin_unlock_bh(&fq->q.lock);
- pr_debug("Can't insert skb to queue\n");
- inet_frag_put(&fq->q, &nf_frags);
- return -EINVAL;
+ ret = -EINVAL;
+ goto unlock;
}
/* after queue has assumed skb ownership, only 0 or -EINPROGRESS
@@ -611,9 +609,11 @@ int nf_ct_frag6_gather(struct net *net, struct
sk_buff *skb, u32 user)
nf_ct_frag6_reasm(fq, skb, dev))
ret = 0;
+unlock:
spin_unlock_bh(&fq->q.lock);
-
inet_frag_put(&fq->q, &nf_frags);
+ if (unlikely(ret == -EINVAL))
+ pr_debug("Can't insert skb to queue\n");
return ret;
}
EXPORT_SYMBOL_GPL(nf_ct_frag6_gather);
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists