Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net Multilink PPP: sanity check of option values, storag...



details:   https://anonhg.NetBSD.org/src/rev/13a7a505e936
branches:  trunk
changeset: 970820:13a7a505e936
user:      is <is%NetBSD.org@localhost>
date:      Sat Apr 04 17:12:33 2020 +0000

description:
Multilink PPP: sanity check of option values, storage of remote MRRU.

diffstat:

 sys/net/if_spppsubr.c |  50 +++++++++++++++++++++++++++++++++++---------------
 sys/net/if_spppvar.h  |   5 ++++-
 2 files changed, 39 insertions(+), 16 deletions(-)

diffs (106 lines):

diff -r 0381bcb73f85 -r 13a7a505e936 sys/net/if_spppsubr.c
--- a/sys/net/if_spppsubr.c     Sat Apr 04 17:05:06 2020 +0000
+++ b/sys/net/if_spppsubr.c     Sat Apr 04 17:12:33 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_spppsubr.c,v 1.188 2020/04/01 20:24:50 is Exp $      */
+/*     $NetBSD: if_spppsubr.c,v 1.189 2020/04/04 17:12:33 is Exp $      */
 
 /*
  * Synchronous PPP/Cisco link level subroutines.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.188 2020/04/01 20:24:50 is Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.189 2020/04/04 17:12:33 is Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -2383,12 +2383,19 @@
                        break;
                case LCP_OPT_MP_EID:
                        if (len >= l && l >= 3) {
-                               if (debug)
-                                       addlog(" [rej]");
-                               break;
+                               switch (p[2]) {
+                               case 0: if (l==3+ 0) continue;break;
+                               case 2: if (l==3+ 4) continue;break;
+                               case 3: if (l==3+ 6) continue;break;
+                               case 6: if (l==3+16) continue;break;
+                               case 1: /* FALLTHROUGH */
+                               case 4: if (l<=3+20) continue;break;
+                               case 5: if (l<=3+15) continue;break;
+                               /* XXX should it be default: continue;? */
+                               }
                        }
                        if (debug)
-                               addlog(" [invalid]");
+                               addlog(" [invalid class %d len %d]", p[2], l);
                        break;
                case LCP_OPT_MP_SSNHF:
                        if (len >= 2 && l == 2) {
@@ -2402,15 +2409,7 @@
                case LCP_OPT_MP_MRRU:
                        /* Multilink maximum received reconstructed unit */
                        /* should be fall through, both are same length */
-                       /* for now, check, then reject anyway */
-                       if (len >= 4 && l == 4) {
-                               if (debug)
-                                       addlog(" %d [rej]", (p[2] <<8) + p[3]);
-                               break;
-                       }
-                       if (debug)
-                               addlog(" [invalid]");
-                       break;
+                       /* FALLTHROUGH */
                case LCP_OPT_MRU:
                        /* Maximum receive unit. */
                        if (len >= 4 && l == 4)
@@ -2569,6 +2568,27 @@
                                break;
                        }
                        continue;
+               case LCP_OPT_MP_EID:
+                       /*
+                        * Endpoint identification.
+                        * Always agreeable,
+                        * but ignored by now.
+                        */
+                       if (debug) {
+                               addlog(" type %d", p[2]);
+                               sppp_print_bytes(p+3, p[1]-3);
+                       }
+                       continue;
+               case LCP_OPT_MP_MRRU:
+                       /*
+                        * Maximum received reconstructed unit. 
+                        * Always agreeable,
+                        * but ignored by now.
+                        */
+                       sp->lcp.their_mrru = p[2] * 256 + p[3];
+                       if (debug)
+                               addlog(" %ld", sp->lcp.their_mrru);
+                       continue;
                }
                if (rlen + l > blen) {
                        if (debug)
diff -r 0381bcb73f85 -r 13a7a505e936 sys/net/if_spppvar.h
--- a/sys/net/if_spppvar.h      Sat Apr 04 17:05:06 2020 +0000
+++ b/sys/net/if_spppvar.h      Sat Apr 04 17:12:33 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_spppvar.h,v 1.22 2017/10/12 09:53:55 knakahara Exp $        */
+/*     $NetBSD: if_spppvar.h,v 1.23 2020/04/04 17:12:33 is Exp $       */
 
 #ifndef _NET_IF_SPPPVAR_H_
 #define _NET_IF_SPPPVAR_H_
@@ -45,6 +45,9 @@
        int     max_terminate;
        int     max_configure;
        int     max_failure;
+       /* multilink variables */
+       u_long  mrru;           /* our   max received reconstructed unit */
+       u_long  their_mrru;     /* their max receive dreconstructed unit */
 };
 
 #define IDX_IPCP 1             /* idx into state table */



Home | Main Index | Thread Index | Old Index