diff options
author | Chris Kuiper <ckuiper@google.com> | 2019-05-02 19:39:55 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-05-02 19:41:00 -0700 |
commit | 8972e47a2edb01d66c2fc6373a5663b68e3da82c (patch) | |
tree | 28195396bd4e663cfd2886ffbfd93f8d66af24dd /pkg/tcpip/transport/udp/endpoint_state.go | |
parent | 5f8225c009fcf297139c54c7b329da4aff679ece (diff) |
Support reception of multicast data on more than one socket
This requires two changes:
1) Support for more than one socket to join a given multicast group.
2) Duplicate delivery of incoming multicast packets to all sockets listening
for it.
In addition, I tweaked the code (and added a test) to disallow duplicates
IP_ADD_MEMBERSHIP calls for the same group and NIC. This is how Linux does
it.
PiperOrigin-RevId: 246437315
Change-Id: Icad8300b4a8c3f501d9b4cd283bd3beabef88b72
Diffstat (limited to 'pkg/tcpip/transport/udp/endpoint_state.go')
-rw-r--r-- | pkg/tcpip/transport/udp/endpoint_state.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/pkg/tcpip/transport/udp/endpoint_state.go b/pkg/tcpip/transport/udp/endpoint_state.go index 163dcbc13..74e8e9fd5 100644 --- a/pkg/tcpip/transport/udp/endpoint_state.go +++ b/pkg/tcpip/transport/udp/endpoint_state.go @@ -66,6 +66,12 @@ func (e *endpoint) loadRcvBufSizeMax(max int) { func (e *endpoint) afterLoad() { e.stack = stack.StackFromEnv + for _, m := range e.multicastMemberships { + if err := e.stack.JoinGroup(e.netProto, m.nicID, m.multicastAddr); err != nil { + panic(err) + } + } + if e.state != stateBound && e.state != stateConnected { return } @@ -103,10 +109,4 @@ func (e *endpoint) afterLoad() { if err != nil { panic(*err) } - - for _, m := range e.multicastMemberships { - if err := e.stack.JoinGroup(e.netProto, m.nicID, m.multicastAddr); err != nil { - panic(err) - } - } } |