make MRU configurable, NAK config requests for larger values
authorBrendan O'Dea <bod@optus.net>
Thu, 15 Sep 2005 09:34:46 +0000 (09:34 +0000)
committerBrendan O'Dea <bod@optus.net>
Thu, 15 Sep 2005 09:34:46 +0000 (09:34 +0000)
Changes
Docs/manual.html
Docs/startup-config.5
etc/startup-config.default
l2tpns.c
l2tpns.h
l2tpns.spec
ppp.c

diff --git a/Changes b/Changes
index bcdfb4e..a4cf2da 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,7 +1,8 @@
-* Wed Sep 14 2005 Brendan O'Dea <bod@optus.net> 2.1.6
+* Thu Sep 15 2005 Brendan O'Dea <bod@optus.net> 2.1.6
 - Any traffic on a tunnel resets lastrec, not just control messages.
 - Use a unique identifier for LCP.
 - Fix Code-Reject/Protocol-Reject.
+- Make MRU configurable, NAK config requests for larger values.
 
 * Sat Sep 3 2005 Brendan O'Dea <bod@optus.net> 2.1.5
 - Avoid Code-Reject loop.
index bebc7c8..a963e19 100644 (file)
@@ -192,6 +192,10 @@ PPP counter and timer values, as described in &sect;4.1 of
 <a href="ftp://ftp.rfc-editor.org/in-notes/rfc1661.txt">RFC1661</a>.
 </LI>
 
+<LI><B>ppp_mru</B> (int)<BR>
+PPP link MRU (default: 1452).
+</LI>
+
 <LI><B>primary_dns</B> (ip address)
 <LI><B>secondary_dns</B> (ip address)<BR>
 Whenever a PPP connection is established, DNS servers will be sent to the
index ee59995..4736e8c 100644 (file)
@@ -2,7 +2,7 @@
 .de Id
 .ds Dt \\$4 \\$5
 ..
-.Id $Id: startup-config.5,v 1.13 2005-09-02 23:59:56 bodea Exp $
+.Id $Id: startup-config.5,v 1.14 2005-09-15 09:34:49 bodea Exp $
 .TH STARTUP-CONFIG 5 "\*(Dt" L2TPNS "File Formats and Conventions"
 .SH NAME
 startup\-config \- configuration file for l2tpns
@@ -73,6 +73,9 @@ Number of configure requests to send before giving up (default: 10).
 Number of Configure-Nak requests to send before sending a
 Configure-Reject (default: 5).
 .TP
+.B ppp_mru
+PPP link MRU (default: 1452).
+.TP
 .BR primary_dns , " secondary_dns"
 Whenever a PPP connection is established, DNS servers will be sent to the
 user, both a primary and a secondary.  If either is set to 0.0.0.0, then that
index 7c788c3..85f8bd1 100644 (file)
@@ -15,6 +15,9 @@ set l2tp_secret "secret"
 #set ppp_max_configure 10
 #set ppp_max_failure 5
 
+# Link MRU
+#set ppp_mru 1452
+
 # Only 2 DNS server entries are allowed
 set primary_dns 10.0.0.1
 set secondary_dns 10.0.0.2
index 6839c25..9671a69 100644 (file)
--- a/l2tpns.c
+++ b/l2tpns.c
@@ -4,7 +4,7 @@
 // Copyright (c) 2002 FireBrick (Andrews & Arnold Ltd / Watchfront Ltd) - GPL licenced
 // vim: sw=8 ts=8
 
-char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.131 2005-09-13 14:27:14 bodea Exp $";
+char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.132 2005-09-15 09:34:48 bodea Exp $";
 
 #include <arpa/inet.h>
 #include <assert.h>
@@ -108,6 +108,7 @@ config_descriptt config_values[] = {
        CONFIG("ppp_restart_time", ppp_restart_time, INT),
        CONFIG("ppp_max_configure", ppp_max_configure, INT),
        CONFIG("ppp_max_failure", ppp_max_failure, INT),
+       CONFIG("ppp_mru", ppp_mru, INT),
        CONFIG("primary_dns", default_dns1, IPv4),
        CONFIG("secondary_dns", default_dns2, IPv4),
        CONFIG("primary_radius", radiusserver[0], IPv4),
@@ -2381,7 +2382,7 @@ void processudp(uint8_t *buf, int len, struct sockaddr_in *addr)
                                        if (amagic == 0) amagic = time_now;
                                        session[s].magic = amagic; // set magic number
                                        session[s].l2tp_flags = aflags; // set flags received
-                                       session[s].mru = DEFAULT_MRU;
+                                       session[s].mru = config->ppp_mru;
                                        controlnull(t); // ack
 
                                        // start LCP
@@ -3500,6 +3501,7 @@ static void initdata(int optdebug, char *optconfig)
        config->ppp_restart_time = 3;
        config->ppp_max_configure = 10;
        config->ppp_max_failure = 5;
+       config->ppp_mru = DEFAULT_MRU;
        strcpy(config->random_device, RANDOMDEVICE);
 
        log_stream = stderr;
@@ -4248,6 +4250,8 @@ static void update_config()
                setbuf(log_stream, NULL);
        }
 
