Mercurial > dropbear
comparison dbutil.c @ 964:67ff2be856ff coverity
merge
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 08 Aug 2014 21:26:07 +0800 |
parents | db9fa5971d24 |
children | 6fb4c010c448 |
comparison
equal
deleted
inserted
replaced
956:46a0b2ebc22c | 964:67ff2be856ff |
---|---|
200 | 200 |
201 void set_sock_priority(int sock, enum dropbear_prio prio) { | 201 void set_sock_priority(int sock, enum dropbear_prio prio) { |
202 | 202 |
203 int iptos_val = 0, so_prio_val = 0, rc; | 203 int iptos_val = 0, so_prio_val = 0, rc; |
204 | 204 |
205 /* Don't log ENOTSOCK errors so that this can harmlessly be called | |
206 * on a client '-J' proxy pipe */ | |
207 | |
205 /* set the TOS bit for either ipv4 or ipv6 */ | 208 /* set the TOS bit for either ipv4 or ipv6 */ |
206 #ifdef IPTOS_LOWDELAY | 209 #ifdef IPTOS_LOWDELAY |
207 if (prio == DROPBEAR_PRIO_LOWDELAY) { | 210 if (prio == DROPBEAR_PRIO_LOWDELAY) { |
208 iptos_val = IPTOS_LOWDELAY; | 211 iptos_val = IPTOS_LOWDELAY; |
209 } else if (prio == DROPBEAR_PRIO_BULK) { | 212 } else if (prio == DROPBEAR_PRIO_BULK) { |
210 iptos_val = IPTOS_THROUGHPUT; | 213 iptos_val = IPTOS_THROUGHPUT; |
211 } | 214 } |
212 #if defined(IPPROTO_IPV6) && defined(IPV6_TCLASS) | 215 #if defined(IPPROTO_IPV6) && defined(IPV6_TCLASS) |
213 rc = setsockopt(sock, IPPROTO_IPV6, IPV6_TCLASS, (void*)&iptos_val, sizeof(iptos_val)); | 216 rc = setsockopt(sock, IPPROTO_IPV6, IPV6_TCLASS, (void*)&iptos_val, sizeof(iptos_val)); |
214 if (rc < 0) { | 217 if (rc < 0 && errno != ENOTSOCK) { |
215 TRACE(("Couldn't set IPV6_TCLASS (%s)", strerror(errno))); | 218 TRACE(("Couldn't set IPV6_TCLASS (%s)", strerror(errno))); |
216 } | 219 } |
217 #endif | 220 #endif |
218 rc = setsockopt(sock, IPPROTO_IP, IP_TOS, (void*)&iptos_val, sizeof(iptos_val)); | 221 rc = setsockopt(sock, IPPROTO_IP, IP_TOS, (void*)&iptos_val, sizeof(iptos_val)); |
219 if (rc < 0) { | 222 if (rc < 0 && errno != ENOTSOCK) { |
220 TRACE(("Couldn't set IP_TOS (%s)", strerror(errno))); | 223 TRACE(("Couldn't set IP_TOS (%s)", strerror(errno))); |
221 } | 224 } |
222 #endif | 225 #endif |
223 | 226 |
224 #ifdef SO_PRIORITY | 227 #ifdef SO_PRIORITY |
227 } else if (prio == DROPBEAR_PRIO_BULK) { | 230 } else if (prio == DROPBEAR_PRIO_BULK) { |
228 so_prio_val = TC_PRIO_BULK; | 231 so_prio_val = TC_PRIO_BULK; |
229 } | 232 } |
230 /* linux specific, sets QoS class. see tc-prio(8) */ | 233 /* linux specific, sets QoS class. see tc-prio(8) */ |
231 rc = setsockopt(sock, SOL_SOCKET, SO_PRIORITY, (void*) &so_prio_val, sizeof(so_prio_val)); | 234 rc = setsockopt(sock, SOL_SOCKET, SO_PRIORITY, (void*) &so_prio_val, sizeof(so_prio_val)); |
232 if (rc < 0) | 235 if (rc < 0 && errno != ENOTSOCK) |
233 dropbear_log(LOG_WARNING, "Couldn't set SO_PRIORITY (%s)", | 236 dropbear_log(LOG_WARNING, "Couldn't set SO_PRIORITY (%s)", |
234 strerror(errno)); | 237 strerror(errno)); |
235 #endif | 238 #endif |
236 | 239 |
237 } | 240 } |