From 66d6fd532282fda0cda0ca31d93ff09044f1386a Mon Sep 17 00:00:00 2001 From: Michael Tuexen Date: Sun, 23 Apr 2023 17:48:05 +0200 Subject: [PATCH] sctp: use constants from RFC 8260 to improve compliance Keep the old constants for backwards compatibility. MFC after: 1 week --- sys/netinet/sctp.h | 23 ++++++++++++++++------- sys/netinet/sctp_ss_functions.c | 10 +++++----- sys/netinet/sctp_usrreq.c | 18 +++++++++--------- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/sys/netinet/sctp.h b/sys/netinet/sctp.h index 95dd85c5d8c0..0b3f716ccefd 100644 --- a/sys/netinet/sctp.h +++ b/sys/netinet/sctp.h @@ -192,8 +192,11 @@ struct sctp_paramhdr { /* JRS - Pluggable Congestion Control Socket option */ #define SCTP_PLUGGABLE_CC 0x00001202 /* RS - Pluggable Stream Scheduling Socket option */ -#define SCTP_PLUGGABLE_SS 0x00001203 -#define SCTP_SS_VALUE 0x00001204 +#define SCTP_STREAM_SCHEDULER 0x00001203 +#define SCTP_STREAM_SCHEDULER_VALUE 0x00001204 +/* The next two are for backwards compatibility. */ +#define SCTP_PLUGGABLE_SS SCTP_STREAM_SCHEDULER +#define SCTP_SS_VALUE SCTP_STREAM_SCHEDULER_VALUE #define SCTP_CC_OPTION 0x00001205 /* Options for CC * modules */ /* For I-DATA */ @@ -309,15 +312,21 @@ struct sctp_paramhdr { /* Default simple round-robin */ #define SCTP_SS_DEFAULT 0x00000000 /* Real round-robin */ -#define SCTP_SS_ROUND_ROBIN 0x00000001 +#define SCTP_SS_RR 0x00000001 /* Real round-robin per packet */ -#define SCTP_SS_ROUND_ROBIN_PACKET 0x00000002 +#define SCTP_SS_RR_PKT 0x00000002 /* Priority */ -#define SCTP_SS_PRIORITY 0x00000003 +#define SCTP_SS_PRIO 0x00000003 /* Fair Bandwidth */ -#define SCTP_SS_FAIR_BANDWITH 0x00000004 +#define SCTP_SS_FB 0x00000004 /* First-come, first-serve */ -#define SCTP_SS_FIRST_COME 0x00000005 +#define SCTP_SS_FCFS 0x00000005 +/* The next five are for backwards compatibility. */ +#define SCTP_SS_ROUND_ROBIN SCTP_SS_RR +#define SCTP_SS_ROUND_ROBIN_PACKET SCTP_SS_RR_PKT +#define SCTP_SS_PRIORITY SCTP_SS_PRIO +#define SCTP_SS_FAIR_BANDWITH SCTP_SS_FB +#define SCTP_SS_FIRST_COME SCTP_SS_FCFS /* fragment interleave constants * setting must be one of these or diff --git a/sys/netinet/sctp_ss_functions.c b/sys/netinet/sctp_ss_functions.c index 049c93767125..465a2bc7de5c 100644 --- a/sys/netinet/sctp_ss_functions.c +++ b/sys/netinet/sctp_ss_functions.c @@ -952,7 +952,7 @@ const struct sctp_ss_functions sctp_ss_functions[] = { .sctp_ss_set_value = sctp_ss_default_set_value, .sctp_ss_is_user_msgs_incomplete = sctp_ss_default_is_user_msgs_incomplete }, -/* SCTP_SS_ROUND_ROBIN */ +/* SCTP_SS_RR */ { .sctp_ss_init = sctp_ss_default_init, .sctp_ss_clear = sctp_ss_default_clear, @@ -967,7 +967,7 @@ const struct sctp_ss_functions sctp_ss_functions[] = { .sctp_ss_set_value = sctp_ss_default_set_value, .sctp_ss_is_user_msgs_incomplete = sctp_ss_default_is_user_msgs_incomplete }, -/* SCTP_SS_ROUND_ROBIN_PACKET */ +/* SCTP_SS_RR_PKT */ { .sctp_ss_init = sctp_ss_default_init, .sctp_ss_clear = sctp_ss_default_clear, @@ -982,7 +982,7 @@ const struct sctp_ss_functions sctp_ss_functions[] = { .sctp_ss_set_value = sctp_ss_default_set_value, .sctp_ss_is_user_msgs_incomplete = sctp_ss_default_is_user_msgs_incomplete }, -/* SCTP_SS_PRIORITY */ +/* SCTP_SS_PRIO */ { .sctp_ss_init = sctp_ss_default_init, .sctp_ss_clear = sctp_ss_prio_clear, @@ -997,7 +997,7 @@ const struct sctp_ss_functions sctp_ss_functions[] = { .sctp_ss_set_value = sctp_ss_prio_set_value, .sctp_ss_is_user_msgs_incomplete = sctp_ss_default_is_user_msgs_incomplete }, -/* SCTP_SS_FAIR_BANDWITH */ +/* SCTP_SS_FB */ { .sctp_ss_init = sctp_ss_default_init, .sctp_ss_clear = sctp_ss_fb_clear, @@ -1012,7 +1012,7 @@ const struct sctp_ss_functions sctp_ss_functions[] = { .sctp_ss_set_value = sctp_ss_default_set_value, .sctp_ss_is_user_msgs_incomplete = sctp_ss_default_is_user_msgs_incomplete }, -/* SCTP_SS_FIRST_COME */ +/* SCTP_SS_FCFS */ { .sctp_ss_init = sctp_ss_fcfs_init, .sctp_ss_clear = sctp_ss_fcfs_clear, diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c index 65edfb49a955..6e17545c9a3b 100644 --- a/sys/netinet/sctp_usrreq.c +++ b/sys/netinet/sctp_usrreq.c @@ -1738,7 +1738,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, } break; } - case SCTP_PLUGGABLE_SS: + case SCTP_STREAM_SCHEDULER: { struct sctp_assoc_value *av; @@ -1765,7 +1765,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, } break; } - case SCTP_SS_VALUE: + case SCTP_STREAM_SCHEDULER_VALUE: { struct sctp_stream_value *av; @@ -4033,17 +4033,17 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, } break; } - case SCTP_PLUGGABLE_SS: + case SCTP_STREAM_SCHEDULER: { struct sctp_assoc_value *av; SCTP_CHECK_AND_CAST(av, optval, struct sctp_assoc_value, optsize); if ((av->assoc_value != SCTP_SS_DEFAULT) && - (av->assoc_value != SCTP_SS_ROUND_ROBIN) && - (av->assoc_value != SCTP_SS_ROUND_ROBIN_PACKET) && - (av->assoc_value != SCTP_SS_PRIORITY) && - (av->assoc_value != SCTP_SS_FAIR_BANDWITH) && - (av->assoc_value != SCTP_SS_FIRST_COME)) { + (av->assoc_value != SCTP_SS_RR) && + (av->assoc_value != SCTP_SS_RR_PKT) && + (av->assoc_value != SCTP_SS_PRIO) && + (av->assoc_value != SCTP_SS_FB) && + (av->assoc_value != SCTP_SS_FCFS)) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); error = EINVAL; break; @@ -4082,7 +4082,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, } break; } - case SCTP_SS_VALUE: + case SCTP_STREAM_SCHEDULER_VALUE: { struct sctp_stream_value *av;