summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-04-17 10:23:03 +0200
committerThomas Haller <thaller@redhat.com>2019-04-18 11:11:44 +0200
commit91252bb2fbfd02d712ae556ecc816146155a6f85 (patch)
tree92b7b5e906a5a7409133dc77ff45e47479f413eb
parentcd62d43963647451d2a152e2c4cbf79e243d1123 (diff)
downloadNetworkManager-91252bb2fbfd02d712ae556ecc816146155a6f85.tar.gz
platform: detect kernel support for FRA_IP_PROTO, FRA_SPORT_RANGE, FRA_DPORT_RANGE
-rw-r--r--src/platform/nm-linux-platform.c12
-rw-r--r--src/platform/nm-platform.c5
-rw-r--r--src/platform/nm-platform.h5
3 files changed, 22 insertions, 0 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index 662f3d7046..1fc7cc3908 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -3431,6 +3431,18 @@ _new_from_nl_routing_rule (struct nlmsghdr *nlh, gboolean id_only)
nla_memcpy_checked_size (&props->sport_range, tb[FRA_SPORT_RANGE], sizeof (props->sport_range));
nla_memcpy_checked_size (&props->dport_range, tb[FRA_DPORT_RANGE], sizeof (props->dport_range));
+ if (!_nm_platform_kernel_support_detected (NM_PLATFORM_KERNEL_SUPPORT_TYPE_FRA_IP_PROTO)) {
+ /* support for FRA_IP_PROTO, FRA_SPORT_RANGE, and FRA_DPORT_RANGE was added together
+ * by bfff4862653bb96001ab57c1edd6d03f48e5f035, kernel 4.17, 4 June 2018.
+ *
+ * Unfortunately, a missing attribute does not tell us anything about support.
+ * We can only tell for sure when we have support, but not when we don't have. */
+ if ( tb[FRA_IP_PROTO]
+ || tb[FRA_SPORT_RANGE]
+ || tb[FRA_DPORT_RANGE])
+ _nm_platform_kernel_support_init (NM_PLATFORM_KERNEL_SUPPORT_TYPE_FRA_IP_PROTO, 1);
+ }
+
G_STATIC_ASSERT_EXPR (sizeof (NMFibRuleUidRange) == 8);
G_STATIC_ASSERT_EXPR (G_STRUCT_OFFSET (NMFibRuleUidRange, start) == 0);
G_STATIC_ASSERT_EXPR (G_STRUCT_OFFSET (NMFibRuleUidRange, end) == 4);
diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c
index b5636d60d5..f16e7aec2a 100644
--- a/src/platform/nm-platform.c
+++ b/src/platform/nm-platform.c
@@ -301,6 +301,11 @@ static const struct {
.name = "FRA_PROTOCOL",
.desc = "FRA_PROTOCOL attribute for policy routing rules",
},
+ [NM_PLATFORM_KERNEL_SUPPORT_TYPE_FRA_IP_PROTO] = {
+ .compile_time_default = (FRA_MAX >= 22 /* FRA_IP_PROTO */),
+ .name = "FRA_IP_PROTO",
+ .desc = "FRA_IP_PROTO, FRA_SPORT_RANGE, FRA_DPORT_RANGE attributes for policy routing rules",
+ },
};
int
diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h
index 1d5b18402a..639fe5a51f 100644
--- a/src/platform/nm-platform.h
+++ b/src/platform/nm-platform.h
@@ -849,6 +849,11 @@ typedef enum {
NM_PLATFORM_KERNEL_SUPPORT_TYPE_USER_IPV6LL,
NM_PLATFORM_KERNEL_SUPPORT_TYPE_RTA_PREF,
NM_PLATFORM_KERNEL_SUPPORT_TYPE_FRA_PROTOCOL,
+
+ /* this also includes FRA_SPORT_RANGE and FRA_DPORT_RANGE which
+ * were added at the same time. */
+ NM_PLATFORM_KERNEL_SUPPORT_TYPE_FRA_IP_PROTO,
+
_NM_PLATFORM_KERNEL_SUPPORT_NUM,
} NMPlatformKernelSupportType;