Copilot commented on code in PR #13412:
URL: https://github.com/apache/trafficserver/pull/13412#discussion_r3623554248


##########
src/api/InkAPI.cc:
##########
@@ -4921,6 +4941,21 @@ TSHttpTxnServerPacketMarkSet(TSHttpTxn txnp, int mark)
   return TS_SUCCESS;
 }
 
+TSReturnCode
+TSHttpTxnServerPacketMarkSet(TSHttpTxn txnp, int mark, int mask)
+{
+  sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
+
+  // The current mark lives on the transaction config so the masked update 
composes
+  // correctly even before an origin connection exists.
+  TSMgmtInt current = 0;
+  TSHttpTxnConfigIntGet(txnp, TS_CONFIG_NET_SOCK_PACKET_MARK_OUT, &current);
+  uint32_t new_mark =
+    (static_cast<uint32_t>(current) & ~static_cast<uint32_t>(mask)) | 
(static_cast<uint32_t>(mark) & static_cast<uint32_t>(mask));
+
+  return TSHttpTxnServerPacketMarkSet(txnp, static_cast<int>(new_mark));
+}

Review Comment:
   TSHttpTxnServerPacketMarkSet(txnp, int mark, int mask) computes a uint32_t 
new_mark but then casts it to int to call the two-argument overload. Because 
firewall marks are defined as 32-bit bit patterns, converting uint32_t -> int 
when the high bit is set relies on implementation-defined behavior. Consider 
applying the new_mark directly (using uint32_t for the socket option and 
TSMgmtInt for the recorded txn config) to preserve the exact 32-bit value 
portably.



##########
tests/gold_tests/pluginTest/packet_mark/packet_mark.test.py:
##########
@@ -59,40 +59,46 @@ class PacketMarkTest:
     """Drive a TSHttpTxn*PacketMarkSet API through a test plugin and assert on 
the
     firewall mark read back off the relevant socket.
 
-    This base holds the shared skeleton -- process setup, the common records, 
the
-    curl-and-assert case runner. Each subclass supplies its plugin and echo
-    header and extends _configure() (via super()) with the side-specific mark 
and
-    flag records.
+    This base holds the shared skeleton -- per-run process setup, the common
+    records, and the curl-and-assert case runners. Each subclass supplies its
+    plugin and echo header and extends _configure() (via super()) with the
+    side-specific mark and flag records.
+
+    Every test run gets its own freshly-started origin server and ATS instance,
+    each serving exactly one request. Runs are therefore fully isolated: 
process
+    teardown or a crash in one run cannot disturb any other run.
     """
 
     # Value the plugin sets; the mark is expected to become exactly this.
     SET_MARK = 0x0000000A
     # Seeded starting mark, distinct from SET_MARK so a no-op would be visible.
     SEED_MARK = 0x0000FF00
 
-    # Bumped per instance so each side gets uniquely-numbered processes.
+    # Bumped per created process so each run gets uniquely-numbered processes.
     _counter = 0
 
-    def __init__(self):
-        self._num = PacketMarkTest._counter
-        PacketMarkTest._counter += 1
-        self._server = self._make_server()
-        self._ts = self._make_ats()
-        self._configure(self._ts)
-        self._started = False
+    def __init__(self, seed_mark: int = None):

Review Comment:
   The PacketMarkTest constructor annotates seed_mark as int but defaults it to 
None. Use an Optional type (Python 3.11+: int | None) so the annotation matches 
runtime behavior.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to