]> git.ozlabs.org Git - ppp.git/blobdiff - linux/mppe/linux-2.4.18-pad.patch
modify ppp_generic patch to avoid an if() test and extra additions on
[ppp.git] / linux / mppe / linux-2.4.18-pad.patch
index 01a56ff8ce586708df535e87f81946cdcc7cca1c..40d8a7e08b83c8173f999b59f79affb2b27255da 100644 (file)
@@ -1,29 +1,50 @@
---- linux/drivers/net/ppp_generic.c.orig       Mon Feb 25 11:37:59 2002
-+++ linux/drivers/net/ppp_generic.c    Mon Mar 25 10:19:53 2002
-@@ -1006,8 +1006,15 @@
+--- linux-2.4.18/drivers/net/ppp_generic.c.orig        Mon May 12 01:36:31 2003
++++ linux-2.4.18/drivers/net/ppp_generic.c     Mon May 12 03:09:13 2003
+@@ -99,6 +99,7 @@
+       spinlock_t      rlock;          /* lock for receive side */
+       spinlock_t      wlock;          /* lock for transmit side */
+       int             mru;            /* max receive unit */
++      int             mru_alloc;      /* MAX(1500,MRU) for dev_alloc_skb() */
+       unsigned int    flags;          /* control bits */
+       unsigned int    xstate;         /* transmit state bits */
+       unsigned int    rstate;         /* receive state bits */
+@@ -126,6 +127,7 @@
+       struct sock_fprog pass_filter;  /* filter for packets to pass */
+       struct sock_fprog active_filter;/* filter for pkts to reset idle */
+ #endif /* CONFIG_PPP_FILTER */
++      int             comp_pad;       /* padding for compressor (MPPE) */
+ };
+ /*
+@@ -531,6 +533,10 @@
+               if (get_user(val, (int *) arg))
+                       break;
+               ppp->mru = val;
++              if (ppp->mru > ppp->mru_alloc)
++                  ppp->mru_alloc = ppp->mru;
++              else if (ppp->mru < PPP_MRU)
++                  ppp->mru_alloc = PPP_MRU;   /* shrink to minimum */
+               err = 0;
+               break;
+@@ -1006,8 +1012,8 @@
        /* try to do packet compression */
        if ((ppp->xstate & SC_COMP_RUN) && ppp->xc_state != 0
            && proto != PPP_LCP && proto != PPP_CCP) {
 -              new_skb = alloc_skb(ppp->dev->mtu + ppp->dev->hard_header_len,
 -                                  GFP_ATOMIC);
-+              int new_skb_size = ppp->dev->mtu + ppp->dev->hard_header_len;
-+              int compressor_skb_size = ppp->dev->mtu + PPP_HDRLEN;
-+
-+              if (ppp->xcomp->compress_proto == CI_MPPE) {
-+                      /* CCP [must have] reduced MTU by MPPE_PAD. */
-+                      new_skb_size += MPPE_PAD;
-+                      compressor_skb_size += MPPE_PAD;
-+              }
-+              new_skb = alloc_skb(new_skb_size, GFP_ATOMIC);
++              new_skb = alloc_skb(ppp->dev->mtu + ppp->dev->hard_header_len
++                                  + ppp->comp_pad, GFP_ATOMIC);
                if (new_skb == 0) {
                        printk(KERN_ERR "PPP: no memory (comp pkt)\n");
                        goto drop;
-@@ -1019,15 +1026,27 @@
+@@ -1019,15 +1025,28 @@
                /* compressor still expects A/C bytes in hdr */
                len = ppp->xcomp->compress(ppp->xc_state, skb->data - 2,
                                           new_skb->data, skb->len + 2,
 -                                         ppp->dev->mtu + PPP_HDRLEN);
-+                                         compressor_skb_size);
++                                         ppp->dev->mtu + ppp->comp_pad
++                                         + PPP_HDRLEN);
                if (len > 0 && (ppp->flags & SC_CCP_UP)) {
                        kfree_skb(skb);
                        skb = new_skb;
                }
        }
  
-@@ -1515,14 +1534,14 @@
+@@ -1515,14 +1534,15 @@
        int len;
  
        if (proto == PPP_COMP) {
 -              ns = dev_alloc_skb(ppp->mru + PPP_HDRLEN);
-+              ns = dev_alloc_skb(ppp->mru + 128 + PPP_HDRLEN);
++              ns = dev_alloc_skb(ppp->mru_alloc + PPP_HDRLEN);
                if (ns == 0) {
                        printk(KERN_ERR "ppp_decompress_frame: no memory\n");
                        goto err;
                /* the decompressor still expects the A/C bytes in the hdr */
                len = ppp->rcomp->decompress(ppp->rc_state, skb->data - 2,
 -                              skb->len + 2, ns->data, ppp->mru + PPP_HDRLEN);
-+                              skb->len + 2, ns->data, ppp->mru + 128 + PPP_HDRLEN);
++                              skb->len + 2, ns->data,
++                              ppp->mru_alloc + PPP_HDRLEN);
                if (len < 0) {
                        /* Pass the compressed frame to pppd as an
                           error indication. */
+@@ -1949,6 +1969,20 @@
+                       ppp_xmit_unlock(ppp);
+                       err = 0;
+               }
++              if (ccp_option[0] == CI_MPPE)
++                      /*
++                       * pppd (userland) has reduced the MTU by MPPE_PAD,
++                       * to accomodate "compressor" growth.  We must
++                       * increase the space allocated for compressor
++                       * output in ppp_send_frame() accordingly.  Note
++                       * that from a purist's view, it may be more correct
++                       * to require multilink and fragment large packets,
++                       * but that seems inefficient compared to this
++                       * little trick.
++                       */
++                      ppp->comp_pad = MPPE_PAD;
++              else
++                      ppp->comp_pad = 0;
+       } else {
+               ppp_recv_lock(ppp);
+@@ -2229,6 +2263,7 @@
+       ppp->file.index = unit;
+       ppp->mru = PPP_MRU;
++      ppp->mru_alloc = PPP_MRU;
+       init_ppp_file(&ppp->file, INTERFACE);
+       ppp->file.hdrlen = PPP_HDRLEN - 2;      /* don't count proto bytes */
+       for (i = 0; i < NUM_NP; ++i)