Commit ba983326 authored by Mikio Hara's avatar Mikio Hara Committed by David Symonds

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

Fixes #2130.

R=rsc, dave
CC=golang-dev
https://golang.org/cl/4846044
parent 5b1f159f
...@@ -190,10 +190,8 @@ func newAddr(attrs []syscall.NetlinkRouteAttr, family int) []Addr { ...@@ -190,10 +190,8 @@ func newAddr(attrs []syscall.NetlinkRouteAttr, family int) []Addr {
// addresses for a specific interface. // addresses for a specific interface.
func interfaceMulticastAddrTable(ifindex int) ([]Addr, os.Error) { 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) { ...@@ -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) { ...@@ -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) { ...@@ -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) { ...@@ -267,5 +258,5 @@ func parseProcNetIGMP6(ifi *Interface) ([]Addr, os.Error) {
} }
} }
return ifmat, nil return ifmat
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment