Skip to content

Commit 78a1605

Browse files
author
Martin KaFai Lau
committed
Merge branch 'bpf-misc-changes-around-af_unix'
Kuniyuki Iwashima says: ==================== bpf: Misc changes around AF_UNIX. Patch 1 adapts sk_is_XXX() helpers in __cgroup_bpf_run_filter_sock_addr(). Patch 2 removes an unnecessary sk_fullsock() in bpf_skc_to_unix_sock(). ==================== Link: https://patch.msgid.link/20260203213442.682838-1-kuniyu@google.com Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
2 parents b28dac3 + c26b098 commit 78a1605

2 files changed

Lines changed: 2 additions & 6 deletions

File tree

kernel/bpf/cgroup.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,11 +1680,7 @@ int __cgroup_bpf_run_filter_sock_addr(struct sock *sk,
16801680
struct cgroup *cgrp;
16811681
int ret;
16821682

1683-
/* Check socket family since not all sockets represent network
1684-
* endpoint (e.g. AF_UNIX).
1685-
*/
1686-
if (sk->sk_family != AF_INET && sk->sk_family != AF_INET6 &&
1687-
sk->sk_family != AF_UNIX)
1683+
if (!sk_is_inet(sk) && !sk_is_unix(sk))
16881684
return 0;
16891685

16901686
if (!ctx.uaddr) {

net/core/filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12021,7 +12021,7 @@ BPF_CALL_1(bpf_skc_to_unix_sock, struct sock *, sk)
1202112021
* trigger an explicit type generation here.
1202212022
*/
1202312023
BTF_TYPE_EMIT(struct unix_sock);
12024-
if (sk && sk_fullsock(sk) && sk->sk_family == AF_UNIX)
12024+
if (sk && sk_is_unix(sk))
1202512025
return (unsigned long)sk;
1202612026

1202712027
return (unsigned long)NULL;

0 commit comments

Comments
 (0)