]> git.puffer.fish Git - matthieu/frr.git/commitdiff
build: check for sendmmsg() and struct mmsghdr
authorDavid Lamparter <equinox@diac24.net>
Sat, 10 Apr 2021 21:03:58 +0000 (23:03 +0200)
committerDavid Lamparter <equinox@opensourcerouting.org>
Sun, 16 Jan 2022 23:38:56 +0000 (00:38 +0100)
These will be used by the RFC5424 log target.

Signed-off-by: David Lamparter <equinox@diac24.net>
configure.ac
lib/zebra.h

index 0d598954cc3098ab813cbce708f78e221590592f..3cceb411230255b70faca5e7cb84fbf11643495b 100644 (file)
@@ -1299,8 +1299,11 @@ AC_CHECK_FUNCS([ \
        openat \
        unlinkat \
        posix_fallocate \
+       sendmmsg \
        ])
 
+AC_CHECK_MEMBERS([struct mmsghdr.msg_hdr], [], [], FRR_INCLUDES)
+
 dnl ##########################################################################
 dnl LARGE if block spans a lot of "configure"!
 if test "$enable_clippy_only" != "yes"; then
index 139e47e8d72abd1439872af0c8d5ec1d354fc074..e8ddd869bb91ee8381d46eeddb590e63e7a143a2 100644 (file)
@@ -230,6 +230,26 @@ size_t strlcpy(char *__restrict dest,
               const char *__restrict src, size_t destsize);
 #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