Update ECN tests to function properly in Guitar.

cl/695874210, while deprecating the previous flag protection for send-side ECN, identified a particular block of code as relatively high-risk and so protected it with flag quic_preserve_dscp_with_ecn. Unfortunately, the code that executes when this flag is false does not correctly set the ECN bits when a test is running on Guitar (which uses GOOGLE_IP_TOS), causing failures.

This CL deletes the flag, and protects the entire code block by only executing it when packet_info.ecn_codepoint is not NOT_ECT (which never happens in production today).

Tests now pass in Guitar.

PiperOrigin-RevId: 696290469
diff --git a/quiche/common/quiche_feature_flags_list.h b/quiche/common/quiche_feature_flags_list.h
index fab0f08..09bf653 100755
--- a/quiche/common/quiche_feature_flags_list.h
+++ b/quiche/common/quiche_feature_flags_list.h
@@ -55,7 +55,6 @@
 QUICHE_FLAG(bool, quiche_reloadable_flag_quic_update_transmission_info_on_frame_acked, false, true, "If true, QuicUnackedPacketMap will update transmission info after session_notifier_->OnFrameAcked.")
 QUICHE_FLAG(bool, quiche_reloadable_flag_quic_use_alarm_multiplexer, false, false, "Manages all of the connection alarms via QuicAlarmMultiplexer.")
 QUICHE_FLAG(bool, quiche_reloadable_flag_quic_use_received_client_addresses_cache, true, true, "If true, use a LRU cache to record client addresses of packets received on server's original address.")
-QUICHE_FLAG(bool, quiche_restart_flag_quic_preserve_dscp_with_ecn, false, false, "When true, preserves the existing DSCP setting when setting ECN.")
 QUICHE_FLAG(bool, quiche_restart_flag_quic_support_flow_label2, false, false, "If true, QUIC will support reading and writing IPv6 flow labels.")
 QUICHE_FLAG(bool, quiche_restart_flag_quic_support_release_time_for_gso, false, false, "If true, QuicGsoBatchWriter will support release time if it is available and the process has the permission to do so.")
 QUICHE_FLAG(bool, quiche_restart_flag_quic_testonly_default_false, false, false, "A testonly restart flag that will always default to false.")
diff --git a/quiche/quic/core/quic_udp_socket_posix.inc b/quiche/quic/core/quic_udp_socket_posix.inc
index cbcfbbd..c368f2b 100644
--- a/quiche/quic/core/quic_udp_socket_posix.inc
+++ b/quiche/quic/core/quic_udp_socket_posix.inc
@@ -12,7 +12,7 @@
 
 #include "absl/base/optimization.h"
 #include "quiche/quic/core/flow_label.h"
-#include "quiche/quic/core/io/socket.h"
+#include "quiche/quic/core/quic_types.h"
 #include "quiche/quic/core/quic_udp_socket.h"
 #include "quiche/quic/platform/api/quic_bug_tracker.h"
 #include "quiche/quic/platform/api/quic_flag_utils.h"
@@ -564,29 +564,20 @@
 
   // TODO(b/270584616): This code block might go away when full support for
   // marking ECN is implemented.
-  if (packet_info.HasValue(QuicUdpPacketInfoBit::ECN)) {
+  if (packet_info.HasValue(QuicUdpPacketInfoBit::ECN) &&
+      packet_info.ecn_codepoint() != ECN_NOT_ECT) {
     int cmsg_level =
         packet_info.peer_address().host().IsIPv4() ? IPPROTO_IP : IPPROTO_IPV6;
     int cmsg_type;
     unsigned char value_buf[20];
     socklen_t value_len = sizeof(value_buf);
-    if (GetQuicRestartFlag(quic_preserve_dscp_with_ecn)) {
-      QUIC_RESTART_FLAG_COUNT_N(quic_preserve_dscp_with_ecn, 1, 2);
-      if (GetEcnCmsgArgsPreserveDscp(
-              fd, packet_info.peer_address().host().address_family(),
-              packet_info.ecn_codepoint(), cmsg_type, value_buf,
-              value_len) != 0) {
-        QUIC_LOG_FIRST_N(ERROR, 100)
-            << "Could not get ECN msg type for this platform.";
-        return WriteResult(WRITE_STATUS_ERROR, EINVAL);
-      }
-    } else {
-      // Only some writers set QuicUdpPacketInfoBit::ECN, so verify that this
-      // is being exercised.
-      QUIC_RESTART_FLAG_COUNT_N(quic_preserve_dscp_with_ecn, 2, 2);
-      cmsg_type = (cmsg_level == IPPROTO_IP) ? IP_TOS : IPV6_TCLASS;
-      *(int*)value_buf = static_cast<int>(packet_info.ecn_codepoint());
-      value_len = sizeof(int);
+    if (GetEcnCmsgArgsPreserveDscp(
+            fd, packet_info.peer_address().host().address_family(),
+            packet_info.ecn_codepoint(), cmsg_type, value_buf,
+            value_len) != 0) {
+      QUIC_LOG_FIRST_N(ERROR, 100)
+          << "Could not get ECN msg type for this platform.";
+      return WriteResult(WRITE_STATUS_ERROR, EINVAL);
     }
     if (!NextCmsg(&hdr, control_buffer, sizeof(control_buffer), cmsg_level,
                   cmsg_type, value_len, &cmsg)) {