Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#3952 closed defect (complete)

Kea cant unload hook during reconfigure process

Reported by: wlodekwencel Owned by: stephen
Priority: medium Milestone: Kea1.0-beta
Component: hooks 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 is not able to unload hook during reconfigure process it needs to be stopped and started with new configuration file.

Test scenario:

  1. start kea with config:
    {
        "Dhcp6":
        {
            "renew-timer":1000,
            "rebind-timer":2000,
            "preferred-lifetime":3000,
            "valid-lifetime":4000,
            "interfaces-config":
            {
                "interfaces":["eth1"]
            }
            ,
            "subnet6":[
            {
                "subnet":"3000::/64",
                "interface":"eth1",
                "pools":[
                {
                    "pool":"3000::5-3000::5"
                }
                ]
            }
            ,
            
            {
                "subnet":"1000::/64",
                "interface":"eth1",
                "pools":[
                {
                    "pool":"1000::5-1000::5"
                }
                ]
            }
            ],
            "hooks-libraries":["/usr/local/lib/libdhcp_user_chk.so"],
            "lease-database":
            {
                "type":"memfile"
            }
            
        }
        ,
        "Logging":
        {
            "loggers":[
            {
                "name":"kea-dhcp6",
                "output_options":[
                {
                    "output":"/usr/local/var/kea/kea.log",
                    "destination":"file"
                }
                ],
                "debuglevel":99,
                "severity":"DEBUG"
            }
            ]
        }
        
    }
    
  2. Performed message exchange on which result hook library affect.
  3. Reconfigure server with config: (hook part is removed)
    {
        "Dhcp6":
        {
            "renew-timer":1000,
            "rebind-timer":2000,
            "preferred-lifetime":3000,
            "valid-lifetime":4000,
            "interfaces-config":
            {
                "interfaces":["eth1"]
            }
            ,
            "subnet6":[
            {
                "subnet":"3000::/64",
                "interface":"eth1",
                "pools":[
                {
                    "pool":"3000::5-3000::5"
                }
                ]
            }
            ,
            
            {
                "subnet":"1000::/64",
                "interface":"eth1",
                "pools":[
                {
                    "pool":"1000::5-1000::5"
                }
                ]
            }
            ],
            "lease-database":
            {
                "type":"memfile"
            }
            
        }
        ,
        "Logging":
        {
            "loggers":[
            {
                "name":"kea-dhcp6",
                "output_options":[
                {
                    "output":"/usr/local/var/kea/kea.log",
                    "destination":"file"
                }
                ],
                "debuglevel":99,
                "severity":"DEBUG"
            }
            ]
        }
        
    }
    
  4. Perform the same message exchange as in step no. 2, we should get different result but not. Kea is not unloading hook library. In log file we see message:
    [kea-dhcp6.callouts/3478] HOOKS_CALLOUTS_BEGIN begin all callouts for hook pkt6_receive
    

after server reconfiguration.

Configuration files and log file attached

Subtickets

Attachments (3)

configuration_file (1.1 KB) - added by wlodekwencel 5 years ago.
configuration_file_after_reconfiguration (1.1 KB) - added by wlodekwencel 5 years ago.
kea.log (24.1 KB) - added by wlodekwencel 5 years ago.

Download all attachments as: .zip

Change History (13)

Changed 5 years ago by wlodekwencel

Changed 5 years ago by wlodekwencel

Changed 5 years ago by wlodekwencel

comment:1 Changed 5 years ago by stephen

  • Owner set to stephen
  • Status changed from new to assigned

comment:2 Changed 5 years ago by stephen

The problem appears to be due to "hooks-libraries" being absent in the second configuration.

The processing of "hooks-libraries" has a persistent change of state to Kea, i.e. that the parser causes the dynamic libraries to be loaded and unloaded. If "hooks-libraries" is removed from the configuration, although no hooks libraries are now specified the parser is not called, and so the currently-loaded libraries are not unloaded.

In the longer term, we need to address that. In the short-term, users can specify an empty array (i.e. "hooks-libraries": []) to cause loaded libraries to be removed.

comment:3 Changed 5 years ago by tmark

May be the same issue as 3238.

comment:4 Changed 5 years ago by hschempf

  • Milestone changed from Kea-proposed to Kea1.0

per team meeting on Aug 5, move to 1.0 Med

comment:5 Changed 5 years ago by stephen

  • Owner changed from stephen to UnAssigned
  • Status changed from assigned to reviewing

May be the same issue as 3238.

It isn't - that concerns the "libreload" command, this is about the lack of a hooks-libraries element during a reconfiguration.

The action solution is outside the scope of this ticket - I have created ticket #3998 for it.

During my investigation of the problem, I rewrote and extended the unit tests for the hooks-libraries elements. This code is now available for review.

No ChangeLog entry is planned, as the extension of tests adds no functionality and is not user-visible.

comment:6 Changed 5 years ago by sar

  • Owner changed from UnAssigned to stephen

In invalidHooksLibraries and reconfigureInvalidHooksLibraries I think it would be useful to check that the parser recorded what we expect. I assume this would be no change of state and no libraries so that the code from noHooksLibraries could be cut and pasted.

Other than that it looks fine.

comment:7 Changed 5 years ago by stephen

  • Owner changed from stephen to sar

In invalidHooksLibraries and reconfigureInvalidHooksLibraries I think it would be useful to check that the parser recorded what we expect. I assume this would be no change of state and no libraries so that the code from noHooksLibraries could be cut and pasted.

I've done this.

I've also added tests to make sure that the library names were correctly propagated to the HooksManager where a (re)configuration was valid and were not propagated when it wasn't. I've also changed some EXPECT_EQ checks to ASSERT_EQ where failure of the check might result in a subsequent statement accessing an invalid vector element.

comment:8 Changed 5 years ago by sar

  • Owner changed from sar to stephen

commit # b2f1256ed4a2d87156ec659067f6b54d6ad91739

the changes look fine, it's ready to be merged.

comment:9 Changed 5 years ago by stephen

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

Merged in commit 4c736f8abfcb411ccfabc1d95514890e0046a9fa

comment:10 Changed 4 years ago by tomek

  • Milestone changed from Kea1.0 to Kea1.0-beta

Milestone renamed

Note: See TracTickets for help on using tickets.