BACKPORT: UPSTREAM: bpf: pass sk to helper functions

Cherrypick from commit 8f917bba0042f1e3b7693743fbe9782709e936e7

BPF helper functions access socket fields through skb->sk. This is not
set in ingress cgroup and socket filters. The association is only made
in skb_set_owner_r once the filter has accepted the packet. Sk is
available as socket lookup has taken place.

Temporarily set skb->sk to sk in these cases.

Signed-off-by: Willem de Bruijn <willemb@google.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Bug: 30950746
Change-Id: Ifcbcbe2ab2882dc79c56f9707be1d6aef08c7fd3
2 files changed