This is an automated email from the ASF dual-hosted git repository. cmcfarlen pushed a commit to branch 10.0.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit ddc3e794f1ff6bfb4f61d892d2911bb204dd089c Author: Leif Hedstrom <[email protected]> AuthorDate: Tue Mar 19 14:16:07 2024 -0600 Adds a conn.mark= operation for a connection (#11159) (cherry picked from commit e978a57f103737a6a74deb726f3d82b43a4709a9) --- example/cripts/example1.cc | 1 + include/cripts/Connections.hpp | 44 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/example/cripts/example1.cc b/example/cripts/example1.cc index df8d404dcb..b6d73c2043 100644 --- a/example/cripts/example1.cc +++ b/example/cripts/example1.cc @@ -91,6 +91,7 @@ do_send_response() conn.congestion = "bbr"; conn.dscp = 8; conn.pacing = 100000; + conn.mark = 17; // Some file operations (note that the paths aren't required here, can just be strings, but it's a good practice) static const File::Path p1("/tmp/foo"); diff --git a/include/cripts/Connections.hpp b/include/cripts/Connections.hpp index 7c5624564e..9a5bb183e2 100644 --- a/include/cripts/Connections.hpp +++ b/include/cripts/Connections.hpp @@ -25,7 +25,6 @@ class Context; #include "ts/apidefs.h" #include "ts/ts.h" - #include "cripts/Matcher.hpp" namespace Cript @@ -170,6 +169,33 @@ class ConnBase }; // End class ConnBase::Congestion + class Mark + { + using self_type = Mark; + + public: + friend class ConnBase; + + Mark() = default; + void operator=(const Mark &) = delete; + + // Same here, no API in ATS to Get() the mark on a VC. + operator integer() const { return _val; } + + void + operator=(int val) + { + TSAssert(_owner); + _owner->setMark(val); + _val = val; + } + + private: + ConnBase *_owner = nullptr; + integer _val = -1; + + }; // End class ConnBase::Mark + class Geo { using self_type = Geo; @@ -279,7 +305,7 @@ class ConnBase public: void operator=(const ConnBase &) = delete; - ConnBase() { dscp._owner = congestion._owner = tcpinfo._owner = geo._owner = pacing._owner = this; } + ConnBase() { dscp._owner = congestion._owner = tcpinfo._owner = geo._owner = pacing._owner = mark._owner = this; } [[nodiscard]] virtual int fd() const = 0; // This needs the txnp from the Context @@ -311,11 +337,13 @@ public: [[nodiscard]] virtual int count() const = 0; virtual void setDscp(int val) = 0; + virtual void setMark(int val) = 0; Dscp dscp; Congestion congestion; TcpInfo tcpinfo; Geo geo; Pacing pacing; + Mark mark; Cript::string_view string(unsigned ipv4_cidr = 32, unsigned ipv6_cidr = 128); @@ -350,6 +378,12 @@ public: TSHttpTxnClientPacketDscpSet(_state->txnp, val); } + void + setMark(int val) override + { + TSHttpTxnClientPacketMarkSet(_state->txnp, val); + } + }; // End class Client::Connection } // namespace Client @@ -376,6 +410,12 @@ public: TSHttpTxnServerPacketDscpSet(_state->txnp, val); } + void + setMark(int val) override + { + TSHttpTxnServerPacketMarkSet(_state->txnp, val); + } + }; // End class Server::Connection } // namespace Server
