diff options
author | Donald Sharp <sharpd@nvidia.com> | 2024-01-04 19:55:09 +0100 |
---|---|---|
committer | Donald Sharp <sharpd@nvidia.com> | 2024-01-04 19:56:09 +0100 |
commit | 10387101fecf4956db38945655aa291aec63d9f7 (patch) | |
tree | a11d16483b1dca739182b944ea712ce3002c9f21 | |
parent | Merge pull request #15083 from louis-6wind/fix-isis_spftree_del (diff) | |
download | frr-10387101fecf4956db38945655aa291aec63d9f7.tar.xz frr-10387101fecf4956db38945655aa291aec63d9f7.zip |
lib: Breakout sendmmsg into it's own header
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>
-rw-r--r-- | lib/frrsendmmsg.h | 30 | ||||
-rw-r--r-- | lib/subdir.am | 1 | ||||
-rw-r--r-- | lib/zebra.h | 20 | ||||
-rw-r--r-- | lib/zlog_5424.c | 2 | ||||
-rw-r--r-- | lib/zlog_live.c | 2 |
5 files changed, 35 insertions, 20 deletions
diff --git a/lib/frrsendmmsg.h b/lib/frrsendmmsg.h new file mode 100644 index 000000000..ea63d139a --- /dev/null +++ b/lib/frrsendmmsg.h @@ -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 diff --git a/lib/subdir.am b/lib/subdir.am index 977fd9f9a..4f203c0c8 100644 --- a/lib/subdir.am +++ b/lib/subdir.am @@ -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 \ diff --git a/lib/zebra.h b/lib/zebra.h index e5021df22..fe8ac150a 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -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 diff --git a/lib/zlog_5424.c b/lib/zlog_5424.c index 3049e4a84..2158a7136 100644 --- a/lib/zlog_5424.c +++ b/lib/zlog_5424.c @@ -14,6 +14,8 @@ #include "zebra.h" +#include "frrsendmmsg.h" + #include "zlog_5424.h" #include <sys/un.h> diff --git a/lib/zlog_live.c b/lib/zlog_live.c index 4d3c3508b..1b7696c89 100644 --- a/lib/zlog_live.c +++ b/lib/zlog_live.c @@ -5,6 +5,8 @@ #include "zebra.h" +#include "frrsendmmsg.h" + #include "zlog_live.h" #include "memory.h" |