aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/core/filter.c16
-rw-r--r--net/core/sock.c12
2 files changed, 17 insertions, 11 deletions
diff --git a/net/core/filter.c b/net/core/filter.c
index bd903aaf7aa7..fd607581ab50 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)
433 return err; 433 return err;
434} 434}
435 435
436int sk_detach_filter(struct sock *sk)
437{
438 int ret = -ENOENT;
439 struct sk_filter *filter;
440
441 rcu_read_lock_bh();
442 filter = rcu_dereference(sk->sk_filter);
443 if (filter) {
444 rcu_assign_pointer(sk->sk_filter, NULL);
445 sk_filter_release(sk, filter);
446 ret = 0;
447 }
448 rcu_read_unlock_bh();
449 return ret;
450}
451
436EXPORT_SYMBOL(sk_chk_filter); 452EXPORT_SYMBOL(sk_chk_filter);
437EXPORT_SYMBOL(sk_run_filter); 453EXPORT_SYMBOL(sk_run_filter);
diff --git a/net/core/sock.c b/net/core/sock.c
index d45ecdccc6a1..07101381b8b7 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,
428 char __user *optval, int optlen) 428 char __user *optval, int optlen)
429{ 429{
430 struct sock *sk=sock->sk; 430 struct sock *sk=sock->sk;
431 struct sk_filter *filter;
432 int val; 431 int val;
433 int valbool; 432 int valbool;
434 struct linger ling; 433 struct linger ling;
@@ -652,16 +651,7 @@ set_rcvbuf:
652 break; 651 break;
653 652
654 case SO_DETACH_FILTER: 653 case SO_DETACH_FILTER:
655 rcu_read_lock_bh(); 654 ret = sk_detach_filter(sk);
656 filter = rcu_dereference(sk->sk_filter);
657 if (filter) {
658 rcu_assign_pointer(sk->sk_filter, NULL);
659 sk_filter_release(sk, filter);
660 rcu_read_unlock_bh();
661 break;
662 }
663 rcu_read_unlock_bh();
664 ret = -ENONET;
665 break; 655 break;
666 656
667 case SO_PASSSEC: 657 case SO_PASSSEC: