quic: support the crypto_decrypt probe
from bcc import BPF, USDT
from collections import OrderedDict
-import binascii, getopt, json, sys
+import binascii, getopt, json, sys, time
bpf = """
#define MAX_STR_LEN 128
@@ -212,6 +212,25 @@ int trace_stateless_reset_receive(struct pt_regs *ctx) {
return 0;
}
+int trace_crypto_decrypt(struct pt_regs *ctx) {
+ void *pos = NULL;
+ struct quic_event_t event = {};
+ struct st_quicly_conn_t conn = {};
+ sprintf(event.type, "crypto_decrypt");
+
+ bpf_usdt_readarg(1, ctx, &pos);
+ bpf_probe_read(&conn, sizeof(conn), pos);
+ event.master_conn_id = conn.master_id;
+ bpf_usdt_readarg(2, ctx, &event.packet_num);
+ bpf_usdt_readarg(4, ctx, &event.len);
+
+ if (events.perf_submit(ctx, &event, sizeof(event)) < 0)
+ bpf_trace_printk("failed to perf_submit\\n");
+
+ return 0;
+}
+
+
int trace_packet_prepare(struct pt_regs *ctx) {
void *pos = NULL;
struct quic_event_t event = {};
@@ -553,7 +572,11 @@ def handle_resp_line(cpu, data, size):
def load_common_fields(hsh, line):
for k in ['at', 'type', 'master_conn_id']:
- hsh[k] = getattr(line, k)
+ v = getattr(line, k)
+ if v == 0 and k == 'at':
+ # TODO: This is a synthetic hack
+ v = int(time.time() * 1000)
+ hsh[k] = v
def build_quic_trace_result(res, event, fields):
for k in fields:
@@ -576,6 +599,8 @@ def handle_quic_event(cpu, data, size):
build_quic_trace_result(res, ev, ["dcid"])
elif ev.type == "version_switch":
build_quic_trace_result(res, ev, ["new_version"])
+ elif ev.type == "crypto_decrypt":
+ build_quic_trace_result(res, ev, ["packet_num", "len"])
elif ev.type == "packet_prepare":
build_quic_trace_result(res, ev, ["first_octet", "dcid"])
elif ev.type == "packet_commit":
@@ -667,6 +692,7 @@ if sys.argv[1] == "quic":
u.enable_probe(probe="version_switch", fn_name="trace_version_switch")
u.enable_probe(probe="idle_timeout", fn_name="trace_idle_timeout")
u.enable_probe(probe="stateless_reset_receive", fn_name="trace_stateless_reset_receive")
+ u.enable_probe(probe="crypto_decrypt", fn_name="trace_crypto_decrypt")
u.enable_probe(probe="packet_prepare", fn_name="trace_packet_prepare")
u.enable_probe(probe="packet_commit", fn_name="trace_packet_commit")
u.enable_probe(probe="packet_acked", fn_name="trace_packet_acked")
