-
Notifications
You must be signed in to change notification settings - Fork 181
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 filter by ip6 address #26
Conversation
fix #6 |
1. assume that there are no other ipv6 extension headers and the default is to handle layer 4 protocols directly. 2. rename filter_mark to filter_meta, other metadata should be supported later Signed-off-by: Duan Jiong <[email protected]>
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! A few things.
u8 proto; | ||
u8 pad[7]; | ||
u8 l4_proto; | ||
u16 l3_proto; |
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 tuple sizes don't match in C and Go. In Go it's 42 bytes, in C - 40 bytes. To make it 40 bytes in both, you need to swap l4_proto
with l3_proto
.
Because of that the event_t
doesn't match with Event
.
You can use the following to validate offsets and size (until #28 has been fixed):
$ clang -O2 -g -I./headers -target bpf -c kprobe_pwru.c -o foo.o
$ pahole foo.o | less
# meanwhile in Go add the following function:
func init() {
fmt.Println("tuple", reflect.TypeOf(Tuple{}).Size())
fmt.Println("meta", reflect.TypeOf(Meta{}).Size())
fmt.Println("event", reflect.TypeOf(Event{}).Size())
}
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.
Understood, thank you.
bpf/kprobe_pwru.c
Outdated
} | ||
} else if (ip_vsn == 6) { | ||
/* | ||
* The transport layer protocol is represented in ipv6 by the next header type, but there are other |
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 think it's fine to assume that IPv6 packets with extension headers can be ignored if the filter {s,d}port is set. So you can expect that the next header type will be pointing to the L4.
internal/pwru/output.go
Outdated
u32ToNetIPv4(event.Tuple.Saddr), byteorder.NetworkToHost16(event.Tuple.Sport), | ||
u32ToNetIPv4(event.Tuple.Daddr), byteorder.NetworkToHost16(event.Tuple.Dport), | ||
protoToStr(event.Tuple.Proto)) | ||
fmt.Printf(" [%s]:%d->[%s]:%d(%s)", |
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.
Let's use the square brackets only for the IPv6 type addrs.
bpf/kprobe_pwru.c
Outdated
return true; | ||
} | ||
|
||
//Should we introduce builtin memcmp etc., like bpf in cilium |
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.
Let's instead create a GH issue to track this.
da6ca33
to
2ed5b6b
Compare
It was reworked as suggested. |
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 🚀
@duanjiong Hi, could you ACK #190? |
Signed-off-by: Duan Jiong [email protected]