-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Support IP comparison #2248
Comments
This would be a nice feature, thanks for the suggestion! I think that the solution using |
May I draft a PR regarding this? 😃 |
Yes, please do, that would be great :-) |
I'm able to convert string-format IPv6 address to char array now, but I think we may need the ability to compare char array in bpftrace language, otherwise we can only compare them char by char, or compare them stringified. What I'm having now:
There is a working branch on https://github.com/xh4n3/bpftrace/commits/features/add-pton-builtin I have some ideas, which one do you recommend? @viktormalik
|
Done. |
Is your feature request related to a problem? Please describe.
One example:
This script may output a lot skbs, IP filtering should be added here.
Workaround 1
This prints error message: ERROR: strncmp() only supports string arguments (inet provided)
Workaround 2
This prints error message: ERROR: str() expects an integer or a pointer type as first argument (inet provided)
Workaround 3
This actually worked, but if the script isn't very human-readable.
Describe the solution you'd like
Solution 1: Add a new built-in func like pton, so we can compare numbers
Then this script can be hand over to anyone unfamiliar with hex to dig into network issues, IMHO, this would work great with the command line arguments #1945
Describe alternative solutions or features you've considered
Somehow fixing the case in workaround 1/2, but strncmp takes a length argument, which would be hard to determine.
The text was updated successfully, but these errors were encountered: