Skip to content

Commit

Permalink
Invert if condition for linter nesting
Browse files Browse the repository at this point in the history
  • Loading branch information
QxBytes committed Dec 4, 2023
1 parent b76303c commit 78f5def
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions network/network_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,15 +698,16 @@ func (nm *networkManager) addIpv6SnatRule(extIf *externalInterface, nwInfo *Netw
}

for _, ipAddr := range extIf.IPAddresses {
if ipAddr.IP.To4() == nil {
logger.Info("Adding ipv6 snat rule")
matchSrcPrefix := fmt.Sprintf("-s %s", ipv6SubnetPrefix.String())
nu := networkutils.NewNetworkUtils(nm.netlink, nm.plClient)
if err := nu.AddSnatRule(nm.iptablesClient, matchSrcPrefix, ipAddr.IP); err != nil {
return fmt.Errorf("adding iptable snat rule failed:%w", err)
}
ipv6SnatRuleSet = true
if ipAddr.IP.To4() != nil {
continue
}
logger.Info("Adding ipv6 snat rule")
matchSrcPrefix := fmt.Sprintf("-s %s", ipv6SubnetPrefix.String())
nu := networkutils.NewNetworkUtils(nm.netlink, nm.plClient)
if err := nu.AddSnatRule(nm.iptablesClient, matchSrcPrefix, ipAddr.IP); err != nil {
return fmt.Errorf("adding iptable snat rule failed:%w", err)
}
ipv6SnatRuleSet = true
}

if !ipv6SnatRuleSet {
Expand Down

0 comments on commit 78f5def

Please sign in to comment.