Skip to content

Commit 99e339d

Browse files
committed
fail silently should iptables legacy interface fail to create
1 parent 95a61c7 commit 99e339d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

cns/restserver/internalapi_linux.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,14 @@ func (service *HTTPRestService) programSNATRules(req *cns.CreateNetworkContainer
4545
ncPrimaryIP, _, _ := net.ParseCIDR(req.IPConfiguration.IPSubnet.IPAddress + "/" + fmt.Sprintf("%d", req.IPConfiguration.IPSubnet.PrefixLength))
4646

4747
iptl, err := service.iptables.GetIPTablesLegacy()
48-
if err != nil {
49-
return types.UnexpectedError, fmt.Sprintf("[Azure CNS] Error. Failed to create iptables legacy interface : %v", err)
50-
}
51-
err = iptl.Delete(iptables.Nat, iptables.Postrouting, "-j", SWIFTPOSTROUTING)
52-
// ignore if command fails
5348
if err == nil {
54-
logger.Printf("[Azure CNS] Deleted legacy jump to SWIFT-POSTROUTING Chain")
49+
err = iptl.Delete(iptables.Nat, iptables.Postrouting, "-j", SWIFTPOSTROUTING)
50+
// ignore if command fails
51+
if err == nil {
52+
logger.Printf("[Azure CNS] Deleted legacy jump to SWIFT-POSTROUTING Chain")
53+
}
54+
} else {
55+
logger.Printf("[Azure CNS] Could not create iptables legacy interface, continuing : %v", err)
5556
}
5657

5758
ipt, err := service.iptables.GetIPTables()

0 commit comments

Comments
 (0)