diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/core/filter.c | 16 | ||||
-rw-r--r-- | net/core/sock.c | 12 |
2 files changed, 17 insertions, 11 deletions
diff --git a/net/core/filter.c b/net/core/filter.c index bd903aaf7aa..fd607581ab5 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -433,5 +433,21 @@ int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk) return err; } +int sk_detach_filter(struct sock *sk) +{ + int ret = -ENOENT; + struct sk_filter *filter; + + rcu_read_lock_bh(); + filter = rcu_dereference(sk->sk_filter); + if (filter) { + rcu_assign_pointer(sk->sk_filter, NULL); + sk_filter_release(sk, filter); + ret = 0; + } + rcu_read_unlock_bh(); + return ret; +} + EXPORT_SYMBOL(sk_chk_filter); EXPORT_SYMBOL(sk_run_filter); diff --git a/net/core/sock.c b/net/core/sock.c index d45ecdccc6a..07101381b8b 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -428,7 +428,6 @@ int sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, int optlen) { struct sock *sk=sock->sk; - struct sk_filter *filter; int val; int valbool; struct linger ling; @@ -652,16 +651,7 @@ set_rcvbuf: break; case SO_DETACH_FILTER: - rcu_read_lock_bh(); - filter = rcu_dereference(sk->sk_filter); - if (filter) { - rcu_assign_pointer(sk->sk_filter, NULL); - sk_filter_release(sk, filter); - rcu_read_unlock_bh(); - break; - } - rcu_read_unlock_bh(); - ret = -ENONET; + ret = sk_detach_filter(sk); break; case SO_PASSSEC: |