Skip to content

Commit

Permalink
Merge pull request #160 from dj-nlx/main
Browse files Browse the repository at this point in the history
gh-28 nat64 fixes
  • Loading branch information
UltraInstinct14 authored Dec 15, 2022
2 parents b61e46a + 2c53896 commit 9ef2d0d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion loxinet/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,9 @@ func (R *RuleH) AddNatLbRule(serv cmn.LbServiceArg, servEndPoints []cmn.LbEndPoi
if pNetAddr == nil {
return RuleUnknownEpErr, errors.New("malformed-lbep error")
}
if tk.IsNetIPv4(serv.ServIP) && tk.IsNetIPv6(k.EpIP) {
return RuleUnknownServiceErr, errors.New("malformed-service nat46 error")
}
if serv.Proto == "icmp" && k.EpPort != 0 {
return RuleUnknownServiceErr, errors.New("malformed-service error")
}
Expand Down Expand Up @@ -1639,6 +1642,7 @@ func (r *ruleEnt) Nat2DP(work DpWorkT) int {
r.Sync = DpCreateErr
return -1
}

ep.RIP = sip
} else {
ep.RIP = r.tuples.l3Dst.addr.IP.Mask(r.tuples.l3Dst.addr.Mask)
Expand All @@ -1647,7 +1651,16 @@ func (r *ruleEnt) Nat2DP(work DpWorkT) int {
} else {
for idx := range nWork.endPoints {
ep := &nWork.endPoints[idx]
ep.RIP = net.IPv4(0, 0, 0, 0)
if tk.IsNetIPv6(nWork.ServiceIP.String()) && tk.IsNetIPv4(ep.XIP.String()) {
e, sip := r.zone.L3.IfaSelectAny(ep.XIP)
if e != 0 {
r.Sync = DpCreateErr
return -1
}
ep.RIP = sip
} else {
ep.RIP = net.IPv4(0, 0, 0, 0)
}
}
}

Expand Down

0 comments on commit 9ef2d0d

Please sign in to comment.