route: Fix compile warning with glibc
[project/relayd.git] / main.c
diff --git a/main.c b/main.c
index 7f33d90adb38291e12bdafc24b3ed8e043b6788b..b3c13f7f7a49f3693df2efa1adfcae8dbaba56cf 100644 (file)
--- a/main.c
+++ b/main.c
@@ -165,7 +165,7 @@ static void send_arp_request(struct relayd_interface *rif, const uint8_t *ipaddr
        fill_arp_packet(&pkt, rif, rif->src_ip, ipaddr);
 
        pkt.arp.arp_op = htons(ARPOP_REQUEST);
-       memcpy(pkt.arp.arp_spa, rif->src_ip, ETH_ALEN);
+       memcpy(pkt.arp.arp_spa, rif->src_ip, sizeof(pkt.arp.arp_spa));
        memset(pkt.arp.arp_tha, 0, ETH_ALEN);
        memset(pkt.eth.ether_dhost, 0xff, ETH_ALEN);
 
@@ -653,6 +653,11 @@ static struct relayd_interface *alloc_interface(const char *ifname, bool managed
        if (strlen(ifname) >= IFNAMSIZ)
                return NULL;
 
+       list_for_each_entry(rif, &interfaces, list) {
+               if (!strncmp(rif->ifname, ifname, IFNAMSIZ))
+                       return rif;
+       }
+
        rif = calloc(1, sizeof(*rif));
        if (!rif)
                return NULL;