vppinfra: Protect Linux specific features behind CLIB_LINUX 65/40265/2
authorTom Jones <thj@freebsd.org>
Fri, 26 Jan 2024 14:54:57 +0000 (14:54 +0000)
committerDamjan Marion <dmarion@0xa5.net>
Tue, 13 Feb 2024 16:27:26 +0000 (16:27 +0000)
Place Linux specific features behind CLIB_LINUX. The previous #ifdef
calls would still pass even if CLIB_LINUX is set to 0 in clib.h, instead
use #if.

Type: improvement
Change-Id: Ibe4424eee4bc0065f54764b017b9a56a3e854380
Signed-off-by: Tom Jones <thj@freebsd.org>
src/vppinfra/socket.c

index dd447ab..2abf2b2 100644 (file)
@@ -226,7 +226,7 @@ static clib_error_t *
 default_socket_recvmsg (clib_socket_t * s, void *msg, int msglen,
                        int fds[], int num_fds)
 {
-#ifdef CLIB_LINUX
+#if CLIB_LINUX
   char ctl[CMSG_SPACE (sizeof (int) * num_fds) +
           CMSG_SPACE (sizeof (struct ucred))];
   struct ucred *cr = 0;
@@ -261,7 +261,7 @@ default_socket_recvmsg (clib_socket_t * s, void *msg, int msglen,
     {
       if (cmsg->cmsg_level == SOL_SOCKET)
        {
-#ifdef CLIB_LINUX
+#if CLIB_LINUX
          if (cmsg->cmsg_type == SCM_CREDENTIALS)
            {
              cr = (struct ucred *) CMSG_DATA (cmsg);
@@ -314,11 +314,13 @@ static const struct
     .family = AF_INET,
     .type = CLIB_SOCKET_TYPE_INET,
     .skip_prefix = 1 },
+#if CLIB_LINUX
   { .prefix = "abstract:",
     .family = AF_UNIX,
     .type = CLIB_SOCKET_TYPE_LINUX_ABSTRACT,
     .skip_prefix = 1,
     .is_local = 1 },
+#endif /* CLIB_LINUX */
   { .prefix = "/",
     .family = AF_UNIX,
     .type = CLIB_SOCKET_TYPE_UNIX,