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_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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue