From c78f21b27da9a1742e81ded8ce3358555ff2e6ed Mon Sep 17 00:00:00 2001 From: Fuji Goro Date: Tue, 25 Feb 2020 08:06:14 +0000 Subject: [PATCH 1/3] quic: add -v and -s to filter response headers --- h2olog | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/h2olog b/h2olog index 6502873..9f89d73 100755 --- a/h2olog +++ b/h2olog @@ -710,6 +710,9 @@ def handle_quic_event(cpu, data, size): if allowed_quic_event and ev.type != allowed_quic_event: return + if allowed_res_header_name and ev.type == "send_response_header" and ev.h2o_header_name != allowed_res_header_name: + return + res = OrderedDict() load_common_fields(res, ev) @@ -767,9 +770,12 @@ def handle_quic_event(cpu, data, size): print(json.dumps(res, separators = (',', ':'))) def usage(): - print ("USAGE: h2olog -p PID") - print (" h2olog quic -p PID") - print (" h2olog quic -t event_type -p PID") + print(""" +USAGE: h2olog -p PID + h2olog quic -p PID + h2olog quic -t event_type -p PID + h2olog quic -v -s response_header_name -p PID +""".strip()) exit() def trace_http(): @@ -802,12 +808,19 @@ if len(sys.argv) > 1 and sys.argv[1] == "quic": try: h2o_pid = 0 allowed_quic_event = None - opts, args = getopt.getopt(sys.argv[optidx:], 'p:t:') + allowed_res_header_name = None + verbose = False + opts, args = getopt.getopt(sys.argv[optidx:], 'vp:t:s:') for opt, arg in opts: if opt == "-p": h2o_pid = arg - if opt == "-t": + elif opt == "-t": allowed_quic_event = arg + elif opt == "-v": + verbose = True + elif opt == "-s": # reSponse + allowed_res_header_name = arg.lower() + except getopt.error as msg: print(msg) sys.exit(2) @@ -844,7 +857,8 @@ if sys.argv[1] == "quic": u.enable_probe(probe="quictrace_recv", fn_name="trace_quictrace_recv") u.enable_probe(probe="quictrace_recv_ack_delay", fn_name="trace_quictrace_recv_ack_delay") u.enable_probe(probe="quictrace_lost", fn_name="trace_quictrace_lost") - u.enable_probe(probe="send_response_header", fn_name="trace_send_response_header") + if verbose: + u.enable_probe(probe="send_response_header", fn_name="trace_send_response_header") b = BPF(text=quic_bpf, usdt_contexts=[u]) else: u.enable_probe(probe="receive_request", fn_name="trace_receive_req") From 13146a8e3b2c3f6a907e83c7541e05c5676439da Mon Sep 17 00:00:00 2001 From: FUJI Goro Date: Tue, 3 Mar 2020 18:42:02 -0800 Subject: [PATCH 2/3] =?UTF-8?q?Fix=20errors:=20LLVM=20ERROR:=20Program=20u?= =?UTF-8?q?sed=20external=20function=20=E2=80=98=5Fbpf=5Freadarg=5Ftrace?= =?UTF-8?q?=5Fsend=5Fresponse=5Fheader=5F1=E2=80=99=20which=20could=20not?= =?UTF-8?q?=20be=20resolved!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- h2olog | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/h2olog b/h2olog index 9f89d73..3548b5a 100755 --- a/h2olog +++ b/h2olog @@ -857,8 +857,7 @@ if sys.argv[1] == "quic": u.enable_probe(probe="quictrace_recv", fn_name="trace_quictrace_recv") u.enable_probe(probe="quictrace_recv_ack_delay", fn_name="trace_quictrace_recv_ack_delay") u.enable_probe(probe="quictrace_lost", fn_name="trace_quictrace_lost") - if verbose: - u.enable_probe(probe="send_response_header", fn_name="trace_send_response_header") + u.enable_probe(probe="send_response_header", fn_name="trace_send_response_header") b = BPF(text=quic_bpf, usdt_contexts=[u]) else: u.enable_probe(probe="receive_request", fn_name="trace_receive_req") From 320974b23e382f99b0b2dfbed22340e7686120fa Mon Sep 17 00:00:00 2001 From: Fuji Goro Date: Wed, 4 Mar 2020 04:30:25 +0000 Subject: [PATCH 3/3] Fix -v to work (amended 13146a8e3b2c3f6a907e83c7541e05c5676439da) --- h2olog | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/h2olog b/h2olog index 3548b5a..d20413b 100755 --- a/h2olog +++ b/h2olog @@ -710,8 +710,11 @@ def handle_quic_event(cpu, data, size): if allowed_quic_event and ev.type != allowed_quic_event: return - if allowed_res_header_name and ev.type == "send_response_header" and ev.h2o_header_name != allowed_res_header_name: - return + if ev.type == "send_response_header": # HTTP-level events + if not verbose: + return + if allowed_res_header_name and ev.h2o_header_name != allowed_res_header_name: + return res = OrderedDict() load_common_fields(res, ev) @@ -820,7 +823,6 @@ try: verbose = True elif opt == "-s": # reSponse allowed_res_header_name = arg.lower() - except getopt.error as msg: print(msg) sys.exit(2)