Skip to content

Commit

Permalink
Merge pull request #926 from vanonox/selectSameProtocol
Browse files Browse the repository at this point in the history
IfaSelect return at least ip of same protocol of dest addr
  • Loading branch information
TrekkieCoder authored Jan 10, 2025
2 parents 3678f70 + 0f9ca57 commit e50e998
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/loxinet/layer3.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,12 @@ func (l3 *L3H) IfaSelect(Obj string, addr net.IP, findAny bool) (int, net.IP, st
continue
}
if len(ifa.Ifas) > 0 {
for _, ifaEnt := range ifa.Ifas {
if (tk.IsNetIPv4(addr.String()) && tk.IsNetIPv4(ifaEnt.IfaNet.IP.String())) ||
(tk.IsNetIPv6(addr.String()) && tk.IsNetIPv6(ifaEnt.IfaNet.IP.String())) {
return 0, ifaEnt.IfaAddr, Obj
}
}
return 0, ifa.Ifas[0].IfaAddr, Obj
}
}
Expand Down Expand Up @@ -309,6 +315,12 @@ func (l3 *L3H) IfaSelect(Obj string, addr net.IP, findAny bool) (int, net.IP, st

// Select first IP
if len(ifa.Ifas) > 0 {
for _, ifaEnt := range ifa.Ifas {
if (tk.IsNetIPv4(addr.String()) && tk.IsNetIPv4(ifaEnt.IfaNet.IP.String())) ||
(tk.IsNetIPv6(addr.String()) && tk.IsNetIPv6(ifaEnt.IfaNet.IP.String())) {
return 0, ifaEnt.IfaAddr, Obj
}
}
return 0, ifa.Ifas[0].IfaAddr, Obj
}

Expand Down

0 comments on commit e50e998

Please sign in to comment.