public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] linux: Use socket-constants-time64.h on tst-socket-timestamp-compat
@ 2022-02-14 13:37 Adhemerval Zanella
  2022-02-14 14:28 ` Carlos O'Donell
  2022-02-14 16:48 ` Tulio Magno Quites Machado Filho
  0 siblings, 2 replies; 3+ messages in thread
From: Adhemerval Zanella @ 2022-02-14 13:37 UTC (permalink / raw)
  To: libc-alpha, Tulio Magno Quites Machado Filho, Florian Weimer

The kernel header might not define the SO_TIMESTAMP{NS}_OLD or
SO_TIMESTAMP{NS}_NEW if it older than v5.1.
---
 .../sysv/linux/tst-socket-timestamp-compat.c  | 25 ++++++++++---------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/tst-socket-timestamp-compat.c b/sysdeps/unix/sysv/linux/tst-socket-timestamp-compat.c
index 0ff1a214e6..2b1feb4766 100644
--- a/sysdeps/unix/sysv/linux/tst-socket-timestamp-compat.c
+++ b/sysdeps/unix/sysv/linux/tst-socket-timestamp-compat.c
@@ -22,6 +22,7 @@
 #include <support/xsocket.h>
 #include <support/xunistd.h>
 #include <stdbool.h>
+#include <socket-constants-time64.h>
 
 /* AF_INET socket and address used to receive data.  */
 static int srv;
