[quagga-dev 8936] [PATCH] ospf6d: account for IPv6 headers in MTU checks

John W. O'Brien john at saltant.com
Thu Oct 27 07:13:18 BST 2011


This patch accounts for the essential header only, and not for
permissible extra headers which can still induce fragmentation. A
complete resolution would require additional information from the
kernel which is not generally available.

    * ospf6_message.h
       * Define constant per RFC-2460 and leave breadcrumbs to signal
         limitation of approach

    * ospf6_message.c
       * ospf6_hello_send()
       * ospf6_dbdesc_send()
       * ospf6_dbdesc_send_newone()
       * ospf6_lsreq_send()
       * ospf6_lsupdate_send_neighbor()
       * ospf6_lsupdate_send_interface()
       * ospf6_lsack_send_neighbor()
       * ospf6_lsack_send_interface()

diff --git a/ospf6d/ospf6_message.c b/ospf6d/ospf6_message.c
index f40ad4b..f536837 100644
--- a/ospf6d/ospf6_message.c
+++ b/ospf6d/ospf6_message.c
@@ -1820,7 +1820,8 @@ ospf6_hello_send (struct thread *thread)
        if (on->state < OSPF6_NEIGHBOR_INIT)
          continue;

-      if (p - sendbuf + sizeof (u_int32_t) > oi->ifmtu)
+      if (p - sendbuf + sizeof (u_int32_t)
+          + IPV6_HEADER_SIZE > oi->ifmtu)
          {
            if (IS_OSPF6_DEBUG_MESSAGE (OSPF6_MESSAGE_TYPE_HELLO, SEND))
              zlog_debug ("sending Hello message: exceeds I/F MTU");
@@ -1895,8 +1896,8 @@ ospf6_dbdesc_send (struct thread *thread)
            ospf6_lsa_age_update_to_send (lsa, 
on->ospf6_if->transdelay);

            /* MTU check */
-          if (p - sendbuf + sizeof (struct ospf6_lsa_header) >
-              on->ospf6_if->ifmtu)
+          if (p - sendbuf + sizeof (struct ospf6_lsa_header)
+              + IPV6_HEADER_SIZE > on->ospf6_if->ifmtu)
              {
                ospf6_lsa_unlock (lsa);
                break;
@@ -1930,7 +1931,8 @@ ospf6_dbdesc_send_newone (struct thread *thread)
    for (lsa = ospf6_lsdb_head (on->summary_list); lsa;
         lsa = ospf6_lsdb_next (lsa))
      {
-      if (size + sizeof (struct ospf6_lsa_header) > 
on->ospf6_if->ifmtu)
+      if (size + sizeof (struct ospf6_lsa_header)
+          + IPV6_HEADER_SIZE > on->ospf6_if->ifmtu)
          {
            ospf6_lsa_unlock (lsa);
            break;
@@ -1997,7 +1999,8 @@ ospf6_lsreq_send (struct thread *thread)
         lsa = ospf6_lsdb_next (lsa))
      {
        /* MTU check */
-      if (p - sendbuf + sizeof (struct ospf6_lsreq_entry) > 
on->ospf6_if->ifmtu)
+      if (p - sendbuf + sizeof (struct ospf6_lsreq_entry)
+          + IPV6_HEADER_SIZE > on->ospf6_if->ifmtu)
          {
            ospf6_lsa_unlock (lsa);
            break;
@@ -2066,7 +2069,7 @@ ospf6_lsupdate_send_neighbor (struct thread 
*thread)
      {
        /* MTU check */
        if ( (p - sendbuf + (unsigned int)OSPF6_LSA_SIZE (lsa->header))
-          > on->ospf6_if->ifmtu)
+          + IPV6_HEADER_SIZE > on->ospf6_if->ifmtu)
          {
            ospf6_lsa_unlock (lsa);
            break;
@@ -2086,7 +2089,7 @@ ospf6_lsupdate_send_neighbor (struct thread 
*thread)
      {
        /* MTU check */
        if ( (p - sendbuf + (unsigned int)OSPF6_LSA_SIZE (lsa->header))
-          > on->ospf6_if->ifmtu)
+          + IPV6_HEADER_SIZE > on->ospf6_if->ifmtu)
          {
            ospf6_lsa_unlock (lsa);
            break;
@@ -2159,7 +2162,7 @@ ospf6_lsupdate_send_interface (struct thread 
*thread)
      {
        /* MTU check */
        if ( (p - sendbuf + ((unsigned int)OSPF6_LSA_SIZE 
(lsa->header)))
-          > oi->ifmtu)
+          + IPV6_HEADER_SIZE > oi->ifmtu)
          {
            ospf6_lsa_unlock (lsa);
            break;
@@ -2226,7 +2229,8 @@ ospf6_lsack_send_neighbor (struct thread *thread)
         lsa = ospf6_lsdb_next (lsa))
      {
        /* MTU check */
-      if (p - sendbuf + sizeof (struct ospf6_lsa_header) > 
on->ospf6_if->ifmtu)
+      if (p - sendbuf + sizeof (struct ospf6_lsa_header)
+          + IPV6_HEADER_SIZE > on->ospf6_if->ifmtu)
          {
            /* if we run out of packet size/space here,
               better to try again soon. */
@@ -2286,7 +2290,8 @@ ospf6_lsack_send_interface (struct thread 
*thread)
         lsa = ospf6_lsdb_next (lsa))
      {
        /* MTU check */
-      if (p - sendbuf + sizeof (struct ospf6_lsa_header) > oi->ifmtu)
+      if (p - sendbuf + sizeof (struct ospf6_lsa_header)
+          + IPV6_HEADER_SIZE > oi->ifmtu)
          {
            /* if we run out of packet size/space here,
               better to try again soon. */
diff --git a/ospf6d/ospf6_message.h b/ospf6d/ospf6_message.h
index 232b875..6c2219a 100644
--- a/ospf6d/ospf6_message.h
+++ b/ospf6d/ospf6_message.h
@@ -22,6 +22,9 @@
  #ifndef OSPF6_MESSAGE_H
  #define OSPF6_MESSAGE_H

+/* XXX: This assumes no extra headers (e.g. IPsec AH/ESP) */
+#define IPV6_HEADER_SIZE      40U
+
  #define OSPF6_MESSAGE_BUFSIZ  4096

  /* Debug option */
-- 
1.7.3.4





More information about the Quagga-dev mailing list