diff options
| author | Brad Fitzpatrick <bradfitz@tailscale.com> | 2023-10-27 17:28:35 -0700 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@tailscale.com> | 2023-10-27 17:28:35 -0700 |
| commit | fd7ea8e2c3f7a8e89ba5d737a914e5226dd3c22e (patch) | |
| tree | b9470816608ff42b798601922e469c665fc594c5 | |
| parent | 387a98fe2878cd2fa8640cf535ee955d03767869 (diff) | |
| download | tailscale-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.go | 5 |
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) |
