[OVN]Any string type dhcp options should be quoted
Any dhcp option[1] which value is string type in ovn should be added quotes, otherwise it would be regard as constant. [1]https://github.com/ovn-org/ovn/blob/main/lib/ovn-l7.h#L116 Closes-Bug: #1946764 Change-Id: Id174cd944c3b883b749046bc49d00e011eb891fe (cherry picked from commit18c32e4339
) (cherry picked from commitf1e7d20b01
)
This commit is contained in:
parent
2eb44d5985
commit
52bb040e4e
|
@ -172,6 +172,14 @@ SUPPORTED_DHCP_OPTS_MAPPING = {
|
|||
'23': 'dns_server'},
|
||||
}
|
||||
|
||||
# OVN string type DHCP options
|
||||
OVN_STR_TYPE_DHCP_OPTS = [
|
||||
'domain_name',
|
||||
'bootfile_name',
|
||||
'path_prefix',
|
||||
'wpad',
|
||||
'tftp_server']
|
||||
|
||||
# Special option for disabling DHCP via extra DHCP options
|
||||
DHCP_DISABLED_OPT = 'dhcp_disabled'
|
||||
|
||||
|
|
|
@ -153,6 +153,10 @@ def validate_port_extra_dhcp_opts(port):
|
|||
invalid_ipv6=invalid[const.IP_VERSION_6] if failed else [])
|
||||
|
||||
|
||||
def is_dhcp_option_quoted(opt_value):
|
||||
return opt_value.startswith('"') and opt_value.endswith('"')
|
||||
|
||||
|
||||
def get_lsp_dhcp_opts(port, ip_version):
|
||||
# Get dhcp options from Neutron port, for setting DHCP_Options row
|
||||
# in OVN.
|
||||
|
@ -186,6 +190,9 @@ def get_lsp_dhcp_opts(port, ip_version):
|
|||
continue
|
||||
|
||||
opt = mapping[edo['opt_name']]
|
||||
if (opt in constants.OVN_STR_TYPE_DHCP_OPTS and
|
||||
not is_dhcp_option_quoted(edo['opt_value'])):
|
||||
edo['opt_value'] = '"%s"' % edo['opt_value']
|
||||
lsp_dhcp_opts[opt] = edo['opt_value']
|
||||
|
||||
return (lsp_dhcp_disabled, lsp_dhcp_opts)
|
||||
|
|
|
@ -363,7 +363,7 @@ class TestNBDbResources(base.TestOVNFunctionalBase):
|
|||
'mtu': str(n1['network']['mtu']),
|
||||
'router': subnet['gateway_ip'],
|
||||
'ip_forward_enable': '1',
|
||||
'tftp_server': '10.0.0.100',
|
||||
'tftp_server': '"10.0.0.100"',
|
||||
'domain_name': '"%s"' % cfg.CONF.dns_domain,
|
||||
'dns_server': '20.20.20.20'}}
|
||||
expected_dhcp_v4_options_rows['v4-' + p2['port']['id']] = \
|
||||
|
@ -427,7 +427,7 @@ class TestNBDbResources(base.TestOVNFunctionalBase):
|
|||
'dns_server': '{10.10.10.10}',
|
||||
'mtu': str(n1['network']['mtu']),
|
||||
'router': subnet['gateway_ip'],
|
||||
'tftp_server': '100.0.0.100'}}
|
||||
'tftp_server': '"100.0.0.100"'}}
|
||||
expected_dhcp_v4_options_rows['v4-' + p4['port']['id']] = \
|
||||
expected_dhcp_options_rows['v4-' + p4['port']['id']]
|
||||
expected_dhcp_v6_options_rows['v6-' + p4['port']['id']] = \
|
||||
|
@ -695,7 +695,7 @@ class TestNBDbResources(base.TestOVNFunctionalBase):
|
|||
'dns_server': '{10.10.10.10}',
|
||||
'mtu': '1200',
|
||||
'router': subnet['gateway_ip'],
|
||||
'tftp_server': '8.8.8.8'}}
|
||||
'tftp_server': '"8.8.8.8"'}}
|
||||
self._verify_dhcp_option_rows(expected_dhcp_options_rows)
|
||||
self._verify_dhcp_option_row_for_port(
|
||||
p1['id'], expected_dhcp_options_rows['v4-' + p1['id']],
|
||||
|
|
|
@ -190,7 +190,7 @@ class TestOvnNbSync(base.TestOVNFunctionalBase):
|
|||
'lease_time': str(12 * 60 * 60),
|
||||
'mtu': str(n1['network']['mtu']),
|
||||
'router': n1_s1['subnet']['gateway_ip'],
|
||||
'tftp_server': '20.0.0.20',
|
||||
'tftp_server': '"20.0.0.20"',
|
||||
'domain_name': '"ovn.test"',
|
||||
'dns_server': '8.8.8.8'}})
|
||||
self.expected_dhcp_options_rows.append({
|
||||
|
@ -237,7 +237,7 @@ class TestOvnNbSync(base.TestOVNFunctionalBase):
|
|||
'lease_time': str(3 * 60 * 60),
|
||||
'mtu': str(n1['network']['mtu'] / 2),
|
||||
'router': '10.0.0.254',
|
||||
'tftp_server': '20.0.0.234',
|
||||
'tftp_server': '"20.0.0.234"',
|
||||
'domain_name': '"ovn.test"',
|
||||
'dns_server': '8.8.8.8'},
|
||||
'external_ids': {'subnet_id': n1_s1['subnet']['id'],
|
||||
|
@ -260,7 +260,7 @@ class TestOvnNbSync(base.TestOVNFunctionalBase):
|
|||
'lease_time': str(12 * 60 * 60),
|
||||
'mtu': str(n1['network']['mtu']),
|
||||
'router': n1_s1['subnet']['gateway_ip'],
|
||||
'tftp_server': '20.0.0.20',
|
||||
'tftp_server': '"20.0.0.20"',
|
||||
'domain_name': '"ovn.test"',
|
||||
'dns_server': '8.8.8.8'}})
|
||||
self.expected_dhcp_options_rows.append({
|
||||
|
@ -321,7 +321,7 @@ class TestOvnNbSync(base.TestOVNFunctionalBase):
|
|||
'lease_time': str(12 * 60 * 60),
|
||||
'mtu': str(n1['network']['mtu']),
|
||||
'router': n2_s1['subnet']['gateway_ip'],
|
||||
'tftp_server': '20.0.0.20',
|
||||
'tftp_server': '"20.0.0.20"',
|
||||
'domain_name': '"ovn.test"',
|
||||
'dns_server': '8.8.8.8'}})
|
||||
self.missed_dhcp_options.extend([
|
||||
|
@ -644,7 +644,7 @@ class TestOvnNbSync(base.TestOVNFunctionalBase):
|
|||
'lease_time': str(3 * 60 * 60),
|
||||
'mtu': str(n3['network']['mtu'] / 2),
|
||||
'router': '30.0.0.254',
|
||||
'tftp_server': '30.0.0.234',
|
||||
'tftp_server': '"30.0.0.234"',
|
||||
'dns_server': '8.8.8.8'},
|
||||
'external_ids': {'subnet_id': n3_s1['subnet']['id'],
|
||||
'port_id': fake_port_id1}}
|
||||
|
|
|
@ -270,7 +270,7 @@ class TestDHCPUtils(base.BaseTestCase):
|
|||
# Assert the names got translated to their OVN names
|
||||
expected_options = {'tftp_server_address': '10.0.0.1',
|
||||
'ntp_server': '10.0.2.1',
|
||||
'bootfile_name': 'homer_simpson.bin'}
|
||||
'bootfile_name': '"homer_simpson.bin"'}
|
||||
self.assertEqual(expected_options, options)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue