diff mbox series

[RFC,2/2] lapi/if_addr.h: Define IFA_FLAGS

Message ID 20210929181709.31788-3-petr.vorel@gmail.com
State Changes Requested
Headers show
Series Fix old toolchain (< v3.14) | expand

Commit Message

Petr Vorel Sept. 29, 2021, 6:17 p.m. UTC
and use it in icmp_rate_limit01.c.

This fixes error on toolchains with very old kernel headers, e.g.
Buildroot sourcery-arm:

icmp_rate_limit01.c:82:3: error: 'IFA_F_NOPREFIXROUTE' undeclared (first use in this function)
   IFA_F_NOPREFIXROUTE);

Fixed because IFA_F_NOPREFIXROUTE was added in 3.14 and the oldest
system we still support is Cent0S 7 with 3.10 kernel.

NOTE: Cent0S 7 is obviously heavily patched thus it contains
IFA_F_NOPREFIXROUTE and therefore CI build didn't catch this error.

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
---
 include/lapi/if_addr.h            | 4 ++++
 testcases/cve/icmp_rate_limit01.c | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

Comments

Martin Doucha Sept. 30, 2021, 11:17 a.m. UTC | #1
Hi,

On 29. 09. 21 20:17, Petr Vorel wrote:
> and use it in icmp_rate_limit01.c.
> 
> This fixes error on toolchains with very old kernel headers, e.g.
> Buildroot sourcery-arm:
> 
> icmp_rate_limit01.c:82:3: error: 'IFA_F_NOPREFIXROUTE' undeclared (first use in this function)
>    IFA_F_NOPREFIXROUTE);
> 
> Fixed because IFA_F_NOPREFIXROUTE was added in 3.14 and the oldest
> system we still support is Cent0S 7 with 3.10 kernel.
> 
> NOTE: Cent0S 7 is obviously heavily patched thus it contains
> IFA_F_NOPREFIXROUTE and therefore CI build didn't catch this error.
> 
> Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
> ---
>  include/lapi/if_addr.h            | 4 ++++
>  testcases/cve/icmp_rate_limit01.c | 3 ++-
>  2 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/include/lapi/if_addr.h b/include/lapi/if_addr.h
> index 07e6a7c9b..0f7e44784 100644
> --- a/include/lapi/if_addr.h
> +++ b/include/lapi/if_addr.h
> @@ -8,6 +8,10 @@
>  
>  #include <linux/if_addr.h>
>  
> +#ifndef IFA_FLAGS
> +# define IFA_FLAGS 8
> +#endif

I don't understand why the move of IFA_FLAGS from lapi/rtnetlink.h to
lapi/if_addr.h is split into two separate patches. IFA_FLAGS is required
for compiling tst_netdevice.c so this patchset is not very bisect-friendly.

> +
>  #ifndef IFA_F_NOPREFIXROUTE
>  # define IFA_F_NOPREFIXROUTE	0x200
>  #endif
> diff --git a/testcases/cve/icmp_rate_limit01.c b/testcases/cve/icmp_rate_limit01.c
> index b3a237b30..3ada32675 100644
> --- a/testcases/cve/icmp_rate_limit01.c
> +++ b/testcases/cve/icmp_rate_limit01.c
> @@ -27,11 +27,12 @@
>  #include <sys/socket.h>
>  #include <netinet/in.h>
>  #include <arpa/inet.h>
> -#include <linux/if_addr.h>
>  #include <linux/errqueue.h>
>  
>  #include <sched.h>
>  #include <limits.h>
> +
> +#include "lapi/if_addr.h"
>  #include "tst_test.h"
>  #include "tst_netdevice.h"
>  
>
Petr Vorel Sept. 30, 2021, 5:17 p.m. UTC | #2
Hi Martin
,
> > +++ b/include/lapi/if_addr.h
> > @@ -8,6 +8,10 @@

> >  #include <linux/if_addr.h>

> > +#ifndef IFA_FLAGS
> > +# define IFA_FLAGS 8
> > +#endif

> I don't understand why the move of IFA_FLAGS from lapi/rtnetlink.h to
> lapi/if_addr.h is split into two separate patches. IFA_FLAGS is required
> for compiling tst_netdevice.c so this patchset is not very bisect-friendly.

Ah, good catch, thank you. Silly error I mixed up IFA_F_NOPREFIXROUTE and IFA_FLAGS => v2.

Kind regards,
Petr

> > +
> >  #ifndef IFA_F_NOPREFIXROUTE
> >  # define IFA_F_NOPREFIXROUTE	0x200
> >  #endif
diff mbox series

Patch

diff --git a/include/lapi/if_addr.h b/include/lapi/if_addr.h
index 07e6a7c9b..0f7e44784 100644
--- a/include/lapi/if_addr.h
+++ b/include/lapi/if_addr.h
@@ -8,6 +8,10 @@ 
 
 #include <linux/if_addr.h>
 
+#ifndef IFA_FLAGS
+# define IFA_FLAGS 8
+#endif
+
 #ifndef IFA_F_NOPREFIXROUTE
 # define IFA_F_NOPREFIXROUTE	0x200
 #endif
diff --git a/testcases/cve/icmp_rate_limit01.c b/testcases/cve/icmp_rate_limit01.c
index b3a237b30..3ada32675 100644
--- a/testcases/cve/icmp_rate_limit01.c
+++ b/testcases/cve/icmp_rate_limit01.c
@@ -27,11 +27,12 @@ 
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
-#include <linux/if_addr.h>
 #include <linux/errqueue.h>
 
 #include <sched.h>
 #include <limits.h>
+
+#include "lapi/if_addr.h"
 #include "tst_test.h"
 #include "tst_netdevice.h"