-
Notifications
You must be signed in to change notification settings - Fork 748
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
conntrack: allow to filter by subnet #627
Conversation
/assign @dcbw @danwinship |
conntrack_linux.go
Outdated
// AddIP adds an IP to the conntrack filter | ||
func (f *ConntrackFilter) AddIP(tp ConntrackFilterType, ip net.IP) error { | ||
// Convert IP to a subnet with a full mask | ||
iplen := 8 * len(ip) |
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.
@aojea can you explain a bit more what you're doing here? THere's gotta be something we can do that I can understand in 2 minutes of looking at it. Also, we're not To4() or To16() canonicalizing anything here; does the Contains() down below handle that automatically for us?
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 creates a full mask, I tested locally but indeed is a bit opaque because I think it depends on the golang net IP internal types. I will make it explicit so there is no doubt, if you have an ipv4 it add /32 if you have ipv6 it adds /128
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.
The contains check if an IP belongs to an IP subnet , the IP 192.268.2.1 belongs to the subnet 192.168.2.1/32
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.
thanks for the explanation, new push looks good to me
57952bd
to
e9f53c8
Compare
lgtm |
LGTM |
please push again to trigger CI |
Add a new conntrack filter to be able to filter by subnet, in addition to current IP address filter. Signed-off-by: Antonio Ojea <[email protected]>
Add a new conntrack filter to be able to filter by subnet, in
addition to current IP address filter.
This keeps compatibility, since the IP filter is just an IP subnet filter with full mask.
Signed-off-by: Antonio Ojea [email protected]