Skip to content

Commit 2e404f6

Browse files
Nikolay Aleksandrovdavem330
authored andcommitted
inet: frags: use INET_FRAG_EVICTED to prevent icmp messages
Now that we have INET_FRAG_EVICTED we might as well use it to stop sending icmp messages in the "frag_expire" functions instead of stripping INET_FRAG_FIRST_IN from their flags when evicting. Also fix the comment style in ip6_expire_frag_queue(). Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com> Reviewed-by: Florian Westphal <fw@strlen.de> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f926e23 commit 2e404f6

3 files changed

Lines changed: 15 additions & 16 deletions

File tree

‎net/ipv4/inet_fragment.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ inet_evict_bucket(struct inet_frags *f, struct inet_frag_bucket *hb)
151151
goto evict_again;
152152
}
153153

154-
/* suppress xmit of (icmp) error packet */
155-
fq->flags &= ~INET_FRAG_FIRST_IN;
156154
fq->flags |= INET_FRAG_EVICTED;
157155
hlist_del(&fq->list);
158156
hlist_add_head(&fq->list, &expired);

‎net/ipv4/ip_fragment.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,16 +189,18 @@ static void ip_expire(unsigned long arg)
189189
goto out;
190190

191191
ipq_kill(qp);
192-
193-
if (!(qp->q.flags & INET_FRAG_EVICTED))
194-
IP_INC_STATS_BH(net, IPSTATS_MIB_REASMTIMEOUT);
195192
IP_INC_STATS_BH(net, IPSTATS_MIB_REASMFAILS);
196193

197-
if ((qp->q.flags & INET_FRAG_FIRST_IN) && qp->q.fragments != NULL) {
194+
if (!(qp->q.flags & INET_FRAG_EVICTED)) {
198195
struct sk_buff *head = qp->q.fragments;
199196
const struct iphdr *iph;
200197
int err;
201198

199+
IP_INC_STATS_BH(net, IPSTATS_MIB_REASMTIMEOUT);
200+
201+
if (!(qp->q.flags & INET_FRAG_FIRST_IN) || !qp->q.fragments)
202+
goto out;
203+
202204
rcu_read_lock();
203205
head->dev = dev_get_by_index_rcu(net, qp->iif);
204206
if (!head->dev)
@@ -211,8 +213,7 @@ static void ip_expire(unsigned long arg)
211213
if (err)
212214
goto out_rcu_unlock;
213215

214-
/*
215-
* Only an end host needs to send an ICMP
216+
/* Only an end host needs to send an ICMP
216217
* "Fragment Reassembly Timeout" message, per RFC792.
217218
*/
218219
if (qp->user == IP_DEFRAG_AF_PACKET ||
@@ -221,7 +222,6 @@ static void ip_expire(unsigned long arg)
221222
(skb_rtable(head)->rt_type != RTN_LOCAL)))
222223
goto out_rcu_unlock;
223224

224-
225225
/* Send an ICMP "Fragment Reassembly Timeout" message. */
226226
icmp_send(head, ICMP_TIME_EXCEEDED, ICMP_EXC_FRAGTIME, 0);
227227
out_rcu_unlock:

‎net/ipv6/reassembly.c‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,19 +141,20 @@ void ip6_expire_frag_queue(struct net *net, struct frag_queue *fq,
141141
if (!dev)
142142
goto out_rcu_unlock;
143143

144-
if (!(fq->q.flags & INET_FRAG_EVICTED))
145-
IP6_INC_STATS_BH(net, __in6_dev_get(dev),
146-
IPSTATS_MIB_REASMTIMEOUT);
147144
IP6_INC_STATS_BH(net, __in6_dev_get(dev), IPSTATS_MIB_REASMFAILS);
148145

146+
if (fq->q.flags & INET_FRAG_EVICTED)
147+
goto out_rcu_unlock;
148+
149+
IP6_INC_STATS_BH(net, __in6_dev_get(dev), IPSTATS_MIB_REASMTIMEOUT);
150+
149151
/* Don't send error if the first segment did not arrive. */
150152
if (!(fq->q.flags & INET_FRAG_FIRST_IN) || !fq->q.fragments)
151153
goto out_rcu_unlock;
152154

153-
/*
154-
But use as source device on which LAST ARRIVED
155-
segment was received. And do not use fq->dev
156-
pointer directly, device might already disappeared.
155+
/* But use as source device on which LAST ARRIVED
156+
* segment was received. And do not use fq->dev
157+
* pointer directly, device might already disappeared.
157158
*/
158159
fq->q.fragments->dev = dev;
159160
icmpv6_send(fq->q.fragments, ICMPV6_TIME_EXCEED, ICMPV6_EXC_FRAGTIME, 0);

0 commit comments

Comments
 (0)