Send large packets we cannot handle properly via TCP.
authorGuus Sliepen <guus@tinc-vpn.org>
Tue, 15 Sep 2009 21:22:13 +0000 (23:22 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Tue, 15 Sep 2009 21:22:13 +0000 (23:22 +0200)
During the path MTU discovery phase, we might not know the maximum MTU yet, but
we do know a safe minimum.  If we encounter a packet that is larger than that
the minimum, we now send it via TCP instead to ensure it arrives.  We also
allow large packets that we cannot fragment or create ICMP replies for to be
sent via TCP.

src/net_packet.c
src/route.c

index 2be599ebc6d3aa7a969a45d881ad858d22f68b6c..aca84683e5aaa5a500758803bdcaf90ba435ac8e 100644 (file)
@@ -355,9 +355,9 @@ static void send_udppacket(node_t *n, vpn_packet_t *origpkt)
                return;
        }
 
-       if(n->options & OPTION_PMTU_DISCOVERY && !n->minmtu && (inpkt->data[12] | inpkt->data[13])) {
+       if(n->options & OPTION_PMTU_DISCOVERY && inpkt->len > n->minmtu && (inpkt->data[12] | inpkt->data[13])) {
                ifdebug(TRAFFIC) logger(LOG_INFO,
-                               _("No minimum MTU established yet for %s (%s), forwarding via TCP"),
+                               _("Packet for %s (%s) larger than minimum MTU, forwarding via TCP"),
                                n->name, n->hostname);
 
                send_tcppacket(n->nexthop->connection, origpkt);
index d748db163d1999db9a7b938eb93c821d010004a4..9b689039c17250f2a57b2c9c44a37132783f478c 100644 (file)
@@ -769,13 +769,12 @@ static void route_mac(node_t *source, vpn_packet_t *packet)
                        } else {
                                fragment_ipv4_packet(via, packet);
                        }
+                       return;
                } else if(type == ETH_P_IPV6) {
                        packet->len = via->mtu;
                        route_ipv6_unreachable(source, packet, ICMP6_PACKET_TOO_BIG, 0);
-               } else
-                       ifdebug(TRAFFIC) logger(LOG_INFO, _("Large packet of unhandled type %hx dropped"), type);
-
-               return;
+                       return;
+               }
        }
 
        send_packet(subnet->owner, packet);