+       if (config->ppp_mru < 0) config->ppp_mru = 0;
+
        // Update radius
        config->numradiusservers = 0;
        for (i = 0; i < MAXRADSERVER; i++)
index 8a20cb3..71f8ddc 100644 (file)
--- a/l2tpns.h
+++ b/l2tpns.h
@@ -1,5 +1,5 @@
 // L2TPNS Global Stuff
-// $Id: l2tpns.h,v 1.89 2005-09-13 14:23:07 bodea Exp $
+// $Id: l2tpns.h,v 1.90 2005-09-15 09:34:49 bodea Exp $
 
 #ifndef __L2TPNS_H__
 #define __L2TPNS_H__
@@ -15,7 +15,7 @@
 #include <sys/types.h>
 #include <libcli.h>
 
-#define VERSION        "2.1.6"
+#define VERSION        "2.1.7"
 
 // Limits
 #define MAXTUNNEL      500             // could be up to 65535
@@ -519,6 +519,7 @@ typedef struct
        int             ppp_restart_time;               // timeout for PPP restart
        int             ppp_max_configure;              // max lcp configure requests to send
        int             ppp_max_failure;                // max lcp configure naks to send
+       int             ppp_mru;                        // MRU to advertise
 
        char            radiussecret[64];
        int             radius_accounting;
index f6d74e2..2acc203 100644 (file)
@@ -43,5 +43,5 @@ rm -rf %{buildroot}
 %attr(644,root,root) /usr/share/man/man[58]/*
 
 %changelog
-* Wed Sep 14 2005 Brendan O'Dea <bod@optus.net> 2.1.6-1
+* Thu Sep 15 2005 Brendan O'Dea <bod@optus.net> 2.1.6-1
 - 2.1.6 release, see /usr/share/doc/l2tpns-2.1.6/Changes
diff --git a/ppp.c b/ppp.c
index 774efbd..9f0a713 100644 (file)
--- a/ppp.c
+++ b/ppp.c
@@ -1,6 +1,6 @@
 // L2TPNS PPP Stuff
 
-char const *cvs_id_ppp = "$Id: ppp.c,v 1.80 2005-09-13 14:23:07 bodea Exp $";
+char const *cvs_id_ppp = "$Id: ppp.c,v 1.81 2005-09-15 09:34:49 bodea Exp $";
 
 #include <stdio.h>
 #include <string.h>
@@ -577,7 +577,18 @@ void processlcp(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l)
                        switch (type)
                        {
                                case 1: // Maximum-Receive-Unit
-                                       session[s].mru = ntohs(*(uint16_t *)(o + 2));
+                                       {
+                                               uint16_t mru = ntohs(*(uint16_t *)(o + 2));
+                                               if (!config->ppp_mru || mru <= config->ppp_mru)
+                                               {
+                                                       session[s].mru = mru;
+                                                       break;
+                                               }
+
+                                               LOG(3, s, t, "    Remote requesting MRU of %u.  Rejecting.\n", mru);
+                                               mru = htons(config->ppp_mru);
+                                               q = ppp_conf_nak(s, b, sizeof(b), PPPLCP, &response, q, p, o, (uint8_t *) &mru, sizeof(mru));
+                                       }
                                        break;
 
                                case 2: // Async-Control-Character-Map
@@ -738,8 +749,9 @@ void processlcp(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l)
                                case 1: // Maximum-Receive-Unit
                                        if (*p == ConfigNak)
                                        {
-                                               session[s].mru = ntohs(*(uint16_t *)(o + 2));
-                                               LOG(3, s, t, "    Remote requested MRU of %u\n", session[s].mru);
+                                               session[s].mru = 0;
+                                               LOG(3, s, t, "    Remote requested MRU of %u; removing option\n",
+                                                       ntohs(*(uint16_t *)(o + 2)));
                                        }
                                        else
                                        {