X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Froute.c;h=e3bcf3bb09ffc302cc135167212c18019fa1abdd;hp=4e7f7e585db410c41f733a582aae7c2540064e43;hb=50af33d01f425983dd2b1d7b61092a6325be3f41;hpb=3e4829e78a3c7f7e19017d05611e5b69d5268119 diff --git a/src/route.c b/src/route.c index 4e7f7e58..e3bcf3bb 100644 --- a/src/route.c +++ b/src/route.c @@ -50,7 +50,10 @@ static const size_t ip6_size = sizeof(struct ip6_hdr); static const size_t icmp6_size = sizeof(struct icmp6_hdr); static const size_t ns_size = sizeof(struct nd_neighbor_solicit); static const size_t opt_size = sizeof(struct nd_opt_hdr); -#define max(a, b) ((a) > (b) ? (a) : (b)) + +#ifndef MAX +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#endif /* RFC 1071 */ @@ -217,7 +220,7 @@ void age_subnets(void) { for(node = myself->subnet_tree->head; node; node = next) { next = node->next; s = node->data; - if(s->expires && s->expires < now) { + if(s->expires && s->expires <= now) { ifdebug(TRAFFIC) { char netstr[MAXNETSTR]; if(net2str(netstr, sizeof netstr, s)) @@ -398,10 +401,10 @@ static void route_ipv4_unicast(node_t *source, vpn_packet_t *packet) { if(directonly && subnet->owner != via) return route_ipv4_unreachable(source, packet, ICMP_DEST_UNREACH, ICMP_NET_ANO); - if(via && packet->len > max(via->mtu, 590) && via != myself) { + if(via && packet->len > MAX(via->mtu, 590) && via != myself) { ifdebug(TRAFFIC) logger(LOG_INFO, "Packet for %s (%s) length %d larger than MTU %d", subnet->owner->name, subnet->owner->hostname, packet->len, via->mtu); if(packet->data[20] & 0x40) { - packet->len = max(via->mtu, 590); + packet->len = MAX(via->mtu, 590); route_ipv4_unreachable(source, packet, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED); } else { fragment_ipv4_packet(via, packet); @@ -549,9 +552,9 @@ static void route_ipv6_unicast(node_t *source, vpn_packet_t *packet) { if(directonly && subnet->owner != via) return route_ipv6_unreachable(source, packet, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADMIN); - if(via && packet->len > max(via->mtu, 1294) && via != myself) { + if(via && packet->len > MAX(via->mtu, 1294) && via != myself) { ifdebug(TRAFFIC) logger(LOG_INFO, "Packet for %s (%s) length %d larger than MTU %d", subnet->owner->name, subnet->owner->hostname, packet->len, via->mtu); - packet->len = max(via->mtu, 1294); + packet->len = MAX(via->mtu, 1294); route_ipv6_unreachable(source, packet, ICMP6_PACKET_TOO_BIG, 0); return; } @@ -844,7 +847,7 @@ static void route_mac(node_t *source, vpn_packet_t *packet) { } void route(node_t *source, vpn_packet_t *packet) { - if(forwarding_mode == FMODE_KERNEL) { + if(forwarding_mode == FMODE_KERNEL && source != myself) { send_packet(myself, packet); return; }