-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
datapath: support dhcpv4 discover as a valid lxc source ip #15980
Conversation
Add a new datapath option which allows endpoint to send a DHCP discover message which has been previously dropped by "Invalid source ip" filter in lxc_bpf program which by default allows only LXC_IPV4 as a source IP. With this option endpoints like OpenStack vms can ask for IP address using DHCP which is the standard way of IPAM in OS. Signed-off-by: Ondrej Blazek <ondra.blazkuj@gmail.com>
Could we somehow limit this to those endpoints? With k8s Pods we could maybe rely on annotations, but I'm not sure how that would work in your case, with OpenStack VMs. |
@@ -544,13 +544,23 @@ static __always_inline int handle_ipv4_from_lxc(struct __ctx_buff *ctx, | |||
|
|||
tuple.nexthdr = ip4->protocol; | |||
|
|||
if (unlikely(!is_valid_lxc_src_ipv4(ip4))) | |||
if (unlikely(!is_valid_lxc_src_ipv4(ip4))) { | |||
#ifndef ENABLE_DHCP_MESSAGES |
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 there are use cases for this besides DHCP, so maybe we should make it a bit more generic and allow all srcIP spoofing? I'm also worried of the impact is_valid_dhcpv4_message
could have on the BPF complexity.
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.
you mean you are thinking about having this as a part of is_valid_lxc_src_ipv4
func - for all packets? Also does it make sense to you to switch #ifndef
for #ifdef
for better extensibility/readability?
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 mean we should just accept packets if ENABLE_DHCP_MESSAGES
is defined, regardless of whether or not they are DHCP packets.
Well that's what |
I was wondering how to expose this to users, but I guess in your case, you simply use |
We actually use it like this https://github.com/oblazek/cilium/blob/ob-openstack/plugins/cilium-openstack/plugin/bridge.go#L239 I have created a new "plugin" (https://github.com/oblazek/cilium/blob/ob-openstack/plugins/cilium-openstack/) which allows us to register openstack vms to cilium (with labels - metadata in case of openstack). It's not finished yet, but functional. |
I think we should close this PR in favor of #16134. |
Add a new datapath option which allows endpoint to send
a DHCP discover message which has been previously dropped by
"Invalid source ip" filter in lxc_bpf program which by default
allows only LXC_IPV4 as a source IP.
With this option endpoints like OpenStack vms can ask for IP
address using DHCP which is the standard way of IPAM in OS.
Signed-off-by: Ondrej Blazek ondra.blazkuj@gmail.com
Without these changes:
With these changes: