]> git.ozlabs.org Git - ppp.git/commitdiff
Corrected version of MPPE kernel support (Frank Cusack)
authorDavid F. Skoll <dfs@roaringpenguin.com>
Tue, 2 Apr 2002 14:12:48 +0000 (14:12 +0000)
committerDavid F. Skoll <dfs@roaringpenguin.com>
Tue, 2 Apr 2002 14:12:48 +0000 (14:12 +0000)
linux/mppe/linux-2.2.20-make.patch
linux/mppe/linux-2.4.18-include.patch [new file with mode: 0644]
linux/mppe/linux-2.4.18-make.patch [new file with mode: 0644]
linux/mppe/linux-2.4.18-pad.patch [new file with mode: 0644]
linux/mppe/mppeinstall.sh
linux/mppe/ppp_mppe_compress.c

index b0a936ee05a1698110a74321595995c216c5e9d3..d925004ee72d2638a37725ab28883384568c9a33 100644 (file)
@@ -1,6 +1,31 @@
---- linux/drivers/net/Makefile.orig    Fri Nov  2 08:39:07 2001
-+++ linux/drivers/net/Makefile Tue Mar 19 09:31:06 2002
-@@ -325,11 +325,13 @@
+--- linux/drivers/net/Makefile.orig    Mon Mar 25 11:38:09 2002
++++ linux/drivers/net/Makefile Mon Mar 25 11:42:18 2002
+@@ -26,6 +26,8 @@
+ CONFIG_BSDCOMP_MODULE  :=
+ CONFIG_PPPDEF_BUILTIN :=
+ CONFIG_PPPDEF_MODULE  :=
++CONFIG_PPPMPPE_BUILTIN :=
++CONFIG_PPPMPPE_MODULE  :=
+ CONFIG_7990_BUILTIN :=
+ CONFIG_7990_MODULE :=
+ CONFIG_82596_BUILTIN :=
+@@ -40,6 +42,7 @@
+     CONFIG_BSDCOMP_BUILTIN = y
+     CONFIG_SLHC_BUILTIN = y
+     CONFIG_PPPDEF_BUILTIN = y
++    CONFIG_PPPMPPE_BUILTIN = y
+   endif
+ else
+   ifeq ($(CONFIG_ISDN),m)
+@@ -47,6 +50,7 @@
+       CONFIG_BSDCOMP_MODULE = y
+       CONFIG_SLHC_MODULE = y
+       CONFIG_PPPDEF_MODULE = y
++      CONFIG_PPPMPPE_MODULE = y
+     endif
+   endif
+ endif
+@@ -325,11 +329,13 @@
  CONFIG_BSDCOMP_BUILTIN = y
  CONFIG_SLHC_BUILTIN = y
  CONFIG_PPPDEF_BUILTIN = y
  CONFIG_BSDCOMP_BUILTIN = y
  CONFIG_SLHC_BUILTIN = y
  CONFIG_PPPDEF_BUILTIN = y
@@ -14,7 +39,7 @@
    MX_OBJS += ppp.o
    endif
  endif
    MX_OBJS += ppp.o
    endif
  endif
-@@ -1100,6 +1102,17 @@
+@@ -1120,6 +1126,17 @@
    endif
  endif
  
    endif
  endif
  
  ifeq ($(CONFIG_ARIADNE2),y)
  L_OBJS += ariadne2.o
  CONFIG_8390_BUILTIN = y
  ifeq ($(CONFIG_ARIADNE2),y)
  L_OBJS += ariadne2.o
  CONFIG_8390_BUILTIN = y
-@@ -1449,3 +1462,8 @@
+@@ -1469,3 +1486,6 @@
  
  rcpci.o: rcpci45.o rclanmtl.o
        $(LD) -r -o rcpci.o rcpci45.o rclanmtl.o
 +
  
  rcpci.o: rcpci45.o rclanmtl.o
        $(LD) -r -o rcpci.o rcpci45.o rclanmtl.o
 +
-+ifdef CONFIG_PPPMPPE_MODULE
 +ppp_mppe.o: $(PPPMPPE_OBJS)
 +      $(LD) -r -o $@ $(PPPMPPE_OBJS)
 +ppp_mppe.o: $(PPPMPPE_OBJS)
 +      $(LD) -r -o $@ $(PPPMPPE_OBJS)
-+endif
diff --git a/linux/mppe/linux-2.4.18-include.patch b/linux/mppe/linux-2.4.18-include.patch
new file mode 100644 (file)
index 0000000..b8dd56f
--- /dev/null
@@ -0,0 +1,103 @@
+--- linux/include/linux/ppp-comp.h.orig        Fri Aug  6 10:44:11 1999
++++ linux/include/linux/ppp-comp.h     Mon Mar 25 09:11:33 2002
+@@ -187,6 +187,100 @@
+ #define DEFLATE_CHK_SEQUENCE  0
+ /*
++ * Definitions for MPPE.
++ */
++
++#define CI_MPPE                       18      /* config option for MPPE */
++#define CILEN_MPPE            6       /* length of config option */
++
++#define MPPE_PAD              4       /* MPPE growth per frame */
++#define MPPE_MAX_KEY_LEN      16      /* largest key length (128-bit) */
++
++/* option bits for ccp_options.mppe */
++#define MPPE_OPT_40           0x01    /* 40 bit */
++#define MPPE_OPT_128          0x02    /* 128 bit */
++#define MPPE_OPT_STATEFUL     0x04    /* stateful mode */
++/* unsupported opts */
++#define MPPE_OPT_56           0x08    /* 56 bit */
++#define MPPE_OPT_MPPC         0x10    /* MPPC compression */
++#define MPPE_OPT_D            0x20    /* Unknown */
++#define MPPE_OPT_UNSUPPORTED (MPPE_OPT_56|MPPE_OPT_MPPC|MPPE_OPT_D)
++#define MPPE_OPT_UNKNOWN      0x40    /* Bits !defined in RFC 3078 were set */
++
++/*
++ * This is not nice ... the alternative is a bitfield struct though.
++ * And unfortunately, we cannot share the same bits for the option
++ * names above since C and H are the same bit.  We could do a u_int32
++ * but then we have to do a htonl() all the time and/or we still need
++ * to know which octet is which.
++ */
++#define MPPE_C_BIT            0x01    /* MPPC */
++#define MPPE_D_BIT            0x10    /* Obsolete, usage unknown */
++#define MPPE_L_BIT            0x20    /* 40-bit */
++#define MPPE_S_BIT            0x40    /* 128-bit */
++#define MPPE_M_BIT            0x80    /* 56-bit, not supported */
++#define MPPE_H_BIT            0x01    /* Stateless (in a different byte) */
++
++/* Does not include H bit; used for least significant octet only. */
++#define MPPE_ALL_BITS (MPPE_D_BIT|MPPE_L_BIT|MPPE_S_BIT|MPPE_M_BIT|MPPE_H_BIT)
++
++/* Build a CI from mppe opts (see RFC 3078) */
++#define MPPE_OPTS_TO_CI(opts, ci)             \
++    do {                                      \
++      u_char *ptr = ci; /* u_char[4] */       \
++                                              \
++      /* H bit */                             \
++      if (opts & MPPE_OPT_STATEFUL)           \
++          *ptr++ = 0x0;                       \
++      else                                    \
++          *ptr++ = MPPE_H_BIT;                \
++      *ptr++ = 0;                             \
++      *ptr++ = 0;                             \
++                                              \
++      /* S,L bits */                          \
++      *ptr = 0;                               \
++      if (opts & MPPE_OPT_128)                \
++          *ptr |= MPPE_S_BIT;                 \
++      if (opts & MPPE_OPT_40)                 \
++          *ptr |= MPPE_L_BIT;                 \
++      /* M,D,C bits not supported */          \
++    } while (/* CONSTCOND */ 0)
++
++/* The reverse of the above */
++#define MPPE_CI_TO_OPTS(ci, opts)             \
++    do {                                      \
++      u_char *ptr = ci; /* u_char[4] */       \
++                                              \
++      opts = 0;                               \
++                                              \
++      /* H bit */                             \
++      if (!(ptr[0] & MPPE_H_BIT))             \
++          opts |= MPPE_OPT_STATEFUL;          \
++                                              \
++      /* S,L bits */                          \
++      if (ptr[3] & MPPE_S_BIT)                \
++          opts |= MPPE_OPT_128;               \
++      if (ptr[3] & MPPE_L_BIT)                \
++          opts |= MPPE_OPT_40;                \
++                                              \
++      /* M,D,C bits */                        \
++      if (ptr[3] & MPPE_M_BIT)                \
++          opts |= MPPE_OPT_56;                \
++      if (ptr[3] & MPPE_D_BIT)                \
++          opts |= MPPE_OPT_D;                 \
++      if (ptr[3] & MPPE_C_BIT)                \
++          opts |= MPPE_OPT_MPPC;              \
++                                              \
++      /* Other bits */                        \
++      if (ptr[0] & ~MPPE_H_BIT)               \
++          opts |= MPPE_OPT_UNKNOWN;           \
++      if (ptr[1] || ptr[2])                   \
++          opts |= MPPE_OPT_UNKNOWN;           \
++      if (ptr[3] & ~MPPE_ALL_BITS)            \
++          opts |= MPPE_OPT_UNKNOWN;           \
++    } while (/* CONSTCOND */ 0)
++
++/*
+  * Definitions for other, as yet unsupported, compression methods.
+  */
diff --git a/linux/mppe/linux-2.4.18-make.patch b/linux/mppe/linux-2.4.18-make.patch
new file mode 100644 (file)
index 0000000..aae7fe7
--- /dev/null
@@ -0,0 +1,44 @@
+--- linux/drivers/net/Config.in.orig   Mon Mar 25 09:07:26 2002
++++ linux/drivers/net/Config.in        Mon Mar 25 11:18:03 2002
+@@ -279,6 +279,7 @@
+    dep_tristate '  PPP support for sync tty ports' CONFIG_PPP_SYNC_TTY $CONFIG_PPP
+    dep_tristate '  PPP Deflate compression' CONFIG_PPP_DEFLATE $CONFIG_PPP
+    dep_tristate '  PPP BSD-Compress compression' CONFIG_PPP_BSDCOMP $CONFIG_PPP
++   dep_tristate '  PPP MPPE compression (encryption)' CONFIG_PPP_MPPE $CONFIG_PPP
+    if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
+       dep_tristate '  PPP over Ethernet (EXPERIMENTAL)' CONFIG_PPPOE $CONFIG_PPP
+    fi
+--- linux/drivers/net/Makefile.orig    Mon Mar 25 09:07:26 2002
++++ linux/drivers/net/Makefile Mon Mar 25 11:58:11 2002
+@@ -18,8 +18,9 @@
+ export-objs     :=    8390.o arlan.o aironet4500_core.o aironet4500_card.o \
+                       ppp_async.o ppp_generic.o slhc.o pppox.o auto_irq.o \
+                       net_init.o mii.o
+-list-multi    :=      rcpci.o
++list-multi    :=      rcpci.o ppp_mppe.o
+ rcpci-objs    :=      rcpci45.o rclanmtl.o
++ppp_mppe-objs :=      ppp_mppe_compress.o sha1.o arcfour.o
+ ifeq ($(CONFIG_TULIP),y)
+   obj-y += tulip/tulip.o
+@@ -139,6 +140,14 @@
+ obj-$(CONFIG_PPP_BSDCOMP) += bsd_comp.o
+ obj-$(CONFIG_PPPOE) += pppox.o pppoe.o
++ifeq ($(CONFIG_PPP_MPPE),y)
++  obj-y += $(ppp_mppe-objs)
++else
++  ifeq ($(CONFIG_PPP_MPPE),m)
++    obj-m += ppp_mppe.o
++  endif
++endif
++
+ obj-$(CONFIG_SLIP) += slip.o
+ ifeq ($(CONFIG_SLIP_COMPRESSED),y)
+   obj-$(CONFIG_SLIP) += slhc.o
+@@ -237,3 +246,5 @@
+ rcpci.o: $(rcpci-objs)
+       $(LD) -r -o $@ $(rcpci-objs)
++ppp_mppe.o: $(ppp_mppe-objs)
++      $(LD) -r -o $@ $(ppp_mppe-objs)
diff --git a/linux/mppe/linux-2.4.18-pad.patch b/linux/mppe/linux-2.4.18-pad.patch
new file mode 100644 (file)
index 0000000..30c6971
--- /dev/null
@@ -0,0 +1,59 @@
+--- 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 @@
+       /* 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);
+               if (new_skb == 0) {
+                       printk(KERN_ERR "PPP: no memory (comp pkt)\n");
+                       goto drop;
+@@ -1019,15 +1026,27 @@
+               /* 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);
+               if (len > 0 && (ppp->flags & SC_CCP_UP)) {
+                       kfree_skb(skb);
+                       skb = new_skb;
+                       skb_put(skb, len);
+                       skb_pull(skb, 2);       /* pull off A/C bytes */
+-              } else {
++              } else if (len == 0) {
+                       /* didn't compress, or CCP not up yet */
+                       kfree_skb(new_skb);
++              } else {
++                      /*
++                       * (len < 0)
++                       * MPPE requires that we do not send unencrypted
++                       * frames.  The compressor will return -1 if we
++                       * should drop the frame.  We cannot simply test
++                       * the compress_proto because MPPE and MPPC share
++                       * the same number.
++                       */
++                      printk(KERN_ERR "ppp: compressor dropped pkt\n");
++                      kfree_skb(new_skb);
++                      goto drop;
+               }
+       }
+@@ -1515,7 +1534,7 @@
+       int len;
+       if (proto == PPP_COMP) {
+-              ns = dev_alloc_skb(ppp->mru + PPP_HDRLEN);
++              ns = dev_alloc_skb(ppp->mru + 128 + PPP_HDRLEN);
+               if (ns == 0) {
+                       printk(KERN_ERR "ppp_decompress_frame: no memory\n");
+                       goto err;
index f2f17400c7d2295c0d5b5e74b694ac3d78c30b5f..5a81ffd0305cdde62924a70332d8e14672d81e9e 100644 (file)
@@ -1,26 +1,28 @@
 #!/bin/sh
 #
 #!/bin/sh
 #
-# A quickie script to install MPPE into the 2.2.20 kernel.
+# A quickie script to install MPPE into the 2.2.19+ or 2.4.18 kernel.
 # Does no error checking!!!
 #
 
 # Does no error checking!!!
 #
 
-mppe_files="sha1.[ch] arcfour.[ch] ppp_mppe.c"
+mppe_files="sha1.[ch] arcfour.[ch] ppp_mppe_compress.c"
 
 [ $1 ] || exit 1
 [ -d "$1" ] || exit 1
 
 
 [ $1 ] || exit 1
 [ -d "$1" ] || exit 1
 
+echo -n "Is this a 2.2 kernel or 2.4 kernel: "
+read ver
 echo "I will now patch the kernel in directory $1"
 echo -n "Press ret to continue, CTRL-C to exit: "
 read
 
 patchdir=`pwd`
 pushd "$1" >/dev/null
 echo "I will now patch the kernel in directory $1"
 echo -n "Press ret to continue, CTRL-C to exit: "
 read
 
 patchdir=`pwd`
 pushd "$1" >/dev/null
-for patch in $patchdir/linux*.patch; do
+for patch in $patchdir/linux-$ver.*.patch; do
     patch -p1 < $patch
 done
 
 for file in $mppe_files; do
     patch -p1 < $patch
 done
 
 for file in $mppe_files; do
-    cp $patchdir/$file drivers/net
+    cp -v $patchdir/$file drivers/net
 done
 
 popd >/dev/null
 done
 
 popd >/dev/null
index 8b62ba734370af7876e1065042f92c88fb0e44c8..efdb5d15e95af072a6f8b8a1a571760c8fdd2cb1 100644 (file)
@@ -2,7 +2,7 @@
  *  ==FILEVERSION 20020320==
  *
  * ppp_mppe_compress.c - interface MPPE to the PPP code.
  *  ==FILEVERSION 20020320==
  *
  * ppp_mppe_compress.c - interface MPPE to the PPP code.
- * This version is for use with Linux kernel 2.2.x (ppp driver 2.3.x).
+ * This version is for use with Linux kernel 2.2.19+ and 2.4.x.
  *
  * By Frank Cusack <frank@google.com>.
  * Copyright (c) 2002 Google, Inc.
  *
  * By Frank Cusack <frank@google.com>.
  * Copyright (c) 2002 Google, Inc.
@@ -19,7 +19,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/types.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 
 #include <linux/ppp_defs.h>
 #include <linux/string.h>
 
 #include <linux/ppp_defs.h>
@@ -559,7 +559,7 @@ mppe_incomp(void *arg, unsigned char *ibuf, int icnt)
  * Module interface table
  *************************************************************/
 
  * Module interface table
  *************************************************************/
 
-/* These are in ppp.c */
+/* These are in ppp.c (2.2.x) or ppp_generic.c (2.4.x) */
 extern int  ppp_register_compressor   (struct compressor *cp);
 extern void ppp_unregister_compressor (struct compressor *cp);
 
 extern int  ppp_register_compressor   (struct compressor *cp);
 extern void ppp_unregister_compressor (struct compressor *cp);
 
@@ -583,7 +583,19 @@ struct compressor ppp_mppe = {
     mppe_comp_stats,   /* decomp_stat */
 };
 
     mppe_comp_stats,   /* decomp_stat */
 };
 
-__initfunc(int ppp_mppe_install(void))
+/* 2.2 compatibility defines */
+#ifndef __init
+#define __init
+#endif
+#ifndef __exit
+#define __exit
+#endif
+#ifndef MODULE_LICENSE
+#define MODULE_LICENSE(license)
+#endif
+
+int __init
+ppp_mppe_init(void)
 {  
     int answer = ppp_register_compressor(&ppp_mppe);
 
 {  
     int answer = ppp_register_compressor(&ppp_mppe);
 
@@ -592,20 +604,12 @@ __initfunc(int ppp_mppe_install(void))
     return answer;
 }
 
     return answer;
 }
 
-#ifdef MODULE
-
-int
-init_module(void)
-{
-    return ppp_mppe_install();
-}
-     
-void
-cleanup_module(void)
+void __exit
+ppp_mppe_cleanup(void)
 {
 {
-    if (MOD_IN_USE)
-       printk(KERN_INFO "PPP MPPE Compression module busy\n");
-    else
-       ppp_unregister_compressor(&ppp_mppe);
+    ppp_unregister_compressor(&ppp_mppe);
 }
 }
-#endif
+
+module_init(ppp_mppe_init);
+module_exit(ppp_mppe_cleanup);
+MODULE_LICENSE("BSD without advertisement clause");