Author: tuexen
Date: Tue Nov 15 20:41:50 2011
New Revision: 227540
URL: http://svn.freebsd.org/changeset/base/227540

Log:
  Set the MTU of an path to an approriate value if the interface MTU
  can't be determined.
  
  MFC after: 3 days.

Modified:
  head/sys/netinet/sctp_pcb.c

Modified: head/sys/netinet/sctp_pcb.c
==============================================================================
--- head/sys/netinet/sctp_pcb.c Tue Nov 15 20:17:18 2011        (r227539)
+++ head/sys/netinet/sctp_pcb.c Tue Nov 15 20:41:50 2011        (r227540)
@@ -4064,13 +4064,8 @@ sctp_add_remote_addr(struct sctp_tcb *st
                /* Now get the interface MTU */
                if (net->ro._s_addr && net->ro._s_addr->ifn_p) {
                        net->mtu = 
SCTP_GATHER_MTU_FROM_INTFC(net->ro._s_addr->ifn_p);
-               } else {
-                       net->mtu = 0;
                }
-               if (net->mtu == 0) {
-                       /* Huh ?? */
-                       net->mtu = SCTP_DEFAULT_MTU;
-               } else {
+               if (net->mtu > 0) {
                        uint32_t rmtu;
 
                        rmtu = SCTP_GATHER_MTU_FROM_ROUTE(net->ro._s_addr, 
&net->ro._l_addr.sa, net->ro.ro_rt);
@@ -4090,11 +4085,31 @@ sctp_add_remote_addr(struct sctp_tcb *st
                                net->mtu = rmtu;
                        }
                }
-               if (from == SCTP_ALLOC_ASOC) {
-                       stcb->asoc.smallest_mtu = net->mtu;
+       }
+       if (net->mtu == 0) {
+               switch (newaddr->sa_family) {
+#ifdef INET
+               case AF_INET:
+                       net->mtu = SCTP_DEFAULT_MTU;
+                       break;
+#endif
+#ifdef INET6
+               case AF_INET6:
+                       net->mtu = 1280;
+                       break;
+#endif
+               default:
+                       break;
                }
-       } else {
-               net->mtu = stcb->asoc.smallest_mtu;
+       }
+       if (net->port) {
+               net->mtu -= (uint32_t) sizeof(struct udphdr);
+       }
+       if (from == SCTP_ALLOC_ASOC) {
+               stcb->asoc.smallest_mtu = net->mtu;
+       }
+       if (stcb->asoc.smallest_mtu > net->mtu) {
+               stcb->asoc.smallest_mtu = net->mtu;
        }
 #ifdef INET6
        if (newaddr->sa_family == AF_INET6) {
@@ -4104,12 +4119,7 @@ sctp_add_remote_addr(struct sctp_tcb *st
                (void)sa6_recoverscope(sin6);
        }
 #endif
-       if (net->port) {
-               net->mtu -= sizeof(struct udphdr);
-       }
-       if (stcb->asoc.smallest_mtu > net->mtu) {
-               stcb->asoc.smallest_mtu = net->mtu;
-       }
+
        /* JRS - Use the congestion control given in the CC module */
        if (stcb->asoc.cc_functions.sctp_set_initial_cc_param != NULL)
                (*stcb->asoc.cc_functions.sctp_set_initial_cc_param) (stcb, 
net);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to