@ -197,10 +197,9 @@ func (s *State) String() string {
fmt . Fprintf ( & sb , "interfaces.State{defaultRoute=%v ifs={" , s . DefaultRouteInterface )
fmt . Fprintf ( & sb , "interfaces.State{defaultRoute=%v ifs={" , s . DefaultRouteInterface )
ifs := make ( [ ] string , 0 , len ( s . InterfaceUp ) )
ifs := make ( [ ] string , 0 , len ( s . InterfaceUp ) )
for k := range s . InterfaceUp {
for k := range s . InterfaceUp {
if a llLoopbackIPs ( s . InterfaceIPs [ k ] ) {
if a nyInterestingIP ( s . InterfaceIPs [ k ] ) {
continue
ifs = append ( ifs , k )
}
}
ifs = append ( ifs , k )
}
}
sort . Slice ( ifs , func ( i , j int ) bool {
sort . Slice ( ifs , func ( i , j int ) bool {
upi , upj := s . InterfaceUp [ ifs [ i ] ] , s . InterfaceUp [ ifs [ j ] ]
upi , upj := s . InterfaceUp [ ifs [ i ] ] , s . InterfaceUp [ ifs [ j ] ]
@ -218,7 +217,7 @@ func (s *State) String() string {
fmt . Fprintf ( & sb , "%s:[" , ifName )
fmt . Fprintf ( & sb , "%s:[" , ifName )
needSpace := false
needSpace := false
for _ , ip := range s . InterfaceIPs [ ifName ] {
for _ , ip := range s . InterfaceIPs [ ifName ] {
if ip . IsLinkLocalUnicast ( ) {
if ! isInterestingIP ( ip ) {
continue
continue
}
}
if needSpace {
if needSpace {
@ -403,14 +402,23 @@ var (
v6Global1 = mustCIDR ( "2000::/3" )
v6Global1 = mustCIDR ( "2000::/3" )
)
)
func allLoopbackIPs ( ips [ ] netaddr . IP ) bool {
// anyInterestingIP reports ips contains any IP that matches
if len ( ips ) == 0 {
// isInterestingIP.
return false
func anyInterestingIP ( ips [ ] netaddr . IP ) bool {
}
for _ , ip := range ips {
for _ , ip := range ips {
if ! ip . IsLoopback ( ) {
if isInterestingIP ( ip ) {
return fals e
return tru e
}
}
}
}
return false
}
// isInterestingIP reports whether ip is an interesting IP that we
// should log in interfaces.State logging. We don't need to show
// localhost or link-local addresses.
func isInterestingIP ( ip netaddr . IP ) bool {
if ip . IsLoopback ( ) || ip . IsLinkLocalUnicast ( ) {
return false
}
return true
return true
}
}