Send kea-dev mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.isc.org/mailman/listinfo/kea-dev
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of kea-dev digest..."
Today's Topics:
1. Successfully replicated the Facebook trick with embedded
Python hook (Dave Cole)
2. [PATCH] [master] Fix: Release the reference of hook library
(Yahu Gao)
----------------------------------------------------------------------
Message: 1
Date: Mon, 11 Dec 2017 01:44:24 +0000
From: Dave Cole <[email protected]>
To: "[email protected]" <[email protected]>
Subject: [kea-dev] Successfully replicated the Facebook trick with
embedded Python hook
Message-ID:
<syxpr01mb1727466c0d7ed4ee9cf61ee6f2...@syxpr01mb1727.ausprd01.prod.outlook.com>
Content-Type: text/plain; charset="iso-8859-1"
I have been working on embedding Python into Kea via a hook as we
have some non-trivial requirements here. One of the first things
I needed to do was replicate the Facebook trick as described
in this port:
https://code.facebook.com/posts/845909058837784/using-isc-kea-dhcp-in-our-data-centers/
As far as I can tell, the trick as described by Facebook only
works for Kea before release 1.0. With experimentation I
discovered that it is still possible to get the behaviour they
describe, but I am not sure the solution is perfect.
The coverage of Kea is not complete, but it is fairly straight
forward to follow the established code to expose more of Kea.
If there is any interest in this hook I will work towards a
public release.
The embedding was not as straight forward as it should have been
because I had to work around the fact that Kea does not load
hooks with the RTLD_GLOBAL flag. RTLD_GLOBAL is required to
enable loading of Python libraries containing C extensions (such
as database adapters).
Using the hook you should be free to use any Python modules you
require.
* The hook tries to follow the C++ interface closely to avoid the
requirement for extensive documentation. On startup it looks
for the documented hook functions in your Python module and
registers any it finds.
* The sample Python code lets Kea perform the complete DHCP
transaction up to the point where it wants to save the
allocated lease. When the hook tells Kea to skip lease saving
Kea wants to NAK the REQUEST. The NAK is turned into an ACK in
pkt4_send() and the rest of the (mostly) empty packet is
populated.
Although the solution works, it does look and feel a little bit
dirty. I really wish there was a nicer way to tell Kea not to
manage leases.
- - 8< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
from kea import *
from ipaddress import IPv4Address, IPv4Network
subnet = IPv4Network(u'10.0.0.0/20')
name_servers = [IPv4Address(u'192.0.3.1'), IPv4Address(u'192.0.3.2')]
packed_servers = ''.join([addr.packed for addr in name_servers])
def lease4_select(handle):
lease = handle.getArgument('lease4')
addr = str(subnet[42])
lease.addr = addr
handle.setContext('addr', addr)
if handle.getArgument('query4').getType() == DHCPREQUEST:
handle.setStatus(NEXT_STEP_SKIP)
return 0
def pkt4_send(handle):
response = handle.getArgument('response4')
if response.getType() == DHCPNAK:
response.setType(DHCPACK)
addr = handle.getContext('addr')
response.setRemoteAddr(addr)
response.setYiaddr(addr)
for option in (DHO_SUBNET_MASK, DHO_ROUTERS, DHO_DOMAIN_NAME_SERVERS,
DHO_DOMAIN_NAME, DHO_DHCP_LEASE_TIME, DHO_DHCP_RENEWAL_TIME,
DHO_DHCP_REBINDING_TIME):
response.delOption(option)
response.addOption(Option(DHO_SUBNET_MASK).setString(subnet.netmask.packed))
response.addOption(Option(DHO_ROUTERS).setString(subnet[1].packed))
response.addOption(Option(DHO_DOMAIN_NAME_SERVERS).setString(packed_servers))
response.addOption(Option(DHO_DOMAIN_NAME).setString('simplehook.org'))
response.addOption(Option(DHO_DHCP_LEASE_TIME).setUint32(7200))
response.addOption(Option(DHO_DHCP_RENEWAL_TIME).setUint32(1800))
response.addOption(Option(DHO_DHCP_REBINDING_TIME).setUint32(3600))
return 0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Below is the complete debug log produced by Kea 1.3 for a DHCP
request generated by dhtest.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2017-12-11 00:48:06.166 INFO [kea-dhcp4.dhcp4/1326] DHCP4_STARTING Kea DHCPv4
server version 1.3.0 starting
2017-12-11 00:48:06.168 INFO [kea-dhcp4.dhcpsrv/1326] DHCPSRV_CFGMGR_ADD_IFACE
listening on interface eth1
2017-12-11 00:48:06.169 INFO [kea-dhcp4.dhcpsrv/1326]
DHCPSRV_CFGMGR_SOCKET_TYPE_DEFAULT "dhcp-socket-type" not specified , using
default socket type raw
2017-12-11 00:48:06.170 INFO [kea-dhcp4.dhcpsrv/1326]
DHCPSRV_CFGMGR_NEW_SUBNET4 a new subnet has been added to configuration:
0.0.0.0/0 with params: t1=900, t2=1800, valid-lifetime=3600
2017-12-11 00:48:06.181 INFO [kea-dhcp4.kea-python/1326] PYTHON_LOG registered
callout lease4_select
2017-12-11 00:48:06.182 INFO [kea-dhcp4.kea-python/1326] PYTHON_LOG registered
callout pkt4_send
2017-12-11 00:48:06.182 INFO [kea-dhcp4.kea-python/1326] PYTHON_LOG load was
not found
2017-12-11 00:48:06.182 INFO [kea-dhcp4.hooks/1326] HOOKS_LIBRARY_LOADED hooks
library /opt/kea/hook/libkeapython.so successfully loaded
2017-12-11 00:48:06.182 INFO [kea-dhcp4.dhcp4/1326] DHCP4_CONFIG_COMPLETE
DHCPv4 server has completed configuration: added IPv4 subnets: 1; DDNS: disabled
2017-12-11 00:48:06.182 INFO [kea-dhcp4.dhcpsrv/1326] DHCPSRV_MEMFILE_DB
opening memory file lease database: lfc-interval=3600 type=memfile universe=4
2017-12-11 00:48:06.183 INFO [kea-dhcp4.dhcpsrv/1326]
DHCPSRV_MEMFILE_LEASE_FILE_LOAD loading leases from file
/usr/local/var/kea/kea-leases4.csv
2017-12-11 00:48:06.183 INFO [kea-dhcp4.dhcpsrv/1326]
DHCPSRV_MEMFILE_LFC_SETUP setting up the Lease File Cleanup interval to 3600 sec
2017-12-11 00:48:06.201 INFO [kea-dhcp4.dhcp4/1326] DHCP4_STARTED Kea DHCPv4
server version 1.3.0 started
2017-12-11 00:48:09.126 DEBUG [kea-dhcp4.packets/1326] DHCP4_BUFFER_RECEIVED
received buffer from 0.0.0.0:68 to 255.255.255.255:67 over interface eth1
2017-12-11 00:48:09.127 DEBUG [kea-dhcp4.options/1326] DHCP4_BUFFER_UNPACK
parsing buffer received from 0.0.0.0 to 255.255.255.255 over interface eth1
2017-12-11 00:48:09.127 DEBUG [kea-dhcp4.dhcpsrv/1326]
DHCPSRV_CFGMGR_SUBNET4_ADDR selected subnet 0.0.0.0/0 for packet received by
matching address 100.100.100.100
2017-12-11 00:48:09.127 DEBUG [kea-dhcp4.packets/1326] DHCP4_SUBNET_SELECTED
[hwtype=1 08:00:27:bd:b3:a5], cid=[no info], tid=0x5a660c0b: the subnet with ID
1 was selected for client assignments
2017-12-11 00:48:09.127 DEBUG [kea-dhcp4.packets/1326] DHCP4_SUBNET_DATA
[hwtype=1 08:00:27:bd:b3:a5], cid=[no info], tid=0x5a660c0b: the selected
subnet details: 0.0.0.0/0
2017-12-11 00:48:09.127 DEBUG [kea-dhcp4.packets/1326] DHCP4_PACKET_RECEIVED
[hwtype=1 08:00:27:bd:b3:a5], cid=[no info], tid=0x5a660c0b: DHCPDISCOVER (type
1) received from 0.0.0.0 to 255.255.255.255 on interface eth1
2017-12-11 00:48:09.128 DEBUG [kea-dhcp4.packets/1326] DHCP4_QUERY_DATA
[hwtype=1 08:00:27:bd:b3:a5], cid=[no info], tid=0x5a660c0b, packet details:
local_address=255.255.255.255:67, remote_address=0.0.0.0:68,
msg_type=DHCPDISCOVER (1), transid=0x5a660c0b,
options:
type=053, len=001: 1 (uint8)
type=055, len=005: 1(uint8) 28(uint8) 3(uint8) 15(uint8) 6(uint8)
2017-12-11 00:48:09.128 DEBUG [kea-dhcp4.dhcpsrv/1326]
DHCPSRV_CFGMGR_SUBNET4_ADDR selected subnet 0.0.0.0/0 for packet received by
matching address 100.100.100.100
2017-12-11 00:48:09.128 DEBUG [kea-dhcp4.packets/1326] DHCP4_SUBNET_SELECTED
[hwtype=1 08:00:27:bd:b3:a5], cid=[no info], tid=0x5a660c0b: the subnet with ID
1 was selected for client assignments
2017-12-11 00:48:09.129 DEBUG [kea-dhcp4.packets/1326] DHCP4_SUBNET_DATA
[hwtype=1 08:00:27:bd:b3:a5], cid=[no info], tid=0x5a660c0b: the selected
subnet details: 0.0.0.0/0
2017-12-11 00:48:09.129 DEBUG [kea-dhcp4.hosts/1326]
HOSTS_CFG_GET_ONE_SUBNET_ID_IDENTIFIER get one host with IPv4 reservation for
subnet id 1, identified by hwaddr=080027BDB3A5
2017-12-11 00:48:09.129 DEBUG [kea-dhcp4.hosts/1326]
HOSTS_CFG_GET_ALL_IDENTIFIER get all hosts with reservations using identifier:
hwaddr=080027BDB3A5
2017-12-11 00:48:09.129 DEBUG [kea-dhcp4.hosts/1326]
HOSTS_CFG_GET_ALL_IDENTIFIER_COUNT using identifier hwaddr=080027BDB3A5, found
0 host(s)
2017-12-11 00:48:09.129 DEBUG [kea-dhcp4.hosts/1326]
HOSTS_CFG_GET_ONE_SUBNET_ID_IDENTIFIER_NULL host not found using subnet id 1
and identifier hwaddr=080027BDB3A5
2017-12-11 00:48:09.130 DEBUG [kea-dhcp4.ddns/1326]
DHCP4_CLIENT_HOSTNAME_PROCESS [hwtype=1 08:00:27:bd:b3:a5], cid=[no info],
tid=0x5a660c0b: processing client's Hostname option
2017-12-11 00:48:09.130 DEBUG [kea-dhcp4.dhcpsrv/1326]
DHCPSRV_MEMFILE_GET_HWADDR obtaining IPv4 leases for hardware address hwtype=1
08:00:27:bd:b3:a5
2017-12-11 00:48:09.130 DEBUG [kea-dhcp4.alloc-engine/1326]
ALLOC_ENGINE_V4_OFFER_NEW_LEASE allocation engine will try to offer new lease
to the client [hwtype=1 08:00:27:bd:b3:a5], cid=[no info], tid=0x5a660c0b
2017-12-11 00:48:09.130 DEBUG [kea-dhcp4.hosts/1326]
HOSTS_CFG_GET_ONE_SUBNET_ID_ADDRESS4 get one host with reservation for subnet
id 1 and IPv4 address 0.0.0.1
2017-12-11 00:48:09.130 DEBUG [kea-dhcp4.hosts/1326] HOSTS_CFG_GET_ALL_ADDRESS4
get all hosts with reservations for IPv4 address 0.0.0.1
2017-12-11 00:48:09.130 DEBUG [kea-dhcp4.hosts/1326]
HOSTS_CFG_GET_ALL_ADDRESS4_COUNT using address 0.0.0.1, found 0 host(s)
2017-12-11 00:48:09.130 DEBUG [kea-dhcp4.hosts/1326]
HOSTS_CFG_GET_ONE_SUBNET_ID_ADDRESS4_NULL host not found using subnet id 1 and
address 0.0.0.1
2017-12-11 00:48:09.131 DEBUG [kea-dhcp4.dhcpsrv/1326]
DHCPSRV_MEMFILE_GET_ADDR4 obtaining IPv4 lease for address 0.0.0.1
2017-12-11 00:48:09.131 DEBUG [kea-dhcp4.callouts/1326] HOOKS_CALLOUTS_BEGIN
begin all callouts for hook lease4_select
2017-12-11 00:48:09.131 DEBUG [kea-dhcp4.callouts/1326] HOOKS_CALLOUT_CALLED
hooks library with index 1 has called a callout on hook lease4_select that has
address 0x7f6298310bb6 (callout duration: 0.248 ms)
2017-12-11 00:48:09.131 DEBUG [kea-dhcp4.callouts/1326] HOOKS_CALLOUTS_COMPLETE
completed callouts for hook lease4_select (total callouts duration: 0.248 ms)
2017-12-11 00:48:09.131 DEBUG [kea-dhcp4.dhcpsrv/1326]
DHCPSRV_MEMFILE_GET_ADDR4 obtaining IPv4 lease for address 0.0.0.1
2017-12-11 00:48:09.132 INFO [kea-dhcp4.leases/1326] DHCP4_LEASE_ADVERT
[hwtype=1 08:00:27:bd:b3:a5], cid=[no info], tid=0x5a660c0b: lease 10.0.0.42
will be advertised
2017-12-11 00:48:09.132 DEBUG [kea-dhcp4.callouts/1326] HOOKS_CALLOUTS_BEGIN
begin all callouts for hook pkt4_send
2017-12-11 00:48:09.132 DEBUG [kea-dhcp4.callouts/1326] HOOKS_CALLOUT_CALLED
hooks library with index 1 has called a callout on hook pkt4_send that has
address 0x7f6298310e02 (callout duration: 0.213 ms)
2017-12-11 00:48:09.132 DEBUG [kea-dhcp4.callouts/1326] HOOKS_CALLOUTS_COMPLETE
completed callouts for hook pkt4_send (total callouts duration: 0.213 ms)
2017-12-11 00:48:09.132 DEBUG [kea-dhcp4.options/1326] DHCP4_PACKET_PACK
[hwtype=1 08:00:27:bd:b3:a5], cid=[no info], tid=0x5a660c0b: preparing on-wire
format of the packet to be sent
2017-12-11 00:48:09.133 DEBUG [kea-dhcp4.packets/1326] DHCP4_PACKET_SEND
[hwtype=1 08:00:27:bd:b3:a5], cid=[no info], tid=0x5a660c0b: trying to send
packet DHCPOFFER (type 2) from 100.100.100.100:67 to 10.0.0.42:68 on interface
eth1
2017-12-11 00:48:09.133 DEBUG [kea-dhcp4.packets/1326] DHCP4_RESPONSE_DATA
[hwtype=1 08:00:27:bd:b3:a5], cid=[no info], tid=0x5a660c0b: responding with
packet DHCPOFFER (type 2), packet details: local_address=100.100.100.100:67,
remote_address=10.0.0.42:68, msg_type=DHCPOFFER (2), transid=0x5a660c0b,
options:
type=001, len=004: ff:ff:f0:00
type=003, len=004: 0a:00:00:01
type=006, len=008: c0:00:03:01:c0:00:03:02
type=015, len=014: 73:69:6d:70:6c:65:68:6f:6f:6b:2e:6f:72:67
type=051, len=004: 00:00:1c:20
type=053, len=001: 2 (uint8)
type=054, len=004: 100.100.100.100
type=058, len=004: 00:00:07:08
type=059, len=004: 00:00:0e:10
2017-12-11 00:48:09.135 DEBUG [kea-dhcp4.packets/1326] DHCP4_BUFFER_RECEIVED
received buffer from 0.0.0.0:68 to 255.255.255.255:67 over interface eth1
2017-12-11 00:48:09.135 DEBUG [kea-dhcp4.options/1326] DHCP4_BUFFER_UNPACK
parsing buffer received from 0.0.0.0 to 255.255.255.255 over interface eth1
2017-12-11 00:48:09.135 DEBUG [kea-dhcp4.dhcpsrv/1326]
DHCPSRV_CFGMGR_SUBNET4_ADDR selected subnet 0.0.0.0/0 for packet received by
matching address 100.100.100.100
2017-12-11 00:48:09.136 DEBUG [kea-dhcp4.packets/1326] DHCP4_SUBNET_SELECTED
[hwtype=1 08:00:27:bd:b3:a5], cid=[no info], tid=0x5a660c0b: the subnet with ID
1 was selected for client assignments
2017-12-11 00:48:09.136 DEBUG [kea-dhcp4.packets/1326] DHCP4_SUBNET_DATA
[hwtype=1 08:00:27:bd:b3:a5], cid=[no info], tid=0x5a660c0b: the selected
subnet details: 0.0.0.0/0
2017-12-11 00:48:09.136 DEBUG [kea-dhcp4.packets/1326] DHCP4_PACKET_RECEIVED
[hwtype=1 08:00:27:bd:b3:a5], cid=[no info], tid=0x5a660c0b: DHCPREQUEST (type
3) received from 0.0.0.0 to 255.255.255.255 on interface eth1
2017-12-11 00:48:09.136 DEBUG [kea-dhcp4.packets/1326] DHCP4_QUERY_DATA
[hwtype=1 08:00:27:bd:b3:a5], cid=[no info], tid=0x5a660c0b, packet details:
local_address=255.255.255.255:67, remote_address=0.0.0.0:68,
msg_type=DHCPREQUEST (3), transid=0x5a660c0b,
options:
type=050, len=004: 10.0.0.42 (ipv4-address)
type=053, len=001: 3 (uint8)
type=054, len=004: 100.100.100.100 (ipv4-address)
type=055, len=005: 1(uint8) 28(uint8) 3(uint8) 15(uint8) 6(uint8)
2017-12-11 00:48:09.137 DEBUG [kea-dhcp4.dhcpsrv/1326]
DHCPSRV_CFGMGR_SUBNET4_ADDR selected subnet 0.0.0.0/0 for packet received by
matching address 100.100.100.100
2017-12-11 00:48:09.137 DEBUG [kea-dhcp4.packets/1326] DHCP4_SUBNET_SELECTED
[hwtype=1 08:00:27:bd:b3:a5], cid=[no info], tid=0x5a660c0b: the subnet with ID
1 was selected for client assignments
2017-12-11 00:48:09.137 DEBUG [kea-dhcp4.packets/1326] DHCP4_SUBNET_DATA
[hwtype=1 08:00:27:bd:b3:a5], cid=[no info], tid=0x5a660c0b: the selected
subnet details: 0.0.0.0/0
2017-12-11 00:48:09.137 DEBUG [kea-dhcp4.hosts/1326]
HOSTS_CFG_GET_ONE_SUBNET_ID_IDENTIFIER get one host with IPv4 reservation for
subnet id 1, identified by hwaddr=080027BDB3A5
2017-12-11 00:48:09.137 DEBUG [kea-dhcp4.hosts/1326]
HOSTS_CFG_GET_ALL_IDENTIFIER get all hosts with reservations using identifier:
hwaddr=080027BDB3A5
2017-12-11 00:48:09.137 DEBUG [kea-dhcp4.hosts/1326]
HOSTS_CFG_GET_ALL_IDENTIFIER_COUNT using identifier hwaddr=080027BDB3A5, found
0 host(s)
2017-12-11 00:48:09.137 DEBUG [kea-dhcp4.hosts/1326]
HOSTS_CFG_GET_ONE_SUBNET_ID_IDENTIFIER_NULL host not found using subnet id 1
and identifier hwaddr=080027BDB3A5
2017-12-11 00:48:09.137 DEBUG [kea-dhcp4.ddns/1326]
DHCP4_CLIENT_HOSTNAME_PROCESS [hwtype=1 08:00:27:bd:b3:a5], cid=[no info],
tid=0x5a660c0b: processing client's Hostname option
2017-12-11 00:48:09.137 DEBUG [kea-dhcp4.dhcpsrv/1326]
DHCPSRV_MEMFILE_GET_HWADDR obtaining IPv4 leases for hardware address hwtype=1
08:00:27:bd:b3:a5
2017-12-11 00:48:09.137 DEBUG [kea-dhcp4.hosts/1326]
HOSTS_CFG_GET_ONE_SUBNET_ID_ADDRESS4 get one host with reservation for subnet
id 1 and IPv4 address 10.0.0.42
2017-12-11 00:48:09.137 DEBUG [kea-dhcp4.hosts/1326] HOSTS_CFG_GET_ALL_ADDRESS4
get all hosts with reservations for IPv4 address 10.0.0.42
2017-12-11 00:48:09.137 DEBUG [kea-dhcp4.hosts/1326]
HOSTS_CFG_GET_ALL_ADDRESS4_COUNT using address 10.0.0.42, found 0 host(s)
2017-12-11 00:48:09.137 DEBUG [kea-dhcp4.hosts/1326]
HOSTS_CFG_GET_ONE_SUBNET_ID_ADDRESS4_NULL host not found using subnet id 1 and
address 10.0.0.42
2017-12-11 00:48:09.137 DEBUG [kea-dhcp4.dhcpsrv/1326]
DHCPSRV_MEMFILE_GET_ADDR4 obtaining IPv4 lease for address 10.0.0.42
2017-12-11 00:48:09.137 DEBUG [kea-dhcp4.alloc-engine/1326]
ALLOC_ENGINE_V4_REQUEST_ALLOC_REQUESTED [hwtype=1 08:00:27:bd:b3:a5], cid=[no
info], tid=0x5a660c0b: trying to allocate requested address 10.0.0.42
2017-12-11 00:48:09.137 DEBUG [kea-dhcp4.dhcpsrv/1326]
DHCPSRV_MEMFILE_GET_ADDR4 obtaining IPv4 lease for address 10.0.0.42
2017-12-11 00:48:09.137 DEBUG [kea-dhcp4.callouts/1326] HOOKS_CALLOUTS_BEGIN
begin all callouts for hook lease4_select
2017-12-11 00:48:09.138 DEBUG [kea-dhcp4.callouts/1326] HOOKS_CALLOUT_CALLED
hooks library with index 1 has called a callout on hook lease4_select that has
address 0x7f6298310bb6 (callout duration: 0.101 ms)
2017-12-11 00:48:09.138 DEBUG [kea-dhcp4.callouts/1326] HOOKS_CALLOUTS_COMPLETE
completed callouts for hook lease4_select (total callouts duration: 0.101 ms)
2017-12-11 00:48:09.138 DEBUG [kea-dhcp4.dhcpsrv/1326]
DHCPSRV_HOOK_LEASE4_SELECT_SKIP Lease4 creation was skipped, because of callout
skip flag.
2017-12-11 00:48:09.138 DEBUG [kea-dhcp4.bad-packets/1326]
DHCP4_PACKET_NAK_0004 [hwtype=1 08:00:27:bd:b3:a5], cid=[no info],
tid=0x5a660c0b: failed to grant a lease, client sent ciaddr 0.0.0.0,
requested-ip-address 10.0.0.42
2017-12-11 00:48:09.138 DEBUG [kea-dhcp4.callouts/1326] HOOKS_CALLOUTS_BEGIN
begin all callouts for hook pkt4_send
2017-12-11 00:48:09.138 DEBUG [kea-dhcp4.callouts/1326] HOOKS_CALLOUT_CALLED
hooks library with index 1 has called a callout on hook pkt4_send that has
address 0x7f6298310e02 (callout duration: 0.098 ms)
2017-12-11 00:48:09.138 DEBUG [kea-dhcp4.callouts/1326] HOOKS_CALLOUTS_COMPLETE
completed callouts for hook pkt4_send (total callouts duration: 0.098 ms)
2017-12-11 00:48:09.138 DEBUG [kea-dhcp4.options/1326] DHCP4_PACKET_PACK
[hwtype=1 08:00:27:bd:b3:a5], cid=[no info], tid=0x5a660c0b: preparing on-wire
format of the packet to be sent
2017-12-11 00:48:09.138 DEBUG [kea-dhcp4.packets/1326] DHCP4_PACKET_SEND
[hwtype=1 08:00:27:bd:b3:a5], cid=[no info], tid=0x5a660c0b: trying to send
packet DHCPACK (type 5) from 100.100.100.100:67 to 10.0.0.42:68 on interface
eth1
2017-12-11 00:48:09.139 DEBUG [kea-dhcp4.packets/1326] DHCP4_RESPONSE_DATA
[hwtype=1 08:00:27:bd:b3:a5], cid=[no info], tid=0x5a660c0b: responding with
packet DHCPACK (type 5), packet details: local_address=100.100.100.100:67,
remote_address=10.0.0.42:68, msg_type=DHCPACK (5), transid=0x5a660c0b,
options:
type=001, len=004: ff:ff:f0:00
type=003, len=004: 0a:00:00:01
type=006, len=008: c0:00:03:01:c0:00:03:02
type=015, len=014: 73:69:6d:70:6c:65:68:6f:6f:6b:2e:6f:72:67
type=051, len=004: 00:00:1c:20
type=053, len=001: 5 (uint8)
type=054, len=004: 100.100.100.100
type=058, len=004: 00:00:07:08
type=059, len=004: 00:00:0e:10
^C2017-12-11 00:48:10.679 DEBUG [kea-dhcp4.packets/1326]
DHCP4_BUFFER_WAIT_SIGNAL signal received while waiting for next packet, next
waiting signal is 2
2017-12-11 00:48:10.679 DEBUG [kea-dhcp4.dhcp4/1326] DHCP4_COMMAND_RECEIVED
received command shutdown, arguments: (none)
2017-12-11 00:48:10.680 DEBUG [kea-dhcp4.dhcp4/1326] DHCP4_SHUTDOWN_REQUEST
shutdown of server requested
2017-12-11 00:48:10.680 INFO [kea-dhcp4.dhcp4/1326] DHCP4_SHUTDOWN server
shutdown
2017-12-11 00:48:10.680 DEBUG [kea-dhcp4.dhcpsrv/1326]
DHCPSRV_TIMERMGR_UNREGISTER_ALL_TIMERS unregistering all timers
2017-12-11 00:48:10.681 DEBUG [kea-dhcp4.commands/1326] COMMAND_DEREGISTERED
Command build-report deregistered
2017-12-11 00:48:10.681 DEBUG [kea-dhcp4.commands/1326] COMMAND_DEREGISTERED
Command config-get deregistered
2017-12-11 00:48:10.681 DEBUG [kea-dhcp4.commands/1326] COMMAND_DEREGISTERED
Command config-reload deregistered
2017-12-11 00:48:10.681 DEBUG [kea-dhcp4.commands/1326] COMMAND_DEREGISTERED
Command config-test deregistered
2017-12-11 00:48:10.681 DEBUG [kea-dhcp4.commands/1326] COMMAND_DEREGISTERED
Command config-write deregistered
2017-12-11 00:48:10.682 DEBUG [kea-dhcp4.commands/1326] COMMAND_DEREGISTERED
Command leases-reclaim deregistered
2017-12-11 00:48:10.682 DEBUG [kea-dhcp4.commands/1326] COMMAND_DEREGISTERED
Command libreload deregistered
2017-12-11 00:48:10.682 DEBUG [kea-dhcp4.commands/1326] COMMAND_DEREGISTERED
Command config-set deregistered
2017-12-11 00:48:10.682 DEBUG [kea-dhcp4.commands/1326] COMMAND_DEREGISTERED
Command shutdown deregistered
2017-12-11 00:48:10.682 DEBUG [kea-dhcp4.commands/1326] COMMAND_DEREGISTERED
Command statistic-get deregistered
2017-12-11 00:48:10.683 DEBUG [kea-dhcp4.commands/1326] COMMAND_DEREGISTERED
Command statistic-get-all deregistered
2017-12-11 00:48:10.683 DEBUG [kea-dhcp4.commands/1326] COMMAND_DEREGISTERED
Command statistic-remove deregistered
2017-12-11 00:48:10.683 DEBUG [kea-dhcp4.commands/1326] COMMAND_DEREGISTERED
Command statistic-remove-all deregistered
2017-12-11 00:48:10.683 DEBUG [kea-dhcp4.commands/1326] COMMAND_DEREGISTERED
Command statistic-reset deregistered
2017-12-11 00:48:10.683 DEBUG [kea-dhcp4.commands/1326] COMMAND_DEREGISTERED
Command statistic-reset-all deregistered
2017-12-11 00:48:10.683 DEBUG [kea-dhcp4.commands/1326] COMMAND_DEREGISTERED
Command version-get deregistered
2017-12-11 00:48:10.697 DEBUG [kea-dhcp4.dhcpsrv/1326] DHCPSRV_CLOSE_DB closing
currently open memfile database
2017-12-11 00:48:10.697 DEBUG [kea-dhcp4.dhcpsrv/1326]
DHCPSRV_TIMERMGR_UNREGISTER_TIMER unregistering timer: memfile-lfc
2017-12-11 00:48:10.697 DEBUG [kea-dhcp4.dhcpsrv/1326]
DHCPSRV_MEMFILE_LFC_UNREGISTER_TIMER_FAILED failed to unregister timer
'memfile-lfc': unable to unregister non existing timer 'memfile-lfc'
2017-12-11 00:48:10.698 DEBUG [kea-dhcp4.hooks/1326] HOOKS_LIBRARY_UNLOADING
unloading library /opt/kea/hook/libkeapython.so
2017-12-11 00:48:10.699 INFO [kea-dhcp4.kea-python/1326] PYTHON_LOG unload was
not found
2017-12-11 00:48:10.699 DEBUG [kea-dhcp4.hooks/1326] HOOKS_UNLOAD_SUCCESS
'unload' function in hook library /opt/kea/hook/libkeapython.so returned success
2017-12-11 00:48:10.700 DEBUG [kea-dhcp4.callouts/1326]
HOOKS_ALL_CALLOUTS_DEREGISTERED hook library at index 1 removed all callouts on
hook lease4_select
2017-12-11 00:48:10.701 DEBUG [kea-dhcp4.hooks/1326] HOOKS_CALLOUTS_REMOVED
callouts removed from hook lease4_select for library
/opt/kea/hook/libkeapython.so
2017-12-11 00:48:10.701 DEBUG [kea-dhcp4.callouts/1326]
HOOKS_ALL_CALLOUTS_DEREGISTERED hook library at index 1 removed all callouts on
hook pkt4_send
2017-12-11 00:48:10.701 DEBUG [kea-dhcp4.hooks/1326] HOOKS_CALLOUTS_REMOVED
callouts removed from hook pkt4_send for library /opt/kea/hook/libkeapython.so
2017-12-11 00:48:10.701 INFO [kea-dhcp4.hooks/1326] HOOKS_LIBRARY_UNLOADED
hooks library /opt/kea/hook/libkeapython.so successfully unloaded
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
------------------------------
Message: 2
Date: Mon, 11 Dec 2017 10:50:20 +0800
From: Yahu Gao <[email protected]>
To: <[email protected]>
Subject: [kea-dev] [PATCH] [master] Fix: Release the reference of hook
library
Message-ID:
<[email protected]>
Content-Type: text/plain
Problem: Kea unload the hook library when handing the first incoming
message after reload by using command "keactrl reload -c configfile".
This cause hook library function cannot be called and message handling
stop.
Reason: Kea hold the hook library reference by using shared_ptr in
several place. Hook library is not correctly released when reload the
kea, But released when handing the first incoming message.
Fix: Release the reference of hook library in correct place when reload
the kea. After reload the hook library, shared_ptr hold the correct
reference to it.
Signed-off-by: Anders Wallin <[email protected]>
Signed-off-by: Yahu Gao <[email protected]>
---
src/lib/hooks/hooks_manager.cc | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/lib/hooks/hooks_manager.cc b/src/lib/hooks/hooks_manager.cc
index b4702ba..73ee637 100644
--- a/src/lib/hooks/hooks_manager.cc
+++ b/src/lib/hooks/hooks_manager.cc
@@ -12,6 +12,9 @@
#include <hooks/hooks_manager.h>
#include <hooks/server_hooks.h>
+#include <dhcp/pkt6.h>
+#include <dhcpsrv/callout_handle_store.h>
+
#include <boost/shared_ptr.hpp>
#include <string>
@@ -121,6 +124,10 @@ HooksManager::loadLibraries(const HookLibsCollection&
libraries) {
void
HooksManager::unloadLibrariesInternal() {
+ // Clean callout_handle_store for static CalloutHandlePtr.
+ // fix the Kea reload cause the hook library unload.
+ isc::dhcp::Pkt6Ptr pkt6ptr_empty;
+ isc::dhcp::getCalloutHandle(pkt6ptr_empty);
// The order of deletion does not matter here, as each library manager
// holds its own pointer to the callout manager. However, we may as
// well delete the library managers first: if there are no other references
--
1.8.3.1
------------------------------
Subject: Digest Footer
_______________________________________________
kea-dev mailing list
[email protected]
https://lists.isc.org/mailman/listinfo/kea-dev
------------------------------
End of kea-dev Digest, Vol 45, Issue 1
**************************************