- added a new ser.cfg option: sctp_enable = 0|1|2. 0 means disable
(equivalent with sctp_disable=yes), 1 enable (sctp_disable=no) and
2 is auto mode (sctp enabled only if supported by the OS).
- sctp is now by default in auto enable mode: enabled if supported by the OS
... | ... |
@@ -220,7 +220,9 @@ core: |
220 | 220 |
between the short name and long name in cache as CNAME record |
221 | 221 |
|
222 | 222 |
new config variables: |
223 |
- disable_sctp = yes/no - diable sctp support |
|
223 |
+ disable_sctp = yes/no - disable sctp support (default auto, see enable_sctp) |
|
224 |
+ enable_sctp = 0/1/2 - disable (0)/enable (1)/auto (2) sctp support, |
|
225 |
+ default auto (2) |
|
224 | 226 |
sctp_children = number - sctp children no (similar to udp children) |
225 | 227 |
sctp_socket_rcvbuf = number - size for the sctp socket receive buffer |
226 | 228 |
sctp_socket_sndbuf = number - size for the sctp socket send buffer |
... | ... |
@@ -324,6 +324,7 @@ TLS_CA_LIST "tls_ca_list" |
324 | 324 |
TLS_HANDSHAKE_TIMEOUT "tls_handshake_timeout" |
325 | 325 |
TLS_SEND_TIMEOUT "tls_send_timeout" |
326 | 326 |
DISABLE_SCTP "disable_sctp" |
327 |
+ENABLE_SCTP "enable_sctp" |
|
327 | 328 |
SCTP_CHILDREN "sctp_children" |
328 | 329 |
SCTP_SOCKET_RCVBUF "sctp_socket_rcvbuf"|"sctp_socket_receive_buffer" |
329 | 330 |
SCTP_SOCKET_SNDBUF "sctp_socket_sndbuf"|"sctp_socket_send_buffer" |
... | ... |
@@ -634,6 +635,7 @@ EAT_ABLE [\ \t\b\r] |
634 | 634 |
<INITIAL>{TLS_SEND_TIMEOUT} { count(); yylval.strval=yytext; |
635 | 635 |
return TLS_SEND_TIMEOUT; } |
636 | 636 |
<INITIAL>{DISABLE_SCTP} { count(); yylval.strval=yytext; return DISABLE_SCTP;} |
637 |
+<INITIAL>{ENABLE_SCTP} { count(); yylval.strval=yytext; return ENABLE_SCTP;} |
|
637 | 638 |
<INITIAL>{SCTP_CHILDREN} { count(); yylval.strval=yytext; |
638 | 639 |
return SCTP_CHILDREN; } |
639 | 640 |
<INITIAL>{SCTP_SOCKET_RCVBUF} { count(); yylval.strval=yytext; |
... | ... |
@@ -380,6 +380,7 @@ static void free_socket_id_lst(struct socket_id* i); |
380 | 380 |
%token TLS_PRIVATE_KEY |
381 | 381 |
%token TLS_CA_LIST |
382 | 382 |
%token DISABLE_SCTP |
383 |
+%token ENABLE_SCTP |
|
383 | 384 |
%token SCTP_CHILDREN |
384 | 385 |
%token SCTP_SOCKET_RCVBUF |
385 | 386 |
%token SCTP_SOCKET_SNDBUF |
... | ... |
@@ -1093,6 +1094,14 @@ assign_stm: |
1093 | 1093 |
#endif |
1094 | 1094 |
} |
1095 | 1095 |
| DISABLE_SCTP EQUAL error { yyerror("boolean value expected"); } |
1096 |
+ | ENABLE_SCTP EQUAL NUMBER { |
|
1097 |
+ #ifdef USE_SCTP |
|
1098 |
+ sctp_disable=($3<=1)?!$3:$3; |
|
1099 |
+ #else |
|
1100 |
+ warn("sctp support not compiled in"); |
|
1101 |
+ #endif |
|
1102 |
+ } |
|
1103 |
+ | ENABLE_SCTP EQUAL error { yyerror("boolean or number expected"); } |
|
1096 | 1104 |
| SCTP_CHILDREN EQUAL NUMBER { |
1097 | 1105 |
#ifdef USE_SCTP |
1098 | 1106 |
sctp_children_no=$3; |
... | ... |
@@ -221,7 +221,7 @@ Options:\n\ |
221 | 221 |
-W poll method\n" |
222 | 222 |
#endif |
223 | 223 |
#ifdef USE_SCTP |
224 |
-" -S Disable sctp\n\ |
|
224 |
+" -S disable sctp\n\ |
|
225 | 225 |
-O Number of sctp child processes (default: equal to `-n')\n" |
226 | 226 |
#endif /* USE_SCTP */ |
227 | 227 |
" -V Version number\n\ |
... | ... |
@@ -303,7 +303,7 @@ int tls_disable = 1; /* tls disabled by default */ |
303 | 303 |
#endif /* USE_TLS */ |
304 | 304 |
#ifdef USE_SCTP |
305 | 305 |
int sctp_children_no = 0; |
306 |
-int sctp_disable = 0; /* 1 if sctp is disabled */ |
|
306 |
+int sctp_disable = 2; /* 1 if sctp is disabled, 2 if auto mode, 0 enabled */ |
|
307 | 307 |
#endif /* USE_SCTP */ |
308 | 308 |
|
309 | 309 |
struct process_table *pt=0; /*array with children pids, 0= main proc, |
... | ... |
@@ -1819,6 +1819,21 @@ try_again: |
1819 | 1819 |
} |
1820 | 1820 |
#endif |
1821 | 1821 |
#ifdef USE_SCTP |
1822 |
+ if (sctp_disable!=1){ |
|
1823 |
+ /* fix it */ |
|
1824 |
+ if (sctp_check_support()==-1){ |
|
1825 |
+ /* check if sctp support is auto, if not warn about disabling it */ |
|
1826 |
+ if (sctp_disable!=2){ |
|
1827 |
+ fprintf(stderr, "ERROR: " "sctp enabled, but not supported by" |
|
1828 |
+ " the OS\n"); |
|
1829 |
+ goto error; |
|
1830 |
+ } |
|
1831 |
+ sctp_disable=1; |
|
1832 |
+ }else{ |
|
1833 |
+ /* sctp_disable!=1 and sctp supported => enable sctp */ |
|
1834 |
+ sctp_disable=0; |
|
1835 |
+ } |
|
1836 |
+ } |
|
1822 | 1837 |
if (!sctp_disable){ |
1823 | 1838 |
if (sctp_children_no<=0) sctp_children_no=children_no; |
1824 | 1839 |
} |
... | ... |
@@ -52,6 +52,21 @@ |
52 | 52 |
|
53 | 53 |
|
54 | 54 |
|
55 |
+/* check if the underlying OS supports sctp |
|
56 |
+ returns 0 if yes, -1 on error */ |
|
57 |
+int sctp_check_support() |
|
58 |
+{ |
|
59 |
+ int s; |
|
60 |
+ s = socket(PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP); |
|
61 |
+ if (s!=-1){ |
|
62 |
+ close(s); |
|
63 |
+ return 0; |
|
64 |
+ } |
|
65 |
+ return -1; |
|
66 |
+} |
|
67 |
+ |
|
68 |
+ |
|
69 |
+ |
|
55 | 70 |
/* init all the sockaddr_union members of the socket_info struct |
56 | 71 |
returns 0 on success and -1 on error */ |
57 | 72 |
inline static int sctp_init_su(struct socket_info* sock_info) |