Message ID | 20200320023426.60684-2-yuehaibing@huawei.com |
---|---|
State | Accepted |
Delegated to: | BPF Maintainers |
Headers | show |
Series | minor cleanups | expand |
On 3/19/20 7:34 PM, YueHaibing wrote: > If BPF_STREAM_PARSER is not set, gcc warns: > > net/ipv4/tcp_bpf.c:483:12: warning: 'tcp_bpf_sendpage' defined but not used [-Wunused-function] > net/ipv4/tcp_bpf.c:395:12: warning: 'tcp_bpf_sendmsg' defined but not used [-Wunused-function] > net/ipv4/tcp_bpf.c:13:13: warning: 'tcp_bpf_stream_read' defined but not used [-Wunused-function] > > Moves the unused functions into the #ifdef Maybe explicit "into the #ifdef CONFIG_BPF_STREAM_PARSER"? > > Reported-by: Hulk Robot <hulkci@huawei.com> > Fixes: f747632b608f ("bpf: sockmap: Move generic sockmap hooks from BPF TCP") > Signed-off-by: YueHaibing <yuehaibing@huawei.com> > Reviewed-by: Lorenz Bauer <lmb@cloudflare.com> > Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com> Acked-by: Yonghong Song <yhs@fb.com>
On 3/20/20 5:21 AM, Yonghong Song wrote: > On 3/19/20 7:34 PM, YueHaibing wrote: >> If BPF_STREAM_PARSER is not set, gcc warns: >> >> net/ipv4/tcp_bpf.c:483:12: warning: 'tcp_bpf_sendpage' defined but not used [-Wunused-function] >> net/ipv4/tcp_bpf.c:395:12: warning: 'tcp_bpf_sendmsg' defined but not used [-Wunused-function] >> net/ipv4/tcp_bpf.c:13:13: warning: 'tcp_bpf_stream_read' defined but not used [-Wunused-function] >> >> Moves the unused functions into the #ifdef > > Maybe explicit "into the #ifdef CONFIG_BPF_STREAM_PARSER"? > >> Reported-by: Hulk Robot <hulkci@huawei.com> >> Fixes: f747632b608f ("bpf: sockmap: Move generic sockmap hooks from BPF TCP") >> Signed-off-by: YueHaibing <yuehaibing@huawei.com> >> Reviewed-by: Lorenz Bauer <lmb@cloudflare.com> >> Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com> > > Acked-by: Yonghong Song <yhs@fb.com> Both applied and addressed feedback from Yonghong, thanks!
diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c index fe7b4fbc31c1..37c91f25cae3 100644 --- a/net/ipv4/tcp_bpf.c +++ b/net/ipv4/tcp_bpf.c @@ -10,19 +10,6 @@ #include <net/inet_common.h> #include <net/tls.h> -static bool tcp_bpf_stream_read(const struct sock *sk) -{ - struct sk_psock *psock; - bool empty = true; - - rcu_read_lock(); - psock = sk_psock(sk); - if (likely(psock)) - empty = list_empty(&psock->ingress_msg); - rcu_read_unlock(); - return !empty; -} - static int tcp_bpf_wait_data(struct sock *sk, struct sk_psock *psock, int flags, long timeo, int *err) { @@ -298,6 +285,20 @@ int tcp_bpf_sendmsg_redir(struct sock *sk, struct sk_msg *msg, } EXPORT_SYMBOL_GPL(tcp_bpf_sendmsg_redir); +#ifdef CONFIG_BPF_STREAM_PARSER +static bool tcp_bpf_stream_read(const struct sock *sk) +{ + struct sk_psock *psock; + bool empty = true; + + rcu_read_lock(); + psock = sk_psock(sk); + if (likely(psock)) + empty = list_empty(&psock->ingress_msg); + rcu_read_unlock(); + return !empty; +} + static int tcp_bpf_send_verdict(struct sock *sk, struct sk_psock *psock, struct sk_msg *msg, int *copied, int flags) { @@ -528,7 +529,6 @@ static int tcp_bpf_sendpage(struct sock *sk, struct page *page, int offset, return copied ? copied : err; } -#ifdef CONFIG_BPF_STREAM_PARSER enum { TCP_BPF_IPV4, TCP_BPF_IPV6,