netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net] selftests: txtimestamp: fix compilation issue
@ 2021-02-03 20:52 Vadim Fedorenko
  2021-02-04 13:34 ` Willem de Bruijn
  0 siblings, 1 reply; 3+ messages in thread
From: Vadim Fedorenko @ 2021-02-03 20:52 UTC (permalink / raw)
  To: Jakub Kicinski, Jian Yang; +Cc: Vadim Fedorenko, netdev

PACKET_TX_TIMESTAMP is defined in if_packet.h but it is not included in
test. But we cannot include it because we have definitions of struct and
including leads to redefinition error. So define PACKET_TX_TIMESTAMP too.

Fixes: 5ef5c90e3cb3 (selftests: move timestamping selftests to net folder)
Signed-off-by: Vadim Fedorenko <vfedorenko@novek.ru>
---
 tools/testing/selftests/net/txtimestamp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/testing/selftests/net/txtimestamp.c b/tools/testing/selftests/net/txtimestamp.c
index 490a8cc..2010f47 100644
--- a/tools/testing/selftests/net/txtimestamp.c
+++ b/tools/testing/selftests/net/txtimestamp.c
@@ -53,6 +53,7 @@
 #define NSEC_PER_USEC	1000L
 #define USEC_PER_SEC	1000000L
 #define NSEC_PER_SEC	1000000000LL
+#define PACKET_TX_TIMESTAMP		16
 
 /* command line parameters */
 static int cfg_proto = SOCK_STREAM;
-- 
1.8.3.1


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

* Re: [net] selftests: txtimestamp: fix compilation issue
  2021-02-03 20:52 [net] selftests: txtimestamp: fix compilation issue Vadim Fedorenko
@ 2021-02-04 13:34 ` Willem de Bruijn
  2021-02-04 15:10   ` Vadim Fedorenko
  0 siblings, 1 reply; 3+ messages in thread
From: Willem de Bruijn @ 2021-02-04 13:34 UTC (permalink / raw)
  To: Vadim Fedorenko; +Cc: Jakub Kicinski, Jian Yang, Network Development

On Wed, Feb 3, 2021 at 4:11 PM Vadim Fedorenko <vfedorenko@novek.ru> wrote:
>
> PACKET_TX_TIMESTAMP is defined in if_packet.h but it is not included in
> test. But we cannot include it because we have definitions of struct and
> including leads to redefinition error. So define PACKET_TX_TIMESTAMP too.

The conflicts are with <netpacket/packet.h>. I think it will build if
you remove that.

> Fixes: 5ef5c90e3cb3 (selftests: move timestamping selftests to net folder)

This commit only moved the file. The file was moved twice. Even though
it cannot really be applied easily before the move, this goes back to
commit 8fe2f761cae9 ("net-timestamp: expand documentation").

> Signed-off-by: Vadim Fedorenko <vfedorenko@novek.ru>

Do you also get the compiler warning about ambiguous control flow?

  tools/testing/selftests/net/txtimestamp.c:498:6: warning: suggest
explicit braces to avoid ambiguous ‘else’ [-Wdangling-else]

When touching this file, might be good to also fix that up:

-               if (cfg_use_pf_packet || cfg_ipproto == IPPROTO_RAW)
+               if (cfg_use_pf_packet || cfg_ipproto == IPPROTO_RAW) {
                        if (family == PF_INET)
                                total_len += sizeof(struct iphdr);
                        else
                                total_len += sizeof(struct ipv6hdr);
+               }

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

* Re: [net] selftests: txtimestamp: fix compilation issue
  2021-02-04 13:34 ` Willem de Bruijn
@ 2021-02-04 15:10   ` Vadim Fedorenko
  0 siblings, 0 replies; 3+ messages in thread
From: Vadim Fedorenko @ 2021-02-04 15:10 UTC (permalink / raw)
  To: Willem de Bruijn; +Cc: Jakub Kicinski, Jian Yang, Network Development

On 04.02.2021 13:34, Willem de Bruijn wrote:
> On Wed, Feb 3, 2021 at 4:11 PM Vadim Fedorenko <vfedorenko@novek.ru> wrote:
>>
>> PACKET_TX_TIMESTAMP is defined in if_packet.h but it is not included in
>> test. But we cannot include it because we have definitions of struct and
>> including leads to redefinition error. So define PACKET_TX_TIMESTAMP too.
> 
> The conflicts are with <netpacket/packet.h>. I think it will build if
> you remove that.

Good point. I will try to replace the includes.

>> Fixes: 5ef5c90e3cb3 (selftests: move timestamping selftests to net folder)
> 
> This commit only moved the file. The file was moved twice. Even though
> it cannot really be applied easily before the move, this goes back to
> commit 8fe2f761cae9 ("net-timestamp: expand documentation").
Yeah, you are right. Didn't go so deep.

>> Signed-off-by: Vadim Fedorenko <vfedorenko@novek.ru>
> 
> Do you also get the compiler warning about ambiguous control flow?
> 
>    tools/testing/selftests/net/txtimestamp.c:498:6: warning: suggest
> explicit braces to avoid ambiguous ‘else’ [-Wdangling-else]
> 
> When touching this file, might be good to also fix that up:
> 
> -               if (cfg_use_pf_packet || cfg_ipproto == IPPROTO_RAW)
> +               if (cfg_use_pf_packet || cfg_ipproto == IPPROTO_RAW) {
>                          if (family == PF_INET)
>                                  total_len += sizeof(struct iphdr);
>                          else
>                                  total_len += sizeof(struct ipv6hdr);
> +               }
> 

Yes, but skipped it because the main goal was to fix selftests/net build in 
general and forgot about it later. I will address this warning too.

Thanks Willem!

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

end of thread, other threads:[~2021-02-04 16:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-03 20:52 [net] selftests: txtimestamp: fix compilation issue Vadim Fedorenko
2021-02-04 13:34 ` Willem de Bruijn
2021-02-04 15:10   ` Vadim Fedorenko

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 NNTP newsgroup(s).