@@ -33,7 +33,10 @@ class TestRtNlIfaddrList(NetlinkTestTemplate, SingleVnetTestTemplate):
33
33
def setup_method (self , method ):
34
34
method_name = method .__name__
35
35
if "4" in method_name :
36
- self .IPV4_PREFIXES = ["192.0.2.1/24" ]
36
+ if "nofilter" in method_name :
37
+ self .IPV4_PREFIXES = ["192.0.2.1/24" , "169.254.169.254/16" ]
38
+ else :
39
+ self .IPV4_PREFIXES = ["192.0.2.1/24" ]
37
40
if "6" in method_name :
38
41
self .IPV6_PREFIXES = ["2001:db8::1/64" ]
39
42
super ().setup_method (method )
@@ -49,14 +52,21 @@ def test_46_nofilter(self):
49
52
for rx_msg in self .read_msg_list (msg .nl_hdr .nlmsg_seq , NlRtMsgType .RTM_NEWADDR ):
50
53
ifname = socket .if_indextoname (rx_msg .base_hdr .ifa_index )
51
54
family = rx_msg .base_hdr .ifa_family
52
- ret .append ((ifname , family , rx_msg ))
55
+ scope = rx_msg .base_hdr .ifa_scope
56
+ ret .append ((ifname , family , scope ))
53
57
54
58
ifname = "lo0"
55
- assert len ([r for r in ret if r [0 ] == ifname ]) > 0
59
+ assert len ([r for r in ret if r [0 ] == ifname and r [1 ] == socket .AF_INET and r [2 ] == RtScope .RT_SCOPE_HOST .value ]) == 1
60
+ assert len ([r for r in ret if r [0 ] == ifname and r [1 ] == socket .AF_INET6 and r [2 ] == RtScope .RT_SCOPE_HOST .value ]) == 1
61
+ assert len ([r for r in ret if r [0 ] == ifname and r [1 ] == socket .AF_INET6 and r [2 ] == RtScope .RT_SCOPE_LINK .value ]) == 1
62
+ assert len ([r for r in ret if r [0 ] == ifname ]) == 3
56
63
57
64
ifname = self .vnet .iface_alias_map ["if1" ].name
58
- assert len ([r for r in ret if r [0 ] == ifname and r [1 ] == socket .AF_INET ]) == 1
59
- assert len ([r for r in ret if r [0 ] == ifname and r [1 ] == socket .AF_INET6 ]) == 2
65
+ assert len ([r for r in ret if r [0 ] == ifname and r [1 ] == socket .AF_INET and r [2 ] == RtScope .RT_SCOPE_LINK .value ]) == 1
66
+ assert len ([r for r in ret if r [0 ] == ifname and r [1 ] == socket .AF_INET and r [2 ] == RtScope .RT_SCOPE_UNIVERSE .value ]) == 1
67
+ assert len ([r for r in ret if r [0 ] == ifname and r [1 ] == socket .AF_INET6 and r [2 ] == RtScope .RT_SCOPE_LINK .value ]) == 1
68
+ assert len ([r for r in ret if r [0 ] == ifname and r [1 ] == socket .AF_INET6 and r [2 ] == RtScope .RT_SCOPE_UNIVERSE .value ]) == 1
69
+ assert len ([r for r in ret if r [0 ] == ifname ]) == 4
60
70
61
71
def test_46_filter_iface (self ):
62
72
"""Tests that listing outputs both IPv4/IPv6 for the specific interface"""
0 commit comments