Add code review updates
Docker-DCO-1.1-Signed-off-by: Dhammika Pathirana <dhammika@gmail.com> (github: dhammika)
This commit is contained in:
parent
2d69029a83
commit
a3a4da3822
|
@ -22,18 +22,17 @@ const (
|
||||||
SIOC_BRADDBR = 0x89a0
|
SIOC_BRADDBR = 0x89a0
|
||||||
SIOC_BRDELBR = 0x89a1
|
SIOC_BRDELBR = 0x89a1
|
||||||
SIOC_BRADDIF = 0x89a2
|
SIOC_BRADDIF = 0x89a2
|
||||||
SIOC_BRDELIF = 0x89a3
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var nextSeqNr uint32
|
var nextSeqNr uint32
|
||||||
|
|
||||||
type ifreqHwaddr struct {
|
type ifreqHwaddr struct {
|
||||||
IfrnName [16]byte
|
IfrnName [IFNAMSIZ]byte
|
||||||
IfruHwaddr syscall.RawSockaddr
|
IfruHwaddr syscall.RawSockaddr
|
||||||
}
|
}
|
||||||
|
|
||||||
type ifreqIndex struct {
|
type ifreqIndex struct {
|
||||||
IfrnName [16]byte
|
IfrnName [IFNAMSIZ]byte
|
||||||
IfruIndex int32
|
IfruIndex int32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -905,13 +904,9 @@ func NetworkCreateVethPair(name1, name2 string) error {
|
||||||
// Create the actual bridge device. This is more backward-compatible than
|
// Create the actual bridge device. This is more backward-compatible than
|
||||||
// netlink.NetworkLinkAdd and works on RHEL 6.
|
// netlink.NetworkLinkAdd and works on RHEL 6.
|
||||||
func CreateBridge(name string, setMacAddr bool) error {
|
func CreateBridge(name string, setMacAddr bool) error {
|
||||||
s, err := syscall.Socket(syscall.AF_INET6, syscall.SOCK_STREAM, syscall.IPPROTO_IP)
|
s, err := getIfSocket()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// ipv6 issue, creating with ipv4
|
return err
|
||||||
s, err = syscall.Socket(syscall.AF_INET, syscall.SOCK_STREAM, syscall.IPPROTO_IP)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
defer syscall.Close(s)
|
defer syscall.Close(s)
|
||||||
|
|
||||||
|
@ -930,13 +925,9 @@ func CreateBridge(name string, setMacAddr bool) error {
|
||||||
|
|
||||||
// Delete the actual bridge device.
|
// Delete the actual bridge device.
|
||||||
func DeleteBridge(name string) error {
|
func DeleteBridge(name string) error {
|
||||||
s, err := syscall.Socket(syscall.AF_INET6, syscall.SOCK_STREAM, syscall.IPPROTO_IP)
|
s, err := getIfSocket()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// ipv6 issue, creating with ipv4
|
return err
|
||||||
s, err = syscall.Socket(syscall.AF_INET, syscall.SOCK_STREAM, syscall.IPPROTO_IP)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
defer syscall.Close(s)
|
defer syscall.Close(s)
|
||||||
|
|
||||||
|
@ -946,7 +937,7 @@ func DeleteBridge(name string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
var ifr ifreqFlags
|
var ifr ifreqFlags
|
||||||
copy(ifr.IfrnName[:], []byte(name))
|
copy(ifr.IfrnName[:len(ifr.IfrnName)-1], []byte(name))
|
||||||
if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(s),
|
if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(s),
|
||||||
syscall.SIOCSIFFLAGS, uintptr(unsafe.Pointer(&ifr))); err != 0 {
|
syscall.SIOCSIFFLAGS, uintptr(unsafe.Pointer(&ifr))); err != 0 {
|
||||||
return err
|
return err
|
||||||
|
@ -962,13 +953,9 @@ func DeleteBridge(name string) error {
|
||||||
// Add a slave to abridge device. This is more backward-compatible than
|
// Add a slave to abridge device. This is more backward-compatible than
|
||||||
// netlink.NetworkSetMaster and works on RHEL 6.
|
// netlink.NetworkSetMaster and works on RHEL 6.
|
||||||
func AddToBridge(iface, master *net.Interface) error {
|
func AddToBridge(iface, master *net.Interface) error {
|
||||||
s, err := syscall.Socket(syscall.AF_INET6, syscall.SOCK_STREAM, syscall.IPPROTO_IP)
|
s, err := getIfSocket()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// ipv6 issue, creating with ipv4
|
return err
|
||||||
s, err = syscall.Socket(syscall.AF_INET, syscall.SOCK_STREAM, syscall.IPPROTO_IP)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
defer syscall.Close(s)
|
defer syscall.Close(s)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue