Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#3730 closed defect (fixed)

Fail to reconfigure Kea as a result of setting new packet filter when sockets still open

Reported by: marcin Owned by: marcin
Priority: very high Milestone: Kea0.9.1
Component: dhcp4 Version: git
Keywords: Cc:
CVSS Scoring: Parent Tickets:
Sensitive: no Defect Severity: N/A
Sub-Project: DHCP Feature Depending on Ticket:
Estimated Difficulty: 0 Add Hours to Ticket: 0
Total Hours: 0 Internal?: no

Description

Kea reconfiguration fails on selecting the call to setMatchingPacketFilter because sockets aren't closed, with the following error:

	2015-02-23 16:29:08.944 INFO  [kea-dhcp4.dhcp4/17947] DHCP4_DYNAMIC_RECONFIGURATION initiate server reconfiguration using file: /mnt/wifi/users/NCH/src-owa/src-kea-qualif/etc/kea1.conf, after receiving SIGHUP signal
	2015-02-23 16:29:08.945 INFO  [kea-dhcp4.dhcpsrv/17947] DHCPSRV_CFGMGR_USE_ADDRESS listening on address 10.163.216.230, on interface eth0.102
	2015-02-23 16:29:08.945 INFO  [kea-dhcp4.dhcpsrv/17947] DHCPSRV_CFGMGR_SOCKET_TYPE_SELECT using socket type udp
	2015-02-23 16:29:08.945 INFO  [kea-dhcp4.dhcpsrv/17947] DHCPSRV_MEMFILE_DB opening memory file lease database: lfc-interval=60 name=/var/opt/data/flat/mwpdhcp/ramdisk1/kea1-leases4.csv persist=true type=memfile universe=4
	2015-02-23 16:29:08.946 INFO  [kea-dhcp4.dhcpsrv/17947] DHCPSRV_MEMFILE_LEASE_FILE_LOAD loading leases from file /var/opt/data/flat/mwpdhcp/ramdisk1/kea1-leases4.csv.2
	2015-02-23 16:29:08.946 INFO  [kea-dhcp4.dhcpsrv/17947] DHCPSRV_MEMFILE_LEASE_FILE_LOAD loading leases from file /var/opt/data/flat/mwpdhcp/ramdisk1/kea1-leases4.csv
	2015-02-23 16:29:08.946 INFO  [kea-dhcp4.dhcpsrv/17947] DHCPSRV_MEMFILE_LFC_SETUP setting up the Lease File Cleanup interval to 60 sec
	2015-02-23 16:29:08.946 INFO  [kea-dhcp4.dhcp4/17947] DHCP4_CONFIG_NEW_SUBNET a new subnet has been added to configuration: 10.164.0.0/15 with params: t1=900, t2=1575, valid-lifetime=1800
	2015-02-23 16:29:08.946 INFO  [kea-dhcp4.dhcp4/17947] DHCP4_CONFIG_COMPLETE DHCPv4 server has completed configuration: added IPv4 subnets: 1; DDNS: disabled
	2015-02-23 16:29:08.946 ERROR [kea-dhcp4.dhcp4/17947] DHCP4_CONFIG_LOAD_FAIL configuration error using file: /mnt/wifi/users/NCH/src-owa/src-kea-qualif/etc/kea1.conf, reason: Error while processing command 'config-reload':it is not allowed to set new packet filter when there are open IPv4 sockets - need to close them first, params: '{ "hooks-libraries": [ "/mnt/wifi/users/NCH/src-owa/src-kea-qualif/hooks/libdhcp_nch_hook.so" ], "interfaces-config": { "dhcp-socket-type": "udp", "interfaces": [ "eth0.102/10.163.216.230" ] }, "lease-database": { "lfc-interval": 60, "name": "/var/opt/data/flat/mwpdhcp/ramdisk1/kea1-leases4.csv", "persist": true, "type": "memfile" }, "rebind-timer": 1575, "renew-timer": 900, "subnet4": [ { "id": 1001, "pools": [ { "pool": "10.164.0.2 - 10.165.255.254" } ], "relay": { "ip-address": "10.163.216.250" }, "subnet": "10.164.0.0/15" } ], "valid-lifetime": 1800 }'
	2015-02-23 16:29:08.946 ERROR [kea-dhcp4.dhcp4/17947] DHCP4_DYNAMIC_RECONFIGURATION_FAIL dynamic server reconfiguration failed with file: /mnt/wifi/users/NCH/src-owa/src-kea-qualif/etc/kea1.conf

The closeSockets must be called prior to calling setMatchingPacketFilter in the CfgIface class.

Subtickets

Change History (9)

comment:1 Changed 5 years ago by hschempf

  • Milestone changed from Kea-proposed to Kea0.9.1

comment:2 Changed 5 years ago by marcin

  • Owner set to marcin
  • Status changed from new to accepted

comment:3 Changed 5 years ago by marcin

  • Owner changed from marcin to UnAssigned
  • Status changed from accepted to reviewing

I moved the call to closeSockets to the beginning of this function. I am afraid that it is very hard to test this change because we don't open real sockets in the tests. We also don't set the packet filter (which was the source of the problem) in the test mode because we use the custom packet filter for the tests. I tested this change manually and it worked for me. If we ever have regression in this area it will cause the failure to reconfigure the server and will be caught instantly. Alternatively, we could have a system tests (forge?) to cover the reconfiguration scenario.

Proposed Changelog:

XXX.	[bug]		marcin
	Fixed the bug in the DHCPv4 server whereby the server
	reconfiguration (using the SIGHUP signal) failed because
	of sockets remaining open since the previous configuration.
	(Trac #3730, git abcd)

comment:4 Changed 5 years ago by stephen

  • Owner changed from UnAssigned to stephen

comment:5 Changed 5 years ago by stephen

  • Owner changed from stephen to marcin

Reviewed commit d1968dcc2a1e9081ceb44286f1b6231cb13ac95b

Looks OK and the ChangeLog looks OK as well. I do have one question though: why is the close operation not at the start of the openSockets() method? Excluding comments, the first lines of that method are:

    setState(family, !wildcard_used_, true);
    IfaceMgr& iface_mgr = IfaceMgr::instance();
    closeSockets();
    iface_mgr.clearUnicasts();
  • Does setState() require sockets to be open?
  • If nothing else, there appears to be no reason why the call to closeSockets() should be placed between the definition of iface_mgr and its first use.

comment:6 Changed 5 years ago by marcin

  • Owner changed from marcin to stephen

I moved the call to closeSockets to the beginning of the openSockets method. It makes sense.

comment:7 Changed 5 years ago by stephen

  • Owner changed from stephen to marcin

Reviewed commit 4c37bea6b8432253adfae6baf891ab08e0d62475

All OK, please merge.

comment:8 Changed 5 years ago by marcin

  • Resolution set to fixed
  • Status changed from reviewing to closed

Merged with commit 3ceb0cd97cf5e44e8fc151d0a38db553530dd3ed

comment:9 Changed 5 years ago by nicolas.chaigneau

I tested today with master from GitHub, I confirm this is fixed.

Note: See TracTickets for help on using tickets.