summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@tailscale.com>2023-10-27 17:28:35 -0700
committerBrad Fitzpatrick <bradfitz@tailscale.com>2023-10-27 17:28:35 -0700
commitfd7ea8e2c3f7a8e89ba5d737a914e5226dd3c22e (patch)
treeb9470816608ff42b798601922e469c665fc594c5
parent387a98fe2878cd2fa8640cf535ee955d03767869 (diff)
downloadtailscale-bradfitz/linuxfw_nil_table.tar.xz
tailscale-bradfitz/linuxfw_nil_table.zip
util/linuxfw: don't panic on delete of chain in nil tablebradfitz/linuxfw_nil_table
Fixes #10003 Change-Id: Ibef8326ffbbef5ba59caa21baa1f2cf4f5185971 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
-rw-r--r--util/linuxfw/nftables_runner.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/util/linuxfw/nftables_runner.go b/util/linuxfw/nftables_runner.go
index bc1eecd9c..feeae7477 100644
--- a/util/linuxfw/nftables_runner.go
+++ b/util/linuxfw/nftables_runner.go
@@ -860,7 +860,12 @@ func (n *nftablesRunner) createDummyPostroutingChains() (retErr error) {
}
// deleteChainIfExists deletes a chain if it exists.
+//
+// If table is nil, it returns nil.
func deleteChainIfExists(c *nftables.Conn, table *nftables.Table, name string) error {
+ if table == nil {
+ return nil
+ }
chain, err := getChainFromTable(c, table, name)
if err != nil && !errors.Is(err, errorChainNotFound{table.Name, name}) {
return fmt.Errorf("get chain: %w", err)