diff options
author | Ghanan Gowripalan <ghanan@google.com> | 2021-09-17 15:31:19 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-09-17 15:37:08 -0700 |
commit | 7dacdbef528f7b556f23c1b02a360363dc556e31 (patch) | |
tree | 39f1b8fb51f3aaa830fcfc5459c15ff4bb75223f /pkg/sentry | |
parent | 4076153be6840c50ade746087b221a12d7bd2b3b (diff) |
Allow rebinding packet socket protocol
...to change the network protocol a packet socket may receive packets
from.
This CL is a portion of an originally larger CL that was split with
https://github.com/google/gvisor/commit/a8ad692fd36cbaf7f5a6b9af39d601053dbee338
being the dependent CL. That CL (accidentally) included the change in
the endpoint's `afterLoad` method to take the required lock when
accessing the endpoint's netProto field. That change should have been in
this CL.
The CL that made the change mentioned in the commit message is
cl/396946187.
PiperOrigin-RevId: 397412582
Diffstat (limited to 'pkg/sentry')
-rw-r--r-- | pkg/sentry/socket/netstack/netstack.go | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/pkg/sentry/socket/netstack/netstack.go b/pkg/sentry/socket/netstack/netstack.go index f79bda922..aa081e90d 100644 --- a/pkg/sentry/socket/netstack/netstack.go +++ b/pkg/sentry/socket/netstack/netstack.go @@ -672,13 +672,10 @@ func (s *socketOpsCommon) Bind(t *kernel.Task, sockaddr []byte) *syserr.Error { } a.UnmarshalBytes(sockaddr[:sockAddrLinkSize]) - if a.Protocol != uint16(s.protocol) { - return syserr.ErrInvalidArgument - } - addr = tcpip.FullAddress{ NIC: tcpip.NICID(a.InterfaceIndex), Addr: tcpip.Address(a.HardwareAddr[:header.EthernetAddressSize]), + Port: socket.Ntohs(a.Protocol), } } else { if s.minSockAddrLen() > len(sockaddr) { |