Commit 06aa8b8a authored by Nikolay Aleksandrov's avatar Nikolay Aleksandrov Committed by David S. Miller

inet: frags: rename last_in to flags

The last_in field has been used to store various flags different from
first/last frag in so give it a more descriptive name: flags.
Signed-off-by: default avatarNikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d2373862
...@@ -25,7 +25,7 @@ struct inet_frag_queue { ...@@ -25,7 +25,7 @@ struct inet_frag_queue {
ktime_t stamp; ktime_t stamp;
int len; /* total length of orig datagram */ int len; /* total length of orig datagram */
int meat; int meat;
__u8 last_in; /* first/last segment arrived? */ __u8 flags; /* first/last segment arrived? */
#define INET_FRAG_EVICTED 8 #define INET_FRAG_EVICTED 8
#define INET_FRAG_COMPLETE 4 #define INET_FRAG_COMPLETE 4
......
...@@ -99,7 +99,7 @@ static void lowpan_frag_expire(unsigned long data) ...@@ -99,7 +99,7 @@ static void lowpan_frag_expire(unsigned long data)
spin_lock(&fq->q.lock); spin_lock(&fq->q.lock);
if (fq->q.last_in & INET_FRAG_COMPLETE) if (fq->q.flags & INET_FRAG_COMPLETE)
goto out; goto out;
inet_frag_kill(&fq->q, &lowpan_frags); inet_frag_kill(&fq->q, &lowpan_frags);
...@@ -142,7 +142,7 @@ static int lowpan_frag_queue(struct lowpan_frag_queue *fq, ...@@ -142,7 +142,7 @@ static int lowpan_frag_queue(struct lowpan_frag_queue *fq,
struct net_device *dev; struct net_device *dev;
int end, offset; int end, offset;
if (fq->q.last_in & INET_FRAG_COMPLETE) if (fq->q.flags & INET_FRAG_COMPLETE)
goto err; goto err;
offset = lowpan_cb(skb)->d_offset << 3; offset = lowpan_cb(skb)->d_offset << 3;
...@@ -154,14 +154,14 @@ static int lowpan_frag_queue(struct lowpan_frag_queue *fq, ...@@ -154,14 +154,14 @@ static int lowpan_frag_queue(struct lowpan_frag_queue *fq,
* or have different end, the segment is corrupted. * or have different end, the segment is corrupted.
*/ */
if (end < fq->q.len || if (end < fq->q.len ||
((fq->q.last_in & INET_FRAG_LAST_IN) && end != fq->q.len)) ((fq->q.flags & INET_FRAG_LAST_IN) && end != fq->q.len))
goto err; goto err;
fq->q.last_in |= INET_FRAG_LAST_IN; fq->q.flags |= INET_FRAG_LAST_IN;
fq->q.len = end; fq->q.len = end;
} else { } else {
if (end > fq->q.len) { if (end > fq->q.len) {
/* Some bits beyond end -> corruption. */ /* Some bits beyond end -> corruption. */
if (fq->q.last_in & INET_FRAG_LAST_IN) if (fq->q.flags & INET_FRAG_LAST_IN)
goto err; goto err;
fq->q.len = end; fq->q.len = end;
} }
...@@ -201,13 +201,13 @@ static int lowpan_frag_queue(struct lowpan_frag_queue *fq, ...@@ -201,13 +201,13 @@ static int lowpan_frag_queue(struct lowpan_frag_queue *fq,
if (frag_type == LOWPAN_DISPATCH_FRAG1) { if (frag_type == LOWPAN_DISPATCH_FRAG1) {
/* Calculate uncomp. 6lowpan header to estimate full size */ /* Calculate uncomp. 6lowpan header to estimate full size */
fq->q.meat += lowpan_uncompress_size(skb, NULL); fq->q.meat += lowpan_uncompress_size(skb, NULL);
fq->q.last_in |= INET_FRAG_FIRST_IN; fq->q.flags |= INET_FRAG_FIRST_IN;
} else { } else {
fq->q.meat += skb->len; fq->q.meat += skb->len;
} }
add_frag_mem_limit(&fq->q, skb->truesize); add_frag_mem_limit(&fq->q, skb->truesize);
if (fq->q.last_in == (INET_FRAG_FIRST_IN | INET_FRAG_LAST_IN) && if (fq->q.flags == (INET_FRAG_FIRST_IN | INET_FRAG_LAST_IN) &&
fq->q.meat == fq->q.len) { fq->q.meat == fq->q.len) {
int res; int res;
unsigned long orefdst = skb->_skb_refdst; unsigned long orefdst = skb->_skb_refdst;
......
...@@ -152,8 +152,8 @@ inet_evict_bucket(struct inet_frags *f, struct inet_frag_bucket *hb) ...@@ -152,8 +152,8 @@ inet_evict_bucket(struct inet_frags *f, struct inet_frag_bucket *hb)
} }
/* suppress xmit of (icmp) error packet */ /* suppress xmit of (icmp) error packet */
fq->last_in &= ~INET_FRAG_FIRST_IN; fq->flags &= ~INET_FRAG_FIRST_IN;
fq->last_in |= INET_FRAG_EVICTED; fq->flags |= INET_FRAG_EVICTED;
hlist_del(&fq->list); hlist_del(&fq->list);
hlist_add_head(&fq->list, &expired); hlist_add_head(&fq->list, &expired);
++evicted; ++evicted;
...@@ -289,10 +289,10 @@ void inet_frag_kill(struct inet_frag_queue *fq, struct inet_frags *f) ...@@ -289,10 +289,10 @@ void inet_frag_kill(struct inet_frag_queue *fq, struct inet_frags *f)
if (del_timer(&fq->timer)) if (del_timer(&fq->timer))
atomic_dec(&fq->refcnt); atomic_dec(&fq->refcnt);
if (!(fq->last_in & INET_FRAG_COMPLETE)) { if (!(fq->flags & INET_FRAG_COMPLETE)) {
fq_unlink(fq, f); fq_unlink(fq, f);
atomic_dec(&fq->refcnt); atomic_dec(&fq->refcnt);
fq->last_in |= INET_FRAG_COMPLETE; fq->flags |= INET_FRAG_COMPLETE;
} }
} }
EXPORT_SYMBOL(inet_frag_kill); EXPORT_SYMBOL(inet_frag_kill);
...@@ -311,7 +311,7 @@ void inet_frag_destroy(struct inet_frag_queue *q, struct inet_frags *f) ...@@ -311,7 +311,7 @@ void inet_frag_destroy(struct inet_frag_queue *q, struct inet_frags *f)
struct netns_frags *nf; struct netns_frags *nf;
unsigned int sum, sum_truesize = 0; unsigned int sum, sum_truesize = 0;
WARN_ON(!(q->last_in & INET_FRAG_COMPLETE)); WARN_ON(!(q->flags & INET_FRAG_COMPLETE));
WARN_ON(del_timer(&q->timer) != 0); WARN_ON(del_timer(&q->timer) != 0);
/* Release all fragment data. */ /* Release all fragment data. */
...@@ -349,7 +349,7 @@ static struct inet_frag_queue *inet_frag_intern(struct netns_frags *nf, ...@@ -349,7 +349,7 @@ static struct inet_frag_queue *inet_frag_intern(struct netns_frags *nf,
if (qp->net == nf && f->match(qp, arg)) { if (qp->net == nf && f->match(qp, arg)) {
atomic_inc(&qp->refcnt); atomic_inc(&qp->refcnt);
spin_unlock(&hb->chain_lock); spin_unlock(&hb->chain_lock);
qp_in->last_in |= INET_FRAG_COMPLETE; qp_in->flags |= INET_FRAG_COMPLETE;
inet_frag_put(qp_in, f); inet_frag_put(qp_in, f);
return qp; return qp;
} }
......
...@@ -185,16 +185,16 @@ static void ip_expire(unsigned long arg) ...@@ -185,16 +185,16 @@ static void ip_expire(unsigned long arg)
spin_lock(&qp->q.lock); spin_lock(&qp->q.lock);
if (qp->q.last_in & INET_FRAG_COMPLETE) if (qp->q.flags & INET_FRAG_COMPLETE)
goto out; goto out;
ipq_kill(qp); ipq_kill(qp);
if (!(qp->q.last_in & INET_FRAG_EVICTED)) if (!(qp->q.flags & INET_FRAG_EVICTED))
IP_INC_STATS_BH(net, IPSTATS_MIB_REASMTIMEOUT); IP_INC_STATS_BH(net, IPSTATS_MIB_REASMTIMEOUT);
IP_INC_STATS_BH(net, IPSTATS_MIB_REASMFAILS); IP_INC_STATS_BH(net, IPSTATS_MIB_REASMFAILS);
if ((qp->q.last_in & INET_FRAG_FIRST_IN) && qp->q.fragments != NULL) { if ((qp->q.flags & INET_FRAG_FIRST_IN) && qp->q.fragments != NULL) {
struct sk_buff *head = qp->q.fragments; struct sk_buff *head = qp->q.fragments;
const struct iphdr *iph; const struct iphdr *iph;
int err; int err;
...@@ -302,7 +302,7 @@ static int ip_frag_reinit(struct ipq *qp) ...@@ -302,7 +302,7 @@ static int ip_frag_reinit(struct ipq *qp)
} while (fp); } while (fp);
sub_frag_mem_limit(&qp->q, sum_truesize); sub_frag_mem_limit(&qp->q, sum_truesize);
qp->q.last_in = 0; qp->q.flags = 0;
qp->q.len = 0; qp->q.len = 0;
qp->q.meat = 0; qp->q.meat = 0;
qp->q.fragments = NULL; qp->q.fragments = NULL;
...@@ -323,7 +323,7 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb) ...@@ -323,7 +323,7 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb)
int err = -ENOENT; int err = -ENOENT;
u8 ecn; u8 ecn;
if (qp->q.last_in & INET_FRAG_COMPLETE) if (qp->q.flags & INET_FRAG_COMPLETE)
goto err; goto err;
if (!(IPCB(skb)->flags & IPSKB_FRAG_COMPLETE) && if (!(IPCB(skb)->flags & IPSKB_FRAG_COMPLETE) &&
...@@ -350,9 +350,9 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb) ...@@ -350,9 +350,9 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb)
* or have different end, the segment is corrupted. * or have different end, the segment is corrupted.
*/ */
if (end < qp->q.len || if (end < qp->q.len ||
((qp->q.last_in & INET_FRAG_LAST_IN) && end != qp->q.len)) ((qp->q.flags & INET_FRAG_LAST_IN) && end != qp->q.len))
goto err; goto err;
qp->q.last_in |= INET_FRAG_LAST_IN; qp->q.flags |= INET_FRAG_LAST_IN;
qp->q.len = end; qp->q.len = end;
} else { } else {
if (end&7) { if (end&7) {
...@@ -362,7 +362,7 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb) ...@@ -362,7 +362,7 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb)
} }
if (end > qp->q.len) { if (end > qp->q.len) {
/* Some bits beyond end -> corruption. */ /* Some bits beyond end -> corruption. */
if (qp->q.last_in & INET_FRAG_LAST_IN) if (qp->q.flags & INET_FRAG_LAST_IN)
goto err; goto err;
qp->q.len = end; qp->q.len = end;
} }
...@@ -471,13 +471,13 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb) ...@@ -471,13 +471,13 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb)
qp->ecn |= ecn; qp->ecn |= ecn;
add_frag_mem_limit(&qp->q, skb->truesize); add_frag_mem_limit(&qp->q, skb->truesize);
if (offset == 0) if (offset == 0)
qp->q.last_in |= INET_FRAG_FIRST_IN; qp->q.flags |= INET_FRAG_FIRST_IN;
if (ip_hdr(skb)->frag_off & htons(IP_DF) && if (ip_hdr(skb)->frag_off & htons(IP_DF) &&
skb->len + ihl > qp->q.max_size) skb->len + ihl > qp->q.max_size)
qp->q.max_size = skb->len + ihl; qp->q.max_size = skb->len + ihl;
if (qp->q.last_in == (INET_FRAG_FIRST_IN | INET_FRAG_LAST_IN) && if (qp->q.flags == (INET_FRAG_FIRST_IN | INET_FRAG_LAST_IN) &&
qp->q.meat == qp->q.len) { qp->q.meat == qp->q.len) {
unsigned long orefdst = skb->_skb_refdst; unsigned long orefdst = skb->_skb_refdst;
......
...@@ -222,7 +222,7 @@ static int nf_ct_frag6_queue(struct frag_queue *fq, struct sk_buff *skb, ...@@ -222,7 +222,7 @@ static int nf_ct_frag6_queue(struct frag_queue *fq, struct sk_buff *skb,
int offset, end; int offset, end;
u8 ecn; u8 ecn;
if (fq->q.last_in & INET_FRAG_COMPLETE) { if (fq->q.flags & INET_FRAG_COMPLETE) {
pr_debug("Already completed\n"); pr_debug("Already completed\n");
goto err; goto err;
} }
...@@ -253,11 +253,11 @@ static int nf_ct_frag6_queue(struct frag_queue *fq, struct sk_buff *skb, ...@@ -253,11 +253,11 @@ static int nf_ct_frag6_queue(struct frag_queue *fq, struct sk_buff *skb,
* or have different end, the segment is corrupted. * or have different end, the segment is corrupted.
*/ */
if (end < fq->q.len || if (end < fq->q.len ||
((fq->q.last_in & INET_FRAG_LAST_IN) && end != fq->q.len)) { ((fq->q.flags & INET_FRAG_LAST_IN) && end != fq->q.len)) {
pr_debug("already received last fragment\n"); pr_debug("already received last fragment\n");
goto err; goto err;
} }
fq->q.last_in |= INET_FRAG_LAST_IN; fq->q.flags |= INET_FRAG_LAST_IN;
fq->q.len = end; fq->q.len = end;
} else { } else {
/* Check if the fragment is rounded to 8 bytes. /* Check if the fragment is rounded to 8 bytes.
...@@ -272,7 +272,7 @@ static int nf_ct_frag6_queue(struct frag_queue *fq, struct sk_buff *skb, ...@@ -272,7 +272,7 @@ static int nf_ct_frag6_queue(struct frag_queue *fq, struct sk_buff *skb,
} }
if (end > fq->q.len) { if (end > fq->q.len) {
/* Some bits beyond end -> corruption. */ /* Some bits beyond end -> corruption. */
if (fq->q.last_in & INET_FRAG_LAST_IN) { if (fq->q.flags & INET_FRAG_LAST_IN) {
pr_debug("last packet already reached.\n"); pr_debug("last packet already reached.\n");
goto err; goto err;
} }
...@@ -354,7 +354,7 @@ static int nf_ct_frag6_queue(struct frag_queue *fq, struct sk_buff *skb, ...@@ -354,7 +354,7 @@ static int nf_ct_frag6_queue(struct frag_queue *fq, struct sk_buff *skb,
*/ */
if (offset == 0) { if (offset == 0) {
fq->nhoffset = nhoff; fq->nhoffset = nhoff;
fq->q.last_in |= INET_FRAG_FIRST_IN; fq->q.flags |= INET_FRAG_FIRST_IN;
} }
return 0; return 0;
...@@ -617,7 +617,7 @@ struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb, u32 user) ...@@ -617,7 +617,7 @@ struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb, u32 user)
goto ret_orig; goto ret_orig;
} }
if (fq->q.last_in == (INET_FRAG_FIRST_IN | INET_FRAG_LAST_IN) && if (fq->q.flags == (INET_FRAG_FIRST_IN | INET_FRAG_LAST_IN) &&
fq->q.meat == fq->q.len) { fq->q.meat == fq->q.len) {
ret_skb = nf_ct_frag6_reasm(fq, dev); ret_skb = nf_ct_frag6_reasm(fq, dev);
if (ret_skb == NULL) if (ret_skb == NULL)
......
...@@ -131,7 +131,7 @@ void ip6_expire_frag_queue(struct net *net, struct frag_queue *fq, ...@@ -131,7 +131,7 @@ void ip6_expire_frag_queue(struct net *net, struct frag_queue *fq,
spin_lock(&fq->q.lock); spin_lock(&fq->q.lock);
if (fq->q.last_in & INET_FRAG_COMPLETE) if (fq->q.flags & INET_FRAG_COMPLETE)
goto out; goto out;
inet_frag_kill(&fq->q, frags); inet_frag_kill(&fq->q, frags);
...@@ -141,13 +141,13 @@ void ip6_expire_frag_queue(struct net *net, struct frag_queue *fq, ...@@ -141,13 +141,13 @@ void ip6_expire_frag_queue(struct net *net, struct frag_queue *fq,
if (!dev) if (!dev)
goto out_rcu_unlock; goto out_rcu_unlock;
if (!(fq->q.last_in & INET_FRAG_EVICTED)) if (!(fq->q.flags & INET_FRAG_EVICTED))
IP6_INC_STATS_BH(net, __in6_dev_get(dev), IP6_INC_STATS_BH(net, __in6_dev_get(dev),
IPSTATS_MIB_REASMTIMEOUT); IPSTATS_MIB_REASMTIMEOUT);
IP6_INC_STATS_BH(net, __in6_dev_get(dev), IPSTATS_MIB_REASMFAILS); IP6_INC_STATS_BH(net, __in6_dev_get(dev), IPSTATS_MIB_REASMFAILS);
/* Don't send error if the first segment did not arrive. */ /* Don't send error if the first segment did not arrive. */
if (!(fq->q.last_in & INET_FRAG_FIRST_IN) || !fq->q.fragments) if (!(fq->q.flags & INET_FRAG_FIRST_IN) || !fq->q.fragments)
goto out_rcu_unlock; goto out_rcu_unlock;
/* /*
...@@ -209,7 +209,7 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, ...@@ -209,7 +209,7 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
struct net *net = dev_net(skb_dst(skb)->dev); struct net *net = dev_net(skb_dst(skb)->dev);
u8 ecn; u8 ecn;
if (fq->q.last_in & INET_FRAG_COMPLETE) if (fq->q.flags & INET_FRAG_COMPLETE)
goto err; goto err;
offset = ntohs(fhdr->frag_off) & ~0x7; offset = ntohs(fhdr->frag_off) & ~0x7;
...@@ -240,9 +240,9 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, ...@@ -240,9 +240,9 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
* or have different end, the segment is corrupted. * or have different end, the segment is corrupted.
*/ */
if (end < fq->q.len || if (end < fq->q.len ||
((fq->q.last_in & INET_FRAG_LAST_IN) && end != fq->q.len)) ((fq->q.flags & INET_FRAG_LAST_IN) && end != fq->q.len))
goto err; goto err;
fq->q.last_in |= INET_FRAG_LAST_IN; fq->q.flags |= INET_FRAG_LAST_IN;
fq->q.len = end; fq->q.len = end;
} else { } else {
/* Check if the fragment is rounded to 8 bytes. /* Check if the fragment is rounded to 8 bytes.
...@@ -260,7 +260,7 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, ...@@ -260,7 +260,7 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
} }
if (end > fq->q.len) { if (end > fq->q.len) {
/* Some bits beyond end -> corruption. */ /* Some bits beyond end -> corruption. */
if (fq->q.last_in & INET_FRAG_LAST_IN) if (fq->q.flags & INET_FRAG_LAST_IN)
goto err; goto err;
fq->q.len = end; fq->q.len = end;
} }
...@@ -335,10 +335,10 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, ...@@ -335,10 +335,10 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
*/ */
if (offset == 0) { if (offset == 0) {
fq->nhoffset = nhoff; fq->nhoffset = nhoff;
fq->q.last_in |= INET_FRAG_FIRST_IN; fq->q.flags |= INET_FRAG_FIRST_IN;
} }
if (fq->q.last_in == (INET_FRAG_FIRST_IN | INET_FRAG_LAST_IN) && if (fq->q.flags == (INET_FRAG_FIRST_IN | INET_FRAG_LAST_IN) &&
fq->q.meat == fq->q.len) { fq->q.meat == fq->q.len) {
int res; int res;
unsigned long orefdst = skb->_skb_refdst; unsigned long orefdst = skb->_skb_refdst;
......
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