summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGhanan Gowripalan <ghanan@google.com>2021-09-20 12:14:29 -0700
committergVisor bot <gvisor-bot@google.com>2021-09-20 12:17:13 -0700
commit5951ec5bce17e7696d2fd53ce384839555dd3c79 (patch)
tree887fbe818027d2c0493e903410e12838e24aeef2 /test
parentd139087b3f7be1fdc1af151e8548c4bbdc199875 (diff)
Do not allow unbinding network protocol
Once a packet socket is bound to a network protocol, it cannot be unbound from that protocol; the network protocol binding may only be updated to a different network protocol. To comply with Linux. PiperOrigin-RevId: 397810878
Diffstat (limited to 'test')
-rw-r--r--test/syscalls/linux/packet_socket.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/test/syscalls/linux/packet_socket.cc b/test/syscalls/linux/packet_socket.cc
index 43828a52e..81e607a3f 100644
--- a/test/syscalls/linux/packet_socket.cc
+++ b/test/syscalls/linux/packet_socket.cc
@@ -214,6 +214,11 @@ TEST_P(PacketSocketTest, RebindProtocol) {
ASSERT_NO_FATAL_FAILURE(bind_to_network_protocol(ETH_P_IP));
ASSERT_NO_FATAL_FAILURE(send_udp_message(++counter));
ASSERT_NO_FATAL_FAILURE(test_recv(counter));
+
+ // A zero valued protocol number should not change the bound network protocol.
+ ASSERT_NO_FATAL_FAILURE(bind_to_network_protocol(0));
+ ASSERT_NO_FATAL_FAILURE(send_udp_message(++counter));
+ ASSERT_NO_FATAL_FAILURE(test_recv(counter));
}
INSTANTIATE_TEST_SUITE_P(AllPacketSocketTests, PacketSocketTest,