Opened 2 years ago

Closed 2 years ago

#5366 closed defect (fixed)

override global options in shared networks

Reported by: wlodekwencel Owned by: marcin
Priority: high Milestone: Kea1.3-final
Component: dhcp6 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: 1
Total Hours: 7 Internal?: no

Description

I've started kea with one shared-network that contain 3 different subnets. I've configured preference option in global scope and in each subnet (with different values)

Part of the configuration:

....
       "option-data":[
        {
            "csv-format":true,
            "code":7,
            "data":"1",
            "name":"preference",
            "space":"dhcp6"
        }
        ],
        "lease-database":
        {
            "type":"memfile"
        }
        ,
        "shared-networks":[
        {
            "name":"name-abc",
            "relay":
            {
                "ip-address":"2001:db8::abcd"
            }
            ,
            "subnet6":[
            {
                "subnet":"2001:db8:a::/64",
                "option-data”:[
                {
                    "csv-format":true,
                    "code":7,
                    "data":"33",
                    "name":"preference",
                    "space":"dhcp6"
                }
                ],
                "pools":[
                {
                    "pool":"2001:db8:a::1-2001:db8:a::1"
                }
                ]
            }
            ,
            
            {
                "subnet":"2001:db8:b::/64",
                "option-data":[
                {
                    "csv-format":true,
                    "code":23,
                    "data":"2001:db8::1,2001:db8::2",
                    "name":"dns-servers",
                    "space":"dhcp6"
                }
                ,
                
                {
                    "csv-format":true,
                    "code":7,
                    "data":"44",
                    "name":"preference",
                    "space":"dhcp6"
                }
                ],
                "pools":[
                {
                    "pool":"2001:db8:b::1-2001:db8:b::1"
                }
                ]
            }
            ,
            
            {
                "subnet":"2001:db8:c::/64",
                "option-data":[
                {
                    "csv-format":true,
                    "code":7,
                    "data":"55",
                    "name":"preference",
                    "space":"dhcp6"
                }
                ],
                "pools":[
                {
                    "pool":"2001:db8:c::1-2001:db8:c::1"
                }
                ]
            }
            ]
        }
        ]
    }
    ....

To every assigned address from each subnet kea sends preference value taken from last subnet in the list (in this case it's always 55). When shared-network is available locally (configured with interface, not relay or interface-id) it's getting more interesting because Kea advertise option value in the same way (taking value from the last subnet in the list) BUT when Kea perform Request-Reply message it adds correct value.

Looks like options in subnets that are configured in shared-network are overwritten by the option from the subnet on the end of the list. Exception: locally accessible shared-network and only in Request-Reply exchange.

Subtickets

Change History (10)

comment:1 Changed 2 years ago by marcin

  • Milestone changed from Kea-proposed to Kea1.3-final

I am moving it to 1.3 final milestone on my discretion, because this is a potential bug in the 1.3 deliverable. So, no other choice but to deal with this for 1.3 final.

comment:2 Changed 2 years ago by marcin

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

comment:3 Changed 2 years ago by marcin

To slightly extend the ticket description. The client is requesting one address (IA_NA) and gets the address from the first subnet but options are assigned from the 3rd subnet.

comment:4 Changed 2 years ago by marcin

I am able to reproduce this issue.

comment:5 Changed 2 years ago by marcin

  • Add Hours to Ticket changed from 0 to 6
  • Owner changed from marcin to UnAssigned
  • Status changed from accepted to reviewing
  • Total Hours changed from 0 to 6

I did the following. I created a unit test that replicates pretty much the same what the system test in forge is doing. I ran this test against master branch. The test failed as described in this ticket. Then, I branched off the trac5364 and applied the same test there. The test passed.

In #5364 I fixed several things which I suspected would fix this problem and it did.

The branch trac5366 is branched off trac5364 and it only adds a unit test that confirms the problem is solved.

Proposed ChangeLog entry (assuming we need one?):

13XX.	[bug]		marcin
	Created unit test for the case when there are several IPv6 subnets
	within a shared network and each subnet specifies the same
	DHCP option with a different value. This test verifies the fix
	applied with ticket #5364 which address the problem of assigning
	options from invalid subnet.
	(Trac #5366, git cafe)

comment:6 Changed 2 years ago by wlodekwencel

My tests are now passing.

comment:7 Changed 2 years ago by fdupont

In src/bin/dhcp6/tests/shared_network_unittest.cc I suggest:

5000::8:0000 -> (((5000::8:0}}}

in src/bin/dhcp6/tests/shared_network_unittest.cc it should be fine to have a comment explaining what the 17 configs are for.

Same file:
/ This method retrieves lease statistics from the database and then compares it
->
/ This method retrieves lease statistics from the database and then compares them

I checked on my High Sierra macOS with OpenSSL backend and it worked at the second attempt.

Note there are many details I don't understand about shared network Kea implementation so I recommend a second eye.

comment:8 Changed 2 years ago by tomek

  • Owner changed from UnAssigned to tomek

comment:9 Changed 2 years ago by tomek

  • Add Hours to Ticket changed from 6 to 1
  • Owner changed from tomek to marcin
  • Total Hours changed from 6 to 7

This new unit-test looks good. The configuration used has some unnecessary elements and lacked description. I added both. Please pull and review.

If you're ok with those changes, it's ready for merge. (probably after #5364; make sure you bump the configuration versions up as needed).

comment:10 Changed 2 years ago by marcin

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

Merged with commit 112addd4619509c464dc051f4885e00dc1f69d26

Note: See TracTickets for help on using tickets.