Skip to content

Commit

Permalink
Merge pull request #848 from TrekkieCoder/main
Browse files Browse the repository at this point in the history
onearm:fixed source addr selection
  • Loading branch information
UltraInstinct14 authored Oct 21, 2024
2 parents faf774a + a3853e5 commit e945f22
Showing 1 changed file with 11 additions and 6 deletions.
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

0 comments on commit e945f22

Please sign in to comment.