Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connection tracking - hash mechanism #201
Connection tracking - hash mechanism #201
Changes from 14 commits
da38508
957823e
1da5f24
a6776a0
3bd4bfc
5c21b9f
ebe9aa8
a68f132
8a0532b
747a19b
74e8a18
909ef58
1a052c5
487643c
3e909c1
acb30a0
bb8c08a
862a303
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ronensc If you externalize the
hashType
type you will be able to also returnhashType
and not []byteThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we "trick" somehow (maybe interface?) so that it will be a parameter to the functions what length of Hash to use >???
@mariomac maybe you have an idea ??? ^^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, actually the
fnv.New32a
and rest of hashers implement theio.Writer
interface. You can change the function signature to something like:and invoke it like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or, if you want to be even more restrictive in what you can pass as argument, you can use the
hash.Hash
interface instead ofio.Writer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be risky. It could end up flooding the log file. Is there a way to avoid repeated logs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can replace it with a prometheus metric. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe this needs to be tracked as a metric. It doesn't seem like it's likely to occur but can if someone wants to be malicious. For now, maybe let it go, but we should have a general solution to avoid spamming the log file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you include the ephemeral port in the hash, it will count a lot of connections. We need to get an agreement on what a "connection" is. Example: Let's say you access a web page. Is that one connection? With this implementation, it could be anywhere from 1 to 6 connections.
A typical web page will refer to JavaScript files, CSS files, images, etc. The browser will need to fetch these files. Pretty much all modern browsers today will allow up to 6 simultaneous connections to the same domain, and will reuse these connections to fetch all the files. Each of these connections will have a different ephemeral port.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I tried to make the decision of what is a connection configurable. But it's still not flexible enough to support this use-case.
This specific unit test configures the classic 5-tuple to distinguish between connections. The other unit test uses a slightly different configuration. It uses the same 5-tuple but includes both flow directions in the same connection.