Introduce kDefaultMaxPacketSizeForTunnels

This CL makes no functional changes, it simply refactors the 1350 MTU to a single constant. We'll then be able to use this constant from Chrome for QUIC connections that carry connect-udp, such as for IP Protection.

PiperOrigin-RevId: 626451281
diff --git a/quiche/quic/core/quic_constants.h b/quiche/quic/core/quic_constants.h
index 5126040..cb81cd4 100644
--- a/quiche/quic/core/quic_constants.h
+++ b/quiche/quic/core/quic_constants.h
@@ -30,6 +30,12 @@
 inline constexpr uint32_t kDefaultNumConnections = 2;
 // Default initial maximum size in bytes of a QUIC packet.
 inline constexpr QuicByteCount kDefaultMaxPacketSize = 1250;
+// Tunnels (such as MASQUE and QBONE) reduce the inner MTU so they work best
+// with a higher outer MTU. This means that outer connections could fail on some
+// networks where the UDP MTU is between 1250 and 1350, but allows inner QUIC
+// connections to still have 1200 bytes of UDP MTU, even if we apply two nested
+// levels of connect-udp proxying, as we do for IP Protection.
+inline constexpr QuicByteCount kDefaultMaxPacketSizeForTunnels = 1350;
 // Default initial maximum size in bytes of a QUIC packet for servers.
 inline constexpr QuicByteCount kDefaultServerMaxPacketSize = 1000;
 // Maximum transmission unit on Ethernet.
diff --git a/quiche/quic/masque/masque_client.cc b/quiche/quic/masque/masque_client.cc
index f55fff6..6eddcf3 100644
--- a/quiche/quic/masque/masque_client.cc
+++ b/quiche/quic/masque/masque_client.cc
@@ -87,7 +87,7 @@
     return nullptr;
   }
 
-  masque_client->set_initial_max_packet_length(kMasqueMaxOuterPacketSize);
+  masque_client->set_initial_max_packet_length(kDefaultMaxPacketSizeForTunnels);
   masque_client->set_drop_response_body(false);
   if (!masque_client->Initialize()) {
     QUIC_LOG(ERROR) << "Failed to initialize masque_client";
diff --git a/quiche/quic/masque/masque_server_session.cc b/quiche/quic/masque/masque_server_session.cc
index 82b9a4d..a413f58 100644
--- a/quiche/quic/masque/masque_server_session.cc
+++ b/quiche/quic/masque/masque_server_session.cc
@@ -138,10 +138,10 @@
       masque_server_backend_(masque_server_backend),
       event_loop_(event_loop),
       masque_mode_(masque_mode) {
-  // Artificially increase the max packet length to 1350 to ensure we can fit
-  // QUIC packets inside DATAGRAM frames.
+  // Artificially increase the max packet length to ensure we can fit QUIC
+  // packets inside DATAGRAM frames.
   // TODO(b/181606597) Remove this workaround once we use PMTUD.
-  connection->SetMaxPacketLength(kMasqueMaxOuterPacketSize);
+  connection->SetMaxPacketLength(kDefaultMaxPacketSizeForTunnels);
 
   masque_server_backend_->RegisterBackendClient(connection_id(), this);
   QUICHE_DCHECK_NE(event_loop_, nullptr);
diff --git a/quiche/quic/masque/masque_utils.h b/quiche/quic/masque/masque_utils.h
index 900e62c..64bedd7 100644
--- a/quiche/quic/masque/masque_utils.h
+++ b/quiche/quic/masque/masque_utils.h
@@ -28,7 +28,6 @@
 // Maximum packet size for encapsulated connections.
 enum : QuicByteCount {
   kMasqueMaxEncapsulatedPacketSize = 1250,
-  kMasqueMaxOuterPacketSize = 1350,
   kMasqueIpPacketBufferSize = 1501,
   // Enough for a VLAN tag, but not Stacked VLANs.
   kMasqueEthernetFrameBufferSize = 1523,