Skip to content

Commit 94f6519

Browse files
nhormandavem330
authored andcommitted
SCTP: Reduce log spamming for sctp setsockopt
During a recent discussion regarding some sctp socket options, it was noted that we have several points at which we issue log warnings that can be flooded at an unbounded rate by any user. Fix this by converting all the pr_warns in the sctp_setsockopt path to be pr_warn_ratelimited. Note there are several debug level messages as well. I'm leaving those alone, as, if you turn on pr_debug, you likely want lots of verbosity. Signed-off-by: Neil Horman <nhorman@tuxdriver.com> CC: Vlad Yasevich <vyasevich@gmail.com> CC: David Miller <davem@davemloft.net> CC: netdev@vger.kernel.org Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 0a9a8bf commit 94f6519

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

net/sctp/socket.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2578,8 +2578,9 @@ static int sctp_setsockopt_delayed_ack(struct sock *sk,
25782578
if (params.sack_delay == 0 && params.sack_freq == 0)
25792579
return 0;
25802580
} else if (optlen == sizeof(struct sctp_assoc_value)) {
2581-
pr_warn("Use of struct sctp_assoc_value in delayed_ack socket option deprecated\n");
2582-
pr_warn("Use struct sctp_sack_info instead\n");
2581+
pr_warn_ratelimited(DEPRECATED
2582+
"Use of struct sctp_assoc_value in delayed_ack socket option.\n"
2583+
"Use struct sctp_sack_info instead\n");
25832584
if (copy_from_user(&params, optval, optlen))
25842585
return -EFAULT;
25852586

@@ -2994,8 +2995,9 @@ static int sctp_setsockopt_maxseg(struct sock *sk, char __user *optval, unsigned
29942995
int val;
29952996

29962997
if (optlen == sizeof(int)) {
2997-
pr_warn("Use of int in maxseg socket option deprecated\n");
2998-
pr_warn("Use struct sctp_assoc_value instead\n");
2998+
pr_warn_ratelimited(DEPRECATED
2999+
"Use of int in maxseg socket option.\n"
3000+
"Use struct sctp_assoc_value instead\n");
29993001
if (copy_from_user(&val, optval, optlen))
30003002
return -EFAULT;
30013003
params.assoc_id = 0;
@@ -3252,8 +3254,9 @@ static int sctp_setsockopt_maxburst(struct sock *sk,
32523254
int assoc_id = 0;
32533255

32543256
if (optlen == sizeof(int)) {
3255-
pr_warn("Use of int in max_burst socket option deprecated\n");
3256-
pr_warn("Use struct sctp_assoc_value instead\n");
3257+
pr_warn_ratelimited(DEPRECATED
3258+
"Use of int in max_burst socket option deprecated.\n"
3259+
"Use struct sctp_assoc_value instead\n");
32573260
if (copy_from_user(&val, optval, optlen))
32583261
return -EFAULT;
32593262
} else if (optlen == sizeof(struct sctp_assoc_value)) {
@@ -4573,8 +4576,9 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
45734576
if (copy_from_user(&params, optval, len))
45744577
return -EFAULT;
45754578
} else if (len == sizeof(struct sctp_assoc_value)) {
4576-
pr_warn("Use of struct sctp_assoc_value in delayed_ack socket option deprecated\n");
4577-
pr_warn("Use struct sctp_sack_info instead\n");
4579+
pr_warn_ratelimited(DEPRECATED
4580+
"Use of struct sctp_assoc_value in delayed_ack socket option.\n"
4581+
"Use struct sctp_sack_info instead\n");
45784582
if (copy_from_user(&params, optval, len))
45794583
return -EFAULT;
45804584
} else
@@ -5218,8 +5222,9 @@ static int sctp_getsockopt_maxseg(struct sock *sk, int len,
52185222
struct sctp_association *asoc;
52195223

52205224
if (len == sizeof(int)) {
5221-
pr_warn("Use of int in maxseg socket option deprecated\n");
5222-
pr_warn("Use struct sctp_assoc_value instead\n");
5225+
pr_warn_ratelimited(DEPRECATED
5226+
"Use of int in maxseg socket option.\n"
5227+
"Use struct sctp_assoc_value instead\n");
52235228
params.assoc_id = 0;
52245229
} else if (len >= sizeof(struct sctp_assoc_value)) {
52255230
len = sizeof(struct sctp_assoc_value);
@@ -5310,8 +5315,9 @@ static int sctp_getsockopt_maxburst(struct sock *sk, int len,
53105315
struct sctp_association *asoc;
53115316

53125317
if (len == sizeof(int)) {
5313-
pr_warn("Use of int in max_burst socket option deprecated\n");
5314-
pr_warn("Use struct sctp_assoc_value instead\n");
5318+
pr_warn_ratelimited(DEPRECATED
5319+
"Use of int in max_burst socket option.\n"
5320+
"Use struct sctp_assoc_value instead\n");
53155321
params.assoc_id = 0;
53165322
} else if (len >= sizeof(struct sctp_assoc_value)) {
53175323
len = sizeof(struct sctp_assoc_value);

0 commit comments

Comments
 (0)