diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2007-10-18 00:21:26 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-10-18 00:21:26 -0400 |
commit | 55b333253d5bcafbe187b50474e40789301c53c6 (patch) | |
tree | dbea170b01196473c95d3d558bfce00bc17187fe /net/core | |
parent | d114f399b4da6fa7f9da3bbf1fb841370c11e788 (diff) |
[NET]: Introduce the sk_detach_filter() call
Filter is attached in a separate function, so do the
same for filter detaching.
This also removes one variable sock_setsockopt().
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-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 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 | ||
436 | int 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 | |||
436 | EXPORT_SYMBOL(sk_chk_filter); | 452 | EXPORT_SYMBOL(sk_chk_filter); |
437 | EXPORT_SYMBOL(sk_run_filter); | 453 | EXPORT_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: |