diff --git a/cmd/ip-masq-agent/ip-masq-agent.go b/cmd/ip-masq-agent/ip-masq-agent.go index 8e42af6c..4d1c9cfa 100644 --- a/cmd/ip-masq-agent/ip-masq-agent.go +++ b/cmd/ip-masq-agent/ip-masq-agent.go @@ -271,7 +271,9 @@ func validateCIDR(cidr string) error { func (m *MasqDaemon) syncMasqRules() error { // make sure our custom chain for non-masquerade exists - m.iptables.EnsureChain(utiliptables.TableNAT, masqChain) + if _, err := m.iptables.EnsureChain(utiliptables.TableNAT, masqChain); err != nil { + return err + } // ensure that any non-local in POSTROUTING jumps to masqChain if err := m.ensurePostroutingJump(); err != nil { @@ -311,8 +313,7 @@ func (m *MasqDaemon) syncMasqRulesIPv6() error { if isIPv6Enabled { // make sure our custom chain for ipv6 non-masquerade exists - _, err := m.ip6tables.EnsureChain(utiliptables.TableNAT, masqChain) - if err != nil { + if _, err := m.ip6tables.EnsureChain(utiliptables.TableNAT, masqChain); err != nil { return err } // ensure that any non-local in POSTROUTING jumps to masqChain diff --git a/cmd/ip-masq-agent/ip-masq-agent_test.go b/cmd/ip-masq-agent/ip-masq-agent_test.go index a81cbf29..8edfd16b 100644 --- a/cmd/ip-masq-agent/ip-masq-agent_test.go +++ b/cmd/ip-masq-agent/ip-masq-agent_test.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +//nolint:errcheck package main import ( @@ -358,8 +359,8 @@ COMMIT } buf := bytes.NewBuffer(nil) fipt.SaveInto("nat", buf) - if string(buf.Bytes()) != string(tt.want) { - t.Errorf("syncMasqRules wrote %q, want %q", string(buf.Bytes()), tt.want) + if buf.String() != tt.want { + t.Errorf("syncMasqRules wrote %q, want %q", buf.String(), tt.want) } }) } @@ -432,8 +433,8 @@ COMMIT } buf := bytes.NewBuffer(nil) fipt6.SaveInto("nat", buf) - if string(buf.Bytes()) != tt.want { - t.Errorf("syncMasqRulesIPv6 wrote %q, want %q", string(buf.Bytes()), tt.want) + if buf.String() != tt.want { + t.Errorf("syncMasqRulesIPv6 wrote %q, want %q", buf.String(), tt.want) } }) } diff --git a/cmd/ip-masq-agent/testing/fakefs/fakefs.go b/cmd/ip-masq-agent/testing/fakefs/fakefs.go index c479b4c2..e8f0b286 100644 --- a/cmd/ip-masq-agent/testing/fakefs/fakefs.go +++ b/cmd/ip-masq-agent/testing/fakefs/fakefs.go @@ -18,7 +18,6 @@ package fakefs import ( "errors" - "io/ioutil" "os" "time" ) @@ -35,7 +34,7 @@ func (DefaultFS) Stat(name string) (os.FileInfo, error) { return os.Stat(name) } func (DefaultFS) ReadFile(name string) ([]byte, error) { - return ioutil.ReadFile(name) + return os.ReadFile(name) } // StringFS returns the string as the contents of the file