Merge pull request #24019 from yuwata/network-ipv4ll

network: refuse 169.254.0.0/24 and 169.254.255.0/24
This commit is contained in:
Yu Watanabe
2022-07-15 07:59:13 +09:00
committed by GitHub
7 changed files with 28 additions and 21 deletions
@@ -6,3 +6,4 @@ Name=veth99
DHCP=ipv4
LinkLocalAddressing=yes
IPv6AcceptRA=no
IPv4LLStartAddress=169.254.133.11
+3 -3
View File
@@ -4570,7 +4570,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
output = check_output('ip -4 address show dev veth99')
print(output)
self.assertNotIn('192.168.5.', output)
self.assertRegex(output, r'inet 169\.254\.\d+\.\d+/16 metric 2048 brd 169\.254\.255\.255 scope link')
self.assertIn('inet 169.254.133.11/16 metric 2048 brd 169.254.255.255 scope link', output)
start_dnsmasq()
print('Wait for a DHCP lease to be acquired and the IPv4LL address to be dropped')
@@ -4587,12 +4587,12 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
stop_dnsmasq()
print('Wait for the DHCP lease to be expired and an IPv4LL address to be acquired')
self.wait_address_dropped('veth99', r'inet 192\.168\.5\.\d+/24 metric 1024 brd 192\.168\.5\.255 scope global dynamic', ipv='-4', timeout_sec=130)
self.wait_address('veth99', r'inet 169\.254\.\d+\.\d+/16 metric 2048 brd 169\.254\.255\.255 scope link', scope='link', ipv='-4')
self.wait_address('veth99', r'inet 169\.254\.133\.11/16 metric 2048 brd 169\.254\.255\.255 scope link', scope='link', ipv='-4')
output = check_output('ip -4 address show dev veth99')
print(output)
self.assertNotIn('192.168.5.', output)
self.assertRegex(output, r'inet 169\.254\.\d+\.\d+/16 metric 2048 brd 169\.254\.255\.255 scope link')
self.assertIn('inet 169.254.133.11/16 metric 2048 brd 169.254.255.255 scope link', output)
def test_dhcp_client_use_dns(self):
def check(self, ipv4, ipv6):