Message ID | 1598005119-2147-1-git-send-email-xuyang2018.jy@cn.fujitsu.com |
---|---|
State | Accepted |
Headers | show |
Series | tst_af_alg: fix build error when ALG_SET_AEAD_ASSOCLEN undefined | expand |
Hi, > configure.ac | 6 ++++++ > include/lapi/if_alg.h | 39 ++++++++++++++++++++++++++++++--------- > 2 files changed, 36 insertions(+), 9 deletions(-) > diff --git a/configure.ac b/configure.ac > index 382963d8b..f711ac123 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -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. > + > # Tools knobs > # Expect > diff --git a/include/lapi/if_alg.h b/include/lapi/if_alg.h > index 5a74df99b..9c04a444c 100644 > --- a/include/lapi/if_alg.h > +++ b/include/lapi/if_alg.h > @@ -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). > +#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: Reviewed-by: Petr Vorel <pvorel@suse.cz> Kind regards, Petr
Hi, ... > --- a/configure.ac > +++ b/configure.ac > @@ -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) > +]) > + > # Tools knobs ... Kind regards, Petr
Hi Petr > Hi, > >> configure.ac | 6 ++++++ >> include/lapi/if_alg.h | 39 ++++++++++++++++++++++++++++++--------- >> 2 files changed, 36 insertions(+), 9 deletions(-) > >> diff --git a/configure.ac b/configure.ac >> index 382963d8b..f711ac123 100644 >> --- a/configure.ac >> +++ b/configure.ac >> @@ -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. Thanks. >> + >> # Tools knobs > >> # Expect >> diff --git a/include/lapi/if_alg.h b/include/lapi/if_alg.h >> index 5a74df99b..9c04a444c 100644 >> --- a/include/lapi/if_alg.h >> +++ b/include/lapi/if_alg.h >> @@ -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) Agree. ignore it is better. > > (and later forgot to update it). > >> +#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: > Reviewed-by: Petr Vorel <pvorel@suse.cz> > > Kind regards, > Petr > >
Hi Petr > Hi, > > ... >> --- a/configure.ac >> +++ b/configure.ac >> @@ -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) >> +]) 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 >> + >> # Tools knobs > ... > > Kind regards, > Petr > >
Hi Xu, > Hi Petr > > Hi, > > ... > > > --- a/configure.ac > > > +++ b/configure.ac > > > @@ -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) > > > +]) > 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 > ]) I'll fix it and merge. Kind regards, Petr > Best Regards > Yang Xu
Hi, > > ... > > > --- a/configure.ac > > > +++ b/configure.ac > > > @@ -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) > > > +]) > Yes. Do you merge this patch with deleting this ifdef? Or I sent a v2 patch > for this. Merged. > 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
diff --git a/configure.ac b/configure.ac index 382963d8b..f711ac123 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/include/lapi/if_alg.h b/include/lapi/if_alg.h index 5a74df99b..9c04a444c 100644 --- a/include/lapi/if_alg.h +++ b/include/lapi/if_alg.h @@ -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__ */
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()") Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com> --- configure.ac | 6 ++++++ include/lapi/if_alg.h | 39 ++++++++++++++++++++++++++++++--------- 2 files changed, 36 insertions(+), 9 deletions(-)