automerge commit

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2-netsec@44970 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Automerge script
2006-10-12 19:02:56 +00:00
parent 2c9a7acf54
commit bf9aaf7beb
4 changed files with 31 additions and 0 deletions

View File

@@ -12966,10 +12966,13 @@ static int reload_config(void)
} else { } else {
/* Allow SIP clients on the same host to access us: */ /* Allow SIP clients on the same host to access us: */
const int reuseFlag = 1; const int reuseFlag = 1;
setsockopt(sipsock, SOL_SOCKET, SO_REUSEADDR, setsockopt(sipsock, SOL_SOCKET, SO_REUSEADDR,
(const char*)&reuseFlag, (const char*)&reuseFlag,
sizeof reuseFlag); sizeof reuseFlag);
ast_enable_packet_fragmentation(sipsock);
if (bind(sipsock, (struct sockaddr *)&bindaddr, sizeof(bindaddr)) < 0) { if (bind(sipsock, (struct sockaddr *)&bindaddr, sizeof(bindaddr)) < 0) {
ast_log(LOG_WARNING, "Failed to bind to %s:%d: %s\n", ast_log(LOG_WARNING, "Failed to bind to %s:%d: %s\n",
ast_inet_ntoa(iabuf, sizeof(iabuf), bindaddr.sin_addr), ntohs(bindaddr.sin_port), ast_inet_ntoa(iabuf, sizeof(iabuf), bindaddr.sin_addr), ntohs(bindaddr.sin_port),

View File

@@ -235,4 +235,19 @@ char *ast_process_quotes_and_slashes(char *start, char find, char replace_with);
int getloadavg(double *list, int nelem); int getloadavg(double *list, int nelem);
#endif #endif
/*!
\brief Disable PMTU discovery on a socket
\param sock The socket to manipulate
\return Nothing
On Linux, UDP sockets default to sending packets with the Dont Fragment (DF)
bit set. This is supposedly done to allow the application to do PMTU
discovery, but Asterisk does not do this.
Because of this, UDP packets sent by Asterisk that are larger than the MTU
of any hop in the path will be lost. This function can be called on a socket
to ensure that the DF bit will not be set.
*/
void ast_enable_packet_fragmentation(int sock);
#endif /* _ASTERISK_UTILS_H */ #endif /* _ASTERISK_UTILS_H */

View File

@@ -147,6 +147,8 @@ struct ast_netsock *ast_netsock_bindaddr(struct ast_netsock_list *list, struct i
if (setsockopt(netsocket, IPPROTO_IP, IP_TOS, &tos, sizeof(tos))) if (setsockopt(netsocket, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)))
ast_log(LOG_WARNING, "Unable to set TOS to %d\n", tos); ast_log(LOG_WARNING, "Unable to set TOS to %d\n", tos);
ast_enable_packet_fragmentation(netsocket);
ns = malloc(sizeof(struct ast_netsock)); ns = malloc(sizeof(struct ast_netsock));
if (ns) { if (ns) {
/* Establish I/O callback for socket read */ /* Establish I/O callback for socket read */

11
utils.c
View File

@@ -895,3 +895,14 @@ char *ast_process_quotes_and_slashes(char *start, char find, char replace_with)
*dataPut = 0; *dataPut = 0;
return dataPut; return dataPut;
} }
void ast_enable_packet_fragmentation(int sock)
{
#ifdef __linux__
int val = IP_PMTUDISC_DONT;
if (setsockopt(sock, IPPROTO_IP, IP_MTU_DISCOVER, &val, sizeof(val)))
ast_log(LOG_WARNING, "Unable to disable PMTU discovery. Large UDP packets may fail to be delivered when sent from this socket.\n");
#endif
}