]> git.proxmox.com Git - mirror_frr.git/blobdiff - vrrpd/vrrp_arp.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / vrrpd / vrrp_arp.c
index 8e903e137f20b57f69bf0f1dc5c34e07ab17955f..0072053798f7e2b52f0eca74d3a53e3ed965a4e7 100644 (file)
@@ -1,23 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * VRRP ARP handling.
  * Copyright (C) 2001-2017 Alexandre Cassen
  * Portions:
  *     Copyright (C) 2018-2019 Cumulus Networks, Inc.
  *     Quentin Young
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 #include <zebra.h>
 
@@ -124,7 +111,7 @@ void vrrp_garp_send(struct vrrp_router *r, struct in_addr *v4)
        if (ifp->flags & IFF_NOARP) {
                zlog_warn(
                        VRRP_LOGPFX VRRP_LOGPFX_VRID VRRP_LOGPFX_FAM
-                       "Unable to send gratuitous ARP on %s; has IFF_NOARP\n",
+                       "Unable to send gratuitous ARP on %s; has IFF_NOARP",
                        r->vr->vrid, family2str(r->family), ifp->name);
                return;
        }
@@ -132,6 +119,14 @@ void vrrp_garp_send(struct vrrp_router *r, struct in_addr *v4)
        /* Build garp */
        garpbuf_len = vrrp_build_garp(garpbuf, ifp, v4);
 
+       if (garpbuf_len < 0) {
+               zlog_warn(
+                       VRRP_LOGPFX VRRP_LOGPFX_VRID VRRP_LOGPFX_FAM
+                       "Unable to send gratuitous ARP on %s; MAC address unknown",
+                       r->vr->vrid, family2str(r->family), ifp->name);
+               return;
+       };
+
        /* Send garp */
        inet_ntop(AF_INET, v4, astr, sizeof(astr));
 
@@ -162,7 +157,7 @@ void vrrp_garp_send_all(struct vrrp_router *r)
        if (ifp->flags & IFF_NOARP) {
                zlog_warn(
                        VRRP_LOGPFX VRRP_LOGPFX_VRID VRRP_LOGPFX_FAM
-                       "Unable to send gratuitous ARP on %s; has IFF_NOARP\n",
+                       "Unable to send gratuitous ARP on %s; has IFF_NOARP",
                        r->vr->vrid, family2str(r->family), ifp->name);
                return;
        }
@@ -180,7 +175,7 @@ void vrrp_garp_init(void)
        /* Create the socket descriptor */
        /* FIXME: why ETH_P_RARP? */
        errno = 0;
-       frr_elevate_privs(&vrrp_privs) {
+       frr_with_privs(&vrrp_privs) {
                garp_fd = socket(PF_PACKET, SOCK_RAW | SOCK_CLOEXEC,
                                 htons(ETH_P_RARP));
        }