Skip to contentSkip to conversation

tst_af_alg: fix build error when ALG_SET_AEAD_ASSOCLEN undefined

PATCH New Yang Xu 2 participants 7 messages Aug 21, 2020 – Aug 28, 2020

lore
Share & tools
lore

Yang Xu

author
#0 lore raw

PATCH 1/1 tst_af_alg: fix build error when ALG_SET_AEAD_ASSOCLEN undefined

On older kernel such as 3.10.0-1136.el7.x86_64, compile failed as below:
tst_af_alg.c: In function ?tst_alg_sendmsg?:
tst_af_alg.c:205:21: error: ?ALG_SET_AEAD_ASSOCLEN? undeclared (first use in this function)

   cmsg->cmsg_type = ALG_SET_AEAD_ASSOCLEN;
                     ^

tst_af_alg.c:205:21: note: each undeclared identifier is reported only once for each function it appears in
make: *** [tst_af_alg.o] Error 1

It compile failed because ltp lapi/if_alg.h can't handle fallback logic, so corret it.

The ALG_SET_AEAD_ASSOCLEN flag was introduced since kernel commit af8e80731a ("crypto: af_alg - add user space interface for AEAD") in 2014.

Fixes 3cbb963abb ("lib/tst_af_alg: add tst_alg_sendmsg()")
---
 configure.ac          |  6 ++++++
 include/lapi/if_alg.h | 39 ++++++++++++++++++++++++++++++---------
 2 files changed, 36 insertions(+), 9 deletions(-)
configure.ac +6 -0
index 382963d8b..f711ac123 100644
@@ -193,6 +193,12 @@ AC_CHECK_TYPES([struct xt_entry_match, struct xt_entry_target],,,[
 #include <linux/netfilter_ipv4/ip_tables.h>
 ])
 
+AC_CHECK_TYPES([struct sockaddr_alg, struct af_alg_iv],,,[
+#ifdef HAVE_LINUX_IF_ALG_H
+# include <linux/if_alg.h>
+#endif
+])
+
 # Tools knobs
 
 # Expect
include/lapi/if_alg.h +30 -9
index 5a74df99b..9c04a444c 100644
@@ -8,9 +8,10 @@
 
 #ifdef HAVE_LINUX_IF_ALG_H
 #  include <linux/if_alg.h>
-#else
+#endif
 #  include <stdint.h>
 
+#ifndef HAVE_STRUCT_SOCKADDR_ALG
 struct sockaddr_alg {
 	uint16_t	salg_family;
 	uint8_t		salg_type[14];
@@ -18,21 +19,41 @@ struct sockaddr_alg {
 	uint32_t	salg_mask;
 	uint8_t		salg_name[64];
 };
+#endif
 
+#ifndef HAVE_STRUCT_AF_ALG_IV
 struct af_alg_iv {
 	uint32_t	ivlen;
 	uint8_t		iv[0];
 };
+#endif
 
-#define ALG_SET_KEY		1
-#define ALG_SET_IV		2
-#define ALG_SET_OP		3
-#define ALG_SET_AEAD_ASSOCLEN	4
-#define ALG_SET_AEAD_AUTHSIZE	5
+#ifndef ALG_SET_KEY
+# define ALG_SET_KEY		1
+#endif
 
-#define ALG_OP_DECRYPT		0
-#define ALG_OP_ENCRYPT		1
+#ifndef ALG_SET_IV
+# define ALG_SET_IV		2
+#endif
 
-#endif /* !HAVE_LINUX_IF_ALG_H */
+#ifndef ALG_SET_OP
+# define ALG_SET_OP		3
+#endif
+
+#ifndef ALG_SET_AEAD_ASSOCLEN
+# define ALG_SET_AEAD_ASSOCLEN	4
+#endif
+
+#ifndef ALG_SET_AEAD_AUTHSIZE
+# define ALG_SET_AEAD_AUTHSIZE	5
+#endif
+
+#ifndef ALG_OP_DECRYPT
+# define ALG_OP_DECRYPT		0
+#endif
+
+#ifndef ALG_OP_ENCRYPT
+# define ALG_OP_ENCRYPT		1
+#endif
 
 #endif /* IF_ALG_H__ */
Signature · 1 line
2.23.0
#1 lore raw

PATCH 1/1 tst_af_alg: fix build error when ALG_SET_AEAD_ASSOCLEN undefined

Hi,

Quoted 9 lines
 configure.ac          |  6 ++++++
 include/lapi/if_alg.h | 39 ++++++++++++++++++++++++++++++---------
 2 files changed, 36 insertions(+), 9 deletions(-)
configure.ac +0 -0
index 382963d8b..f711ac123 100644

configure.ac AC_CHECK_TYPES([struct xt_entry_match, struct xt_entry_target],,,[ · line 200

Quoted 8 lines
configure.ac +5 -0
@@ -193,6 +193,12 @@ AC_CHECK_TYPES([struct xt_entry_match, struct xt_entry_target],,,[
 #include <linux/netfilter_ipv4/ip_tables.h>
 ])
 
+AC_CHECK_TYPES([struct sockaddr_alg, struct af_alg_iv],,,[
+#ifdef HAVE_LINUX_IF_ALG_H
+# include <linux/if_alg.h>
+#endif
+])

nit: This list was meant to be sorted. I'll handle that during merge.

Quoted 9 lines
configure.ac +1 -0
+
 # Tools knobs
 
 # Expect
include/lapi/if_alg.h +0 -0
index 5a74df99b..9c04a444c 100644

include/lapi/if_alg.h line 12

Quoted 6 lines
include/lapi/if_alg.h +1 -1
@@ -8,9 +8,10 @@
 
 #ifdef HAVE_LINUX_IF_ALG_H
 #  include <linux/if_alg.h>
-#else
+#endif
 #  include <stdint.h>

BTW <stdint.h> is needed only for "#ifndef HAVE_STRUCT_SOCKADDR_ALG" and "#ifndef HAVE_STRUCT_AF_ALG_IVL" (for uint*_t) but we can ignore that as a detail (better than have complicated guarder:
#if ! (defined(HAVE_STRUCT_SOCKADDR_ALG) && defined(HAVE_STRUCT_AF_ALG_IVL)

(and later forgot to update it).

include/lapi/if_alg.h struct sockaddr_alg { · line 22

Quoted 9 lines
include/lapi/if_alg.h +2 -0
+#ifndef HAVE_STRUCT_SOCKADDR_ALG
 struct sockaddr_alg {
 	uint16_t	salg_family;
 	uint8_t		salg_type[14];
@@ -18,21 +19,41 @@ struct sockaddr_alg {
 	uint32_t	salg_mask;
 	uint8_t		salg_name[64];
 };
+#endif

The rest lgtm:

Kind regards,
Petr

author
#2 lore raw

PATCH 1/1 tst_af_alg: fix build error when ALG_SET_AEAD_ASSOCLEN undefined

Hi Petr

Quoted 14 lines

Hi,

Quoted 11 lines
  configure.ac          |  6 ++++++
  include/lapi/if_alg.h | 39 ++++++++++++++++++++++++++++++---------
  2 files changed, 36 insertions(+), 9 deletions(-)
configure.ac +0 -0
index 382963d8b..f711ac123 100644
@@ -193,6 +193,12 @@ AC_CHECK_TYPES([struct xt_entry_match, struct xt_entry_target],,,[
  #include <linux/netfilter_ipv4/ip_tables.h>
  ])
Quoted 6 lines

configure.ac AC_CHECK_TYPES([struct xt_entry_match, struct xt_entry_target],,,[ · line 200

Quoted 5 lines
configure.ac +5 -0
+AC_CHECK_TYPES([struct sockaddr_alg, struct af_alg_iv],,,[
+#ifdef HAVE_LINUX_IF_ALG_H
+# include <linux/if_alg.h>
+#endif
+])

nit: This list was meant to be sorted. I'll handle that during merge.

Thanks.

Quoted 10 lines
Quoted 9 lines
configure.ac +1 -0
+
  # Tools knobs
 
  # Expect
include/lapi/if_alg.h +0 -0
index 5a74df99b..9c04a444c 100644
@@ -8,9 +8,10 @@
Quoted 9 lines

include/lapi/if_alg.h line 12

Quoted 5 lines
include/lapi/if_alg.h +1 -1
  #ifdef HAVE_LINUX_IF_ALG_H
  #  include <linux/if_alg.h>
-#else
+#endif
  #  include <stdint.h>

BTW <stdint.h> is needed only for "#ifndef HAVE_STRUCT_SOCKADDR_ALG" and "#ifndef HAVE_STRUCT_AF_ALG_IVL" (for uint*_t) but we can ignore that as a detail (better than have complicated guarder:
#if ! (defined(HAVE_STRUCT_SOCKADDR_ALG) && defined(HAVE_STRUCT_AF_ALG_IVL)

Agree. ignore it is better.

Quoted 20 lines

(and later forgot to update it).

include/lapi/if_alg.h struct sockaddr_alg { · line 22

Quoted 9 lines
include/lapi/if_alg.h +2 -0
+#ifndef HAVE_STRUCT_SOCKADDR_ALG
  struct sockaddr_alg {
  	uint16_t	salg_family;
  	uint8_t		salg_type[14];
@@ -18,21 +19,41 @@ struct sockaddr_alg {
  	uint32_t	salg_mask;
  	uint8_t		salg_name[64];
  };
+#endif

The rest lgtm:

Kind regards,
Petr

#3 lore raw

PATCH 1/1 tst_af_alg: fix build error when ALG_SET_AEAD_ASSOCLEN undefined

In reply to Yang Xu

Hi,

...

configure.ac AC_CHECK_TYPES([struct xt_entry_match, struct xt_entry_target],,,[ · line 199

Quoted 10 lines
configure.ac +4 -0
@@ -193,6 +193,12 @@ AC_CHECK_TYPES([struct xt_entry_match, struct xt_entry_target],,,[
 #include <linux/netfilter_ipv4/ip_tables.h>
 ])
 
+AC_CHECK_TYPES([struct sockaddr_alg, struct af_alg_iv],,,[
+#ifdef HAVE_LINUX_IF_ALG_H
+# include <linux/if_alg.h>
+#endif

IMHO <linux/if_alg.h> does not need to be guarded.
(as the definitions are in it it either fail because missing or fail because not loaded)

configure.ac AC_CHECK_TYPES([struct xt_entry_match, struct xt_entry_target],,,[ · line 202

Quoted 3 lines
configure.ac +2 -0
+])
+
 # Tools knobs

...

Kind regards,
Petr

author
#4 lore raw

PATCH 1/1 tst_af_alg: fix build error when ALG_SET_AEAD_ASSOCLEN undefined

Hi Petr

Quoted 9 lines

Hi,

...

Quoted 5 lines
configure.ac +0 -0
@@ -193,6 +193,12 @@ AC_CHECK_TYPES([struct xt_entry_match, struct xt_entry_target],,,[
  #include <linux/netfilter_ipv4/ip_tables.h>
  ])
Quoted 8 lines

configure.ac AC_CHECK_TYPES([struct xt_entry_match, struct xt_entry_target],,,[ · line 199

Quoted 4 lines
configure.ac +4 -0
+AC_CHECK_TYPES([struct sockaddr_alg, struct af_alg_iv],,,[
+#ifdef HAVE_LINUX_IF_ALG_H
+# include <linux/if_alg.h>
+#endif

IMHO <linux/if_alg.h> does not need to be guarded.
(as the definitions are in it it either fail because missing or fail because not loaded)

Quoted 1 line
configure.ac +1 -0
+])

Yes. Do you merge this patch with deleting this ifdef? Or I sent a v2 patch for this.

Also, I think you can remove" #ifdef HAVE_LINUX_IF_PACKET_H" pair in configure.ac
AC_CHECK_TYPES([struct tpacket_req3],,,[
#ifdef HAVE_LINUX_IF_PACKET_H

# include <linux/if_packet.h>
#endif
])

Best Regards
Yang Xu

Quoted 8 lines

configure.ac AC_CHECK_TYPES([struct xt_entry_match, struct xt_entry_target],,,[ · line 202

Quoted 2 lines
configure.ac +1 -0
+
  # Tools knobs

...

Kind regards,
Petr

#5 lore raw

PATCH 1/1 tst_af_alg: fix build error when ALG_SET_AEAD_ASSOCLEN undefined

Hi Xu,

Quoted 22 lines

Hi Petr

Quoted 9 lines

Hi,

...

Quoted 5 lines
configure.ac +0 -0
@@ -193,6 +193,12 @@ AC_CHECK_TYPES([struct xt_entry_match, struct xt_entry_target],,,[
  #include <linux/netfilter_ipv4/ip_tables.h>
  ])
Quoted 8 lines

configure.ac AC_CHECK_TYPES([struct xt_entry_match, struct xt_entry_target],,,[ · line 199

Quoted 4 lines
configure.ac +4 -0
+AC_CHECK_TYPES([struct sockaddr_alg, struct af_alg_iv],,,[
+#ifdef HAVE_LINUX_IF_ALG_H
+# include <linux/if_alg.h>
+#endif

IMHO <linux/if_alg.h> does not need to be guarded.
(as the definitions are in it it either fail because missing or fail because not loaded)

Quoted 1 line
configure.ac +1 -0
+])

Yes. Do you merge this patch with deleting this ifdef? Or I sent a v2 patch for this.

Quoted 7 lines

Also, I think you can remove" #ifdef HAVE_LINUX_IF_PACKET_H" pair in configure.ac
AC_CHECK_TYPES([struct tpacket_req3],,,[
#ifdef HAVE_LINUX_IF_PACKET_H

# include <linux/if_packet.h>
#endif
])

I'll fix it and merge.

Kind regards,
Petr

Quoted 2 lines

Best Regards
Yang Xu

#6 lore raw

PATCH 1/1 tst_af_alg: fix build error when ALG_SET_AEAD_ASSOCLEN undefined

In reply to Yang Xu

Hi,

Quoted 14 lines
Quoted 14 lines

...

configure.ac AC_CHECK_TYPES([struct xt_entry_match, struct xt_entry_target],,,[ · line 199

Quoted 10 lines
configure.ac +4 -0
@@ -193,6 +193,12 @@ AC_CHECK_TYPES([struct xt_entry_match, struct xt_entry_target],,,[
  #include <linux/netfilter_ipv4/ip_tables.h>
  ])
 
+AC_CHECK_TYPES([struct sockaddr_alg, struct af_alg_iv],,,[
+#ifdef HAVE_LINUX_IF_ALG_H
+# include <linux/if_alg.h>
+#endif

IMHO <linux/if_alg.h> does not need to be guarded.
(as the definitions are in it it either fail because missing or fail because not loaded)

Quoted 3 lines
Quoted 1 line

configure.ac AC_CHECK_TYPES([struct xt_entry_match, struct xt_entry_target],,,[ · line 200

Quoted 1 line
configure.ac +1 -0
+])

Yes. Do you merge this patch with deleting this ifdef? Or I sent a v2 patch for this.

Merged.

Quoted 7 lines

Also, I think you can remove" #ifdef HAVE_LINUX_IF_PACKET_H" pair in configure.ac
AC_CHECK_TYPES([struct tpacket_req3],,,[
#ifdef HAVE_LINUX_IF_PACKET_H

# include <linux/if_packet.h>
#endif
])

I'll cleanup this in a separate patch.

Kind regards,
Petr