X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fsubnet.c;h=5356f3a77c02430bb6fd57b04e196e9ae51f1882;hb=d8ea4c11dec5946c135ad2d2d05954473a0bfda9;hp=7ff8f7aab518d27372fd74436eb5198546e72aa2;hpb=57991e264202ad83e2c1b663777b358bf5573652;p=tinc diff --git a/src/subnet.c b/src/subnet.c index 7ff8f7aa..5356f3a7 100644 --- a/src/subnet.c +++ b/src/subnet.c @@ -92,13 +92,15 @@ void subnet_add(node_t *n, subnet_t *subnet) { subnet->owner = n; splay_insert(subnet_tree, subnet); - splay_insert(n->subnet_tree, subnet); + if (n) + splay_insert(n->subnet_tree, subnet); subnet_cache_flush(); } void subnet_del(node_t *n, subnet_t *subnet) { - splay_delete(n->subnet_tree, subnet); + if (n) + splay_delete(n->subnet_tree, subnet); splay_delete(subnet_tree, subnet); subnet_cache_flush(); @@ -126,7 +128,7 @@ subnet_t *lookup_subnet_mac(const node_t *owner, const mac_t *address) { if(!memcmp(address, &p->net.mac.address, sizeof *address)) { r = p; - if(p->owner->status.reachable) + if(!p->owner || p->owner->status.reachable) break; } } @@ -155,7 +157,7 @@ subnet_t *lookup_subnet_ipv4(const ipv4_t *address) { if(!maskcmp(address, &p->net.ipv4.address, p->net.ipv4.prefixlength)) { r = p; - if(p->owner->status.reachable) + if(!p->owner || p->owner->status.reachable) break; } } @@ -184,7 +186,7 @@ subnet_t *lookup_subnet_ipv6(const ipv6_t *address) { if(!maskcmp(address, &p->net.ipv6.address, p->net.ipv6.prefixlength)) { r = p; - if(p->owner->status.reachable) + if(!p->owner || p->owner->status.reachable) break; } } @@ -275,7 +277,7 @@ bool dump_subnets(connection_t *c) { send_request(c, "%d %d %s %s", CONTROL, REQ_DUMP_SUBNETS, - netstr, subnet->owner->name); + netstr, subnet->owner ? subnet->owner->name : "(broadcast)"); } return send_request(c, "%d %d", CONTROL, REQ_DUMP_SUBNETS);