[go: nahoru, domu]

Skip to content

Commit

Permalink
Simplify H2 unknown frame type probe
Browse files Browse the repository at this point in the history
This patch simplifies the probe point for HTTP/2 unknown frame type
by dropping a frame structure parameter, as we don't have a clear
use case for it as of now.
  • Loading branch information
hfujita committed Feb 13, 2020
1 parent bee4213 commit b9c6a4b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
2 changes: 1 addition & 1 deletion h2o-probes.d
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
provider h2o {
probe h1_accept(uint64_t conn_id, struct st_h2o_socket_t *sock, struct st_h2o_conn_t *conn);
probe h1_close(uint64_t conn_id);
probe h2_unknown_frame_type(uint64_t conn_id, uint8_t frame_type, struct st_h2o_http2_frame_t *frame);
probe h2_unknown_frame_type(uint64_t conn_id, uint8_t frame_type);
probe h3_accept(uint64_t conn_id, struct st_h2o_conn_t *conn, struct st_quicly_conn_t *quic);
probe h3_close(uint64_t conn_id);
probe h3_stream_create(uint64_t conn_id, uint64_t req_id);
Expand Down
2 changes: 1 addition & 1 deletion lib/http2/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ ssize_t expect_default(h2o_http2_conn_t *conn, const uint8_t *src, size_t len, c
if (hret != 0)
ret = hret;
} else {
H2O_PROBE_CONN(H2_UNKNOWN_FRAME_TYPE, &conn->super, frame.type, &frame);
H2O_PROBE_CONN(H2_UNKNOWN_FRAME_TYPE, &conn->super, frame.type);
}

return ret;
Expand Down
25 changes: 7 additions & 18 deletions t/90dtrace.t
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,11 @@ if ($tracer_pid == 0) {
or die "failed to create temporary file:$tempdir/trace.out:$!";
if ($^O eq 'linux') {
exec qw(bpftrace -v -B none -p), $server->{pid}, "-e", <<'EOT';
struct st_h2o_http2_frame_t {uint32_t length; uint8_t type; uint8_t flags; uint32_t stream_id;};
usdt::h2o:receive_request {printf("*** %llu:%llu version %d.%d ***\n", arg0, arg1, arg2 / 256, arg2 % 256)}
usdt::h2o:receive_request_header {printf("%s: %s\n", str(arg2, arg3), str(arg4, arg5))}
usdt::h2o:send_response {printf("%llu:%llu status:%u\n", arg0, arg1, arg2)}
usdt::h2o:send_response_header {printf("%s: %s\n", str(arg2, arg3), str(arg4, arg5))}
usdt::h2o:h2_unknown_frame_type {
printf("Unknown HTTP/2 frame type: %d stream_id: %d\n",
arg1,
((struct st_h2o_http2_frame_t *)arg2)->stream_id)
usdt::h2o:h2_unknown_frame_type {printf("Unknown HTTP/2 frame type: %d\n", arg1)
}
EOT
die "failed to spawn bpftrace:$!";
Expand Down Expand Up @@ -94,16 +90,8 @@ EOT
}
EOT
"-n", <<'EOT'
struct st_h2o_http2_frame_t {
uint32_t length;
uint8_t type;
uint8_t flags;
uint32_t stream_id;
};
:h2o::h2_unknown_frame_type {
printf("\nXXXXUnknown HTTP/2 frame type: %d stream_id: %d\n",
arg1,
((struct st_h2o_http2_frame_t *) copyin(arg2, sizeof(struct st_h2o_http2_frame_t)))->stream_id);
printf("\nXXXXUnknown HTTP/2 frame type: %d\n", arg1);
}
EOT
);
Expand Down Expand Up @@ -180,7 +168,7 @@ subtest "http/2 unknown frames" => sub {
h2g.connect(host)
h2g.send_prefix()
h2g.send_settings([[2,0]])
# Ack settings
# Complete SETTINGS-ACK exchange
settings_exch = 0
while settings_exch < 2 do
f = h2g.read(-1)
Expand All @@ -194,6 +182,7 @@ subtest "http/2 unknown frames" => sub {
next
end
end
# Send frames with unknown types (101, 103, 105)
h2g.send_raw_frame(1, 101)
h2g.send_raw_frame(3, 103)
h2g.send_raw_frame(5, 105)
Expand All @@ -212,9 +201,9 @@ EOR
sleep 1;
} while (($trace = $read_trace->()) eq '');

like $trace, qr{Unknown HTTP/2 frame type: 101 stream_id: 1}s;
like $trace, qr{Unknown HTTP/2 frame type: 103 stream_id: 3}s;
like $trace, qr{Unknown HTTP/2 frame type: 105 stream_id: 5}s;
like $trace, qr{Unknown HTTP/2 frame type: 101}s;
like $trace, qr{Unknown HTTP/2 frame type: 103}s;
like $trace, qr{Unknown HTTP/2 frame type: 105}s;
};

# wait until the server and the tracer exits
Expand Down

0 comments on commit b9c6a4b

Please sign in to comment.