From 5951ec5bce17e7696d2fd53ce384839555dd3c79 Mon Sep 17 00:00:00 2001 From: Ghanan Gowripalan Date: Mon, 20 Sep 2021 12:14:29 -0700 Subject: 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 --- test/syscalls/linux/packet_socket.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/syscalls/linux/packet_socket.cc') 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, -- cgit v1.2.3