提交 e06b5bbc 编写于 作者: J Jakub Sitnicki 提交者: Daniel Borkmann

selftests/bpf: Use constants for socket states in sock_fields test

Replace magic numbers in BPF code with constants from bpf.h, so that they
don't require an explanation in the comments.
Signed-off-by: NJakub Sitnicki <jakub@cloudflare.com>
Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
Acked-by: NMartin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/20220317113920.1068535-4-jakub@cloudflare.com
上级 2d2202ba
...@@ -134,11 +134,11 @@ int egress_read_sock_fields(struct __sk_buff *skb) ...@@ -134,11 +134,11 @@ int egress_read_sock_fields(struct __sk_buff *skb)
if (!sk) if (!sk)
RET_LOG(); RET_LOG();
/* Not the testing egress traffic or /* Not testing the egress traffic or the listening socket,
* TCP_LISTEN (10) socket will be copied at the ingress side. * which are covered by the cgroup_skb/ingress test program.
*/ */
if (sk->family != AF_INET6 || !is_loopback6(sk->src_ip6) || if (sk->family != AF_INET6 || !is_loopback6(sk->src_ip6) ||
sk->state == 10) sk->state == BPF_TCP_LISTEN)
return CG_OK; return CG_OK;
if (sk->src_port == bpf_ntohs(srv_sa6.sin6_port)) { if (sk->src_port == bpf_ntohs(srv_sa6.sin6_port)) {
...@@ -232,8 +232,8 @@ int ingress_read_sock_fields(struct __sk_buff *skb) ...@@ -232,8 +232,8 @@ int ingress_read_sock_fields(struct __sk_buff *skb)
sk->src_port != bpf_ntohs(srv_sa6.sin6_port)) sk->src_port != bpf_ntohs(srv_sa6.sin6_port))
return CG_OK; return CG_OK;
/* Only interested in TCP_LISTEN */ /* Only interested in the listening socket */
if (sk->state != 10) if (sk->state != BPF_TCP_LISTEN)
return CG_OK; return CG_OK;
/* It must be a fullsock for cgroup_skb/ingress prog */ /* It must be a fullsock for cgroup_skb/ingress prog */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册