aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ppp_generic.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-10-23 14:47:02 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-23 14:47:02 -0400
commit5f05647dd81c11a6a165ccc8f0c1370b16f3bcb0 (patch)
tree7851ef1c93aa1aba7ef327ca4b75fd35e6d10f29 /drivers/net/ppp_generic.c
parent02f36038c568111ad4fc433f6fa760ff5e38fab4 (diff)
parentec37a48d1d16c30b655ac5280209edf52a6775d4 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6: (1699 commits) bnx2/bnx2x: Unsupported Ethtool operations should return -EINVAL. vlan: Calling vlan_hwaccel_do_receive() is always valid. tproxy: use the interface primary IP address as a default value for --on-ip tproxy: added IPv6 support to the socket match cxgb3: function namespace cleanup tproxy: added IPv6 support to the TPROXY target tproxy: added IPv6 socket lookup function to nf_tproxy_core be2net: Changes to use only priority codes allowed by f/w tproxy: allow non-local binds of IPv6 sockets if IP_TRANSPARENT is enabled tproxy: added tproxy sockopt interface in the IPV6 layer tproxy: added udp6_lib_lookup function tproxy: added const specifiers to udp lookup functions tproxy: split off ipv6 defragmentation to a separate module l2tp: small cleanup nf_nat: restrict ICMP translation for embedded header can: mcp251x: fix generation of error frames can: mcp251x: fix endless loop in interrupt handler if CANINTF_MERRF is set can-raw: add msg_flags to distinguish local traffic 9p: client code cleanup rds: make local functions/variables static ... Fix up conflicts in net/core/dev.c, drivers/net/pcmcia/smc91c92_cs.c and drivers/net/wireless/ath/ath9k/debug.c as per David
Diffstat (limited to 'drivers/net/ppp_generic.c')
-rw-r--r--drivers/net/ppp_generic.c46
1 files changed, 25 insertions, 21 deletions
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index 4bddb2afdd15..09cf56d0416a 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -1548,9 +1548,11 @@ ppp_channel_push(struct channel *pch)
1548 * Receive-side routines. 1548 * Receive-side routines.
1549 */ 1549 */
1550 1550
1551/* misuse a few fields of the skb for MP reconstruction */ 1551struct ppp_mp_skb_parm {
1552#define sequence priority 1552 u32 sequence;
1553#define BEbits cb[0] 1553 u8 BEbits;
1554};
1555#define PPP_MP_CB(skb) ((struct ppp_mp_skb_parm *)((skb)->cb))
1554 1556
1555static inline void 1557static inline void
1556ppp_do_recv(struct ppp *ppp, struct sk_buff *skb, struct channel *pch) 1558ppp_do_recv(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
@@ -1879,13 +1881,13 @@ ppp_receive_mp_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
1879 seq = (skb->data[3] << 16) | (skb->data[4] << 8)| skb->data[5]; 1881 seq = (skb->data[3] << 16) | (skb->data[4] << 8)| skb->data[5];
1880 mask = 0xffffff; 1882 mask = 0xffffff;
1881 } 1883 }
1882 skb->BEbits = skb->data[2]; 1884 PPP_MP_CB(skb)->BEbits = skb->data[2];
1883 skb_pull(skb, mphdrlen); /* pull off PPP and MP headers */ 1885 skb_pull(skb, mphdrlen); /* pull off PPP and MP headers */
1884 1886
1885 /* 1887 /*
1886 * Do protocol ID decompression on the first fragment of each packet. 1888 * Do protocol ID decompression on the first fragment of each packet.
1887 */ 1889 */
1888 if ((skb->BEbits & B) && (skb->data[0] & 1)) 1890 if ((PPP_MP_CB(skb)->BEbits & B) && (skb->data[0] & 1))
1889 *skb_push(skb, 1) = 0; 1891 *skb_push(skb, 1) = 0;
1890 1892
1891 /* 1893 /*
@@ -1897,7 +1899,7 @@ ppp_receive_mp_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
1897 seq += mask + 1; 1899 seq += mask + 1;
1898 else if ((int)(seq - ppp->minseq) > (int)(mask >> 1)) 1900 else if ((int)(seq - ppp->minseq) > (int)(mask >> 1))
1899 seq -= mask + 1; /* should never happen */ 1901 seq -= mask + 1; /* should never happen */
1900 skb->sequence = seq; 1902 PPP_MP_CB(skb)->sequence = seq;
1901 pch->lastseq = seq; 1903 pch->lastseq = seq;
1902 1904
1903 /* 1905 /*
@@ -1933,8 +1935,8 @@ ppp_receive_mp_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
1933 before the start of the queue. */ 1935 before the start of the queue. */
1934 if (skb_queue_len(&ppp->mrq) >= PPP_MP_MAX_QLEN) { 1936 if (skb_queue_len(&ppp->mrq) >= PPP_MP_MAX_QLEN) {
1935 struct sk_buff *mskb = skb_peek(&ppp->mrq); 1937 struct sk_buff *mskb = skb_peek(&ppp->mrq);
1936 if (seq_before(ppp->minseq, mskb->sequence)) 1938 if (seq_before(ppp->minseq, PPP_MP_CB(mskb)->sequence))
1937 ppp->minseq = mskb->sequence; 1939 ppp->minseq = PPP_MP_CB(mskb)->sequence;
1938 } 1940 }
1939 1941
1940 /* Pull completed packets off the queue and receive them. */ 1942 /* Pull completed packets off the queue and receive them. */
@@ -1964,12 +1966,12 @@ ppp_mp_insert(struct ppp *ppp, struct sk_buff *skb)
1964{ 1966{
1965 struct sk_buff *p; 1967 struct sk_buff *p;
1966 struct sk_buff_head *list = &ppp->mrq; 1968 struct sk_buff_head *list = &ppp->mrq;
1967 u32 seq = skb->sequence; 1969 u32 seq = PPP_MP_CB(skb)->sequence;
1968 1970
1969 /* N.B. we don't need to lock the list lock because we have the 1971 /* N.B. we don't need to lock the list lock because we have the
1970 ppp unit receive-side lock. */ 1972 ppp unit receive-side lock. */
1971 skb_queue_walk(list, p) { 1973 skb_queue_walk(list, p) {
1972 if (seq_before(seq, p->sequence)) 1974 if (seq_before(seq, PPP_MP_CB(p)->sequence))
1973 break; 1975 break;
1974 } 1976 }
1975 __skb_queue_before(list, p, skb); 1977 __skb_queue_before(list, p, skb);
@@ -1998,22 +2000,22 @@ ppp_mp_reconstruct(struct ppp *ppp)
1998 tail = NULL; 2000 tail = NULL;
1999 for (p = head; p != (struct sk_buff *) list; p = next) { 2001 for (p = head; p != (struct sk_buff *) list; p = next) {
2000 next = p->next; 2002 next = p->next;
2001 if (seq_before(p->sequence, seq)) { 2003 if (seq_before(PPP_MP_CB(p)->sequence, seq)) {
2002 /* this can't happen, anyway ignore the skb */ 2004 /* this can't happen, anyway ignore the skb */
2003 printk(KERN_ERR "ppp_mp_reconstruct bad seq %u < %u\n", 2005 printk(KERN_ERR "ppp_mp_reconstruct bad seq %u < %u\n",
2004 p->sequence, seq); 2006 PPP_MP_CB(p)->sequence, seq);
2005 head = next; 2007 head = next;
2006 continue; 2008 continue;
2007 } 2009 }
2008 if (p->sequence != seq) { 2010 if (PPP_MP_CB(p)->sequence != seq) {
2009 /* Fragment `seq' is missing. If it is after 2011 /* Fragment `seq' is missing. If it is after
2010 minseq, it might arrive later, so stop here. */ 2012 minseq, it might arrive later, so stop here. */
2011 if (seq_after(seq, minseq)) 2013 if (seq_after(seq, minseq))
2012 break; 2014 break;
2013 /* Fragment `seq' is lost, keep going. */ 2015 /* Fragment `seq' is lost, keep going. */
2014 lost = 1; 2016 lost = 1;
2015 seq = seq_before(minseq, p->sequence)? 2017 seq = seq_before(minseq, PPP_MP_CB(p)->sequence)?
2016 minseq + 1: p->sequence; 2018 minseq + 1: PPP_MP_CB(p)->sequence;
2017 next = p; 2019 next = p;
2018 continue; 2020 continue;
2019 } 2021 }
@@ -2027,7 +2029,7 @@ ppp_mp_reconstruct(struct ppp *ppp)
2027 */ 2029 */
2028 2030
2029 /* B bit set indicates this fragment starts a packet */ 2031 /* B bit set indicates this fragment starts a packet */
2030 if (p->BEbits & B) { 2032 if (PPP_MP_CB(p)->BEbits & B) {
2031 head = p; 2033 head = p;
2032 lost = 0; 2034 lost = 0;
2033 len = 0; 2035 len = 0;
@@ -2036,7 +2038,8 @@ ppp_mp_reconstruct(struct ppp *ppp)
2036 len += p->len; 2038 len += p->len;
2037 2039
2038 /* Got a complete packet yet? */ 2040 /* Got a complete packet yet? */
2039 if (lost == 0 && (p->BEbits & E) && (head->BEbits & B)) { 2041 if (lost == 0 && (PPP_MP_CB(p)->BEbits & E) &&
2042 (PPP_MP_CB(head)->BEbits & B)) {
2040 if (len > ppp->mrru + 2) { 2043 if (len > ppp->mrru + 2) {
2041 ++ppp->dev->stats.rx_length_errors; 2044 ++ppp->dev->stats.rx_length_errors;
2042 printk(KERN_DEBUG "PPP: reconstructed packet" 2045 printk(KERN_DEBUG "PPP: reconstructed packet"
@@ -2062,7 +2065,7 @@ ppp_mp_reconstruct(struct ppp *ppp)
2062 * and we haven't found a complete valid packet yet, 2065 * and we haven't found a complete valid packet yet,
2063 * we can discard up to and including this fragment. 2066 * we can discard up to and including this fragment.
2064 */ 2067 */
2065 if (p->BEbits & E) 2068 if (PPP_MP_CB(p)->BEbits & E)
2066 head = next; 2069 head = next;
2067 2070
2068 ++seq; 2071 ++seq;
@@ -2072,10 +2075,11 @@ ppp_mp_reconstruct(struct ppp *ppp)
2072 if (tail != NULL) { 2075 if (tail != NULL) {
2073 /* If we have discarded any fragments, 2076 /* If we have discarded any fragments,
2074 signal a receive error. */ 2077 signal a receive error. */
2075 if (head->sequence != ppp->nextseq) { 2078 if (PPP_MP_CB(head)->sequence != ppp->nextseq) {
2076 if (ppp->debug & 1) 2079 if (ppp->debug & 1)
2077 printk(KERN_DEBUG " missed pkts %u..%u\n", 2080 printk(KERN_DEBUG " missed pkts %u..%u\n",
2078 ppp->nextseq, head->sequence-1); 2081 ppp->nextseq,
2082 PPP_MP_CB(head)->sequence-1);
2079 ++ppp->dev->stats.rx_dropped; 2083 ++ppp->dev->stats.rx_dropped;
2080 ppp_receive_error(ppp); 2084 ppp_receive_error(ppp);
2081 } 2085 }
@@ -2084,7 +2088,7 @@ ppp_mp_reconstruct(struct ppp *ppp)
2084 /* copy to a single skb */ 2088 /* copy to a single skb */
2085 for (p = head; p != tail->next; p = p->next) 2089 for (p = head; p != tail->next; p = p->next)
2086 skb_copy_bits(p, 0, skb_put(skb, p->len), p->len); 2090 skb_copy_bits(p, 0, skb_put(skb, p->len), p->len);
2087 ppp->nextseq = tail->sequence + 1; 2091 ppp->nextseq = PPP_MP_CB(tail)->sequence + 1;
2088 head = tail->next; 2092 head = tail->next;
2089 } 2093 }
2090 2094