#define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif
+volatile int dummy;
static timeout_t age_subnets_timeout;
/* RFC 1071 */
checksum = (checksum & 0xFFFF) + (checksum >> 16);
}
+ // Work around a compiler optimization bug.
+ if(checksum) {
+ dummy = 1;
+ }
+
return ~checksum;
}
}
static void age_subnets(void *data) {
+ (void)data;
bool left = false;
for splay_each(subnet_t, s, myself->subnet_tree) {
logger(DEBUG_TRAFFIC, LOG_INFO, "Fragmenting packet of %d bytes to %s (%s)", packet->len, dest->name, dest->hostname);
offset = DATA(packet) + ether_size + ip_size;
- maxlen = (dest->mtu - ether_size - ip_size) & ~0x7;
+ maxlen = (MAX(dest->mtu, 590) - ether_size - ip_size) & ~0x7;
ip_off = ntohs(ip.ip_off);
origf = ip_off & ~IP_OFFMASK;
ip_off &= IP_OFFMASK;
}
if(!subnet->owner->status.reachable) {
- return route_ipv4_unreachable(source, packet, ether_size, ICMP_DEST_UNREACH, ICMP_NET_UNREACH);
+ route_ipv4_unreachable(source, packet, ether_size, ICMP_DEST_UNREACH, ICMP_NET_UNREACH);
+ return;
}
if(forwarding_mode == FMODE_OFF && source != myself && subnet->owner != myself) {
- return route_ipv4_unreachable(source, packet, ether_size, ICMP_DEST_UNREACH, ICMP_NET_ANO);
+ route_ipv4_unreachable(source, packet, ether_size, ICMP_DEST_UNREACH, ICMP_NET_ANO);
+ return;
}
if(decrement_ttl && source != myself && subnet->owner != myself)
}
if(directonly && subnet->owner != via) {
- return route_ipv4_unreachable(source, packet, ether_size, ICMP_DEST_UNREACH, ICMP_NET_ANO);
+ route_ipv4_unreachable(source, packet, ether_size, ICMP_DEST_UNREACH, ICMP_NET_ANO);
+ return;
}
if(via && packet->len > MAX(via->mtu, 590) && via != myself) {
}
if(!subnet->owner->status.reachable) {
- return route_ipv6_unreachable(source, packet, ether_size, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOROUTE);
+ route_ipv6_unreachable(source, packet, ether_size, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOROUTE);
+ return;
}
if(forwarding_mode == FMODE_OFF && source != myself && subnet->owner != myself) {
- return route_ipv6_unreachable(source, packet, ether_size, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADMIN);
+ route_ipv6_unreachable(source, packet, ether_size, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADMIN);
+ return;
}
if(decrement_ttl && source != myself && subnet->owner != myself)
}
if(directonly && subnet->owner != via) {
- return route_ipv6_unreachable(source, packet, ether_size, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADMIN);
+ route_ipv6_unreachable(source, packet, ether_size, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADMIN);
+ return;
}
if(via && packet->len > MAX(via->mtu, 1294) && via != myself) {
memcpy(DATA(packet), DATA(packet) + ETH_ALEN, ETH_ALEN); /* copy destination address */
DATA(packet)[ETH_ALEN * 2 - 1] ^= 0xFF; /* mangle source address so it looks like it's not from us */
- ip6.ip6_dst = ip6.ip6_src; /* swap destination and source protocoll address */
+ ip6.ip6_dst = ip6.ip6_src; /* swap destination and source protocol address */
ip6.ip6_src = ns.nd_ns_target;
if(has_opt) {