@@ -23,8 +23,8 @@ func (c *IPtablesProvider) GetIPTables() (iptablesClient, error) {
2323 client , err := goiptables .New ()
2424 return client , errors .Wrap (err , "failed to get iptables client" )
2525}
26- func (c * IPtablesProvider ) GetIPTablesLegacy () iptablesLegacyClient {
27- return & iptablesLegacy {}
26+ func (c * IPtablesProvider ) GetIPTablesLegacy () ( iptablesLegacyClient , error ) {
27+ return & iptablesLegacy {}, nil
2828}
2929
3030type iptablesLegacy struct {}
@@ -43,8 +43,12 @@ func (service *HTTPRestService) programSNATRules(req *cns.CreateNetworkContainer
4343 // in podsubnet case, ncPrimaryIP is the pod subnet's primary ip
4444 // in vnet scale case, ncPrimaryIP is the node's ip
4545 ncPrimaryIP , _ , _ := net .ParseCIDR (req .IPConfiguration .IPSubnet .IPAddress + "/" + fmt .Sprintf ("%d" , req .IPConfiguration .IPSubnet .PrefixLength ))
46- iptl := service .iptables .GetIPTablesLegacy ()
47- err := iptl .Delete (iptables .Nat , iptables .Postrouting , "-j" , SWIFTPOSTROUTING )
46+
47+ 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 )
4852 // ignore if command fails
4953 if err == nil {
5054 logger .Printf ("[Azure CNS] Deleted legacy jump to SWIFT-POSTROUTING Chain" )
0 commit comments