Bring the interface down if sending broadcast packets fails for any reason

This commit is contained in:
Jeremy Lakeman 2013-08-28 16:25:05 +09:30
parent b916363b40
commit d2a88b8b2d

View File

@ -912,8 +912,9 @@ overlay_broadcast_ensemble(struct network_destination *destination,
bytes, len, 0, (struct sockaddr *)&destination->address, sizeof(destination->address)) != len){ bytes, len, 0, (struct sockaddr *)&destination->address, sizeof(destination->address)) != len){
int e=errno; int e=errno;
WHY_perror("sendto(c)"); WHY_perror("sendto(c)");
// only close the interface on some kinds of errors // close the interface if we had any error while sending broadcast packets,
if (e==ENETDOWN || e==EINVAL) // unicast packets should not bring the interface down
if (destination == interface->destination)
overlay_interface_close(interface); overlay_interface_close(interface);
// TODO mark unicast destination as failed // TODO mark unicast destination as failed
return -1; return -1;