]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: use SA_SIZE for RT_ROUNDUP on FreeBSD
authorDavid Lamparter <equinox@opensourcerouting.org>
Tue, 3 Mar 2015 20:04:20 +0000 (21:04 +0100)
committerDaniel Walton <dwalton@cumulusnetworks.com>
Thu, 26 May 2016 15:33:29 +0000 (15:33 +0000)
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>
(cherry picked from commit 7e92322cfcc6c062acae3b550f90d36fe40763f1)

zebra/kernel_socket.c

index 10fb2d2631689d5ebab098cae01e3c2800fd7dd4..b00f9fbdff594efffbfcbeff03f222cd7e8caeb8 100644 (file)
@@ -59,6 +59,12 @@ extern struct zebra_privs_t zserv_privs;
  * 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) */
@@ -115,6 +121,8 @@ extern struct zebra_privs_t zserv_privs;
            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
@@ -1115,15 +1123,6 @@ rtm_write (int message,
     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)) \
     { \
@@ -1131,7 +1130,6 @@ rtm_write (int message,
       memcpy (pnt, (caddr_t)(X), len); \
       pnt += len; \
     }
-#endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */
 
   pnt = (caddr_t) msg.buf;