diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml
index 7338b11280..8f317c25a7 100644
--- a/man/systemd.unit.xml
+++ b/man/systemd.unit.xml
@@ -1117,11 +1117,12 @@
the exact assignment is looked for with right and left hand
side matching.
- ConditionKernelVersion= may be used to check whether the kernel version (as reported
- by uname -r) matches a certain expression (or if prefixed with the exclamation mark does not
- match it). The argument must be a single string. If the string starts with one of <,
- <=, =, >=, > a relative
- version comparison is done, otherwise the specified string is matched with shell-style globs.
+ ConditionKernelVersion= may be used to check whether the kernel version (as
+ reported by uname -r) matches a certain expression (or if prefixed with the
+ exclamation mark does not match it). The argument must be a single string. If the string starts with
+ one of <, <=, =,
+ !=, >=, > a relative version
+ comparison is done, otherwise the specified string is matched with shell-style globs.
Note that using the kernel version string is an unreliable way to determine which features are supported
by a kernel, because of the widespread practice of backporting drivers, features, and fixes from newer upstream
diff --git a/src/shared/condition.c b/src/shared/condition.c
index 5853b4d61f..38ebaef62b 100644
--- a/src/shared/condition.c
+++ b/src/shared/condition.c
@@ -138,6 +138,7 @@ typedef enum {
ORDER_LOWER,
ORDER_GREATER,
ORDER_EQUAL,
+ ORDER_UNEQUAL,
_ORDER_MAX,
_ORDER_INVALID = -1
} OrderOperator;
@@ -150,6 +151,7 @@ static OrderOperator parse_order(const char **s) {
[ORDER_LOWER] = "<",
[ORDER_GREATER] = ">",
[ORDER_EQUAL] = "=",
+ [ORDER_UNEQUAL] = "!=",
};
OrderOperator i;
@@ -180,6 +182,9 @@ static bool test_order(int k, OrderOperator p) {
case ORDER_EQUAL:
return k == 0;
+ case ORDER_UNEQUAL:
+ return k != 0;
+
case ORDER_GREATER_OR_EQUAL:
return k >= 0;