From 23f0dc01aec74e21eca3bf1fd532a0ef853db7b4 Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Thu, 10 Oct 2019 10:27:40 +0200
Subject: [PATCH 57/76] rtnl_rule: decode fib_rule_uid_range without use of
<linux/fib_rules.h>
* rtnl_rule.c (decode_fib_rule_uid_range): Define struct type for
fib_rule_uid_range explicitly.
(decode_fib_rule_uid_range) [!HAVE_STRUCT_FIB_RULE_UID_RANGE]: Remove.
* xlat/fib_rule_flags.in: Add fallback definitions.
References: https://bugzilla.redhat.com/show_bug.cgi?id=1758201
---
rtnl_rule.c | 9 ++++-----
xlat/fib_rule_flags.in | 12 ++++++------
2 files changed, 10 insertions(+), 11 deletions(-)
Index: strace-5.1/rtnl_rule.c
===================================================================
--- strace-5.1.orig/rtnl_rule.c 2018-12-10 01:00:00.000000000 +0100
+++ strace-5.1/rtnl_rule.c 2020-01-29 12:32:57.315224088 +0100
@@ -42,8 +42,10 @@
const unsigned int len,
const void *const opaque_data)
{
-#ifdef HAVE_STRUCT_FIB_RULE_UID_RANGE
- struct fib_rule_uid_range range;
+ struct /* fib_rule_uid_range */ {
+ uint32_t start;
+ uint32_t end;
+ } range;
if (len < sizeof(range))
return false;
@@ -54,9 +56,6 @@
}
return true;
-#else
- return false;
-#endif
}
static bool
Index: strace-5.1/xlat/fib_rule_flags.in
===================================================================
--- strace-5.1.orig/xlat/fib_rule_flags.in 2017-08-14 03:06:59.000000000 +0200
+++ strace-5.1/xlat/fib_rule_flags.in 2020-01-29 12:32:57.316224079 +0100
@@ -1,6 +1,6 @@
-FIB_RULE_PERMANENT
-FIB_RULE_INVERT
-FIB_RULE_UNRESOLVED
-FIB_RULE_IIF_DETACHED
-FIB_RULE_OIF_DETACHED
-FIB_RULE_FIND_SADDR
+FIB_RULE_PERMANENT 0x00000001
+FIB_RULE_INVERT 0x00000002
+FIB_RULE_UNRESOLVED 0x00000004
+FIB_RULE_IIF_DETACHED 0x00000008
+FIB_RULE_OIF_DETACHED 0x00000010
+FIB_RULE_FIND_SADDR 0x00010000
Index: strace-5.1/xlat/fib_rule_flags.h
===================================================================
--- strace-5.1.orig/xlat/fib_rule_flags.h 2019-05-22 15:08:30.000000000 +0200
+++ strace-5.1/xlat/fib_rule_flags.h 2020-01-29 12:33:16.856044719 +0100
@@ -3,35 +3,65 @@
#include "gcc_compat.h"
#include "static_assert.h"
-
-#ifndef XLAT_MACROS_ONLY
-
-# ifdef IN_MPERS
-
-# error static const struct xlat fib_rule_flags in mpers mode
-
-# else
-
-static
-const struct xlat fib_rule_flags[] = {
#if defined(FIB_RULE_PERMANENT) || (defined(HAVE_DECL_FIB_RULE_PERMANENT) && HAVE_DECL_FIB_RULE_PERMANENT)
- XLAT(FIB_RULE_PERMANENT),
+DIAG_PUSH_IGNORE_TAUTOLOGICAL_COMPARE
+static_assert((FIB_RULE_PERMANENT) == (0x00000001), "FIB_RULE_PERMANENT != 0x00000001");
+DIAG_POP_IGNORE_TAUTOLOGICAL_COMPARE
+#else
+# define FIB_RULE_PERMANENT 0x00000001
#endif
#if defined(FIB_RULE_INVERT) || (defined(HAVE_DECL_FIB_RULE_INVERT) && HAVE_DECL_FIB_RULE_INVERT)
- XLAT(FIB_RULE_INVERT),
+DIAG_PUSH_IGNORE_TAUTOLOGICAL_COMPARE
+static_assert((FIB_RULE_INVERT) == (0x00000002), "FIB_RULE_INVERT != 0x00000002");
+DIAG_POP_IGNORE_TAUTOLOGICAL_COMPARE
+#else
+# define FIB_RULE_INVERT 0x00000002
#endif
#if defined(FIB_RULE_UNRESOLVED) || (defined(HAVE_DECL_FIB_RULE_UNRESOLVED) && HAVE_DECL_FIB_RULE_UNRESOLVED)
- XLAT(FIB_RULE_UNRESOLVED),
+DIAG_PUSH_IGNORE_TAUTOLOGICAL_COMPARE
+static_assert((FIB_RULE_UNRESOLVED) == (0x00000004), "FIB_RULE_UNRESOLVED != 0x00000004");
+DIAG_POP_IGNORE_TAUTOLOGICAL_COMPARE
+#else
+# define FIB_RULE_UNRESOLVED 0x00000004
#endif
#if defined(FIB_RULE_IIF_DETACHED) || (defined(HAVE_DECL_FIB_RULE_IIF_DETACHED) && HAVE_DECL_FIB_RULE_IIF_DETACHED)
- XLAT(FIB_RULE_IIF_DETACHED),
+DIAG_PUSH_IGNORE_TAUTOLOGICAL_COMPARE
+static_assert((FIB_RULE_IIF_DETACHED) == (0x00000008), "FIB_RULE_IIF_DETACHED != 0x00000008");
+DIAG_POP_IGNORE_TAUTOLOGICAL_COMPARE
+#else
+# define FIB_RULE_IIF_DETACHED 0x00000008
#endif
#if defined(FIB_RULE_OIF_DETACHED) || (defined(HAVE_DECL_FIB_RULE_OIF_DETACHED) && HAVE_DECL_FIB_RULE_OIF_DETACHED)
- XLAT(FIB_RULE_OIF_DETACHED),
+DIAG_PUSH_IGNORE_TAUTOLOGICAL_COMPARE
+static_assert((FIB_RULE_OIF_DETACHED) == (0x00000010), "FIB_RULE_OIF_DETACHED != 0x00000010");
+DIAG_POP_IGNORE_TAUTOLOGICAL_COMPARE
+#else
+# define FIB_RULE_OIF_DETACHED 0x00000010
#endif
#if defined(FIB_RULE_FIND_SADDR) || (defined(HAVE_DECL_FIB_RULE_FIND_SADDR) && HAVE_DECL_FIB_RULE_FIND_SADDR)
- XLAT(FIB_RULE_FIND_SADDR),
+DIAG_PUSH_IGNORE_TAUTOLOGICAL_COMPARE
+static_assert((FIB_RULE_FIND_SADDR) == (0x00010000), "FIB_RULE_FIND_SADDR != 0x00010000");
+DIAG_POP_IGNORE_TAUTOLOGICAL_COMPARE
+#else
+# define FIB_RULE_FIND_SADDR 0x00010000
#endif
+
+#ifndef XLAT_MACROS_ONLY
+
+# ifdef IN_MPERS
+
+# error static const struct xlat fib_rule_flags in mpers mode
+
+# else
+
+static
+const struct xlat fib_rule_flags[] = {
+ XLAT(FIB_RULE_PERMANENT),
+ XLAT(FIB_RULE_INVERT),
+ XLAT(FIB_RULE_UNRESOLVED),
+ XLAT(FIB_RULE_IIF_DETACHED),
+ XLAT(FIB_RULE_OIF_DETACHED),
+ XLAT(FIB_RULE_FIND_SADDR),
XLAT_END
};