summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2021-09-16 18:58:20 +0000
committergVisor bot <gvisor-bot@google.com>2021-09-16 18:58:20 +0000
commite73986dd376c2c71d81ab8ccabdea3aecac5e9d5 (patch)
tree73c039e763ec11687a730ade4a9beeaf1d699d41 /pkg/tcpip
parent812a722c54a8c359f77d1bdfea9f63b810e5a5a8 (diff)
parent282a4dd52b337dccfb578e9d32dd1005c864dd8d (diff)
Merge release-20210906.0-34-g282a4dd52 (automated)
Diffstat (limited to 'pkg/tcpip')
-rw-r--r--pkg/tcpip/transport/icmp/endpoint.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/pkg/tcpip/transport/icmp/endpoint.go b/pkg/tcpip/transport/icmp/endpoint.go
index 00497bf07..1e519085d 100644
--- a/pkg/tcpip/transport/icmp/endpoint.go
+++ b/pkg/tcpip/transport/icmp/endpoint.go
@@ -688,9 +688,20 @@ func (e *endpoint) bindLocked(addr tcpip.FullAddress) tcpip.Error {
return nil
}
+func (e *endpoint) isBroadcastOrMulticast(nicID tcpip.NICID, addr tcpip.Address) bool {
+ return addr == header.IPv4Broadcast ||
+ header.IsV4MulticastAddress(addr) ||
+ header.IsV6MulticastAddress(addr) ||
+ e.stack.IsSubnetBroadcast(nicID, e.NetProto, addr)
+}
+
// Bind binds the endpoint to a specific local address and port.
// Specifying a NIC is optional.
func (e *endpoint) Bind(addr tcpip.FullAddress) tcpip.Error {
+ if len(addr.Addr) != 0 && e.isBroadcastOrMulticast(addr.NIC, addr.Addr) {
+ return &tcpip.ErrBadLocalAddress{}
+ }
+
e.mu.Lock()
defer e.mu.Unlock()