zebra: use SA_SIZE for RT_ROUNDUP on FreeBSD
FreeBSD provides SA_SIZE (and none of the other options to infer padded
size of a struct sockaddr). Just define SAROUNDUP to SA_SIZE if it is
available.
This also drops a superfluous-looking extra macro branch which would
require ROUNDUP. It seemed redundant to my eyes, but I have no idea
what odd things might have triggered addition of this in the first
place...
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c
index 1518c1a..5eb92d9 100644
--- a/zebra/kernel_socket.c
+++ b/zebra/kernel_socket.c
@@ -58,6 +58,12 @@
* Because of these varying conventions, the only sane approach is for
* the <net/route.h> header to define some flavor of ROUNDUP macro.
*/
+
+#if defined(SA_SIZE)
+/* SAROUNDUP is the only thing we need, and SA_SIZE provides that */
+#define SAROUNDUP(a) SA_SIZE(a)
+#else /* !SA_SIZE */
+
#if defined(RT_ROUNDUP)
#define ROUNDUP(a) RT_ROUNDUP(a)
#endif /* defined(RT_ROUNDUP) */
@@ -114,6 +120,8 @@
ROUNDUP(sizeof(struct sockaddr_dl)) : sizeof(struct sockaddr)))
#endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */
+#endif /* !SA_SIZE */
+
/*
* We use a call to an inline function to copy (PNT) to (DEST)
* 1. Calculating the length of the copy requires an #ifdef to determine
@@ -1114,15 +1122,6 @@
msg.rtm.rtm_flags |= RTF_REJECT;
-#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
-#define SOCKADDRSET(X,R) \
- if (msg.rtm.rtm_addrs & (R)) \
- { \
- int len = ROUNDUP ((X)->sa.sa_len); \
- memcpy (pnt, (caddr_t)(X), len); \
- pnt += len; \
- }
-#else
#define SOCKADDRSET(X,R) \
if (msg.rtm.rtm_addrs & (R)) \
{ \
@@ -1130,7 +1129,6 @@
memcpy (pnt, (caddr_t)(X), len); \
pnt += len; \
}
-#endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */
pnt = (caddr_t) msg.buf;