Skip to content

Commit 00ae87d

Browse files
committed
fix: use ip.To4()
1 parent 7b5e353 commit 00ae87d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

nl/tc_linux.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -1460,15 +1460,15 @@ func (p *TcPedit) SetIPv6Src(ip6 net.IP) {
14601460

14611461
func (p *TcPedit) SetDstIP(ip net.IP) {
14621462
if ip.To4() != nil {
1463-
p.SetIPv4Dst(ip)
1463+
p.SetIPv4Dst(ip.To4())
14641464
} else {
14651465
p.SetIPv6Dst(ip)
14661466
}
14671467
}
14681468

14691469
func (p *TcPedit) SetSrcIP(ip net.IP) {
14701470
if ip.To4() != nil {
1471-
p.SetIPv4Src(ip)
1471+
p.SetIPv4Src(ip.To4())
14721472
} else {
14731473
p.SetIPv6Src(ip)
14741474
}
@@ -1533,7 +1533,7 @@ func (p *TcPedit) SetIPv6Dst(ip6 net.IP) {
15331533
}
15341534

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

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

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

15541554
tKey := TcPeditKey{}
15551555
tKeyEx := TcPeditKeyEx{}

0 commit comments

Comments
 (0)