odr fails if IPv4 subnet is given but no dhcp servers are configured
We hit a bug if a realm with a configured ipv4 subnet is used but no dhcp servers are given:
[realm hiu-drucker]
vid = 2302
subnet_ipv4 = 172.21.118.136/29
subnet_ipv6 = 2a00:1398:5:8301::/64
provide_default_route = False
Odr fails with the following traceback:
Mar 4 10:26:30 ovpn-mgmt-0b.scc.kit.edu odrd[975559]: [#033[31m#033[1merror #033[0m] #033[1mDHCP request failed #033[0m [#033[34m#033[1movpnclient#033[0m] #033[36mname#033[0m=#033[35mscc-box2vlan-0010@hiu-drucker#033[0m #033[36mserver#033[0m=#033[35m<OvpnServer 'tap6u'>#033[0m
Mar 4 10:26:30 ovpn-mgmt-0b.scc.kit.edu odrd[975559]: Traceback (most recent call last):
Mar 4 10:26:30 ovpn-mgmt-0b.scc.kit.edu odrd[975559]: File "/usr/local/lib/python3.9/dist-packages/odr/ovpn_client.py", line 138, in do_request
Mar 4 10:26:30 ovpn-mgmt-0b.scc.kit.edu odrd[975559]: return await self._send_request(
Mar 4 10:26:30 ovpn-mgmt-0b.scc.kit.edu odrd[975559]: File "/usr/local/lib/python3.9/dist-packages/odr/odrd.py", line 295, in start_dhcp_address_request
Mar 4 10:26:30 ovpn-mgmt-0b.scc.kit.edu odrd[975559]: request = odr.dhcprequestor.DhcpAddressInitialRequest(
Mar 4 10:26:30 ovpn-mgmt-0b.scc.kit.edu odrd[975559]: File "/usr/local/lib/python3.9/dist-packages/odr/dhcprequestor.py", line 425, in __init__
Mar 4 10:26:30 ovpn-mgmt-0b.scc.kit.edu odrd[975559]: DhcpAddressRequest.__init__(
Mar 4 10:26:30 ovpn-mgmt-0b.scc.kit.edu odrd[975559]: File "/usr/local/lib/python3.9/dist-packages/odr/dhcprequestor.py", line 181, in __init__
Mar 4 10:26:30 ovpn-mgmt-0b.scc.kit.edu odrd[975559]: self._server_ips = [IPv4Address(ip) for ip in server_ips]
Mar 4 10:26:30 ovpn-mgmt-0b.scc.kit.edu odrd[975559]: TypeError: 'NoneType' object is not iterable
Mar 4 10:26:30 ovpn-mgmt-0b.scc.kit.edu odrd[975559]: [#033[32m#033[1mdebug #033[0m] #033[1mwriting deferred return value 0#033[0m [#033[34m#033[1movpncmdconn#033[0m]
Mar 4 10:26:30 ovpn-mgmt-0b.scc.kit.edu odrd[975559]: Exception ignored in: <function DhcpAddressRequest.__del__ at 0x7fdf472f84c0>
Mar 4 10:26:30 ovpn-mgmt-0b.scc.kit.edu odrd[975559]: Traceback (most recent call last):
Mar 4 10:26:30 ovpn-mgmt-0b.scc.kit.edu odrd[975559]: File "/usr/local/lib/python3.9/dist-packages/odr/dhcprequestor.py", line 212, in __del__
Mar 4 10:26:30 ovpn-mgmt-0b.scc.kit.edu odrd[975559]: self._log.debug('xid %d destroyed', self.xid)
Mar 4 10:26:30 ovpn-mgmt-0b.scc.kit.edu odrd[975559]: File "/usr/local/lib/python3.9/dist-packages/odr/dhcprequestor.py", line 218, in xid
Mar 4 10:26:30 ovpn-mgmt-0b.scc.kit.edu odrd[975559]: return self._xid
Mar 4 10:26:30 ovpn-mgmt-0b.scc.kit.edu odrd[975559]: AttributeError: 'DhcpAddressInitialRequest' object has no attribute '_xid'
Odr fails in line dhcprequestor.py#L181 because dhcp_servers are not in the realm configuration. realm_data.dhcp_server_ips
is not set and therefore None
is returned when creating the request.
Maybe the simplest solution is to prevent doing a request if realm_data.dhcp_server_ips
is false. This can be done by adding and self._realm_data.dhcp_server_ips
to the condition in ovpn_client.py#L115.
Edited by Benedikt Neuffer