perform cheap checks first
authorMathew Heard <splitice@users.noreply.github.com>
Tue, 29 Jun 2021 00:49:01 +0000 (10:49 +1000)
committerGuus Sliepen <guus@tinc-vpn.org>
Wed, 30 Jun 2021 21:43:34 +0000 (23:43 +0200)
minor optimization

src/net_packet.c

index c2132b8..ff9f79c 100644 (file)
@@ -1630,7 +1630,7 @@ static void handle_incoming_vpn_packet(listen_socket_t *ls, vpn_packet_t *pkt, s
                pkt->offset = 2 * sizeof(node_id_t);
                from = lookup_node_id(SRCID(pkt));
 
-               if(from && !memcmp(DSTID(pkt), &nullid, sizeof(nullid)) && from->status.sptps) {
+               if(from && from->status.sptps && !memcmp(DSTID(pkt), &nullid, sizeof(nullid))) {
                        if(sptps_verify_datagram(&from->sptps, DATA(pkt), pkt->len - 2 * sizeof(node_id_t))) {
                                n = from;
                        } else {
@@ -1666,7 +1666,7 @@ skip_harder:
                        pkt->len -= pkt->offset;
                }
 
-               if(!memcmp(DSTID(pkt), &nullid, sizeof(nullid)) || !relay_enabled) {
+               if(!relay_enabled || !memcmp(DSTID(pkt), &nullid, sizeof(nullid))) {
                        direct = true;
                        from = n;
                        to = myself;