Skip to content

Commit c458bce

Browse files
committed
add field/setters to conn tracker
Signed-off-by: Benjamin Kilimnik <bkilimnik@pixielabs.ai>
1 parent f862137 commit c458bce

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/stirling/source_connectors/socket_tracer/conn_tracker.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ struct SocketOpen {
6868
uint64_t timestamp_ns = 0;
6969
// TODO(yzhao): Consider using std::optional to indicate the address has not been initialized.
7070
SockAddr remote_addr;
71+
SockAddr local_addr;
7172
};
7273

7374
struct SocketClose {
@@ -336,6 +337,11 @@ class ConnTracker : NotCopyMoveable {
336337
*/
337338
const SockAddr& remote_endpoint() const { return open_info_.remote_addr; }
338339

340+
/**
341+
* Get local IP endpoint of the connection.
342+
*/
343+
const SockAddr& local_endpoint() const { return open_info_.local_addr; }
344+
339345
/**
340346
* Get the connection information (e.g. remote IP, port, PID, etc.) for this connection.
341347
*/
@@ -577,6 +583,7 @@ class ConnTracker : NotCopyMoveable {
577583
void SetConnID(struct conn_id_t conn_id);
578584

579585
void SetRemoteAddr(const union sockaddr_t addr, std::string_view reason);
586+
void SetLocalAddr(const union sockaddr_t addr, std::string_view reason);
580587

581588
// Returns false if the protocol change is disallowed.
582589
bool SetProtocol(traffic_protocol_t protocol, std::string_view reason);
@@ -799,6 +806,8 @@ std::string DebugString(const ConnTracker& c, std::string_view prefix) {
799806
info += absl::Substitute("state=$0\n", magic_enum::enum_name(c.state()));
800807
info += absl::Substitute("$0remote_addr=$1:$2\n", prefix, c.remote_endpoint().AddrStr(),
801808
c.remote_endpoint().port());
809+
info += absl::Substitute("$0remote_addr=$1:$2\n", prefix, c.local_endpoint().AddrStr(),
810+
c.local_endpoint().port());
802811
info += absl::Substitute("$0protocol=$1\n", prefix, magic_enum::enum_name(c.protocol()));
803812
if constexpr (std::is_same_v<TFrameType, protocols::http2::Stream>) {
804813
info += c.http2_client_streams_.DebugString(absl::StrCat(prefix, " "));

0 commit comments

Comments
 (0)