Skip to content

Commit

Permalink
fix: use ip.To4()
Browse files Browse the repository at this point in the history
  • Loading branch information
Charlie17Li committed Sep 9, 2024
1 parent 7b5e353 commit 00ae87d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions nl/tc_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -1460,15 +1460,15 @@ func (p *TcPedit) SetIPv6Src(ip6 net.IP) {

func (p *TcPedit) SetDstIP(ip net.IP) {
if ip.To4() != nil {
p.SetIPv4Dst(ip)
p.SetIPv4Dst(ip.To4())
} else {
p.SetIPv6Dst(ip)
}
}

func (p *TcPedit) SetSrcIP(ip net.IP) {
if ip.To4() != nil {
p.SetIPv4Src(ip)
p.SetIPv4Src(ip.To4())
} else {
p.SetIPv6Src(ip)
}
Expand Down Expand Up @@ -1533,7 +1533,7 @@ func (p *TcPedit) SetIPv6Dst(ip6 net.IP) {
}

func (p *TcPedit) SetIPv4Src(ip net.IP) {
u32 := NativeEndian().Uint32(ip[12:16])
u32 := NativeEndian().Uint32(ip[:4])

tKey := TcPeditKey{}
tKeyEx := TcPeditKeyEx{}
Expand All @@ -1549,7 +1549,7 @@ func (p *TcPedit) SetIPv4Src(ip net.IP) {
}

func (p *TcPedit) SetIPv4Dst(ip net.IP) {
u32 := NativeEndian().Uint32(ip[12:16])
u32 := NativeEndian().Uint32(ip[:4])

tKey := TcPeditKey{}
tKeyEx := TcPeditKeyEx{}
Expand Down

0 comments on commit 00ae87d

Please sign in to comment.