Skip to content

Commit

Permalink
Merge pull request #4697 from martinkennelly/ensure-chain-udn
Browse files Browse the repository at this point in the history
UDN LGW: ensure masq chain exists before adding rules
  • Loading branch information
tssurya committed Sep 6, 2024
2 parents 244efcf + 24b4749 commit a551930
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions go-controller/pkg/node/gateway_iptables.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ func deleteIptRules(rules []nodeipt.Rule) error {
return nodeipt.DelRules(rules)
}

// ensureChain ensures that a chain exists within a table
func ensureChain(table, chain string) error {
for _, proto := range clusterIPTablesProtocols() {
ipt, err := util.GetIPTablesHelper(proto)
if err != nil {
return fmt.Errorf("failed to get IPTables helper to add UDN chain: %v", err)
}
addChaintoTable(ipt, table, chain)
}
return nil
}

func getGatewayInitRules(chain string, proto iptables.Protocol) []nodeipt.Rule {
iptRules := []nodeipt.Rule{}
if chain == egressservice.Chain {
Expand Down
5 changes: 5 additions & 0 deletions go-controller/pkg/node/gateway_localnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ func newLocalGateway(nodeName string, hostSubnets []*net.IPNet, gwNextHops []net
klog.Info("Creating new local gateway")
gw := &gateway{}

if util.IsNetworkSegmentationSupportEnabled() {
if err := ensureChain("nat", iptableUDNMasqueradeChain); err != nil {
return nil, fmt.Errorf("failed to ensure chain %s in NAT table: %w", iptableUDNMasqueradeChain, err)
}
}
for _, hostSubnet := range hostSubnets {
// local gateway mode uses mp0 as default path for all ingress traffic into OVN
var nextHop *net.IPNet
Expand Down

0 comments on commit a551930

Please sign in to comment.