transport capture: rename to tap (#5666)

This is a rename PR only. It renames the capture transport socket
and associated tools to the tap transport socket. It also updates
some documentation. In a subsequent PR I'm going to refactor the
tap transport socket to use the new common tap framework so that
the tap transport socket can be configured via admin, the HTTP
tap filter can write to a file, the tap transport socket can have
matching, etc.

Signed-off-by: Matt Klein <mklein@lyft.com>

Mirrored from https://github.com/envoyproxy/envoy @ 7a5849f2a8bcc55fa16da3eaee94d9c99a11147c
pull/620/head
data-plane-api(CircleCI) 6 years ago
parent d714c26513
commit 40afd47af0
  1. 4
      docs/BUILD
  2. 4
      envoy/config/transport_socket/tap/v2alpha/BUILD
  3. 10
      envoy/config/transport_socket/tap/v2alpha/tap.proto
  4. 4
      envoy/data/tap/v2alpha/BUILD
  5. 8
      envoy/data/tap/v2alpha/transport.proto
  6. 16
      tools/BUILD
  7. 0
      tools/data/tap2pcap_h2_ipv4.pb_text
  8. 0
      tools/data/tap2pcap_h2_ipv4.txt
  9. 24
      tools/tap2pcap.py
  10. 14
      tools/tap2pcap_test.py

@ -70,11 +70,11 @@ proto_library(
"//envoy/config/resource_monitor/fixed_heap/v2alpha:fixed_heap", "//envoy/config/resource_monitor/fixed_heap/v2alpha:fixed_heap",
"//envoy/config/resource_monitor/injected_resource/v2alpha:injected_resource", "//envoy/config/resource_monitor/injected_resource/v2alpha:injected_resource",
"//envoy/config/trace/v2:trace", "//envoy/config/trace/v2:trace",
"//envoy/config/transport_socket/capture/v2alpha:capture", "//envoy/config/transport_socket/tap/v2alpha:tap",
"//envoy/data/accesslog/v2:accesslog", "//envoy/data/accesslog/v2:accesslog",
"//envoy/data/core/v2alpha:health_check_event", "//envoy/data/core/v2alpha:health_check_event",
"//envoy/data/tap/v2alpha:capture",
"//envoy/data/tap/v2alpha:http", "//envoy/data/tap/v2alpha:http",
"//envoy/data/tap/v2alpha:transport",
"//envoy/data/tap/v2alpha:wrapper", "//envoy/data/tap/v2alpha:wrapper",
"//envoy/service/accesslog/v2:als", "//envoy/service/accesslog/v2:als",
"//envoy/service/auth/v2:attribute_context", "//envoy/service/auth/v2:attribute_context",

@ -3,8 +3,8 @@ load("//bazel:api_build_system.bzl", "api_proto_library_internal")
licenses(["notice"]) # Apache 2 licenses(["notice"]) # Apache 2
api_proto_library_internal( api_proto_library_internal(
name = "capture", name = "tap",
srcs = ["capture.proto"], srcs = ["tap.proto"],
deps = [ deps = [
"//envoy/api/v2/core:base", "//envoy/api/v2/core:base",
], ],

@ -1,10 +1,10 @@
syntax = "proto3"; syntax = "proto3";
package envoy.config.transport_socket.capture.v2alpha; package envoy.config.transport_socket.tap.v2alpha;
option java_package = "io.envoyproxy.envoy.config.transport_socket.capture.v2alpha"; option java_package = "io.envoyproxy.envoy.config.transport_socket.tap.v2alpha";
option go_package = "v2"; option go_package = "v2";
// [#protodoc-title: Capture] // [#protodoc-title: Tap]
import "envoy/api/v2/core/base.proto"; import "envoy/api/v2/core/base.proto";
@ -33,9 +33,9 @@ message FileSink {
Format format = 2; Format format = 2;
} }
// Configuration for capture transport socket. This wraps another transport socket, providing the // Configuration for tap transport socket. This wraps another transport socket, providing the
// ability to interpose and record in plain text any traffic that is surfaced to Envoy. // ability to interpose and record in plain text any traffic that is surfaced to Envoy.
message Capture { message Tap {
oneof sink_selector { oneof sink_selector {
// Trace is to be written to a file sink. // Trace is to be written to a file sink.
FileSink file_sink = 1; FileSink file_sink = 1;

@ -3,8 +3,8 @@ load("//bazel:api_build_system.bzl", "api_proto_library_internal")
licenses(["notice"]) # Apache 2 licenses(["notice"]) # Apache 2
api_proto_library_internal( api_proto_library_internal(
name = "capture", name = "transport",
srcs = ["capture.proto"], srcs = ["transport.proto"],
deps = ["//envoy/api/v2/core:address"], deps = ["//envoy/api/v2/core:address"],
) )

@ -1,7 +1,7 @@
syntax = "proto3"; syntax = "proto3";
// [#protodoc-title: Common tap] // [#protodoc-title: Transport tap data]
// Trace capture format for the capture transport socket extension. This dumps plain text read/write // Trace format for the tap transport socket extension. This dumps plain text read/write
// sequences on a socket. // sequences on a socket.
package envoy.data.tap.v2alpha; package envoy.data.tap.v2alpha;
@ -23,7 +23,7 @@ message Connection {
envoy.api.v2.core.Address remote_address = 3; envoy.api.v2.core.Address remote_address = 3;
} }
// Event in a capture trace. // Event in a trace.
message Event { message Event {
// Timestamp for event. // Timestamp for event.
google.protobuf.Timestamp timestamp = 1; google.protobuf.Timestamp timestamp = 1;
@ -47,7 +47,7 @@ message Event {
} }
} }
// Sequence of read/write events that constitute a captured trace on a socket. // Sequence of read/write events that constitute a trace on a socket.
// Multiple Trace messages might be emitted for a given connection ID, with the // Multiple Trace messages might be emitted for a given connection ID, with the
// sink (e.g. file set, network) responsible for later reassembly. // sink (e.g. file set, network) responsible for later reassembly.
message Trace { message Trace {

@ -1,27 +1,27 @@
licenses(["notice"]) # Apache 2 licenses(["notice"]) # Apache 2
py_binary( py_binary(
name = "capture2pcap", name = "tap2pcap",
srcs = ["capture2pcap.py"], srcs = ["tap2pcap.py"],
licenses = ["notice"], # Apache 2 licenses = ["notice"], # Apache 2
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [ deps = [
"//envoy/data/tap/v2alpha:capture_py", "//envoy/data/tap/v2alpha:transport_py",
], ],
) )
py_test( py_test(
name = "capture2pcap_test", name = "tap2pcap_test",
srcs = ["capture2pcap_test.py"], srcs = ["tap2pcap_test.py"],
data = [ data = [
"data/capture2pcap_h2_ipv4.pb_text", "data/tap2pcap_h2_ipv4.pb_text",
"data/capture2pcap_h2_ipv4.txt", "data/tap2pcap_h2_ipv4.txt",
], ],
# Don't run this by default, since we don't want to force local dependency on Wireshark/tshark, # Don't run this by default, since we don't want to force local dependency on Wireshark/tshark,
# will explicitly invoke in CI. # will explicitly invoke in CI.
tags = ["manual"], tags = ["manual"],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [":capture2pcap"], deps = [":tap2pcap"],
) )
py_binary( py_binary(

@ -1,14 +1,14 @@
"""Tool to convert Envoy capture trace format to PCAP. """Tool to convert Envoy tap trace format to PCAP.
Uses od and text2pcap (part of Wireshark) utilities to translate the Envoy Uses od and text2pcap (part of Wireshark) utilities to translate the Envoy
capture trace proto format to a PCAP file suitable for consuming in Wireshark tap trace proto format to a PCAP file suitable for consuming in Wireshark
and other tools in the PCAP ecosystem. The TCP stream in the output PCAP is and other tools in the PCAP ecosystem. The TCP stream in the output PCAP is
synthesized based on the known IP/port/timestamps that Envoy produces in its synthesized based on the known IP/port/timestamps that Envoy produces in its
capture files; it is not a literal wire capture. tap files; it is not a literal wire tap.
Usage: Usage:
bazel run @envoy_api//tools:capture2pcap <capture .pb/.pb_text> <pcap path> bazel run @envoy_api//tools:tap2pcap <tap .pb/.pb_text> <pcap path>
Known issues: Known issues:
- IPv6 PCAP generation has malformed TCP packets. This appears to be a text2pcap - IPv6 PCAP generation has malformed TCP packets. This appears to be a text2pcap
@ -28,7 +28,7 @@ import time
from google.protobuf import text_format from google.protobuf import text_format
from envoy.data.tap.v2alpha import capture_pb2 from envoy.data.tap.v2alpha import transport_pb2
def DumpEvent(direction, timestamp, data): def DumpEvent(direction, timestamp, data):
@ -43,13 +43,13 @@ def DumpEvent(direction, timestamp, data):
return dump.getvalue() return dump.getvalue()
def Capture2Pcap(capture_path, pcap_path): def Tap2Pcap(tap_path, pcap_path):
trace = capture_pb2.Trace() trace = transport_pb2.Trace()
if capture_path.endswith('.pb_text'): if tap_path.endswith('.pb_text'):
with open(capture_path, 'r') as f: with open(tap_path, 'r') as f:
text_format.Merge(f.read(), trace) text_format.Merge(f.read(), trace)
else: else:
with open(capture_path, 'r') as f: with open(tap_path, 'r') as f:
trace.ParseFromString(f.read()) trace.ParseFromString(f.read())
local_address = trace.connection.local_address.socket_address.address local_address = trace.connection.local_address.socket_address.address
@ -82,6 +82,6 @@ def Capture2Pcap(capture_path, pcap_path):
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) != 3: if len(sys.argv) != 3:
print('Usage: %s <capture .pb/.pb_text> <pcap path>' % sys.argv[0]) print('Usage: %s <tap .pb/.pb_text> <pcap path>' % sys.argv[0])
sys.exit(1) sys.exit(1)
Capture2Pcap(sys.argv[1], sys.argv[2]) Tap2Pcap(sys.argv[1], sys.argv[2])

@ -1,22 +1,22 @@
"""Tests for capture2pcap.""" """Tests for tap2pcap."""
from __future__ import print_function from __future__ import print_function
import os import os
import subprocess as sp import subprocess as sp
import sys import sys
import capture2pcap import tap2pcap
# Validate that the captured trace when run through capture2cap | tshark matches # Validate that the tapped trace when run through tap2cap | tshark matches
# a golden output file for the tshark dump. Since we run capture2pcap in a # a golden output file for the tshark dump. Since we run tap2pcap in a
# subshell with a limited environment, the inferred time zone should be UTC. # subshell with a limited environment, the inferred time zone should be UTC.
if __name__ == '__main__': if __name__ == '__main__':
srcdir = os.path.join(os.getenv('TEST_SRCDIR'), 'envoy_api') srcdir = os.path.join(os.getenv('TEST_SRCDIR'), 'envoy_api')
capture_path = os.path.join(srcdir, 'tools/data/capture2pcap_h2_ipv4.pb_text') tap_path = os.path.join(srcdir, 'tools/data/tap2pcap_h2_ipv4.pb_text')
expected_path = os.path.join(srcdir, 'tools/data/capture2pcap_h2_ipv4.txt') expected_path = os.path.join(srcdir, 'tools/data/tap2pcap_h2_ipv4.txt')
pcap_path = os.path.join(os.getenv('TEST_TMPDIR'), 'generated.pcap') pcap_path = os.path.join(os.getenv('TEST_TMPDIR'), 'generated.pcap')
capture2pcap.Capture2Pcap(capture_path, pcap_path) tap2pcap.Tap2Pcap(tap_path, pcap_path)
actual_output = sp.check_output(['tshark', '-r', pcap_path, '-d', 'tcp.port==10000,http2', '-P']) actual_output = sp.check_output(['tshark', '-r', pcap_path, '-d', 'tcp.port==10000,http2', '-P'])
with open(expected_path, 'r') as f: with open(expected_path, 'r') as f:
expected_output = f.read() expected_output = f.read()
Loading…
Cancel
Save