mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 10:41:38 -04:00
BACKPORT: bpf: Add socket assign support
Add support for TPROXY via a new bpf helper, bpf_sk_assign(). This helper requires the BPF program to discover the socket via a call to bpf_sk*_lookup_*(), then pass this socket to the new helper. The helper takes its own reference to the socket in addition to any existing reference that may or may not currently be obtained for the duration of BPF processing. For the destination socket to receive the traffic, the traffic must be routed towards that socket via local route. The simplest example route is below, but in practice you may want to route traffic more narrowly (eg by CIDR): $ ip route add local default dev lo This patch avoids trying to introduce an extra bit into the skb->sk, as that would require more invasive changes to all code interacting with the socket to ensure that the bit is handled correctly, such as all error-handling cases along the path from the helper in BPF through to the orphan path in the input. Instead, we opt to use the destructor variable to switch on the prefetch of the socket. Change-Id: I66c9fce30fea682d2acaa741a6bbd46857083ed2 Signed-off-by: Joe Stringer <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Acked-by: Martin KaFai Lau <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
This commit is contained in:
parent
2172c9408e
commit
9974c2cee8
8 changed files with 104 additions and 2 deletions
|
|
@ -501,7 +501,8 @@ static struct sk_buff *ip_rcv_core(struct sk_buff *skb, struct net *net)
|
|||
IPCB(skb)->iif = skb->skb_iif;
|
||||
|
||||
/* Must drop socket now because of tproxy. */
|
||||
skb_orphan(skb);
|
||||
if (!skb_sk_is_prefetched(skb))
|
||||
skb_orphan(skb);
|
||||
|
||||
return skb;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue