summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/transport/udp
diff options
context:
space:
mode:
authorGhanan Gowripalan <ghanan@google.com>2021-01-06 11:39:14 -0800
committergVisor bot <gvisor-bot@google.com>2021-01-06 11:41:42 -0800
commitabe9d9f67f2c2c696ef26690fa8518dfc4e28728 (patch)
treeeabba6c15b22345ab322f7380548c4c8eb5e50fe /pkg/tcpip/transport/udp
parent0c4118d5b8428648c252df55a7867ac6f287f146 (diff)
Support add/remove IPv6 multicast group sock opt
IPv4 was always supported but UDP never supported joining/leaving IPv6 multicast groups via socket options. Add: IPPROTO_IPV6, IPV6_JOIN_GROUP/IPV6_ADD_MEMBERSHIP Remove: IPPROTO_IPV6, IPV6_LEAVE_GROUP/IPV6_DROP_MEMBERSHIP Test: integration_test.TestUDPAddRemoveMembershipSocketOption PiperOrigin-RevId: 350396072
Diffstat (limited to 'pkg/tcpip/transport/udp')
-rw-r--r--pkg/tcpip/transport/udp/endpoint.go14
1 files changed, 4 insertions, 10 deletions
diff --git a/pkg/tcpip/transport/udp/endpoint.go b/pkg/tcpip/transport/udp/endpoint.go
index 9b9e4deb0..4e8bd8b04 100644
--- a/pkg/tcpip/transport/udp/endpoint.go
+++ b/pkg/tcpip/transport/udp/endpoint.go
@@ -708,14 +708,9 @@ func (e *endpoint) SetSockOpt(opt tcpip.SettableSocketOption) *tcpip.Error {
nicID := v.NIC
- // The interface address is considered not-set if it is empty or contains
- // all-zeros. The former represent the zero-value in golang, the latter the
- // same in a setsockopt(IP_ADD_MEMBERSHIP, &ip_mreqn) syscall.
- allZeros := header.IPv4Any
- if len(v.InterfaceAddr) == 0 || v.InterfaceAddr == allZeros {
+ if v.InterfaceAddr.Unspecified() {
if nicID == 0 {
- r, err := e.stack.FindRoute(0, "", v.MulticastAddr, header.IPv4ProtocolNumber, false /* multicastLoop */)
- if err == nil {
+ if r, err := e.stack.FindRoute(0, "", v.MulticastAddr, e.NetProto, false /* multicastLoop */); err == nil {
nicID = r.NICID()
r.Release()
}
@@ -748,10 +743,9 @@ func (e *endpoint) SetSockOpt(opt tcpip.SettableSocketOption) *tcpip.Error {
}
nicID := v.NIC
- if v.InterfaceAddr == header.IPv4Any {
+ if v.InterfaceAddr.Unspecified() {
if nicID == 0 {
- r, err := e.stack.FindRoute(0, "", v.MulticastAddr, header.IPv4ProtocolNumber, false /* multicastLoop */)
- if err == nil {
+ if r, err := e.stack.FindRoute(0, "", v.MulticastAddr, e.NetProto, false /* multicastLoop */); err == nil {
nicID = r.NICID()
r.Release()
}