Skip to content

Commit 05ae2fb

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: nft_socket: make cgroup match work in input too
cgroupv2 helper function ignores the already-looked up sk and uses skb->sk instead. Just pass sk from the calling function instead; this will make cgroup matching work for udp and tcp in input even when edemux did not set skb->sk already. Fixes: e0bb96d ("netfilter: nft_socket: add support for cgroupsv2") Signed-off-by: Florian Westphal <fw@strlen.de> Tested-by: Topi Miettinen <toiwoton@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent e8a64bb commit 05ae2fb

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

net/netfilter/nft_socket.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,11 @@ static void nft_socket_wildcard(const struct nft_pktinfo *pkt,
3737

3838
#ifdef CONFIG_SOCK_CGROUP_DATA
3939
static noinline bool
40-
nft_sock_get_eval_cgroupv2(u32 *dest, const struct nft_pktinfo *pkt, u32 level)
40+
nft_sock_get_eval_cgroupv2(u32 *dest, struct sock *sk, const struct nft_pktinfo *pkt, u32 level)
4141
{
42-
struct sock *sk = skb_to_full_sk(pkt->skb);
4342
struct cgroup *cgrp;
4443

45-
if (!sk || !sk_fullsock(sk) || !net_eq(nft_net(pkt), sock_net(sk)))
44+
if (!sk_fullsock(sk))
4645
return false;
4746

4847
cgrp = sock_cgroup_ptr(&sk->sk_cgrp_data);
@@ -109,7 +108,7 @@ static void nft_socket_eval(const struct nft_expr *expr,
109108
break;
110109
#ifdef CONFIG_SOCK_CGROUP_DATA
111110
case NFT_SOCKET_CGROUPV2:
112-
if (!nft_sock_get_eval_cgroupv2(dest, pkt, priv->level)) {
111+
if (!nft_sock_get_eval_cgroupv2(dest, sk, pkt, priv->level)) {
113112
regs->verdict.code = NFT_BREAK;
114113
return;
115114
}

0 commit comments

Comments
 (0)