]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospf6d/ospf6_network.c
Merge pull request #13141 from mjstapp/fix_ospf_json_keys
[mirror_frr.git] / ospf6d / ospf6_network.c
index 76f98fecdd8e2deb4d520edd3ca6135cf4bbce10..eddf8778e5ca577d5c733d564b2a2f231a8c481d 100644 (file)
@@ -1,21 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (C) 2003 Yasuhiro Ohara
- *
- * This file is part of GNU Zebra.
- *
- * GNU Zebra 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, or (at your option) any
- * later version.
- *
- * GNU Zebra 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>
@@ -33,6 +18,7 @@
 #include "ospf6_top.h"
 #include "ospf6_network.h"
 #include "ospf6d.h"
+#include "ospf6_message.h"
 
 struct in6_addr allspfrouters6;
 struct in6_addr alldrouters6;
@@ -60,20 +46,6 @@ static void ospf6_set_transport_class(int ospf6_sock)
 #endif
 }
 
-static void ospf6_set_checksum(int ospf6_sock)
-{
-       int offset = 12;
-#ifndef DISABLE_IPV6_CHECKSUM
-       if (setsockopt(ospf6_sock, IPPROTO_IPV6, IPV6_CHECKSUM, &offset,
-                      sizeof(offset))
-           < 0)
-               zlog_warn("Network: set IPV6_CHECKSUM failed: %s",
-                         safe_strerror(errno));
-#else
-       zlog_warn("Network: Don't set IPV6_CHECKSUM");
-#endif /* DISABLE_IPV6_CHECKSUM */
-}
-
 void ospf6_serv_close(int *ospf6_sock)
 {
        if (*ospf6_sock != -1) {
@@ -113,7 +85,6 @@ int ospf6_serv_sock(struct ospf6 *ospf6)
        ospf6_reset_mcastloop(ospf6_sock);
        ospf6_set_pktinfo(ospf6_sock);
        ospf6_set_transport_class(ospf6_sock);
-       ospf6_set_checksum(ospf6_sock);
 
        ospf6->fd = ospf6_sock;
        /* setup global in6_addr, allspf6 and alldr6 for later use */
@@ -187,7 +158,7 @@ int ospf6_sendmsg(struct in6_addr *src, struct in6_addr *dst,
        memset(&cmsgbuf, 0, sizeof(cmsgbuf));
        scmsgp = (struct cmsghdr *)&cmsgbuf;
        pktinfo = (struct in6_pktinfo *)(CMSG_DATA(scmsgp));
-       memset(&dst_sin6, 0, sizeof(struct sockaddr_in6));
+       memset(&dst_sin6, 0, sizeof(dst_sin6));
 
        /* source address */
        pktinfo->ipi6_ifindex = ifindex;
@@ -240,7 +211,7 @@ int ospf6_recvmsg(struct in6_addr *src, struct in6_addr *dst,
 
        rcmsgp = (struct cmsghdr *)cmsgbuf;
        pktinfo = (struct in6_pktinfo *)(CMSG_DATA(rcmsgp));
-       memset(&src_sin6, 0, sizeof(struct sockaddr_in6));
+       memset(&src_sin6, 0, sizeof(src_sin6));
 
        /* receive control msg */
        rcmsgp->cmsg_level = IPPROTO_IPV6;
@@ -257,10 +228,13 @@ int ospf6_recvmsg(struct in6_addr *src, struct in6_addr *dst,
        rmsghdr.msg_control = (caddr_t)cmsgbuf;
        rmsghdr.msg_controllen = sizeof(cmsgbuf);
 
-       retval = recvmsg(ospf6_sock, &rmsghdr, 0);
-       if (retval < 0)
-               zlog_warn("recvmsg failed: %s", safe_strerror(errno));
-       else if (retval == iov_totallen(message))
+       retval = recvmsg(ospf6_sock, &rmsghdr, MSG_DONTWAIT);
+       if (retval < 0) {
+               if (errno != EAGAIN && errno != EWOULDBLOCK)
+                       zlog_warn("stream_recvmsg failed: %s",
+                                 safe_strerror(errno));
+               return retval;
+       } else if (retval == iov_totallen(message))
                zlog_warn("recvmsg read full buffer size: %d", retval);
 
        /* source address */