1
0
mirror of https://github.com/golang/go synced 2024-11-22 05:24:39 -07:00

net: fix /proc/net/igmp,igmp6 reading bug on linux

Fixes #2130.

R=rsc, dave
CC=golang-dev
https://golang.org/cl/4846044
This commit is contained in:
Mikio Hara 2011-08-05 09:20:13 +10:00 committed by David Symonds
parent 5b1f159fb5
commit ba9833269d

View File

@ -192,8 +192,6 @@ func interfaceMulticastAddrTable(ifindex int) ([]Addr, os.Error) {
var ( var (
ifi *Interface ifi *Interface
err os.Error err os.Error
ifmat4 []Addr
ifmat6 []Addr
) )
if ifindex > 0 { if ifindex > 0 {
@ -203,20 +201,13 @@ func interfaceMulticastAddrTable(ifindex int) ([]Addr, os.Error) {
} }
} }
ifmat4, err = parseProcNetIGMP(ifi) ifmat4 := parseProcNetIGMP(ifi)
if err != nil { ifmat6 := parseProcNetIGMP6(ifi)
return nil, err
}
ifmat6, err = parseProcNetIGMP6(ifi)
if err != nil {
return nil, err
}
return append(ifmat4, ifmat6...), nil return append(ifmat4, ifmat6...), nil
} }
func parseProcNetIGMP(ifi *Interface) ([]Addr, os.Error) { func parseProcNetIGMP(ifi *Interface) []Addr {
var ( var (
ifmat []Addr ifmat []Addr
name string name string
@ -224,7 +215,7 @@ func parseProcNetIGMP(ifi *Interface) ([]Addr, os.Error) {
fd, err := open("/proc/net/igmp") fd, err := open("/proc/net/igmp")
if err != nil { if err != nil {
return nil, err return nil
} }
defer fd.close() defer fd.close()
@ -244,15 +235,15 @@ func parseProcNetIGMP(ifi *Interface) ([]Addr, os.Error) {
} }
} }
return ifmat, nil return ifmat
} }
func parseProcNetIGMP6(ifi *Interface) ([]Addr, os.Error) { func parseProcNetIGMP6(ifi *Interface) []Addr {
var ifmat []Addr var ifmat []Addr
fd, err := open("/proc/net/igmp6") fd, err := open("/proc/net/igmp6")
if err != nil { if err != nil {
return nil, err return nil
} }
defer fd.close() defer fd.close()
@ -267,5 +258,5 @@ func parseProcNetIGMP6(ifi *Interface) ([]Addr, os.Error) {
} }
} }
return ifmat, nil return ifmat
} }