Fix: remove old IPV6 routes on master
[l2tpns.git] / l2tpns.c
index 4028379..04fe44b 100644 (file)
--- a/l2tpns.c
+++ b/l2tpns.c
@@ -188,6 +188,7 @@ config_descriptt config_values[] = {
        CONFIG("bind_multi_address", bind_multi_address, STRING),
        CONFIG("pppoe_only_equal_svc_name", pppoe_only_equal_svc_name, BOOL),
        CONFIG("multi_hostname", multi_hostname, STRING),
+       CONFIG("no_throttle_local_IP", no_throttle_local_IP, BOOL),
        { NULL, 0, 0, 0 }
 };
 
@@ -1417,7 +1418,7 @@ void processipout(uint8_t *buf, int len)
        sessionidt s;
        sessiont *sp;
        tunnelidt t;
-       in_addr_t ip;
+       in_addr_t ip, ip_src;
 
        uint8_t *data = buf;    // Keep a copy of the originals.
        int size = len;
@@ -1450,6 +1451,7 @@ void processipout(uint8_t *buf, int len)
                return;
        }
 
+       ip_src = *(uint32_t *)(buf + 12);
        ip = *(uint32_t *)(buf + 16);
        if (!(s = sessionbyip(ip)))
        {
@@ -1534,12 +1536,15 @@ void processipout(uint8_t *buf, int len)
 
        if (sp->tbf_out)
        {
-               // Are we throttling this session?
-               if (config->cluster_iam_master)
-                       tbf_queue_packet(sp->tbf_out, data, size);
-               else
-                       master_throttle_packet(sp->tbf_out, data, size);
-               return;
+               if (!config->no_throttle_local_IP || !sessionbyip(ip_src))
+               {
+                       // Are we throttling this session?
+                       if (config->cluster_iam_master)
+                               tbf_queue_packet(sp->tbf_out, data, size);
+                       else
+                               master_throttle_packet(sp->tbf_out, data, size);
+                       return;
+               }
        }
 
        if (sp->walled_garden && !config->cluster_iam_master)
@@ -2115,9 +2120,9 @@ void sessionshutdown(sessionidt s, char const *reason, int cdn_result, int cdn_e
                        free_ip_address(s);
 
                // unroute IPv6, if setup
-               if (session[s].ppp.ipv6cp == Opened && session[s].ipv6prefixlen && del_routes)
+               if (session[s].ipv6route.s6_addr[0] && session[s].ipv6prefixlen && del_routes)
                        route6set(s, session[s].ipv6route, session[s].ipv6prefixlen, 0);
-               
+
                if (b)
                {
                        // This session was part of a bundle