Add code review updates

Docker-DCO-1.1-Signed-off-by: Dhammika Pathirana <dhammika@gmail.com> (github: dhammika)
This commit is contained in:
Dhammika Pathirana 2014-07-10 23:25:53 -07:00
parent 2d69029a83
commit a3a4da3822
1 changed files with 9 additions and 22 deletions

View File

@ -22,18 +22,17 @@ const (
SIOC_BRADDBR = 0x89a0
SIOC_BRDELBR = 0x89a1
SIOC_BRADDIF = 0x89a2
SIOC_BRDELIF = 0x89a3
)
var nextSeqNr uint32
type ifreqHwaddr struct {
IfrnName [16]byte
IfrnName [IFNAMSIZ]byte
IfruHwaddr syscall.RawSockaddr
}
type ifreqIndex struct {
IfrnName [16]byte
IfrnName [IFNAMSIZ]byte
IfruIndex int32
}
@ -905,13 +904,9 @@ func NetworkCreateVethPair(name1, name2 string) error {
// Create the actual bridge device. This is more backward-compatible than
// netlink.NetworkLinkAdd and works on RHEL 6.
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 {
// ipv6 issue, creating with ipv4
s, err = syscall.Socket(syscall.AF_INET, syscall.SOCK_STREAM, syscall.IPPROTO_IP)
if err != nil {
return err
}
return err
}
defer syscall.Close(s)
@ -930,13 +925,9 @@ func CreateBridge(name string, setMacAddr bool) error {
// Delete the actual bridge device.
func DeleteBridge(name string) error {
s, err := syscall.Socket(syscall.AF_INET6, syscall.SOCK_STREAM, syscall.IPPROTO_IP)
s, err := getIfSocket()
if err != nil {
// ipv6 issue, creating with ipv4
s, err = syscall.Socket(syscall.AF_INET, syscall.SOCK_STREAM, syscall.IPPROTO_IP)
if err != nil {
return err
}
return err
}
defer syscall.Close(s)
@ -946,7 +937,7 @@ func DeleteBridge(name string) error {
}
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),
syscall.SIOCSIFFLAGS, uintptr(unsafe.Pointer(&ifr))); err != 0 {
return err
@ -962,13 +953,9 @@ func DeleteBridge(name string) error {
// Add a slave to abridge device. This is more backward-compatible than
// netlink.NetworkSetMaster and works on RHEL 6.
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 {
// ipv6 issue, creating with ipv4
s, err = syscall.Socket(syscall.AF_INET, syscall.SOCK_STREAM, syscall.IPPROTO_IP)
if err != nil {
return err
}
return err
}
defer syscall.Close(s)