Skip to content

Conversation

@cblackburn-igl
Copy link
Contributor

Change summary

NB: This is a replacement pull request for one which I had to close as I was unable to rebase the commits into a single commit, as is required by the coding standard of VyOS. I have linked the previous PR in the Related PR's section so the history can be seen.

This commit adds support in both the CLI and the underlying code for DHCP Option 82 to be used to filter/route DHCP address assignments.

The primary use case for this is to support enterprise switches which can "tag" DHCP requests with physical real world informaiton such as which switch first saw the request and which port it originated from (known in this context as remote-id and circuit-id). Once client-classes have been defined they can be assigned to subnets or ranges so that only certain addresses get assigned to specific requests.

There is also a corresponding documentation update which pairs with this code change.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes)
  • Migration from an old Vyatta component to vyos-1x, please link to related PR inside obsoleted component
  • Other (please describe):

Related Task(s)

https://vyos.dev/T3936

Related PR(s)

vyos/vyos-documentation#1666
#4654 <-- Old Pull request this replaces

How to test / Smoketest result

I have tested these changes by adding new smoketests into the pre existing smoketest file. These new tests specifically check the new functionality including verifying that the generated config files are as expected and that the CLI refuses to take an incorrect commit.

I have also done integration testing in our lab which is set up with a switch which injects DHCP Option 82 information into live DHCP requests and these are processed as expected by VyOS.

Checklist:

  • I have read the CONTRIBUTING document
  • I have linked this PR to one or more Phabricator Task(s)
  • I have run the components SMOKETESTS if applicable
  • My commit headlines contain a valid Task id
  • My change requires a change to the documentation
  • I have updated the documentation accordingly

@github-actions
Copy link

github-actions bot commented Aug 17, 2025

👍
No issues in PR Title / Commit Title

@github-actions
Copy link

Conflicts Found. This pull request has conflicts. Please resolve them before we can evaluate the pull request.

@cblackburn-igl
Copy link
Contributor Author

This is quite a significant conflict that I have to resolve that's going to require some merging commits. These will mean it won't be possible to rebase the commits down into a single commit, similar to the previous pull request that I had to abandon. Do I absolutely have to revert everything and redo it so it can be in one commit or is it acceptable to have a few commits in this case?

@cblackburn-igl
Copy link
Contributor Author

As I've not heard anything about this I'm going to assume that I can continue with multiple commits in the PR.

@cblackburn-igl cblackburn-igl force-pushed the T3936-DHCP-Option-82-Support branch from 326b5e7 to 133cb0c Compare August 28, 2025 14:49
@github-actions
Copy link

Conflicts have been resolved. A maintainer will review the pull request shortly.

Copy link
Member

@dmbaturin dmbaturin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good overall but I added a few suggestions that I think are worth discussing.

@sarthurdev
Copy link
Member

Thanks for the PR. Implementation looks really good, I'll aim to test it locally this week and approve if all checks out.

Only nitpick is option82 as CLI node doesn't feel right having digits in the node name, but not a blocker.

@sever-sever sever-sever requested a review from Copilot October 1, 2025 21:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for DHCP Option 82 (relay agent information) filtering in the VyOS DHCP server. This feature allows DHCP client classes to be defined based on Option 82 circuit-id and remote-id values, enabling address assignment filtering based on physical network information provided by enterprise switches.

  • Added client class configuration with Option 82 circuit-id and remote-id filtering
  • Added client class assignment to subnets and address ranges
  • Added validation for client class references and Option 82 hex format

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/conf_mode/service_dhcp-server.py Added validation for client class references and Option 82 hex format
smoketest/scripts/cli/test_service_dhcp-server.py Added comprehensive tests for client class functionality and validation
python/vyos/template.py Added Jinja2 filter for rendering client class JSON configuration
python/vyos/kea.py Added functions to parse client classes and build Option 82 test expressions
interface-definitions/include/dhcp/dhcp-server-common-config.xml.i Added CLI definitions for client classes and Option 82 configuration
data/templates/dhcp-server/kea-dhcp4.conf.j2 Added client class rendering to Kea DHCP configuration template

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@cblackburn-igl
Copy link
Contributor Author

sigh so, I have absolutely no idea how this PR has now managed to collect an extra 44 commits from seemingly unrelated pull requests.

If it's ok to accept this and everything will work out then please accept the PR. If not then I'll extract all the changes out into a new branch and resubmit the PR.

Git is both the best and the worst.

@sever-sever
Copy link
Member

I see 68 commits and most of them unexpected

@cblackburn-igl
Copy link
Contributor Author

well, in the spirit of this XKCD: https://xkcd.com/1597/ I think we're going to have to have a 3rd attempt at this pull request.

If any of the developers think that it's fine then please merge this one and I'll stop. Otherwise, I'll try and extract all of the changes and put them in a new branch and resubmit.

@dmbaturin
Copy link
Member

@cblackburn-igl No, I'd prefer to avoid merging it with unrelated commits. Please clean up the unrelared history,

Copy link
Contributor

@natali-rs1985 natali-rs1985 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good but needs a minor changes to stay consistent

Also the history is still not cleaned

</leafNode>
<leafNode name="remote-id">
<properties>
<help>Filters on the contents of the remote-id sub option.</help>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<help>Filters on the contents of the remote-id sub option.</help>
<help>Filters on the contents of the remote-id sub option</help>

The same as with circuit-id help string

Comment on lines +293 to +298
if 'client_class' not in dhcp:
raise ConfigError(f'Client class "{client_class}" set in subnet "{subnet}" but does not exist')

if client_class not in dhcp['client_class'].keys():
raise ConfigError(f'Client class "{client_class}" set in subnet "{subnet}" but does not exist')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if 'client_class' not in dhcp:
raise ConfigError(f'Client class "{client_class}" set in subnet "{subnet}" but does not exist')
if client_class not in dhcp['client_class'].keys():
raise ConfigError(f'Client class "{client_class}" set in subnet "{subnet}" but does not exist')
if client_class not in dhcp.get('client_class', {}):
raise ConfigError(f'Client class "{client_class}" set in subnet "{subnet}" but does not exist')

This part can by simplified

Comment on lines +311 to +316
if 'client_class' not in dhcp:
raise ConfigError(f'Client class "{client_class}" set in range "{range}" but does not exist')

if client_class not in dhcp['client_class'].keys():
raise ConfigError(f'Client class "{client_class}" set in range "{range}" but does not exist')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if 'client_class' not in dhcp:
raise ConfigError(f'Client class "{client_class}" set in range "{range}" but does not exist')
if client_class not in dhcp['client_class'].keys():
raise ConfigError(f'Client class "{client_class}" set in range "{range}" but does not exist')
if client_class not in dhcp.get('client_class', {}):
raise ConfigError(f'Client class "{client_class}" set in range "{range}" but does not exist')

The same is here

This commit adds support in both the CLI and the underlying code for
DHCP Option 82 to be used to filter/route DHCP address assignments.

The primary use case for this is to support enterprise switches which
can "tag" DHCP requests with physical real world informaiton such as
which switch first saw the request and which port it originated from
(known in this context as remote-id and circuit-id). Once
client-classes have been defined they can be assigned to subnets or
ranges so that only certain addresses get assigned to specific
requests.

There is also a corresponding documentation update which pairs with
this code change.

(cherry picked from commit 326b5e7)
@sarthurdev sarthurdev force-pushed the T3936-DHCP-Option-82-Support branch from 093340b to 2e86aea Compare October 25, 2025 22:31
@sarthurdev
Copy link
Member

sarthurdev commented Oct 25, 2025

Cleaned up commits and squashed

@github-actions
Copy link

CI integration 👍 passed!

Details

CI logs

  • CLI Smoketests (no interfaces) 👍 passed
  • CLI Smoketests VPP 👍 passed
  • CLI Smoketests (interfaces only) 👍 passed
  • Config tests 👍 passed
  • Config tests VPP 👍 passed
  • RAID1 tests 👍 passed
  • TPM tests 👍 passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

6 participants