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

Socket lookup BPF API from tc/xdp ingress does not respect VRF bindings. #5002

Closed
wants to merge 4 commits into from

Conversation

kernel-patches-daemon-bpf[bot]
Copy link

Pull request for series with
subject: Socket lookup BPF API from tc/xdp ingress does not respect VRF bindings.
version: 3
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=743268

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: f52cc62
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=743268
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: f52cc62
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=743268
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 2b5fdc0
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=743268
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 415d7a4
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=743268
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=743268 expired. Closing PR.

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 415d7a4
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=743775
version: 4

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 415d7a4
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=743775
version: 4

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 415d7a4
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=743775
version: 4

Change BPF helper socket lookup functions to use TC specific variants:
bpf_tc_sk_lookup_tcp() / bpf_tc_sk_lookup_udp() / bpf_tc_skc_lookup_tcp()
instead of sharing implementation with the cg / sk_skb hooking points.
This allows introducing a separate logic for the TC flow.

The tc functions are identical to the original code.

Acked-by: Stanislav Fomichev <sdf@google.com>
Reviewed-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
Reviewed-by: Eyal Birger <eyal.birger@gmail.com>
Signed-off-by: Gilad Sever <gilad9366@gmail.com>
skb->dev always exists in the tc flow. There is no need to use
bpf_skc_lookup(), bpf_sk_lookup() from this code path.

This change facilitates fixing the tc flow to be VRF aware.

Acked-by: Stanislav Fomichev <sdf@google.com>
Reviewed-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
Reviewed-by: Eyal Birger <eyal.birger@gmail.com>
Signed-off-by: Gilad Sever <gilad9366@gmail.com>
@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 415d7a4
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=743775
version: 4

When calling bpf_sk_lookup_tcp(), bpf_sk_lookup_udp() or
bpf_skc_lookup_tcp() from tc/xdp ingress, VRF socket bindings aren't
respoected, i.e. unbound sockets are returned, and bound sockets aren't
found.

VRF binding is determined by the sdif argument to sk_lookup(), however
when called from tc the IP SKB control block isn't initialized and thus
inet{,6}_sdif() always returns 0.

Fix by calculating sdif for the tc/xdp flows by observing the device's
l3 enslaved state.

The cg/sk_skb hooking points which are expected to support
inet{,6}_sdif() pass sdif=-1 which makes __bpf_skc_lookup() use the
existing logic.

Fixes: 6acc9b4 ("bpf: Add helper to retrieve socket in BPF")
Acked-by: Stanislav Fomichev <sdf@google.com>
Reviewed-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
Reviewed-by: Eyal Birger <eyal.birger@gmail.com>
Signed-off-by: Gilad Sever <gilad9366@gmail.com>
Verify that socket lookup via TC/XDP with all BPF APIs is VRF aware.

Reviewed-by: Eyal Birger <eyal.birger@gmail.com>
Signed-off-by: Gilad Sever <gilad9366@gmail.com>
Acked-by: Stanislav Fomichev <sdf@google.com>
@kernel-patches-daemon-bpf
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=743268 irrelevant now. Closing PR.

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