Skip to content

Commit a00eac0

Browse files
committed
ppp: Use a real SKB control block in fragmentation engine.
Do this instead of subverting fields in skb proper. The macros that could very easily match variable or function names were also just asking for trouble. Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent c61393e commit a00eac0

1 file changed

Lines changed: 25 additions & 21 deletions

File tree

‎drivers/net/ppp_generic.c‎

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,9 +1547,11 @@ ppp_channel_push(struct channel *pch)
15471547
* Receive-side routines.
15481548
*/
15491549

1550-
/* misuse a few fields of the skb for MP reconstruction */
1551-
#define sequence priority
1552-
#define BEbits cb[0]
1550+
struct ppp_mp_skb_parm {
1551+
u32 sequence;
1552+
u8 BEbits;
1553+
};
1554+
#define PPP_MP_CB(skb) ((struct ppp_mp_skb_parm *)((skb)->cb))
15531555

15541556
static inline void
15551557
ppp_do_recv(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
@@ -1878,13 +1880,13 @@ ppp_receive_mp_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
18781880
seq = (skb->data[3] << 16) | (skb->data[4] << 8)| skb->data[5];
18791881
mask = 0xffffff;
18801882
}
1881-
skb->BEbits = skb->data[2];
1883+
PPP_MP_CB(skb)->BEbits = skb->data[2];
18821884
skb_pull(skb, mphdrlen); /* pull off PPP and MP headers */
18831885

18841886
/*
18851887
* Do protocol ID decompression on the first fragment of each packet.
18861888
*/
1887-
if ((skb->BEbits & B) && (skb->data[0] & 1))
1889+
if ((PPP_MP_CB(skb)->BEbits & B) && (skb->data[0] & 1))
18881890
*skb_push(skb, 1) = 0;
18891891

18901892
/*
@@ -1896,7 +1898,7 @@ ppp_receive_mp_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
18961898
seq += mask + 1;
18971899
else if ((int)(seq - ppp->minseq) > (int)(mask >> 1))
18981900
seq -= mask + 1; /* should never happen */
1899-
skb->sequence = seq;
1901+
PPP_MP_CB(skb)->sequence = seq;
19001902
pch->lastseq = seq;
19011903

19021904
/*
@@ -1932,8 +1934,8 @@ ppp_receive_mp_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
19321934
before the start of the queue. */
19331935
if (skb_queue_len(&ppp->mrq) >= PPP_MP_MAX_QLEN) {
19341936
struct sk_buff *mskb = skb_peek(&ppp->mrq);
1935-
if (seq_before(ppp->minseq, mskb->sequence))
1936-
ppp->minseq = mskb->sequence;
1937+
if (seq_before(ppp->minseq, PPP_MP_CB(mskb)->sequence))
1938+
ppp->minseq = PPP_MP_CB(mskb)->sequence;
19371939
}
19381940

19391941
/* Pull completed packets off the queue and receive them. */
@@ -1963,12 +1965,12 @@ ppp_mp_insert(struct ppp *ppp, struct sk_buff *skb)
19631965
{
19641966
struct sk_buff *p;
19651967
struct sk_buff_head *list = &ppp->mrq;
1966-
u32 seq = skb->sequence;
1968+
u32 seq = PPP_MP_CB(skb)->sequence;
19671969

19681970
/* N.B. we don't need to lock the list lock because we have the
19691971
ppp unit receive-side lock. */
19701972
skb_queue_walk(list, p) {
1971-
if (seq_before(seq, p->sequence))
1973+
if (seq_before(seq, PPP_MP_CB(p)->sequence))
19721974
break;
19731975
}
19741976
__skb_queue_before(list, p, skb);
@@ -1997,22 +1999,22 @@ ppp_mp_reconstruct(struct ppp *ppp)
19971999
tail = NULL;
19982000
for (p = head; p != (struct sk_buff *) list; p = next) {
19992001
next = p->next;
2000-
if (seq_before(p->sequence, seq)) {
2002+
if (seq_before(PPP_MP_CB(p)->sequence, seq)) {
20012003
/* this can't happen, anyway ignore the skb */
20022004
printk(KERN_ERR "ppp_mp_reconstruct bad seq %u < %u\n",
2003-
p->sequence, seq);
2005+
PPP_MP_CB(p)->sequence, seq);
20042006
head = next;
20052007
continue;
20062008
}
2007-
if (p->sequence != seq) {
2009+
if (PPP_MP_CB(p)->sequence != seq) {
20082010
/* Fragment `seq' is missing. If it is after
20092011
minseq, it might arrive later, so stop here. */
20102012
if (seq_after(seq, minseq))
20112013
break;
20122014
/* Fragment `seq' is lost, keep going. */
20132015
lost = 1;
2014-
seq = seq_before(minseq, p->sequence)?
2015-
minseq + 1: p->sequence;
2016+
seq = seq_before(minseq, PPP_MP_CB(p)->sequence)?
2017+
minseq + 1: PPP_MP_CB(p)->sequence;
20162018
next = p;
20172019
continue;
20182020
}
@@ -2026,7 +2028,7 @@ ppp_mp_reconstruct(struct ppp *ppp)
20262028
*/
20272029

20282030
/* B bit set indicates this fragment starts a packet */
2029-
if (p->BEbits & B) {
2031+
if (PPP_MP_CB(p)->BEbits & B) {
20302032
head = p;
20312033
lost = 0;
20322034
len = 0;
@@ -2035,7 +2037,8 @@ ppp_mp_reconstruct(struct ppp *ppp)
20352037
len += p->len;
20362038

20372039
/* Got a complete packet yet? */
2038-
if (lost == 0 && (p->BEbits & E) && (head->BEbits & B)) {
2040+
if (lost == 0 && (PPP_MP_CB(p)->BEbits & E) &&
2041+
(PPP_MP_CB(head)->BEbits & B)) {
20392042
if (len > ppp->mrru + 2) {
20402043
++ppp->dev->stats.rx_length_errors;
20412044
printk(KERN_DEBUG "PPP: reconstructed packet"
@@ -2061,7 +2064,7 @@ ppp_mp_reconstruct(struct ppp *ppp)
20612064
* and we haven't found a complete valid packet yet,
20622065
* we can discard up to and including this fragment.
20632066
*/
2064-
if (p->BEbits & E)
2067+
if (PPP_MP_CB(p)->BEbits & E)
20652068
head = next;
20662069

20672070
++seq;
@@ -2071,10 +2074,11 @@ ppp_mp_reconstruct(struct ppp *ppp)
20712074
if (tail != NULL) {
20722075
/* If we have discarded any fragments,
20732076
signal a receive error. */
2074-
if (head->sequence != ppp->nextseq) {
2077+
if (PPP_MP_CB(head)->sequence != ppp->nextseq) {
20752078
if (ppp->debug & 1)
20762079
printk(KERN_DEBUG " missed pkts %u..%u\n",
2077-
ppp->nextseq, head->sequence-1);
2080+
ppp->nextseq,
2081+
PPP_MP_CB(head)->sequence-1);
20782082
++ppp->dev->stats.rx_dropped;
20792083
ppp_receive_error(ppp);
20802084
}
@@ -2083,7 +2087,7 @@ ppp_mp_reconstruct(struct ppp *ppp)
20832087
/* copy to a single skb */
20842088
for (p = head; p != tail->next; p = p->next)
20852089
skb_copy_bits(p, 0, skb_put(skb, p->len), p->len);
2086-
ppp->nextseq = tail->sequence + 1;
2090+
ppp->nextseq = PPP_MP_CB(tail)->sequence + 1;
20872091
head = tail->next;
20882092
}
20892093

0 commit comments

Comments
 (0)