Subject: [bug#49540] [PATCH 1/2] services: nftables: Only manage delete our own table.

From: Brice Waegeneire <[email-masked]>
Date: Mon, 12 Jul 2021 23:08:22 +0200

* gnu/services/networking.scm (%default-nftables-ruleset): Rename table
  from "forward" to "guix".  Clear table before applying before setting
  it up.
(nftables-shepherd-service): Don't flush all the table, just delete our
  own.
---
 gnu/services/networking.scm | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm
index 1ae58041d3..3058c14caf 100644
--- a/gnu/services/networking.scm
+++ b/gnu/services/networking.scm
@@ -13,7 +13,7 @@
 ;;; Copyright © 2019, 2021 Maxim Cournoyer <[email-masked]>
 ;;; Copyright © 2019 Sou Bunnbu <[email-masked]>
 ;;; Copyright © 2019 Alex Griffin <[email-masked]>
-;;; Copyright © 2020 Brice Waegeneire <[email-masked]>
+;;; Copyright © 2020, 2021 Brice Waegeneire <[email-masked]>
 ;;; Copyright © 2021 Oleg Pykhalov <[email-masked]>
 ;;; Copyright © 2021 Christopher Lemmer Webber <[email-masked]>
 ;;; Copyright © 2021 Maxime Devos <[email-masked]>
@@ -1717,7 +1717,12 @@ COMMIT
 (define %default-nftables-ruleset
   (plain-file "nftables.conf"
               "# A simple and safe firewall
-table inet filter {
+
+# Start with our table clean of previous state
+add table inet guix
+delete table inet guix
+
+table inet guix {
   chain input {
     type filter hook input priority 0; policy drop;
 
@@ -1768,7 +1773,7 @@ table inet filter {
         (start #~(lambda _
                    (invoke #$nft "--file" #$ruleset)))
         (stop #~(lambda _
-                  (invoke #$nft "flush" "ruleset"))))))))
+                  (invoke #$nft "delete" "table" "inet" "guix"))))))))
 
 (define nftables-service-type
   (service-type
-- 
2.31.1