Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onearm:fixed source addr selection #848

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions pkg/loxinet/layer3.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ package loxinet
import (
"errors"
"fmt"
"net"
"strings"

nlp "github.com/loxilb-io/loxilb/api/loxinlp"
cmn "github.com/loxilb-io/loxilb/common"
tk "github.com/loxilb-io/loxilib"
"net"
"strings"
)

// constants
Expand Down Expand Up @@ -292,7 +293,8 @@ func (l3 *L3H) IfaSelect(Obj string, addr net.IP, findAny bool) (int, net.IP, st
continue
}

if tk.IsNetIPv6(addr.String()) && tk.IsNetIPv4(ifaEnt.IfaNet.IP.String()) {
if (tk.IsNetIPv6(addr.String()) && tk.IsNetIPv4(ifaEnt.IfaNet.IP.String())) ||
(tk.IsNetIPv4(addr.String()) && tk.IsNetIPv6(ifaEnt.IfaNet.IP.String())) {
continue
}

Expand Down Expand Up @@ -338,7 +340,8 @@ func (l3 *L3H) IfaFindAddr(Obj string, addr net.IP) (int, net.IP) {

for _, ifaEnt := range ifa.Ifas {

if tk.IsNetIPv6(addr.String()) && tk.IsNetIPv4(ifaEnt.IfaNet.IP.String()) {
if (tk.IsNetIPv6(addr.String()) && tk.IsNetIPv4(ifaEnt.IfaNet.IP.String())) ||
(tk.IsNetIPv4(addr.String()) && tk.IsNetIPv6(ifaEnt.IfaNet.IP.String())) {
continue
}

Expand All @@ -363,7 +366,8 @@ func (l3 *L3H) IfaFind(Obj string, addr net.IP) (int, net.IP) {

for _, ifaEnt := range ifa.Ifas {

if tk.IsNetIPv6(addr.String()) && tk.IsNetIPv4(ifaEnt.IfaNet.IP.String()) {
if (tk.IsNetIPv6(addr.String()) && tk.IsNetIPv4(ifaEnt.IfaNet.IP.String())) ||
(tk.IsNetIPv4(addr.String()) && tk.IsNetIPv6(ifaEnt.IfaNet.IP.String())) {
continue
}

Expand Down Expand Up @@ -423,7 +427,8 @@ func (l3 *L3H) IfaSelectAny(addr net.IP, findAny bool) (int, net.IP, string) {
continue
}

if v6 && tk.IsNetIPv4(ifaEnt.IfaNet.IP.String()) {
if (v6 && tk.IsNetIPv4(ifaEnt.IfaNet.IP.String())) ||
(!v6 && tk.IsNetIPv6(ifaEnt.IfaNet.IP.String())) {
continue
}

Expand Down
Loading