Fixed Linux 2.2.20 kernel MPPE patch (Frank Cusack)
[ppp.git] / linux / mppe / linux-2.2.20-pad.patch
1 --- linux/drivers/net/ppp.c.orig        Sun Mar 25 08:31:15 2001
2 +++ linux/drivers/net/ppp.c     Mon Mar 25 09:27:28 2002
3 @@ -2468,10 +2468,14 @@
4             (proto != PPP_LCP)                  &&
5             (proto != PPP_CCP)) {
6                 struct sk_buff *new_skb;
7 +               int new_skb_size = ppp->mtu + PPP_HDRLEN;
8                 int new_count;
9  
10                 /* Allocate an skb for the compressed frame. */
11 -               new_skb = alloc_skb(ppp->mtu + PPP_HDRLEN, GFP_ATOMIC);
12 +               if (ppp->sc_xcomp->compress_proto == CI_MPPE)
13 +                       /* CCP [must have] reduced MTU by MPPE_PAD. */
14 +                       new_skb_size += MPPE_PAD;
15 +               new_skb = alloc_skb(new_skb_size, GFP_ATOMIC);
16                 if (new_skb == NULL) {
17                         printk(KERN_ERR "ppp_send_frame: no memory\n");
18                         kfree_skb(skb);
19 @@ -2482,19 +2486,32 @@
20                 /* Compress the frame. */
21                 new_count = (*ppp->sc_xcomp->compress)
22                         (ppp->sc_xc_state, data, new_skb->data,
23 -                        count, ppp->mtu + PPP_HDRLEN);
24 +                        count, new_skb_size);
25  
26                 /* Did it compress? */
27                 if (new_count > 0 && (ppp->flags & SC_CCP_UP)) {
28                         skb_put(new_skb, new_count);
29                         kfree_skb(skb);
30                         skb = new_skb;
31 -               } else {
32 +               } else if (new_count == 0) {
33                         /*
34                          * The frame could not be compressed, or it could not
35                          * be sent in compressed form because CCP is down.
36                          */
37                         kfree_skb(new_skb);
38 +               } else {
39 +                       /*
40 +                        * (new_count < 0)
41 +                        * MPPE requires that we do not send unencrypted
42 +                        * frames.  The compressor will return -1 if we
43 +                        * should drop the frame.  We cannot simply test
44 +                        * the compress_proto because MPPE and MPPC share
45 +                        * the same number.
46 +                        */
47 +                       printk(KERN_ERR "ppp: compressor dropped pkt\n");
48 +                       kfree_skb(new_skb);
49 +                       ppp->xmit_busy = 0;
50 +                       return;
51                 }
52         }
53