Skip to content
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

Merged
merged 1 commit into from
Oct 25, 2021
Merged

support filter by ip6 address #26

merged 1 commit into from
Oct 25, 2021

Conversation

duanjiong
Copy link
Contributor

  1. ipv6 is a bit tricky to parse out the transport layer protocols, so we don't support transport layer filtering for now.
  2. rename filter_mark to filter_meta, other metadata should be supported later

Signed-off-by: Duan Jiong [email protected]

@duanjiong
Copy link
Contributor Author

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]>
Copy link
Member

@brb brb left a 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;
Copy link
Member

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())
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood, thank you.

}
} else if (ip_vsn == 6) {
/*
* The transport layer protocol is represented in ipv6 by the next header type, but there are other
Copy link
Member

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.

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)",
Copy link
Member

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.

return true;
}

//Should we introduce builtin memcmp etc., like bpf in cilium
Copy link
Member

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.

@duanjiong
Copy link
Contributor Author

It was reworked as suggested.

Copy link
Member

@brb brb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 🚀

@brb brb merged commit e35029e into cilium:master Oct 25, 2021
@brb
Copy link
Member

brb commented Jul 3, 2023

@duanjiong Hi, could you ACK #190?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants