Skip to content

traffic_dump: print request body data and client address filtering#6259

Closed
bneradt wants to merge 2 commits intoapache:masterfrom
bneradt:traffic_dump_body_data
Closed

traffic_dump: print request body data and client address filtering#6259
bneradt wants to merge 2 commits intoapache:masterfrom
bneradt:traffic_dump_body_data

Conversation

@bneradt
Copy link
Contributor

@bneradt bneradt commented Dec 12, 2019

This adds the -b option to traffic dump to dump client request body
data. It also adds the -4 and -6 options so that the client can filter
what is dumped based upon a client IP address.

Note that this has a dependency upon the outstanding bneradt:fix_request_buffer_read_complete_hook branch from this PR:
#6243

The latter is the first commit in this diff and can be ignored in this PR. The second commit is the commit to be reviewed in this PR.

@bneradt bneradt force-pushed the traffic_dump_body_data branch 3 times, most recently from 4f0a1ba to 6a343ed Compare December 13, 2019 19:39
@bryancall bryancall added this to the 10.0.0 milestone Dec 16, 2019
@shinrich
Copy link
Member

shinrich commented Dec 18, 2019

Are the two commits separable? Or should they be squashed before merging?

Looking more closely at the individual commits they do look independent, and should not be squashed.

struct TxnData {
std::string request_body;
};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bneradt bneradt force-pushed the traffic_dump_body_data branch from 3d2b1a0 to 5ca36ea Compare December 18, 2019 23:16
@bneradt
Copy link
Contributor Author

bneradt commented Dec 18, 2019

[approve ci autest]

@bneradt bneradt force-pushed the traffic_dump_body_data branch 3 times, most recently from 925f3f4 to 64d1da4 Compare December 20, 2019 22:49
@bneradt bneradt force-pushed the traffic_dump_body_data branch from 6951e8d to b44ce2e Compare February 7, 2020 00:14
ywkaras
ywkaras previously approved these changes Feb 7, 2020
// client/proxy-request/response headers
TSMBuffer buffer = nullptr;
TSMLoc hdr_loc;
if (TS_SUCCESS == TSHttpTxnClientReqGet(txnp, &buffer, &hdr_loc)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent of these changes, but if we don't fetch the client request data until TXN_CLOSE, will some of the client data (like the URL) be changed from the original? Have you seen that in your dumps so far?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good observation. I did face issues with exactly that (the request target, in particular). That got addressed here:

#6414

This branch will need to be rebased to get that fix.

REBASE(CACHE_LOOKUP_COMPLETE), // TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK
REBASE(PRE_REMAP), // TS_HTTP_PRE_REMAP_HOOK
REBASE(POST_REMAP), // TS_HTTP_POST_REMAP_HOOK
REBASE(REQUEST_BUFFER_READ_COMPLETE), // TS_HTTP_REQUEST_BUFFER_READ_COMPLETE_HOOK
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't familiar with this hook, so I looked it up in the docs, and it isn't there. Would be a great thing to add to the docs. Perhaps in a separate PR.

shinrich
shinrich previously approved these changes Mar 5, 2020
Copy link
Member

@shinrich shinrich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My comments are probably outside the scope of this PR. The restructuring looks good to me. Will need to rebase.

@zwoop
Copy link
Contributor

zwoop commented Mar 11, 2020

This doesn't apply cleanly on the 9.0.x branch either, can you fix the conflicts above please, and also if there are other PRs need for 9.0.x before this, let me know.

@randall
Copy link
Contributor

randall commented May 6, 2020

@bneradt Can you rebase so we can merge this change?

@bneradt
Copy link
Contributor Author

bneradt commented May 6, 2020

@bneradt Can you rebase so we can merge this change?

Thanks @randall . I'm working on another bug fix and refactor for traffic_dump now. I'll prioritize that and remerge this after that is approved.

@zwoop
Copy link
Contributor

zwoop commented Jul 13, 2020

Can we move this out to 9.1.x then ?

@bneradt
Copy link
Contributor Author

bneradt commented Jul 14, 2020 via email

@bneradt bneradt dismissed stale reviews from shinrich and ywkaras via 1cd6401 July 24, 2020 15:20
@bneradt bneradt force-pushed the traffic_dump_body_data branch 2 times, most recently from 1cd6401 to f2ae2e8 Compare July 24, 2020 16:27
@bneradt bneradt force-pushed the traffic_dump_body_data branch from f2ae2e8 to 134667b Compare July 31, 2020 20:24
@Speedracer11
Copy link

What did I do? Why try and block me? I lost half of my carrier.

bneradt added 2 commits August 9, 2020 02:04
The value for TS_HTTP_REQUEST_BUFFER_READ_COMPLETE_HOOK was out of sync with
the corresponding event, TS_EVENT_HTTP_REQUEST_BUFFER_READ_COMPLETE. This
caused the handler for TS_HTTP_REQUEST_BUFFER_READ_COMPLETE_HOOK to never be
invoked with the TS_EVENT_HTTP_REQUEST_BUFFER_READ_COMPLETE event. This patch
fixes this problem and adds comments explaining the otherwise implicit but
very important requirement that these values correspond as they do.

The naming of the event and hook were off too. A hook with name TS_HTTP_X_HOOK
should have an event of name TS_EVENT_HTTP_X, but these got out of sync somehow
for request buffer read complete. This adjusts the event name appropriately.
This adds the -b option to traffic dump to dump client request body
data. It also adds the -4 and -6 options so that the client can filter
what is dumped based upon a client IP address.
@bneradt bneradt force-pushed the traffic_dump_body_data branch from 134667b to b34a8ab Compare August 9, 2020 02:13
@bneradt
Copy link
Contributor Author

bneradt commented Aug 18, 2020

[approve ci clang-analyzer]

@bneradt
Copy link
Contributor Author

bneradt commented Aug 18, 2020

[approve ci docs]

@bneradt
Copy link
Contributor Author

bneradt commented Jul 14, 2021

Are the two commits separable? Or should they be squashed before merging?

Looking more closely at the individual commits they do look independent, and should not be squashed.

Yes, let's not squash them. I separated out the HOOK/EVENT fix into this PR: #8066

Once that is merged I'll create another PR for the Traffic Dump work. In the meantime I'll close this PR.

@bneradt bneradt closed this Jul 14, 2021
@bneradt bneradt removed this from the 10.0.0 milestone Jul 15, 2021
@bneradt bneradt deleted the traffic_dump_body_data branch March 29, 2023 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants