summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/stack/addressable_endpoint_state.go
diff options
context:
space:
mode:
authorGhanan Gowripalan <ghanan@google.com>2020-11-19 11:46:09 -0800
committergVisor bot <gvisor-bot@google.com>2020-11-19 11:48:15 -0800
commit27ee4fe76ad586ac8751951a842b3681f9375025 (patch)
treefc0e8f5a5b1e5ed167ab049afa27287c1cae862e /pkg/tcpip/stack/addressable_endpoint_state.go
parent332671c33969c067398702f61071b004b988b24b (diff)
Don't hold AddressEndpoints for multicast addresses
Group addressable endpoints can simply check if it has joined the multicast group without maintaining address endpoints. This also helps remove the dependency on AddressableEndpoint from GroupAddressableEndpoint. Now that group addresses are not tracked with address endpoints, we can avoid accidentally obtaining a route with a multicast local address. PiperOrigin-RevId: 343336912
Diffstat (limited to 'pkg/tcpip/stack/addressable_endpoint_state.go')
-rw-r--r--pkg/tcpip/stack/addressable_endpoint_state.go22
1 files changed, 0 insertions, 22 deletions
diff --git a/pkg/tcpip/stack/addressable_endpoint_state.go b/pkg/tcpip/stack/addressable_endpoint_state.go
index 9478f3fb7..adeebfe37 100644
--- a/pkg/tcpip/stack/addressable_endpoint_state.go
+++ b/pkg/tcpip/stack/addressable_endpoint_state.go
@@ -594,15 +594,6 @@ func (a *AddressableEndpointState) JoinGroup(group tcpip.Address) (bool, *tcpip.
defer a.mu.Unlock()
joins, ok := a.mu.groups[group]
- if !ok {
- ep, err := a.addAndAcquireAddressLocked(group.WithPrefix(), NeverPrimaryEndpoint, AddressConfigStatic, false /* deprecated */, true /* permanent */)
- if err != nil {
- return false, err
- }
- // We have no need for the address endpoint.
- a.decAddressRefLocked(ep)
- }
-
a.mu.groups[group] = joins + 1
return !ok, nil
}
@@ -618,7 +609,6 @@ func (a *AddressableEndpointState) LeaveGroup(group tcpip.Address) (bool, *tcpip
}
if joins == 1 {
- a.removeGroupAddressLocked(group)
delete(a.mu.groups, group)
return true, nil
}
@@ -635,23 +625,11 @@ func (a *AddressableEndpointState) IsInGroup(group tcpip.Address) bool {
return ok
}
-func (a *AddressableEndpointState) removeGroupAddressLocked(group tcpip.Address) {
- if err := a.removePermanentAddressLocked(group); err != nil {
- // removePermanentEndpointLocked would only return an error if group is
- // not bound to the addressable endpoint, but we know it MUST be assigned
- // since we have group in our map of groups.
- panic(fmt.Sprintf("error removing group address = %s: %s", group, err))
- }
-}
-
// Cleanup forcefully leaves all groups and removes all permanent addresses.
func (a *AddressableEndpointState) Cleanup() {
a.mu.Lock()
defer a.mu.Unlock()
- for group := range a.mu.groups {
- a.removeGroupAddressLocked(group)
- }
a.mu.groups = make(map[tcpip.Address]uint32)
for _, ep := range a.mu.endpoints {