Browse code

sctp: set TOS and ignore unsuported socket options

- set TOS
- ignore non-critical unsuported socket options for better compatibility with
older kernels (e.g. 2.6.18 does not support SCTP_FRAGMENT_INTERLEAVE or
SCTP_PARTIAL_DELIVERY_POINT)

Andrei Pelinescu-Onciul authored on 01/10/2008 17:32:36
Showing 1 changed files
... ...
@@ -83,6 +83,9 @@ error:
83 83
 
84 84
 
85 85
 /* set common (for one to many and one to one) sctp socket options
86
+   tries to ignore non-critical errors (it will only log them), for
87
+   improved portability (for example older linux kernel version support
88
+   only a limited number of sctp socket options)
86 89
    returns 0 on success, -1 on error */
87 90
 static int sctp_init_sock_opt_common(int s)
88 91
 {
... ...
@@ -90,6 +93,14 @@ static int sctp_init_sock_opt_common(int s)
90 90
 	int optval;
91 91
 	socklen_t optlen;
92 92
 	
93
+	/* set tos */
94
+	optval = tos;
95
+	if (setsockopt(s, IPPROTO_IP, IP_TOS, (void*)&optval,sizeof(optval)) ==-1){
96
+		LOG(L_WARN, "WARNING: sctp_init_sock_opt_common: setsockopt tos: %s\n",
97
+				strerror(errno));
98
+		/* continue since this is not critical */
99
+	}
100
+	
93 101
 	/* set receive buffer: SO_RCVBUF*/
94 102
 	if (sctp_options.sctp_so_rcvbuf){
95 103
 		optval=sctp_options.sctp_so_rcvbuf;
... ...
@@ -120,7 +131,7 @@ static int sctp_init_sock_opt_common(int s)
120 120
 					(void*)&optval, sizeof(optval)) ==-1){
121 121
 		LOG(L_ERR, "ERROR: sctp_init_sock_opt_common: setsockopt: "
122 122
 					"SCTP_FRAGMENT_INTERLEAVE: %s\n", strerror(errno));
123
-		goto error;
123
+		/* try to continue */
124 124
 	}
125 125
 	
126 126
 	/* turn off partial delivery: on linux setting SCTP_PARTIAL_DELIVERY_POINT
... ...
@@ -132,14 +143,15 @@ static int sctp_init_sock_opt_common(int s)
132 132
 					(void*)&optval, &optlen) ==-1){
133 133
 		LOG(L_ERR, "ERROR: sctp_init_sock_opt_common: getsockopt: "
134 134
 						"SO_RCVBUF: %s\n", strerror(errno));
135
-		goto error;
135
+		/* try to continue */
136
+		optval=0;
136 137
 	}
137 138
 	if (setsockopt(s, IPPROTO_SCTP, SCTP_PARTIAL_DELIVERY_POINT,
138 139
 					(void*)&optval, sizeof(optval)) ==-1){
139 140
 		LOG(L_ERR, "ERROR: sctp_init_sock_opt_common: setsockopt: "
140 141
 						"SCTP_PARTIAL_DELIVERY_POINT (%d): %s\n",
141 142
 						optval, strerror(errno));
142
-		goto error;
143
+		/* try to continue */
143 144
 	}
144 145
 	
145 146
 	/* nagle / no delay */
... ...
@@ -191,8 +203,9 @@ static int sctp_init_sock_opt_common(int s)
191 191
 	}
192 192
 	
193 193
 	return 0;
194
-error:
194
+/*error:
195 195
 	return -1;
196
+*/
196 197
 }
197 198
 
198 199