Commit 0d7da9dd authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net: add __rcu annotation to sk_filter

Add __rcu annotation to :
        (struct sock)->sk_filter

And use appropriate rcu primitives to reduce sparse warnings if
CONFIG_SPARSE_RCU_POINTER=y
Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1c87733d
...@@ -301,7 +301,7 @@ struct sock { ...@@ -301,7 +301,7 @@ struct sock {
const struct cred *sk_peer_cred; const struct cred *sk_peer_cred;
long sk_rcvtimeo; long sk_rcvtimeo;
long sk_sndtimeo; long sk_sndtimeo;
struct sk_filter *sk_filter; struct sk_filter __rcu *sk_filter;
void *sk_protinfo; void *sk_protinfo;
struct timer_list sk_timer; struct timer_list sk_timer;
ktime_t sk_stamp; ktime_t sk_stamp;
......
...@@ -89,8 +89,8 @@ int sk_filter(struct sock *sk, struct sk_buff *skb) ...@@ -89,8 +89,8 @@ int sk_filter(struct sock *sk, struct sk_buff *skb)
rcu_read_lock_bh(); rcu_read_lock_bh();
filter = rcu_dereference_bh(sk->sk_filter); filter = rcu_dereference_bh(sk->sk_filter);
if (filter) { if (filter) {
unsigned int pkt_len = sk_run_filter(skb, filter->insns, unsigned int pkt_len = sk_run_filter(skb, filter->insns, filter->len);
filter->len);
err = pkt_len ? pskb_trim(skb, pkt_len) : -EPERM; err = pkt_len ? pskb_trim(skb, pkt_len) : -EPERM;
} }
rcu_read_unlock_bh(); rcu_read_unlock_bh();
......
...@@ -1225,7 +1225,7 @@ struct sock *sk_clone(const struct sock *sk, const gfp_t priority) ...@@ -1225,7 +1225,7 @@ struct sock *sk_clone(const struct sock *sk, const gfp_t priority)
sock_reset_flag(newsk, SOCK_DONE); sock_reset_flag(newsk, SOCK_DONE);
skb_queue_head_init(&newsk->sk_error_queue); skb_queue_head_init(&newsk->sk_error_queue);
filter = newsk->sk_filter; filter = rcu_dereference_protected(newsk->sk_filter, 1);
if (filter != NULL) if (filter != NULL)
sk_filter_charge(newsk, filter); sk_filter_charge(newsk, filter);
......
...@@ -1413,7 +1413,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) ...@@ -1413,7 +1413,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
} }
} }
if (sk->sk_filter) { if (rcu_dereference_raw(sk->sk_filter)) {
if (udp_lib_checksum_complete(skb)) if (udp_lib_checksum_complete(skb))
goto drop; goto drop;
} }
......
...@@ -373,7 +373,7 @@ void raw6_icmp_error(struct sk_buff *skb, int nexthdr, ...@@ -373,7 +373,7 @@ void raw6_icmp_error(struct sk_buff *skb, int nexthdr,
static inline int rawv6_rcv_skb(struct sock * sk, struct sk_buff * skb) static inline int rawv6_rcv_skb(struct sock * sk, struct sk_buff * skb)
{ {
if ((raw6_sk(sk)->checksum || sk->sk_filter) && if ((raw6_sk(sk)->checksum || rcu_dereference_raw(sk->sk_filter)) &&
skb_checksum_complete(skb)) { skb_checksum_complete(skb)) {
atomic_inc(&sk->sk_drops); atomic_inc(&sk->sk_drops);
kfree_skb(skb); kfree_skb(skb);
......
...@@ -527,7 +527,7 @@ int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb) ...@@ -527,7 +527,7 @@ int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
} }
} }
if (sk->sk_filter) { if (rcu_dereference_raw(sk->sk_filter)) {
if (udp_lib_checksum_complete(skb)) if (udp_lib_checksum_complete(skb))
goto drop; goto drop;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment