Commit 4ecbb1c2 authored by Eric Dumazet's avatar Eric Dumazet Committed by Jakub Kicinski

net: dropreason: add SKB_DROP_REASON_DUP_FRAG

This is used to track when a duplicate segment received by various
reassembly units is dropped.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 511a3eda
...@@ -68,6 +68,7 @@ ...@@ -68,6 +68,7 @@
FN(IP_INADDRERRORS) \ FN(IP_INADDRERRORS) \
FN(IP_INNOROUTES) \ FN(IP_INNOROUTES) \
FN(PKT_TOO_BIG) \ FN(PKT_TOO_BIG) \
FN(DUP_FRAG) \
FNe(MAX) FNe(MAX)
/** /**
...@@ -300,6 +301,8 @@ enum skb_drop_reason { ...@@ -300,6 +301,8 @@ enum skb_drop_reason {
* MTU) * MTU)
*/ */
SKB_DROP_REASON_PKT_TOO_BIG, SKB_DROP_REASON_PKT_TOO_BIG,
/** @SKB_DROP_REASON_DUP_FRAG: duplicate fragment */
SKB_DROP_REASON_DUP_FRAG,
/** /**
* @SKB_DROP_REASON_MAX: the maximum of drop reason, which shouldn't be * @SKB_DROP_REASON_MAX: the maximum of drop reason, which shouldn't be
* used as a real 'reason' * used as a real 'reason'
......
...@@ -278,10 +278,14 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb) ...@@ -278,10 +278,14 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb)
struct net_device *dev; struct net_device *dev;
unsigned int fragsize; unsigned int fragsize;
int err = -ENOENT; int err = -ENOENT;
SKB_DR(reason);
u8 ecn; u8 ecn;
if (qp->q.flags & INET_FRAG_COMPLETE) /* If reassembly is already done, @skb must be a duplicate frag. */
if (qp->q.flags & INET_FRAG_COMPLETE) {
SKB_DR_SET(reason, DUP_FRAG);
goto err; goto err;
}
if (!(IPCB(skb)->flags & IPSKB_FRAG_COMPLETE) && if (!(IPCB(skb)->flags & IPSKB_FRAG_COMPLETE) &&
unlikely(ip_frag_too_far(qp)) && unlikely(ip_frag_too_far(qp)) &&
...@@ -382,8 +386,9 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb) ...@@ -382,8 +386,9 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb)
insert_error: insert_error:
if (err == IPFRAG_DUP) { if (err == IPFRAG_DUP) {
kfree_skb(skb); SKB_DR_SET(reason, DUP_FRAG);
return -EINVAL; err = -EINVAL;
goto err;
} }
err = -EINVAL; err = -EINVAL;
__IP_INC_STATS(net, IPSTATS_MIB_REASM_OVERLAPS); __IP_INC_STATS(net, IPSTATS_MIB_REASM_OVERLAPS);
...@@ -391,7 +396,7 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb) ...@@ -391,7 +396,7 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb)
inet_frag_kill(&qp->q); inet_frag_kill(&qp->q);
__IP_INC_STATS(net, IPSTATS_MIB_REASMFAILS); __IP_INC_STATS(net, IPSTATS_MIB_REASMFAILS);
err: err:
kfree_skb(skb); kfree_skb_reason(skb, reason);
return err; return err;
} }
......
...@@ -253,7 +253,7 @@ static int nf_ct_frag6_queue(struct frag_queue *fq, struct sk_buff *skb, ...@@ -253,7 +253,7 @@ static int nf_ct_frag6_queue(struct frag_queue *fq, struct sk_buff *skb,
if (err) { if (err) {
if (err == IPFRAG_DUP) { if (err == IPFRAG_DUP) {
/* No error for duplicates, pretend they got queued. */ /* No error for duplicates, pretend they got queued. */
kfree_skb(skb); kfree_skb_reason(skb, SKB_DROP_REASON_DUP_FRAG);
return -EINPROGRESS; return -EINPROGRESS;
} }
goto insert_error; goto insert_error;
......
...@@ -112,10 +112,14 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, ...@@ -112,10 +112,14 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
struct sk_buff *prev_tail; struct sk_buff *prev_tail;
struct net_device *dev; struct net_device *dev;
int err = -ENOENT; int err = -ENOENT;
SKB_DR(reason);
u8 ecn; u8 ecn;
if (fq->q.flags & INET_FRAG_COMPLETE) /* If reassembly is already done, @skb must be a duplicate frag. */
if (fq->q.flags & INET_FRAG_COMPLETE) {
SKB_DR_SET(reason, DUP_FRAG);
goto err; goto err;
}
err = -EINVAL; err = -EINVAL;
offset = ntohs(fhdr->frag_off) & ~0x7; offset = ntohs(fhdr->frag_off) & ~0x7;
...@@ -226,8 +230,9 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, ...@@ -226,8 +230,9 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
insert_error: insert_error:
if (err == IPFRAG_DUP) { if (err == IPFRAG_DUP) {
kfree_skb(skb); SKB_DR_SET(reason, DUP_FRAG);
return -EINVAL; err = -EINVAL;
goto err;
} }
err = -EINVAL; err = -EINVAL;
__IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)), __IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)),
...@@ -237,7 +242,7 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, ...@@ -237,7 +242,7 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
__IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)), __IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)),
IPSTATS_MIB_REASMFAILS); IPSTATS_MIB_REASMFAILS);
err: err:
kfree_skb(skb); kfree_skb_reason(skb, reason);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment