-
-
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
IP address comparison is incomplete #2634
Comments
Hi, i have tested the upstream code, this problem also exists. Maybe we can provide the itoa function to convert an integer to an array. Or atoi to convert array to integer. |
In fact I tried to convert int32 into int8. but I failed. |
Ok, does itoa which convert integer into byte array meet your needs? |
I think the conversion could fulfil my need. |
emm, what's |
Now what I know are uint32, *int8, int8[4], I don't know if there is more. |
ok, see what you mean |
The problem I see here is that Looking at the pton implementation, it already does int->bytearray conversion so converting it back to int (by adding I'd prefer one of the following options:
I prefer the first option (the |
+1 for the first option Although I don't think we should call the function(s) itoa/atoi, as those already have well known meanings different from what is being described here (converting between integers and strings). Would a casting syntax work instead of a new builtin function? Relatedly, I've encountered problems where I wanted to treat an "unsigned int8[]" as a string within bpftrace. |
I think so, something like
Yeah, once we introduce casting from/to arrays, we can approach this, too. |
I like this idea, so the user could choose the right way to convert. |
@lut777 I suppose IPv6 addresses in the Linux Kernel are stored as arrays of 16 uint8 elements. So the example in the reference guide should be sufficient already. |
Good to learn that, Thank you! I will try this later in IPv6 comparison. |
What reproduces the bug?
I tried the following code.
As
pton(const string *addr)
described in doc, it could help me to select packets.But it failed as following error:
I find the pr #2248, which tried to solve this problem. But it doesn't seems quite finished.
bpftrace --info
[root@node1 bpf-probe]# bpftrace --info
System
OS: Linux 5.14.0-316.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Fri May 19 11:26:13 UTC 2023
Arch: x86_64
Build
version: v0.17.0
LLVM: 15.0.7
unsafe uprobe: no
bfd: yes
libdw (DWARF support): no
Kernel helpers
probe_read: yes
probe_read_str: yes
probe_read_user: yes
probe_read_user_str: yes
probe_read_kernel: yes
probe_read_kernel_str: yes
get_current_cgroup_id: yes
send_signal: yes
override_return: no
get_boot_ns: yes
dpath: yes
skboutput: no
Kernel features
Instruction limit: 1000000
Loop support: yes
btf: yes
map batch: yes
uprobe refcount (depends on Build:bcc bpf_attach_uprobe refcount): yes
Map types
hash: yes
percpu hash: yes
array: yes
percpu array: yes
stack_trace: yes
perf_event_array: yes
Probe types
kprobe: yes
tracepoint: yes
perf_event: yes
kfunc: yes
iter:task: yes
iter:task_file: yes
kprobe_multi: yes
raw_tp_special: yes
The text was updated successfully, but these errors were encountered: