]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: Breakout sendmmsg into it's own header
authorDonald Sharp <sharpd@nvidia.com>
Thu, 4 Jan 2024 18:55:09 +0000 (13:55 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Thu, 4 Jan 2024 18:56:09 +0000 (13:56 -0500)
The only 2 places sendmmsg is used is in zlog_5424.c
and zlog_live.c.  Why is the rest of the entire system
paying for this compilation?

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
lib/frrsendmmsg.h [new file with mode: 0644]
lib/subdir.am
lib/zebra.h
lib/zlog_5424.c
lib/zlog_live.c

diff --git a/lib/frrsendmmsg.h b/lib/frrsendmmsg.h
new file mode 100644 (file)
index 0000000..ea63d13
--- /dev/null
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * FRR sendmmsg wrapper
+ * Copyright (C) 2024 by Nvidia, Inc.
+ *                       Donald Sharp
+ */
+#ifndef __FRRSENDMMSG_H__
+#define __FRRSENDMMSG_H__
+
+#if !defined(HAVE_STRUCT_MMSGHDR_MSG_HDR) || !defined(HAVE_SENDMMSG)
+/* avoid conflicts in case we have partial support */
+#define mmsghdr         frr_mmsghdr
+#define sendmmsg frr_sendmmsg
+
+struct mmsghdr {
+       struct msghdr msg_hdr;
+       unsigned int msg_len;
+};
+
+/* just go 1 at a time here, the loop this is used in will handle the rest */
+static inline int sendmmsg(int fd, struct mmsghdr *mmh, unsigned int len,
+                          int flags)
+{
+       int rv = sendmsg(fd, &mmh->msg_hdr, 0);
+
+       return rv > 0 ? 1 : rv;
+}
+#endif
+
+#endif
index 977fd9f9aa4969e988b0453aab68e4802518e3ed..4f203c0c842ffffc3040e03c9f4d050de402ef3c 100644 (file)
@@ -227,6 +227,7 @@ pkginclude_HEADERS += \
        lib/frr_pthread.h \
        lib/frratomic.h \
        lib/frrcu.h \
+       lib/frrsendmmsg.h \
        lib/frrstr.h \
        lib/graph.h \
        lib/hash.h \
index e5021df22b0df05bf7d3c10668577e1dc289cabc..fe8ac150a7bcc4c4a6d6d0170ec989b8b32d2e9b 100644 (file)
@@ -203,26 +203,6 @@ size_t strlcpy(char *__restrict dest,
 void explicit_bzero(void *buf, size_t len);
 #endif
 
-#if !defined(HAVE_STRUCT_MMSGHDR_MSG_HDR) || !defined(HAVE_SENDMMSG)
-/* avoid conflicts in case we have partial support */
-#define mmsghdr frr_mmsghdr
-#define sendmmsg frr_sendmmsg
-
-struct mmsghdr {
-       struct msghdr msg_hdr;
-       unsigned int msg_len;
-};
-
-/* just go 1 at a time here, the loop this is used in will handle the rest */
-static inline int sendmmsg(int fd, struct mmsghdr *mmh, unsigned int len,
-                          int flags)
-{
-       int rv = sendmsg(fd, &mmh->msg_hdr, 0);
-
-       return rv > 0 ? 1 : rv;
-}
-#endif
-
 /*
  * RFC 3542 defines several macros for using struct cmsghdr.
  * Here, we define those that are not present
index 3049e4a849e84c4b4bd42f0cc6edf01c0151bbe6..2158a713606b20da9c33d939cac9e9886684ef76 100644 (file)
@@ -14,6 +14,8 @@
 
 #include "zebra.h"
 
+#include "frrsendmmsg.h"
+
 #include "zlog_5424.h"
 
 #include <sys/un.h>
index 4d3c3508bffd6c229e70a4ff630d1745f7334e66..1b7696c893d05b7a84de89efff5715a8f7fb4f1a 100644 (file)
@@ -5,6 +5,8 @@
 
 #include "zebra.h"
 
+#include "frrsendmmsg.h"
+
 #include "zlog_live.h"
 
 #include "memory.h"