util/linuxfw: fix crash in DelSNATRule when no rules are found

Appears to be a missing nil handling case. I looked back over other
usage of findRule and the others all have nil guards. findRule returns
nil when no rules are found matching the arguments.

Fixes #9553
Signed-off-by: James Tucker <james@tailscale.com>
pull/9560/head
James Tucker 1 year ago committed by James Tucker
parent 697f92f4a7
commit 2066f9fbb2

@ -1109,8 +1109,10 @@ func (n *nftablesRunner) DelSNATRule() error {
return fmt.Errorf("find SNAT rule v4: %w", err)
}
if SNATRule != nil {
_ = conn.DelRule(SNATRule)
}
}
if err := conn.Flush(); err != nil {
return fmt.Errorf("flush del SNAT rule: %w", err)

Loading…
Cancel
Save