]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospfd/ospf_network.c
lib: Convert zlog_err for clippy build
[mirror_frr.git] / ospfd / ospf_network.c
index ed5e8e027d82834c1c6dc4d642df95e61e5653f3..d7cca0f1332fe30d78eeaf0b6305fc350d6744eb 100644 (file)
@@ -38,7 +38,7 @@
 #include "ospfd/ospf_lsdb.h"
 #include "ospfd/ospf_neighbor.h"
 #include "ospfd/ospf_packet.h"
-
+#include "ospfd/ospf_dump.h"
 
 /* Join to the OSPF ALL SPF ROUTERS multicast group. */
 int ospf_if_add_allspfrouters(struct ospf *top, struct prefix *p,
@@ -56,10 +56,12 @@ int ospf_if_add_allspfrouters(struct ospf *top, struct prefix *p,
                        "on # of multicast group memberships has been exceeded?",
                        top->fd, inet_ntoa(p->u.prefix4), ifindex,
                        safe_strerror(errno));
-       else
-               zlog_debug(
-                       "interface %s [%u] join AllSPFRouters Multicast group.",
-                       inet_ntoa(p->u.prefix4), ifindex);
+       else {
+               if (IS_DEBUG_OSPF_EVENT)
+                       zlog_debug(
+                               "interface %s [%u] join AllSPFRouters Multicast group.",
+                               inet_ntoa(p->u.prefix4), ifindex);
+       }
 
        return ret;
 }
@@ -78,10 +80,12 @@ int ospf_if_drop_allspfrouters(struct ospf *top, struct prefix *p,
                        "ifindex %u, AllSPFRouters): %s",
                        top->fd, inet_ntoa(p->u.prefix4), ifindex,
                        safe_strerror(errno));
-       else
-               zlog_debug(
-                       "interface %s [%u] leave AllSPFRouters Multicast group.",
-                       inet_ntoa(p->u.prefix4), ifindex);
+       else {
+               if (IS_DEBUG_OSPF_EVENT)
+                       zlog_debug(
+                               "interface %s [%u] leave AllSPFRouters Multicast group.",
+                               inet_ntoa(p->u.prefix4), ifindex);
+       }
 
        return ret;
 }
@@ -134,7 +138,7 @@ int ospf_if_drop_alldrouters(struct ospf *top, struct prefix *p,
 
 int ospf_if_ipmulticast(struct ospf *top, struct prefix *p, ifindex_t ifindex)
 {
-       u_char val;
+       uint8_t val;
        int ret, len;
 
        /* Prevent receiving self-origined multicast packets. */
@@ -167,42 +171,27 @@ int ospf_if_ipmulticast(struct ospf *top, struct prefix *p, ifindex_t ifindex)
        return ret;
 }
 
-int ospf_bind_vrfdevice(struct ospf *ospf, int ospf_sock)
-{
-       int ret = 0;
-
-#ifdef SO_BINDTODEVICE
-
-       if (ospf && ospf->vrf_id != VRF_DEFAULT &&
-           ospf->vrf_id != VRF_UNKNOWN) {
-               ret = setsockopt(ospf_sock, SOL_SOCKET, SO_BINDTODEVICE,
-                                ospf->name,
-                                strlen(ospf->name));
-               if (ret < 0) {
-                       int save_errno = errno;
-
-                       zlog_warn("%s: Could not setsockopt SO_BINDTODEVICE %s",
-                                       __PRETTY_FUNCTION__,
-                                       safe_strerror(save_errno));
-               }
-
-       }
-#endif
-       return ret;
-}
-
 int ospf_sock_init(struct ospf *ospf)
 {
        int ospf_sock;
        int ret, hincl = 1;
        int bufsize = (8 * 1024 * 1024);
 
+       /* silently ignore. already done */
+       if (ospf->fd > 0)
+               return -1;
+
+       if (ospf->vrf_id == VRF_UNKNOWN) {
+               /* silently return since VRF is not ready */
+               return -1;
+       }
        if (ospfd_privs.change(ZPRIVS_RAISE)) {
                zlog_err("ospf_sock_init: could not raise privs, %s",
                         safe_strerror(errno));
        }
 
-       ospf_sock = socket(AF_INET, SOCK_RAW, IPPROTO_OSPFIGP);
+       ospf_sock = vrf_socket(AF_INET, SOCK_RAW, IPPROTO_OSPFIGP, ospf->vrf_id,
+                              ospf->name);
        if (ospf_sock < 0) {
                int save_errno = errno;
 
@@ -214,12 +203,6 @@ int ospf_sock_init(struct ospf *ospf)
                exit(1);
        }
 
-       ret = ospf_bind_vrfdevice(ospf, ospf_sock);
-       if (ret < 0) {
-               close(ospf_sock);
-               goto out;
-       }
-
 #ifdef IP_HDRINCL
        /* we will include IP header with packet */
        ret = setsockopt(ospf_sock, IPPROTO_IP, IP_HDRINCL, &hincl,