mirror of
https://github.com/opnsense/src.git
synced 2026-05-04 17:05:14 -04:00
Some existing applications setup Netlink socket with SOCK_DGRAM instead of SOCK_RAW. Update the manpage to clarify that the default way of creating the socket should be with SOCK_RAW. Update the code to support both SOCK_RAW and SOCK_DGRAM. Reviewed By: pauamma Differential Revision: https://reviews.freebsd.org/D38075
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
import errno
|
|
import socket
|
|
|
|
import pytest
|
|
from atf_python.sys.net.netlink import NetlinkTestTemplate
|
|
from atf_python.sys.net.netlink import NlConst
|
|
from atf_python.sys.net.vnet import SingleVnetTestTemplate
|
|
|
|
|
|
class TestNlCore(NetlinkTestTemplate, SingleVnetTestTemplate):
|
|
@pytest.mark.parametrize(
|
|
"params",
|
|
[
|
|
pytest.param({"type": socket.SOCK_RAW}, id="SOCK_RAW"),
|
|
pytest.param({"type": socket.SOCK_DGRAM}, id="SOCK_DGRAM"),
|
|
],
|
|
)
|
|
def test_socket_type(self, params):
|
|
s = socket.socket(NlConst.AF_NETLINK, params["type"], NlConst.NETLINK_ROUTE)
|
|
s.close()
|
|
|
|
@pytest.mark.parametrize(
|
|
"params",
|
|
[
|
|
pytest.param({"type": socket.SOCK_STREAM}, id="SOCK_STREAM"),
|
|
pytest.param({"type": socket.SOCK_RDM}, id="SOCK_RDM"),
|
|
pytest.param({"type": socket.SOCK_SEQPACKET}, id="SOCK_SEQPACKET"),
|
|
],
|
|
)
|
|
def test_socket_type_unsup(self, params):
|
|
with pytest.raises(OSError) as exc_info:
|
|
socket.socket(NlConst.AF_NETLINK, params["type"], NlConst.NETLINK_ROUTE)
|
|
assert exc_info.value.errno == errno.EPROTOTYPE
|