[Olsr-dev] mtu problem with multicast ipv6 packets

John Hay (spam-protected)
Wed Nov 5 11:35:28 CET 2008


On Thu, Oct 23, 2008 at 12:08:39PM +0200, Hannes Gredler wrote:
> ok, do we have agreement on the final fix ?
> if so please send it to me :-)

Ok, here is my latest attempt. I have renamed OLSR_DEFAULT_MTU to
OLSR_IPV4_DEFAULT_MTU. On Linux OLSR_IPV6_DEFAULT_MTU comes from
IPV6_MIN_MTU and on the BSDs it comes from IPV6_MMTU. For the rest
it is hardcoded to 1280.

Lightly tested on FreeBSD.

John
-- 
John Hay -- (spam-protected) / (spam-protected)


--- src/unix/ifnet.c.orig	2008-10-03 14:45:07.000000000 +0200
+++ src/unix/ifnet.c	2008-11-05 10:56:20.000000000 +0200
@@ -237,6 +237,9 @@
     ifp->int_mtu = 0;
   else
     {
+      if ((olsr_cnf->ip_version == AF_INET6) &&
+	  (ifr.ifr_mtu > OLSR_IPV6_DEFAULT_MTU))
+	ifr.ifr_mtu = OLSR_IPV6_DEFAULT_MTU;
       ifr.ifr_mtu -= (olsr_cnf->ip_version == AF_INET6) ? UDP_IPV6_HDRSIZE : UDP_IPV4_HDRSIZE;
 
       if(ifp->int_mtu != ifr.ifr_mtu)
@@ -532,7 +535,9 @@
 	olsr_syslog(OLSR_LOG_INFO, "New main address: %s\n", olsr_ip_to_string(&buf, &olsr_cnf->main_addr));
     }
 
-  ifp->int_mtu = OLSR_DEFAULT_MTU;
+  ifp->int_mtu = OLSR_IPV4_DEFAULT_MTU;
+  if (olsr_cnf->ip_version == AF_INET6)
+    ifp->int_mtu = OLSR_IPV6_DEFAULT_MTU;
 
   ifp->int_mtu -= (olsr_cnf->ip_version == AF_INET6) ? UDP_IPV6_HDRSIZE : UDP_IPV4_HDRSIZE;
 
@@ -834,9 +839,12 @@
 
   /* Get MTU */
   if (ioctl(olsr_cnf->ioctl_s, SIOCGIFMTU, &ifr) < 0)
-    ifs.int_mtu = OLSR_DEFAULT_MTU;
+    ifs.int_mtu = OLSR_IPV4_DEFAULT_MTU;
   else
     ifs.int_mtu = ifr.ifr_mtu;
+  if ((olsr_cnf->ip_version == AF_INET6) &&
+      (ifr.ifr_mtu > OLSR_IPV6_DEFAULT_MTU))
+    ifr.ifr_mtu = OLSR_IPV6_DEFAULT_MTU;
 
   ifs.int_mtu -= (olsr_cnf->ip_version == AF_INET6) ? UDP_IPV6_HDRSIZE : UDP_IPV4_HDRSIZE;
 
--- src/win32/ifnet.c.orig	2008-10-03 14:45:07.000000000 +0200
+++ src/win32/ifnet.c	2008-11-05 10:56:20.000000000 +0200
@@ -626,7 +626,7 @@
       OLSR_PRINTF(1, "New main address: %s\n", olsr_ip_to_string(&buf, &olsr_cnf->main_addr));
     }
 
-  ifp->int_mtu = OLSR_DEFAULT_MTU;
+  ifp->int_mtu = OLSR_IPV4_DEFAULT_MTU;
 
   ifp->int_mtu -= (olsr_cnf->ip_version == AF_INET6) ?
     UDP_IPV6_HDRSIZE : UDP_IPV4_HDRSIZE;
--- src/interfaces.h.orig	2008-10-03 14:45:07.000000000 +0200
+++ src/interfaces.h	2008-11-05 11:10:30.000000000 +0200
@@ -54,6 +54,19 @@
 #include "olsr_types.h"
 #include "mantissa.h"
 
+#if defined linux
+#include <linux/ipv6.h>
+#define OLSR_IPV6_DEFAULT_MTU	IPV6_MIN_MTU
+#endif
+#if defined __MacOSX__ || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__
+#include <netinet/ip6.h>
+#define OLSR_IPV6_DEFAULT_MTU IPV6_MMTU
+#endif
+#ifndef OLSR_IPV6_DEFAULT_MTU
+#define OLSR_IPV6_DEFAULT_MTU	1280
+#endif
+#define OLSR_IPV4_DEFAULT_MTU	1500
+
 #define _PATH_PROCNET_IFINET6           "/proc/net/if_inet6"
 
 
@@ -178,8 +191,6 @@
 };
 
 
-#define OLSR_DEFAULT_MTU             1500
-
 /* Ifchange actions */
 
 #define IFCHG_IF_ADD           1




More information about the Olsr-dev mailing list