@@ -88,7 +89,7 @@ do_test_large_buffer (bool mc)
   /* Enable 32 bit timeval precision and check if no 64 bit timeval stamp
      is created.  */
   {
-    int r = setsockopt (srv, SOL_SOCKET, SO_TIMESTAMP_OLD, &(int){1},
+    int r = setsockopt (srv, SOL_SOCKET, COMPAT_SO_TIMESTAMP_OLD, &(int){1},
 			sizeof (int));
     TEST_VERIFY_EXIT (r != -1);
 
@@ -103,10 +104,10 @@ do_test_large_buffer (bool mc)
       if (cmsg->cmsg_level != SOL_SOCKET)
 	continue;
 
-      if (sizeof (time_t) > 4 && cmsg->cmsg_type == SO_TIMESTAMP_NEW)
+      if (sizeof (time_t) > 4 && cmsg->cmsg_type == COMPAT_SO_TIMESTAMP_NEW)
 	found_timestamp = true;
       else
-	TEST_VERIFY (cmsg->cmsg_type != SO_TIMESTAMP_NEW);
+	TEST_VERIFY (cmsg->cmsg_type != COMPAT_SO_TIMESTAMP_NEW);
     }
 
     TEST_COMPARE (found_timestamp, sizeof (time_t) > 4);
@@ -114,7 +115,7 @@ do_test_large_buffer (bool mc)
 
   /* Same as before, but for timespec.  */
   {
-    int r = setsockopt (srv, SOL_SOCKET, SO_TIMESTAMPNS_OLD, &(int){1},
+    int r = setsockopt (srv, SOL_SOCKET, COMPAT_SO_TIMESTAMPNS_OLD, &(int){1},
 			sizeof (int));
     TEST_VERIFY_EXIT (r != -1);
 
@@ -129,10 +130,10 @@ do_test_large_buffer (bool mc)
       if (cmsg->cmsg_level != SOL_SOCKET)
 	continue;
 
-      if (sizeof (time_t) > 4 && cmsg->cmsg_type == SO_TIMESTAMPNS_NEW)
+      if (sizeof (time_t) > 4 && cmsg->cmsg_type == COMPAT_SO_TIMESTAMPNS_NEW)
 	found_timestamp = true;
       else
-	TEST_VERIFY (cmsg->cmsg_type != SO_TIMESTAMPNS_NEW);
+	TEST_VERIFY (cmsg->cmsg_type != COMPAT_SO_TIMESTAMPNS_NEW);
     }
 
     TEST_COMPARE (found_timestamp, sizeof (time_t) > 4);
@@ -151,7 +152,7 @@ do_test_small_buffer (bool mc)
   /* Enable 32 bit timeval precision and check if no 64 bit timeval stamp
      is created.  */
   {
-    int r = setsockopt (srv, SOL_SOCKET, SO_TIMESTAMP_OLD, &(int){1},
+    int r = setsockopt (srv, SOL_SOCKET, COMPAT_SO_TIMESTAMP_OLD, &(int){1},
 			sizeof (int));
     TEST_VERIFY_EXIT (r != -1);
 
@@ -172,10 +173,10 @@ do_test_small_buffer (bool mc)
       if (cmsg->cmsg_level != SOL_SOCKET)
 	continue;
 
-      if (sizeof (time_t) > 4 && cmsg->cmsg_type == SO_TIMESTAMP_NEW)
+      if (sizeof (time_t) > 4 && cmsg->cmsg_type == COMPAT_SO_TIMESTAMP_NEW)
 	found_timestamp = true;
       else
-	TEST_VERIFY (cmsg->cmsg_type != SO_TIMESTAMP_NEW);
+	TEST_VERIFY (cmsg->cmsg_type != COMPAT_SO_TIMESTAMP_NEW);
     }
 
     if (sizeof (time_t) > 4)
@@ -192,7 +193,7 @@ do_test_small_buffer (bool mc)
 
   /* Same as before, but for timespec.  */
   {
-    int r = setsockopt (srv, SOL_SOCKET, SO_TIMESTAMPNS_OLD, &(int){1},
+    int r = setsockopt (srv, SOL_SOCKET, COMPAT_SO_TIMESTAMPNS_OLD, &(int){1},
 			sizeof (int));
     TEST_VERIFY_EXIT (r != -1);
 
@@ -213,10 +214,10 @@ do_test_small_buffer (bool mc)
       if (cmsg->cmsg_level != SOL_SOCKET)
 	continue;
 
-      if (sizeof (time_t) > 4 && cmsg->cmsg_type == SO_TIMESTAMPNS_NEW)
+      if (sizeof (time_t) > 4 && cmsg->cmsg_type == COMPAT_SO_TIMESTAMPNS_NEW)
 	found_timestamp = true;
       else
-	TEST_VERIFY (cmsg->cmsg_type != SO_TIMESTAMPNS_NEW);
+	TEST_VERIFY (cmsg->cmsg_type != COMPAT_SO_TIMESTAMPNS_NEW);
     }
 
     if (sizeof (time_t) > 4)
-- 
2.32.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] linux: Use socket-constants-time64.h on tst-socket-timestamp-compat
  2022-02-14 13:37 [PATCH] linux: Use socket-constants-time64.h on tst-socket-timestamp-compat Adhemerval Zanella
@ 2022-02-14 14:28 ` Carlos O'Donell
  2022-02-14 16:48 ` Tulio Magno Quites Machado Filho
  1 sibling, 0 replies; 3+ messages in thread
From: Carlos O'Donell @ 2022-02-14 14:28 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha, Tulio Magno Quites Machado Filho,
	Florian Weimer

On 2/14/22 08:37, Adhemerval Zanella via Libc-alpha wrote:
> The kernel header might not define the SO_TIMESTAMP{NS}_OLD or
> SO_TIMESTAMP{NS}_NEW if it older than v5.1.

LGTM. Will fix an issue compiling glibc 2.35 on RHEL8.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> ---
>  .../sysv/linux/tst-socket-timestamp-compat.c  | 25 ++++++++++---------
>  1 file changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/tst-socket-timestamp-compat.c b/sysdeps/unix/sysv/linux/tst-socket-timestamp-compat.c
> index 0ff1a214e6..2b1feb4766 100644
> --- a/sysdeps/unix/sysv/linux/tst-socket-timestamp-compat.c
> +++ b/sysdeps/unix/sysv/linux/tst-socket-timestamp-compat.c
> @@ -22,6 +22,7 @@
>  #include <support/xsocket.h>
>  #include <support/xunistd.h>
>  #include <stdbool.h>
> +#include <socket-constants-time64.h>
>  
>  /* AF_INET socket and address used to receive data.  */
>  static int srv;
> @@ -88,7 +89,7 @@ do_test_large_buffer (bool mc)
>    /* Enable 32 bit timeval precision and check if no 64 bit timeval stamp
>       is created.  */
>    {
> -    int r = setsockopt (srv, SOL_SOCKET, SO_TIMESTAMP_OLD, &(int){1},
> +    int r = setsockopt (srv, SOL_SOCKET, COMPAT_SO_TIMESTAMP_OLD, &(int){1},

OK. Use the COMPAT_* versions throughout.

>  			sizeof (int));
>      TEST_VERIFY_EXIT (r != -1);
>  
> @@ -103,10 +104,10 @@ do_test_large_buffer (bool mc)
>        if (cmsg->cmsg_level != SOL_SOCKET)
>  	continue;
>  
> -      if (sizeof (time_t) > 4 && cmsg->cmsg_type == SO_TIMESTAMP_NEW)
> +      if (sizeof (time_t) > 4 && cmsg->cmsg_type == COMPAT_SO_TIMESTAMP_NEW)
>  	found_timestamp = true;
>        else
> -	TEST_VERIFY (cmsg->cmsg_type != SO_TIMESTAMP_NEW);
> +	TEST_VERIFY (cmsg->cmsg_type != COMPAT_SO_TIMESTAMP_NEW);
>      }
>  
>      TEST_COMPARE (found_timestamp, sizeof (time_t) > 4);
> @@ -114,7 +115,7 @@ do_test_large_buffer (bool mc)
>  
>    /* Same as before, but for timespec.  */
>    {
> -    int r = setsockopt (srv, SOL_SOCKET, SO_TIMESTAMPNS_OLD, &(int){1},
> +    int r = setsockopt (srv, SOL_SOCKET, COMPAT_SO_TIMESTAMPNS_OLD, &(int){1},
>  			sizeof (int));
>      TEST_VERIFY_EXIT (r != -1);
>  
> @@ -129,10 +130,10 @@ do_test_large_buffer (bool mc)
>        if (cmsg->cmsg_level != SOL_SOCKET)
>  	continue;
>  
> -      if (sizeof (time_t) > 4 && cmsg->cmsg_type == SO_TIMESTAMPNS_NEW)
> +      if (sizeof (time_t) > 4 && cmsg->cmsg_type == COMPAT_SO_TIMESTAMPNS_NEW)
>  	found_timestamp = true;
>        else
> -	TEST_VERIFY (cmsg->cmsg_type != SO_TIMESTAMPNS_NEW);
> +	TEST_VERIFY (cmsg->cmsg_type != COMPAT_SO_TIMESTAMPNS_NEW);
>      }
>  
>      TEST_COMPARE (found_timestamp, sizeof (time_t) > 4);
> @@ -151,7 +152,7 @@ do_test_small_buffer (bool mc)
>    /* Enable 32 bit timeval precision and check if no 64 bit timeval stamp
>       is created.  */
>    {
> -    int r = setsockopt (srv, SOL_SOCKET, SO_TIMESTAMP_OLD, &(int){1},
> +    int r = setsockopt (srv, SOL_SOCKET, COMPAT_SO_TIMESTAMP_OLD, &(int){1},
>  			sizeof (int));
>      TEST_VERIFY_EXIT (r != -1);
>  
> @@ -172,10 +173,10 @@ do_test_small_buffer (bool mc)
>        if (cmsg->cmsg_level != SOL_SOCKET)
>  	continue;
>  
> -      if (sizeof (time_t) > 4 && cmsg->cmsg_type == SO_TIMESTAMP_NEW)
> +      if (sizeof (time_t) > 4 && cmsg->cmsg_type == COMPAT_SO_TIMESTAMP_NEW)
>  	found_timestamp = true;
>        else
> -	TEST_VERIFY (cmsg->cmsg_type != SO_TIMESTAMP_NEW);
> +	TEST_VERIFY (cmsg->cmsg_type != COMPAT_SO_TIMESTAMP_NEW);
>      }
>  
>      if (sizeof (time_t) > 4)
> @@ -192,7 +193,7 @@ do_test_small_buffer (bool mc)
>  
>    /* Same as before, but for timespec.  */
>    {
> -    int r = setsockopt (srv, SOL_SOCKET, SO_TIMESTAMPNS_OLD, &(int){1},
> +    int r = setsockopt (srv, SOL_SOCKET, COMPAT_SO_TIMESTAMPNS_OLD, &(int){1},
>  			sizeof (int));
>      TEST_VERIFY_EXIT (r != -1);
>  
> @@ -213,10 +214,10 @@ do_test_small_buffer (bool mc)
>        if (cmsg->cmsg_level != SOL_SOCKET)
>  	continue;
>  
> -      if (sizeof (time_t) > 4 && cmsg->cmsg_type == SO_TIMESTAMPNS_NEW)
> +      if (sizeof (time_t) > 4 && cmsg->cmsg_type == COMPAT_SO_TIMESTAMPNS_NEW)
>  	found_timestamp = true;
>        else
> -	TEST_VERIFY (cmsg->cmsg_type != SO_TIMESTAMPNS_NEW);
> +	TEST_VERIFY (cmsg->cmsg_type != COMPAT_SO_TIMESTAMPNS_NEW);
>      }
>  
>      if (sizeof (time_t) > 4)


-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] linux: Use socket-constants-time64.h on tst-socket-timestamp-compat
  2022-02-14 13:37 [PATCH] linux: Use socket-constants-time64.h on tst-socket-timestamp-compat Adhemerval Zanella
  2022-02-14 14:28 ` Carlos O'Donell
@ 2022-02-14 16:48 ` Tulio Magno Quites Machado Filho
  1 sibling, 0 replies; 3+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2022-02-14 16:48 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha, Florian Weimer

Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org> writes:

> The kernel header might not define the SO_TIMESTAMP{NS}_OLD or
> SO_TIMESTAMP{NS}_NEW if it older than v5.1.

This patch solved the issue I was seeing.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>

Thanks!

-- 
Tulio Magno

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-02-14 16:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-14 13:37 [PATCH] linux: Use socket-constants-time64.h on tst-socket-timestamp-compat Adhemerval Zanella
2022-02-14 14:28 ` Carlos O'Donell
2022-02-14 16:48 ` Tulio Magno Quites Machado Filho

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).