Skip to content

Commit

Permalink
route: always go through syscall package
Browse files Browse the repository at this point in the history
Instead of relying on syscall.Syscall, always reach into the syscall
package to call the appropriate functions on Unix systems. We were
already doing this on Darwin. We also have to do this on
OpenBSD. Rather than sometimes reach into syscall and sometimes not,
just always reach in.

For golang/go#42064

Change-Id: Ie292a56766080d0c5ae6b6723d42b5475128290c
Reviewed-on: https://go-review.googlesource.com/c/net/+/366354
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
  • Loading branch information
ianlancetaylor committed Nov 23, 2021
1 parent 6a13c67 commit 9e5a297
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 34 deletions.
26 changes: 5 additions & 21 deletions route/syscall.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,12 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build dragonfly || freebsd || netbsd || openbsd
// +build dragonfly freebsd netbsd openbsd
//go:build darwin || dragonfly || freebsd || netbsd || openbsd
// +build darwin dragonfly freebsd netbsd openbsd

package route

import (
"syscall"
"unsafe"
)
import _ "unsafe" // for linkname

var zero uintptr

func sysctl(mib []int32, old *byte, oldlen *uintptr, new *byte, newlen uintptr) error {
var p unsafe.Pointer
if len(mib) > 0 {
p = unsafe.Pointer(&mib[0])
} else {
p = unsafe.Pointer(&zero)
}
_, _, errno := syscall.Syscall6(syscall.SYS___SYSCTL, uintptr(p), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), newlen)
if errno != 0 {
return error(errno)
}
return nil
}
//go:linkname sysctl syscall.sysctl
func sysctl(mib []int32, old *byte, oldlen *uintptr, new *byte, newlen uintptr) error
13 changes: 0 additions & 13 deletions route/syscall_go1_12_darwin.go

This file was deleted.

0 comments on commit 9e5a297

Please sign in to comment.