mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-15 12:54:27 +00:00
netlink: Add tests when adding an interface route
Add tests for adding a route using an interface only (without an IP address). Reviewed by: rcm Approved by: kp (mentor) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D41436
This commit is contained in:
parent
ca7edd0d2c
commit
1db64f8936
|
@ -3,6 +3,7 @@
|
|||
|
||||
import pytest
|
||||
from atf_python.sys.net.tools import ToolsHelper
|
||||
from atf_python.sys.net.vnet import IfaceFactory
|
||||
from atf_python.sys.net.vnet import SingleVnetTestTemplate
|
||||
from atf_python.sys.netlink.attrs import NlAttrIp
|
||||
from atf_python.sys.netlink.attrs import NlAttrU32
|
||||
|
@ -45,6 +46,46 @@ def test_add_route6_ll_gw(self):
|
|||
ToolsHelper.print_net_debug()
|
||||
ToolsHelper.print_output("netstat -6onW")
|
||||
|
||||
@pytest.mark.timeout(5)
|
||||
def test_add_route6_ll_if_gw(self):
|
||||
tun_ifname = IfaceFactory().create_iface("", "tun")[0].name
|
||||
tun_ifindex = socket.if_nametoindex(tun_ifname)
|
||||
|
||||
msg = NetlinkRtMessage(self.helper, NlRtMsgType.RTM_NEWROUTE)
|
||||
msg.set_request()
|
||||
msg.add_nlflags([NlmNewFlags.NLM_F_CREATE])
|
||||
msg.base_hdr.rtm_family = socket.AF_INET6
|
||||
msg.base_hdr.rtm_dst_len = 64
|
||||
msg.add_nla(NlAttrIp(RtattrType.RTA_DST, "2001:db8:2::"))
|
||||
msg.add_nla(NlAttrU32(RtattrType.RTA_OIF, tun_ifindex))
|
||||
|
||||
rx_msg = self.get_reply(msg)
|
||||
assert rx_msg.is_type(NlMsgType.NLMSG_ERROR)
|
||||
assert rx_msg.error_code == 0
|
||||
|
||||
ToolsHelper.print_net_debug()
|
||||
ToolsHelper.print_output("netstat -6onW")
|
||||
|
||||
@pytest.mark.timeout(5)
|
||||
def test_add_route4_ll_if_gw(self):
|
||||
tun_ifname = IfaceFactory().create_iface("", "tun")[0].name
|
||||
tun_ifindex = socket.if_nametoindex(tun_ifname)
|
||||
|
||||
msg = NetlinkRtMessage(self.helper, NlRtMsgType.RTM_NEWROUTE)
|
||||
msg.set_request()
|
||||
msg.add_nlflags([NlmNewFlags.NLM_F_CREATE])
|
||||
msg.base_hdr.rtm_family = socket.AF_INET
|
||||
msg.base_hdr.rtm_dst_len = 32
|
||||
msg.add_nla(NlAttrIp(RtattrType.RTA_DST, "192.0.2.1"))
|
||||
msg.add_nla(NlAttrU32(RtattrType.RTA_OIF, tun_ifindex))
|
||||
|
||||
rx_msg = self.get_reply(msg)
|
||||
assert rx_msg.is_type(NlMsgType.NLMSG_ERROR)
|
||||
assert rx_msg.error_code == 0
|
||||
|
||||
ToolsHelper.print_net_debug()
|
||||
ToolsHelper.print_output("netstat -4onW")
|
||||
|
||||
@pytest.mark.timeout(20)
|
||||
def test_buffer_override(self):
|
||||
msg_flags = (
|
||||
|
|
Loading…
Reference in a new issue