Skip to content

Commit 0c29681

Browse files
committed
Check hook.isset
1 parent 6ed1386 commit 0c29681

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

runtime/iproutehook.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ func NewIPRouteHook(name string, env string) IPRouteHook {
5757

5858
// Run the hook if it is set
5959
func (hook IPRouteHook) Run() error {
60+
if !hook.isset {
61+
return nil
62+
}
6063
for _, r := range hook.routes {
6164
r = append(r, "proto", "static")
6265
if err := runIPRoute(r...); err != nil {

runtime/nat4hook.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ func NewNat4Hooks() Nat4Hook {
4747

4848
// Runs IPv4 NAT init hook
4949
func (hook Nat4Hook) RunInit() error {
50+
if !hook.isset {
51+
return nil
52+
}
5053
if err := runIP4Tables("-I", "FORWARD", "-j", "ACCEPT"); err != nil {
5154
return err
5255
}
@@ -60,6 +63,9 @@ func (hook Nat4Hook) RunInit() error {
6063

6164
// Runs IPv4 NAT exit hook
6265
func (hook Nat4Hook) RunExit() error {
66+
if !hook.isset {
67+
return nil
68+
}
6369
errcount := 0
6470
var lasterr error
6571
for _, iface := range hook.ifaces {

0 commit comments

Comments
 (0)