Blob Blame History Raw
From 09b9f5a18dbe01d0d3ab9b0db721eadab5e38b35 Mon Sep 17 00:00:00 2001
From: Vrinda Punj <vpunj@redhat.com>
Date: Mon, 29 Jun 2020 17:34:46 -0400
Subject: [PATCH 37/45] fix(cli): add ipset type hash:mac is incompatible with
 the family parameter Fixes: rhbz1541077

(cherry picked from commit dddba7b9c276e9c58f6c2bc554c82252fa084eaf)
(cherry picked from commit 15f5691f0dbffcc1d4c1f42e77e79c6600db0d77)
---
 src/firewall-cmd.in                 | 3 +++
 src/firewall-offline-cmd.in         | 3 +++
 src/tests/regression/regression.at  | 1 +
 src/tests/regression/rhbz1541077.at | 9 +++++++++
 4 files changed, 16 insertions(+)
 create mode 100644 src/tests/regression/rhbz1541077.at

diff --git a/src/firewall-cmd.in b/src/firewall-cmd.in
index 014f3884d64b..b6c2f84f5a9e 100755
--- a/src/firewall-cmd.in
+++ b/src/firewall-cmd.in
@@ -1074,6 +1074,9 @@ if a.permanent:
         if not a.type:
             cmd.fail(parser.format_usage() + "No type specified.")
 
+        if a.type=='hash:mac' and a.family:
+            cmd.fail(parser.format_usage()+ "--family is not compatible with the hash:mac type")
+
         settings = FirewallClientIPSetSettings()
         settings.setType(a.type)
         if a.option:
diff --git a/src/firewall-offline-cmd.in b/src/firewall-offline-cmd.in
index c0ad9ec8f64e..98c00548e3e5 100755
--- a/src/firewall-offline-cmd.in
+++ b/src/firewall-offline-cmd.in
@@ -1577,6 +1577,9 @@ try:
         if not a.type:
             cmd.fail(parser.format_usage() + "No type specified.")
 
+        if a.type=='hash:mac' and a.family:
+            cmd.fail(parser.format_usage() + "--family is not compatible with the hash:mac type")
+        
         settings = FirewallClientIPSetSettings()
         settings.setType(a.type)
         if a.option:
diff --git a/src/tests/regression/regression.at b/src/tests/regression/regression.at
index 5241a11a830d..5c8aae7e64d3 100644
--- a/src/tests/regression/regression.at
+++ b/src/tests/regression/regression.at
@@ -32,3 +32,4 @@ m4_include([regression/rhbz1829104.at])
 m4_include([regression/rhbz1843398.at])
 m4_include([regression/rhbz1689429.at])
 m4_include([regression/rhbz1483921.at])
+m4_include([regression/rhbz1541077.at])
diff --git a/src/tests/regression/rhbz1541077.at b/src/tests/regression/rhbz1541077.at
new file mode 100644
index 000000000000..765ab0c6290b
--- /dev/null
+++ b/src/tests/regression/rhbz1541077.at
@@ -0,0 +1,9 @@
+FWD_START_TEST([hash:mac and family mutually exclusive])
+    AT_KEYWORDS(ipset rhbz1541077)
+
+    FWD_CHECK([firewall-cmd --permanent --new-ipset hashmacv6 --type hash:mac --family inet6], 2, ignore,ignore)
+    
+    FWD_CHECK([firewall-cmd --new-ipset hashmacv6 --type hash:mac --family inet6], 2, ignore,ignore)
+
+    FWD_CHECK([firewall-offline-cmd --new-ipset hashmacv6 --type hash:mac --family inet6], 2, ignore,ignore)
+FWD_END_TEST
-- 
2.27.0