trace_processor: support inet_sock_set_state event
The inet_sock_set_state ftrace event could be used to track sock state
change. The patch parses the inet_sock_set_state event and show the TCP
state on async task tracker.
Bug: 215086208
Test: ui/run-dev-server & manaul check the UI behavior
Test: tools/diff_test_trace_processor.py <trace_processor_shell> \
--query-metric-filter='inet_sock_set_state'
Change-Id: Iad0eae017cc3b4045cee4273c4ccc090c6b25278
diff --git a/Android.bp b/Android.bp
index aa12cd1..e689749 100644
--- a/Android.bp
+++ b/Android.bp
@@ -4173,6 +4173,7 @@
"protos/perfetto/trace/ftrace/scm.proto",
"protos/perfetto/trace/ftrace/sde.proto",
"protos/perfetto/trace/ftrace/signal.proto",
+ "protos/perfetto/trace/ftrace/sock.proto",
"protos/perfetto/trace/ftrace/sync.proto",
"protos/perfetto/trace/ftrace/synthetic.proto",
"protos/perfetto/trace/ftrace/systrace.proto",
@@ -4392,6 +4393,7 @@
"protos/perfetto/trace/ftrace/scm.proto",
"protos/perfetto/trace/ftrace/sde.proto",
"protos/perfetto/trace/ftrace/signal.proto",
+ "protos/perfetto/trace/ftrace/sock.proto",
"protos/perfetto/trace/ftrace/sync.proto",
"protos/perfetto/trace/ftrace/synthetic.proto",
"protos/perfetto/trace/ftrace/systrace.proto",
@@ -4445,6 +4447,7 @@
"external/perfetto/protos/perfetto/trace/ftrace/scm.gen.cc",
"external/perfetto/protos/perfetto/trace/ftrace/sde.gen.cc",
"external/perfetto/protos/perfetto/trace/ftrace/signal.gen.cc",
+ "external/perfetto/protos/perfetto/trace/ftrace/sock.gen.cc",
"external/perfetto/protos/perfetto/trace/ftrace/sync.gen.cc",
"external/perfetto/protos/perfetto/trace/ftrace/synthetic.gen.cc",
"external/perfetto/protos/perfetto/trace/ftrace/systrace.gen.cc",
@@ -4498,6 +4501,7 @@
"protos/perfetto/trace/ftrace/scm.proto",
"protos/perfetto/trace/ftrace/sde.proto",
"protos/perfetto/trace/ftrace/signal.proto",
+ "protos/perfetto/trace/ftrace/sock.proto",
"protos/perfetto/trace/ftrace/sync.proto",
"protos/perfetto/trace/ftrace/synthetic.proto",
"protos/perfetto/trace/ftrace/systrace.proto",
@@ -4551,6 +4555,7 @@
"external/perfetto/protos/perfetto/trace/ftrace/scm.gen.h",
"external/perfetto/protos/perfetto/trace/ftrace/sde.gen.h",
"external/perfetto/protos/perfetto/trace/ftrace/signal.gen.h",
+ "external/perfetto/protos/perfetto/trace/ftrace/sock.gen.h",
"external/perfetto/protos/perfetto/trace/ftrace/sync.gen.h",
"external/perfetto/protos/perfetto/trace/ftrace/synthetic.gen.h",
"external/perfetto/protos/perfetto/trace/ftrace/systrace.gen.h",
@@ -4608,6 +4613,7 @@
"protos/perfetto/trace/ftrace/scm.proto",
"protos/perfetto/trace/ftrace/sde.proto",
"protos/perfetto/trace/ftrace/signal.proto",
+ "protos/perfetto/trace/ftrace/sock.proto",
"protos/perfetto/trace/ftrace/sync.proto",
"protos/perfetto/trace/ftrace/synthetic.proto",
"protos/perfetto/trace/ftrace/systrace.proto",
@@ -4660,6 +4666,7 @@
"external/perfetto/protos/perfetto/trace/ftrace/scm.pb.cc",
"external/perfetto/protos/perfetto/trace/ftrace/sde.pb.cc",
"external/perfetto/protos/perfetto/trace/ftrace/signal.pb.cc",
+ "external/perfetto/protos/perfetto/trace/ftrace/sock.pb.cc",
"external/perfetto/protos/perfetto/trace/ftrace/sync.pb.cc",
"external/perfetto/protos/perfetto/trace/ftrace/synthetic.pb.cc",
"external/perfetto/protos/perfetto/trace/ftrace/systrace.pb.cc",
@@ -4713,6 +4720,7 @@
"protos/perfetto/trace/ftrace/scm.proto",
"protos/perfetto/trace/ftrace/sde.proto",
"protos/perfetto/trace/ftrace/signal.proto",
+ "protos/perfetto/trace/ftrace/sock.proto",
"protos/perfetto/trace/ftrace/sync.proto",
"protos/perfetto/trace/ftrace/synthetic.proto",
"protos/perfetto/trace/ftrace/systrace.proto",
@@ -4765,6 +4773,7 @@
"external/perfetto/protos/perfetto/trace/ftrace/scm.pb.h",
"external/perfetto/protos/perfetto/trace/ftrace/sde.pb.h",
"external/perfetto/protos/perfetto/trace/ftrace/signal.pb.h",
+ "external/perfetto/protos/perfetto/trace/ftrace/sock.pb.h",
"external/perfetto/protos/perfetto/trace/ftrace/sync.pb.h",
"external/perfetto/protos/perfetto/trace/ftrace/synthetic.pb.h",
"external/perfetto/protos/perfetto/trace/ftrace/systrace.pb.h",
@@ -4822,6 +4831,7 @@
"protos/perfetto/trace/ftrace/scm.proto",
"protos/perfetto/trace/ftrace/sde.proto",
"protos/perfetto/trace/ftrace/signal.proto",
+ "protos/perfetto/trace/ftrace/sock.proto",
"protos/perfetto/trace/ftrace/sync.proto",
"protos/perfetto/trace/ftrace/synthetic.proto",
"protos/perfetto/trace/ftrace/systrace.proto",
@@ -4875,6 +4885,7 @@
"external/perfetto/protos/perfetto/trace/ftrace/scm.pbzero.cc",
"external/perfetto/protos/perfetto/trace/ftrace/sde.pbzero.cc",
"external/perfetto/protos/perfetto/trace/ftrace/signal.pbzero.cc",
+ "external/perfetto/protos/perfetto/trace/ftrace/sock.pbzero.cc",
"external/perfetto/protos/perfetto/trace/ftrace/sync.pbzero.cc",
"external/perfetto/protos/perfetto/trace/ftrace/synthetic.pbzero.cc",
"external/perfetto/protos/perfetto/trace/ftrace/systrace.pbzero.cc",
@@ -4928,6 +4939,7 @@
"protos/perfetto/trace/ftrace/scm.proto",
"protos/perfetto/trace/ftrace/sde.proto",
"protos/perfetto/trace/ftrace/signal.proto",
+ "protos/perfetto/trace/ftrace/sock.proto",
"protos/perfetto/trace/ftrace/sync.proto",
"protos/perfetto/trace/ftrace/synthetic.proto",
"protos/perfetto/trace/ftrace/systrace.proto",
@@ -4981,6 +4993,7 @@
"external/perfetto/protos/perfetto/trace/ftrace/scm.pbzero.h",
"external/perfetto/protos/perfetto/trace/ftrace/sde.pbzero.h",
"external/perfetto/protos/perfetto/trace/ftrace/signal.pbzero.h",
+ "external/perfetto/protos/perfetto/trace/ftrace/sock.pbzero.h",
"external/perfetto/protos/perfetto/trace/ftrace/sync.pbzero.h",
"external/perfetto/protos/perfetto/trace/ftrace/synthetic.pbzero.h",
"external/perfetto/protos/perfetto/trace/ftrace/systrace.pbzero.h",
diff --git a/BUILD b/BUILD
index 5b4d5cb..4256c0b 100644
--- a/BUILD
+++ b/BUILD
@@ -1263,6 +1263,7 @@
"src/trace_processor/types/softirq_action.h",
"src/trace_processor/types/task_state.cc",
"src/trace_processor/types/task_state.h",
+ "src/trace_processor/types/tcp_state.h",
"src/trace_processor/types/trace_processor_context.h",
"src/trace_processor/types/variadic.cc",
"src/trace_processor/types/variadic.h",
@@ -2878,6 +2879,7 @@
"protos/perfetto/trace/ftrace/scm.proto",
"protos/perfetto/trace/ftrace/sde.proto",
"protos/perfetto/trace/ftrace/signal.proto",
+ "protos/perfetto/trace/ftrace/sock.proto",
"protos/perfetto/trace/ftrace/sync.proto",
"protos/perfetto/trace/ftrace/synthetic.proto",
"protos/perfetto/trace/ftrace/systrace.proto",
diff --git a/protos/perfetto/trace/ftrace/all_protos.gni b/protos/perfetto/trace/ftrace/all_protos.gni
index 55655f8..8c2ed1f 100644
--- a/protos/perfetto/trace/ftrace/all_protos.gni
+++ b/protos/perfetto/trace/ftrace/all_protos.gni
@@ -54,6 +54,7 @@
"scm.proto",
"sde.proto",
"signal.proto",
+ "sock.proto",
"sync.proto",
"synthetic.proto",
"systrace.proto",
diff --git a/protos/perfetto/trace/ftrace/ftrace_event.proto b/protos/perfetto/trace/ftrace/ftrace_event.proto
index dd718ef..0338cb6 100644
--- a/protos/perfetto/trace/ftrace/ftrace_event.proto
+++ b/protos/perfetto/trace/ftrace/ftrace_event.proto
@@ -54,6 +54,7 @@
import "protos/perfetto/trace/ftrace/scm.proto";
import "protos/perfetto/trace/ftrace/sde.proto";
import "protos/perfetto/trace/ftrace/signal.proto";
+import "protos/perfetto/trace/ftrace/sock.proto";
import "protos/perfetto/trace/ftrace/sync.proto";
import "protos/perfetto/trace/ftrace/synthetic.proto";
import "protos/perfetto/trace/ftrace/systrace.proto";
@@ -452,5 +453,6 @@
RssStatThrottledFtraceEvent rss_stat_throttled = 359;
NetifReceiveSkbFtraceEvent netif_receive_skb = 360;
NetDevXmitFtraceEvent net_dev_xmit = 361;
+ InetSockSetStateFtraceEvent inet_sock_set_state = 362;
}
}
diff --git a/protos/perfetto/trace/ftrace/sock.proto b/protos/perfetto/trace/ftrace/sock.proto
new file mode 100644
index 0000000..9607117
--- /dev/null
+++ b/protos/perfetto/trace/ftrace/sock.proto
@@ -0,0 +1,18 @@
+// Autogenerated by:
+// ../../tools/ftrace_proto_gen/ftrace_proto_gen.cc
+// Do not edit.
+
+syntax = "proto2";
+package perfetto.protos;
+
+message InetSockSetStateFtraceEvent {
+ optional uint32 daddr = 1;
+ optional uint32 dport = 2;
+ optional uint32 family = 3;
+ optional int32 newstate = 4;
+ optional int32 oldstate = 5;
+ optional uint32 protocol = 6;
+ optional uint32 saddr = 7;
+ optional uint64 skaddr = 8;
+ optional uint32 sport = 9;
+}
diff --git a/protos/perfetto/trace/perfetto_trace.proto b/protos/perfetto/trace/perfetto_trace.proto
index bfee00c..3a91f1f 100644
--- a/protos/perfetto/trace/perfetto_trace.proto
+++ b/protos/perfetto/trace/perfetto_trace.proto
@@ -5258,6 +5258,22 @@
// End of protos/perfetto/trace/ftrace/signal.proto
+// Begin of protos/perfetto/trace/ftrace/sock.proto
+
+message InetSockSetStateFtraceEvent {
+ optional uint32 daddr = 1;
+ optional uint32 dport = 2;
+ optional uint32 family = 3;
+ optional int32 newstate = 4;
+ optional int32 oldstate = 5;
+ optional uint32 protocol = 6;
+ optional uint32 saddr = 7;
+ optional uint64 skaddr = 8;
+ optional uint32 sport = 9;
+}
+
+// End of protos/perfetto/trace/ftrace/sock.proto
+
// Begin of protos/perfetto/trace/ftrace/sync.proto
message SyncPtFtraceEvent {
@@ -5761,6 +5777,7 @@
RssStatThrottledFtraceEvent rss_stat_throttled = 359;
NetifReceiveSkbFtraceEvent netif_receive_skb = 360;
NetDevXmitFtraceEvent net_dev_xmit = 361;
+ InetSockSetStateFtraceEvent inet_sock_set_state = 362;
}
}
diff --git a/src/trace_processor/importers/ftrace/ftrace_descriptors.cc b/src/trace_processor/importers/ftrace/ftrace_descriptors.cc
index bf50559..3158248 100644
--- a/src/trace_processor/importers/ftrace/ftrace_descriptors.cc
+++ b/src/trace_processor/importers/ftrace/ftrace_descriptors.cc
@@ -24,7 +24,7 @@
namespace trace_processor {
namespace {
-std::array<MessageDescriptor, 362> descriptors{{
+std::array<MessageDescriptor, 363> descriptors{{
{nullptr, 0, {}},
{nullptr, 0, {}},
{nullptr, 0, {}},
@@ -3875,6 +3875,22 @@
{"skbaddr", ProtoSchemaType::kUint64},
},
},
+ {
+ "inet_sock_set_state",
+ 9,
+ {
+ {},
+ {"daddr", ProtoSchemaType::kUint32},
+ {"dport", ProtoSchemaType::kUint32},
+ {"family", ProtoSchemaType::kUint32},
+ {"newstate", ProtoSchemaType::kInt32},
+ {"oldstate", ProtoSchemaType::kInt32},
+ {"protocol", ProtoSchemaType::kUint32},
+ {"saddr", ProtoSchemaType::kUint32},
+ {"skaddr", ProtoSchemaType::kUint64},
+ {"sport", ProtoSchemaType::kUint32},
+ },
+ },
}};
} // namespace
diff --git a/src/trace_processor/importers/ftrace/ftrace_parser.cc b/src/trace_processor/importers/ftrace/ftrace_parser.cc
index 186b541..03b6e36 100644
--- a/src/trace_processor/importers/ftrace/ftrace_parser.cc
+++ b/src/trace_processor/importers/ftrace/ftrace_parser.cc
@@ -27,6 +27,7 @@
#include "src/trace_processor/storage/stats.h"
#include "src/trace_processor/storage/trace_storage.h"
#include "src/trace_processor/types/softirq_action.h"
+#include "src/trace_processor/types/tcp_state.h"
#include "protos/perfetto/common/gpu_counter_descriptor.pbzero.h"
#include "protos/perfetto/trace/ftrace/binder.pbzero.h"
@@ -54,6 +55,7 @@
#include "protos/perfetto/trace/ftrace/scm.pbzero.h"
#include "protos/perfetto/trace/ftrace/sde.pbzero.h"
#include "protos/perfetto/trace/ftrace/signal.pbzero.h"
+#include "protos/perfetto/trace/ftrace/sock.pbzero.h"
#include "protos/perfetto/trace/ftrace/systrace.pbzero.h"
#include "protos/perfetto/trace/ftrace/task.pbzero.h"
#include "protos/perfetto/trace/ftrace/thermal.pbzero.h"
@@ -126,6 +128,7 @@
oom_kill_id_(context_->storage->InternString("mem.oom_kill")),
workqueue_id_(context_->storage->InternString("workqueue")),
irq_id_(context_->storage->InternString("irq")),
+ tcp_state_id_(context_->storage->InternString("tcp_state")),
ret_arg_id_(context_->storage->InternString("ret")),
direct_reclaim_nr_reclaimed_id_(
context->storage->InternString("direct_reclaim_nr_reclaimed")),
@@ -650,6 +653,10 @@
ParseNetDevXmit(cpu, ts, data);
break;
}
+ case FtraceEvent::kInetSockSetStateFieldNumber: {
+ ParseInetSockSetState(ts, pid, data);
+ break;
+ }
default:
break;
}
@@ -1710,5 +1717,65 @@
.AddArg(len_key, Variadic::UnsignedInteger(evt.len()));
}
+void FtraceParser::ParseInetSockSetState(int64_t timestamp,
+ uint32_t pid,
+ protozero::ConstBytes blob) {
+ protos::pbzero::InetSockSetStateFtraceEvent::Decoder evt(blob.data,
+ blob.size);
+
+ // Skip non TCP protocol.
+ if (evt.protocol() != kIpprotoTcp) {
+ PERFETTO_ELOG("skip non tcp protocol");
+ return;
+ }
+
+ // Skip non IP protocol.
+ if (evt.family() != kAfNet && evt.family() != kAfNet6) {
+ PERFETTO_ELOG("skip non IP protocol");
+ return;
+ }
+
+ // Skip invalid TCP state.
+ if (evt.newstate() >= TCP_MAX_STATES || evt.oldstate() >= TCP_MAX_STATES) {
+ PERFETTO_ELOG("skip invalid tcp state");
+ return;
+ }
+
+ auto got = skaddr_to_stream_.find(evt.skaddr());
+ if (got == skaddr_to_stream_.end()) {
+ skaddr_to_stream_[evt.skaddr()] = ++num_of_tcp_stream_;
+ }
+ uint32_t stream = skaddr_to_stream_[evt.skaddr()];
+ char stream_str[64];
+ sprintf(stream_str, "TCP stream#%" PRIu32 "", stream);
+ StringId stream_id = context_->storage->InternString(stream_str);
+
+ StringId slice_name_id;
+ if (evt.newstate() == TCP_SYN_SENT) {
+ base::StackString<32> str("%s(pid=%" PRIu32 ")",
+ kTcpStateNames[evt.newstate()], pid);
+ slice_name_id = context_->storage->InternString(str.string_view());
+ } else if (evt.newstate() == TCP_ESTABLISHED) {
+ base::StackString<64> str("%s(sport=%" PRIu32 ",dport=%" PRIu32 ")",
+ kTcpStateNames[evt.newstate()], evt.sport(),
+ evt.dport());
+ slice_name_id = context_->storage->InternString(str.string_view());
+ } else {
+ base::StringView slice_name = kTcpStateNames[evt.newstate()];
+ slice_name_id = context_->storage->InternString(slice_name);
+ }
+
+ // Push to async task set tracker.
+ auto async_track =
+ context_->async_track_set_tracker->InternGlobalTrackSet(stream_id);
+ TrackId end_id = context_->async_track_set_tracker->End(
+ async_track, static_cast<int64_t>(evt.skaddr()));
+ context_->slice_tracker->End(timestamp, end_id);
+ TrackId start_id = context_->async_track_set_tracker->Begin(
+ async_track, static_cast<int64_t>(evt.skaddr()));
+ context_->slice_tracker->Begin(timestamp, start_id, tcp_state_id_,
+ slice_name_id);
+}
+
} // namespace trace_processor
} // namespace perfetto
diff --git a/src/trace_processor/importers/ftrace/ftrace_parser.h b/src/trace_processor/importers/ftrace/ftrace_parser.h
index c9ae2c5..fc39cf4 100644
--- a/src/trace_processor/importers/ftrace/ftrace_parser.h
+++ b/src/trace_processor/importers/ftrace/ftrace_parser.h
@@ -156,6 +156,9 @@
int64_t timestamp,
protozero::ConstBytes);
void ParseNetDevXmit(uint32_t cpu, int64_t timestamp, protozero::ConstBytes);
+ void ParseInetSockSetState(int64_t timestamp,
+ uint32_t pid,
+ protozero::ConstBytes);
TraceProcessorContext* context_;
RssStatTracker rss_stat_tracker_;
@@ -182,6 +185,7 @@
const StringId oom_kill_id_;
const StringId workqueue_id_;
const StringId irq_id_;
+ const StringId tcp_state_id_;
const StringId ret_arg_id_;
const StringId direct_reclaim_nr_reclaimed_id_;
const StringId direct_reclaim_order_id_;
@@ -228,6 +232,12 @@
// Record number of transmitted bytes to the network interface card.
std::unordered_map<StringId, uint64_t> nic_transmitted_bytes_;
+ // Keep sock to stream number mapping.
+ std::unordered_map<uint64_t, uint32_t> skaddr_to_stream_;
+
+ // Record number of tcp steams.
+ uint32_t num_of_tcp_stream_ = 0;
+
bool has_seen_first_ftrace_packet_ = false;
// Stores information about the timestamp from the metadata table which is
diff --git a/src/trace_processor/types/BUILD.gn b/src/trace_processor/types/BUILD.gn
index 46d16b9..ba26e24 100644
--- a/src/trace_processor/types/BUILD.gn
+++ b/src/trace_processor/types/BUILD.gn
@@ -21,6 +21,7 @@
"softirq_action.h",
"task_state.cc",
"task_state.h",
+ "tcp_state.h",
"trace_processor_context.h",
"variadic.cc",
"variadic.h",
diff --git a/src/trace_processor/types/tcp_state.h b/src/trace_processor/types/tcp_state.h
new file mode 100644
index 0000000..1db06de
--- /dev/null
+++ b/src/trace_processor/types/tcp_state.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SRC_TRACE_PROCESSOR_TYPES_TCP_STATE_H_
+#define SRC_TRACE_PROCESSOR_TYPES_TCP_STATE_H_
+
+namespace perfetto {
+namespace trace_processor {
+
+// IPV4 protocol
+constexpr int kAfNet = 2;
+// IPV6 protocol
+constexpr int kAfNet6 = 10;
+// TCP protocol
+constexpr int kIpprotoTcp = 6;
+// TCP protocol states, from include/net/tcp_states.h.
+enum {
+ TCP_ESTABLISHED = 1,
+ TCP_SYN_SENT,
+ TCP_SYN_RECV,
+ TCP_FIN_WAIT1,
+ TCP_FIN_WAIT2,
+ TCP_TIME_WAIT,
+ TCP_CLOSE,
+ TCP_CLOSE_WAIT,
+ TCP_LAST_ACK,
+ TCP_LISTEN,
+ TCP_CLOSING,
+ TCP_NEW_SYN_RECV,
+ TCP_MAX_STATES
+};
+// TCP protocol state to string mapping.
+static constexpr const char* const kTcpStateNames[] = {
+ "TCP_UNKNOWN", "TCP_ESTABLISHED", "TCP_SYN_SENT", "TCP_SYN_RECV",
+ "TCP_FIN_WAIT1", "TCP_FIN_WAIT2","TCP_TIME_WAIT", "TCP_CLOSE",
+ "TCP_CLOSE_WAIT","TCP_LAST_ACK", "TCP_LISTEN", "TCP_CLOSING",
+ "TCP_NEW_SYN_RECV","TCP_MAX_STATES"};
+
+} // namespace trace_processor
+} // namespace perfetto
+
+#endif // SRC_TRACE_PROCESSOR_TYPES_TCP_STATE_H_
diff --git a/src/traced/probes/ftrace/event_info.cc b/src/traced/probes/ftrace/event_info.cc
index 6234363..0a40e9a 100644
--- a/src/traced/probes/ftrace/event_info.cc
+++ b/src/traced/probes/ftrace/event_info.cc
@@ -6450,6 +6450,40 @@
kUnsetFtraceId,
325,
kUnsetSize},
+ {"inet_sock_set_state",
+ "sock",
+ {
+ {kUnsetOffset, kUnsetSize, FtraceFieldType::kInvalidFtraceFieldType,
+ "daddr", 1, ProtoSchemaType::kUint32,
+ TranslationStrategy::kInvalidTranslationStrategy},
+ {kUnsetOffset, kUnsetSize, FtraceFieldType::kInvalidFtraceFieldType,
+ "dport", 2, ProtoSchemaType::kUint32,
+ TranslationStrategy::kInvalidTranslationStrategy},
+ {kUnsetOffset, kUnsetSize, FtraceFieldType::kInvalidFtraceFieldType,
+ "family", 3, ProtoSchemaType::kUint32,
+ TranslationStrategy::kInvalidTranslationStrategy},
+ {kUnsetOffset, kUnsetSize, FtraceFieldType::kInvalidFtraceFieldType,
+ "newstate", 4, ProtoSchemaType::kInt32,
+ TranslationStrategy::kInvalidTranslationStrategy},
+ {kUnsetOffset, kUnsetSize, FtraceFieldType::kInvalidFtraceFieldType,
+ "oldstate", 5, ProtoSchemaType::kInt32,
+ TranslationStrategy::kInvalidTranslationStrategy},
+ {kUnsetOffset, kUnsetSize, FtraceFieldType::kInvalidFtraceFieldType,
+ "protocol", 6, ProtoSchemaType::kUint32,
+ TranslationStrategy::kInvalidTranslationStrategy},
+ {kUnsetOffset, kUnsetSize, FtraceFieldType::kInvalidFtraceFieldType,
+ "saddr", 7, ProtoSchemaType::kUint32,
+ TranslationStrategy::kInvalidTranslationStrategy},
+ {kUnsetOffset, kUnsetSize, FtraceFieldType::kInvalidFtraceFieldType,
+ "skaddr", 8, ProtoSchemaType::kUint64,
+ TranslationStrategy::kInvalidTranslationStrategy},
+ {kUnsetOffset, kUnsetSize, FtraceFieldType::kInvalidFtraceFieldType,
+ "sport", 9, ProtoSchemaType::kUint32,
+ TranslationStrategy::kInvalidTranslationStrategy},
+ },
+ kUnsetFtraceId,
+ 362,
+ kUnsetSize},
{"sync_pt",
"sync",
{
diff --git a/src/traced/probes/ftrace/test/data/synthetic/events/sock/inet_sock_set_state/format b/src/traced/probes/ftrace/test/data/synthetic/events/sock/inet_sock_set_state/format
new file mode 100644
index 0000000..d7c36c7
--- /dev/null
+++ b/src/traced/probes/ftrace/test/data/synthetic/events/sock/inet_sock_set_state/format
@@ -0,0 +1,21 @@
+name: inet_sock_set_state
+ID: 924
+format:
+ field:unsigned short common_type; offset:0; size:2; signed:0;
+ field:unsigned char common_flags; offset:2; size:1; signed:0;
+ field:unsigned char common_preempt_count; offset:3; size:1; signed:0;
+ field:int common_pid; offset:4; size:4; signed:1;
+
+ field:const void * skaddr; offset:8; size:8; signed:0;
+ field:int oldstate; offset:16; size:4; signed:1;
+ field:int newstate; offset:20; size:4; signed:1;
+ field:__u16 sport; offset:24; size:2; signed:0;
+ field:__u16 dport; offset:26; size:2; signed:0;
+ field:__u16 family; offset:28; size:2; signed:0;
+ field:__u16 protocol; offset:30; size:2; signed:0;
+ field:__u8 saddr[4]; offset:32; size:4; signed:0;
+ field:__u8 daddr[4]; offset:36; size:4; signed:0;
+ field:__u8 saddr_v6[16]; offset:40; size:16; signed:0;
+ field:__u8 daddr_v6[16]; offset:56; size:16; signed:0;
+
+print fmt: "family=%s protocol=%s sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c oldstate=%s newstate=%s", __print_symbolic(REC->family, { 2, "AF_INET" }, { 10, "AF_INET6" }), __print_symbolic(REC->protocol, { 6, "IPPROTO_TCP" }, { 33, "IPPROTO_DCCP" }, { 132, "IPPROTO_SCTP" }, { 262, "IPPROTO_MPTCP" }), REC->sport, REC->dport, REC->saddr, REC->daddr, REC->saddr_v6, REC->daddr_v6, __print_symbolic(REC->oldstate, { 1, "TCP_ESTABLISHED" }, { 2, "TCP_SYN_SENT" }, { 3, "TCP_SYN_RECV" }, { 4, "TCP_FIN_WAIT1" }, { 5, "TCP_FIN_WAIT2" }, { 6, "TCP_TIME_WAIT" }, { 7, "TCP_CLOSE" }, { 8, "TCP_CLOSE_WAIT" }, { 9, "TCP_LAST_ACK" }, { 10, "TCP_LISTEN" }, { 11, "TCP_CLOSING" }, { 12, "TCP_NEW_SYN_RECV" }), __print_symbolic(REC->newstate, { 1, "TCP_ESTABLISHED" }, { 2, "TCP_SYN_SENT" }, { 3, "TCP_SYN_RECV" }, { 4, "TCP_FIN_WAIT1" }, { 5, "TCP_FIN_WAIT2" }, { 6, "TCP_TIME_WAIT" }, { 7, "TCP_CLOSE" }, { 8, "TCP_CLOSE_WAIT" }, { 9, "TCP_LAST_ACK" }, { 10, "TCP_LISTEN" }, { 11, "TCP_CLOSING" }, { 12, "TCP_NEW_SYN_RECV" })
diff --git a/test/trace_processor/network/index b/test/trace_processor/network/index
index a21082a..bc563d1 100644
--- a/test/trace_processor/network/index
+++ b/test/trace_processor/network/index
@@ -2,3 +2,4 @@
netif_receive_skb.textproto netif_receive_skb.sql netif_receive_skb.out
net_dev_xmit.textproto net_dev_xmit.sql net_dev_xmit.out
netperf_metric.textproto android_netperf netperf_metric.out
+inet_sock_set_state.textproto inet_sock_set_state.sql inet_sock_set_state.out
diff --git a/test/trace_processor/network/inet_sock_set_state.out b/test/trace_processor/network/inet_sock_set_state.out
new file mode 100644
index 0000000..fd67a19
--- /dev/null
+++ b/test/trace_processor/network/inet_sock_set_state.out
@@ -0,0 +1,7 @@
+"ts","name","dur","name"
+10000000,"TCP_SYN_SENT(pid=123)",100000000,"TCP stream#1"
+110000000,"TCP_ESTABLISHED(sport=56789,dport=5001)",500000000,"TCP stream#1"
+610000000,"TCP_CLOSE_WAIT",-1,"TCP stream#1"
+710000000,"TCP_SYN_SENT(pid=567)",10000000,"TCP stream#2"
+720000000,"TCP_ESTABLISHED(sport=56790,dport=5002)",300000000,"TCP stream#2"
+1020000000,"TCP_CLOSE_WAIT",-1,"TCP stream#2"
diff --git a/test/trace_processor/network/inet_sock_set_state.sql b/test/trace_processor/network/inet_sock_set_state.sql
new file mode 100644
index 0000000..badba1e
--- /dev/null
+++ b/test/trace_processor/network/inet_sock_set_state.sql
@@ -0,0 +1,12 @@
+SELECT
+ ts,
+ s.name,
+ dur,
+ t.name
+FROM
+ slice AS s
+ LEFT JOIN track AS t
+ ON s.track_id = t.id
+WHERE
+ t.name GLOB "TCP stream#*"
+ORDER BY ts;
diff --git a/test/trace_processor/network/inet_sock_set_state.textproto b/test/trace_processor/network/inet_sock_set_state.textproto
new file mode 100644
index 0000000..00362f9
--- /dev/null
+++ b/test/trace_processor/network/inet_sock_set_state.textproto
@@ -0,0 +1,121 @@
+packet {
+ ftrace_events {
+ cpu: 0
+ event {
+ timestamp: 10000000
+ pid: 123
+ inet_sock_set_state {
+ family: 2
+ protocol: 6
+ daddr: 19216801
+ saddr: 127001
+ dport: 5001
+ sport: 0
+ newstate: 2
+ oldstate: 7
+ skaddr: 77889900
+ }
+ }
+ }
+}
+packet {
+ ftrace_events {
+ cpu: 1
+ event {
+ timestamp: 110000000
+ pid: 234
+ inet_sock_set_state {
+ family: 2
+ protocol: 6
+ daddr: 19216801
+ saddr: 127001
+ dport: 5001
+ sport: 56789
+ newstate: 1
+ oldstate: 2
+ skaddr: 77889900
+ }
+ }
+ }
+}
+packet {
+ ftrace_events {
+ cpu: 0
+ event {
+ timestamp: 610000000
+ pid: 456
+ inet_sock_set_state {
+ family: 2
+ protocol: 6
+ daddr: 19216801
+ saddr: 127001
+ dport: 5001
+ sport: 56789
+ newstate: 8
+ oldstate: 1
+ skaddr: 77889900
+ }
+ }
+ }
+}
+packet {
+ ftrace_events {
+ cpu: 0
+ event {
+ timestamp: 710000000
+ pid:567
+ inet_sock_set_state {
+ family: 10
+ protocol: 6
+ daddr: 0
+ saddr: 0
+ dport: 5002
+ sport: 0
+ newstate: 2
+ oldstate: 7
+ skaddr: 33445566
+ }
+ }
+ }
+}
+packet {
+ ftrace_events {
+ cpu: 1
+ event {
+ timestamp: 720000000
+ pid: 234
+ inet_sock_set_state {
+ family: 10
+ protocol: 6
+ daddr: 0
+ saddr: 0
+ dport: 5002
+ sport: 56790
+ newstate: 1
+ oldstate: 2
+ skaddr: 33445566
+ }
+ }
+ }
+}
+packet {
+ ftrace_events {
+ cpu: 0
+ event {
+ timestamp: 1020000000
+ pid: 456
+ inet_sock_set_state {
+ family: 10
+ protocol: 6
+ daddr: 0
+ saddr: 0
+ dport: 5002
+ sport: 567090
+ newstate: 8
+ oldstate: 1
+ skaddr: 33445566
+ }
+ }
+ }
+}
+
diff --git a/tools/ftrace_proto_gen/event_list b/tools/ftrace_proto_gen/event_list
index 5a0f31b..8cd573f 100644
--- a/tools/ftrace_proto_gen/event_list
+++ b/tools/ftrace_proto_gen/event_list
@@ -356,3 +356,4 @@
synthetic/rss_stat_throttled
net/netif_receive_skb
net/net_dev_xmit
+sock/inet_sock_set_state