aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/sock.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/core/sock.c')
-rw-r--r--net/core/sock.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/net/core/sock.c b/net/core/sock.c
index 2029d095b4c5..98b243a5b323 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -419,6 +419,14 @@ out:
419 return ret; 419 return ret;
420} 420}
421 421
422static inline void sock_valbool_flag(struct sock *sk, int bit, int valbool)
423{
424 if (valbool)
425 sock_set_flag(sk, bit);
426 else
427 sock_reset_flag(sk, bit);
428}
429
422/* 430/*
423 * This is meant for all protocols to use and covers goings on 431 * This is meant for all protocols to use and covers goings on
424 * at the socket level. Everything here is generic. 432 * at the socket level. Everything here is generic.
@@ -463,11 +471,8 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
463 case SO_DEBUG: 471 case SO_DEBUG:
464 if (val && !capable(CAP_NET_ADMIN)) { 472 if (val && !capable(CAP_NET_ADMIN)) {
465 ret = -EACCES; 473 ret = -EACCES;
466 } 474 } else
467 else if (valbool) 475 sock_valbool_flag(sk, SOCK_DBG, valbool);
468 sock_set_flag(sk, SOCK_DBG);
469 else
470 sock_reset_flag(sk, SOCK_DBG);
471 break; 476 break;
472 case SO_REUSEADDR: 477 case SO_REUSEADDR:
473 sk->sk_reuse = valbool; 478 sk->sk_reuse = valbool;
@@ -477,10 +482,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
477 ret = -ENOPROTOOPT; 482 ret = -ENOPROTOOPT;
478 break; 483 break;
479 case SO_DONTROUTE: 484 case SO_DONTROUTE:
480 if (valbool) 485 sock_valbool_flag(sk, SOCK_LOCALROUTE, valbool);
481 sock_set_flag(sk, SOCK_LOCALROUTE);
482 else
483 sock_reset_flag(sk, SOCK_LOCALROUTE);
484 break; 486 break;
485 case SO_BROADCAST: 487 case SO_BROADCAST:
486 sock_valbool_flag(sk, SOCK_BROADCAST, valbool); 488 sock_valbool_flag(sk, SOCK_BROADCAST, valbool);