Merge branch 'limit_eport_search'
This commit is contained in:
commit
b71e0c028f
|
@ -2,6 +2,7 @@ $Id: Changelog.txt,v 1.354 2014/02/28 12:14:29 nanard Exp $
|
||||||
|
|
||||||
2014/02/28:
|
2014/02/28:
|
||||||
log message when shutting down
|
log message when shutting down
|
||||||
|
natpmp : avoid hang when all external ports in use
|
||||||
|
|
||||||
2014/02/25:
|
2014/02/25:
|
||||||
add implementation of scheduled sendto (asyncsendto) in order
|
add implementation of scheduled sendto (asyncsendto) in order
|
||||||
|
|
|
@ -266,7 +266,11 @@ void ProcessIncomingNATPMPPacket(int s, unsigned char *msg_buff, int len,
|
||||||
} else if(iport==0
|
} else if(iport==0
|
||||||
|| !check_upnp_rule_against_permissions(upnppermlist, num_upnpperm, eport, senderaddr->sin_addr, iport)) {
|
|| !check_upnp_rule_against_permissions(upnppermlist, num_upnpperm, eport, senderaddr->sin_addr, iport)) {
|
||||||
resp[3] = 2; /* Not Authorized/Refused */
|
resp[3] = 2; /* Not Authorized/Refused */
|
||||||
} else do {
|
} else {
|
||||||
|
unsigned short eport_first;
|
||||||
|
char desc[64];
|
||||||
|
eport_first = eport;
|
||||||
|
do {
|
||||||
r = get_redirect_rule(ext_if_name, eport, proto,
|
r = get_redirect_rule(ext_if_name, eport, proto,
|
||||||
iaddr_old, sizeof(iaddr_old),
|
iaddr_old, sizeof(iaddr_old),
|
||||||
&iport_old, 0, 0, 0, 0,
|
&iport_old, 0, 0, 0, 0,
|
||||||
|
@ -284,11 +288,16 @@ void ProcessIncomingNATPMPPacket(int s, unsigned char *msg_buff, int len,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
eport++;
|
eport++;
|
||||||
|
if(eport == eport_first) { /* no external port available */
|
||||||
|
syslog(LOG_ERR, "Failed to find available eport for NAT-PMP %hu %s->%s:%hu",
|
||||||
|
eport, (proto==IPPROTO_TCP)?"tcp":"udp", senderaddrstr, iport);
|
||||||
|
resp[3] = 3; /* Failure */
|
||||||
|
break;
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{ /* do the redirection */
|
/* do the redirection */
|
||||||
char desc[64];
|
|
||||||
#if 0
|
#if 0
|
||||||
timestamp = (unsigned)(time(NULL) - startup_time)
|
timestamp = (unsigned)(time(NULL) - startup_time)
|
||||||
+ lifetime;
|
+ lifetime;
|
||||||
|
@ -314,8 +323,8 @@ void ProcessIncomingNATPMPPacket(int s, unsigned char *msg_buff, int len,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
} while(r==0);
|
} while(r==0);
|
||||||
|
}
|
||||||
*((uint16_t *)(resp+8)) = htons(iport); /* private port */
|
*((uint16_t *)(resp+8)) = htons(iport); /* private port */
|
||||||
*((uint16_t *)(resp+10)) = htons(eport); /* public port */
|
*((uint16_t *)(resp+10)) = htons(eport); /* public port */
|
||||||
*((uint32_t *)(resp+12)) = htonl(lifetime); /* Port Mapping lifetime */
|
*((uint32_t *)(resp+12)) = htonl(lifetime); /* Port Mapping lifetime */
|
||||||
|
|
Loading…
Reference in New Issue