Skip to content

Commit

Permalink
dhcp client: raise DHCPOptionMissingError if subnet mask option is no…
Browse files Browse the repository at this point in the history
…t set
  • Loading branch information
BrianBaboch committed Jan 27, 2025
1 parent dc01939 commit abfc20a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pyroute2/dhcp/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import errno
from logging import getLogger

from pyroute2.dhcp.enums.dhcp import Option
from pyroute2.dhcp.exceptions import DHCPOptionMissingError
from pyroute2.dhcp.leases import Lease
from pyroute2.iproute.linux import AsyncIPRoute
from pyroute2.netlink.exceptions import NetlinkError
Expand All @@ -29,6 +31,8 @@ class ConfigureIP(Hook):
async def bound(self, lease: Lease):
LOG.info('Adding %s/%s to %s', lease.ip,
lease.subnet_mask, lease.interface)
if not lease.subnet_mask:
raise DHCPOptionMissingError(Option.SUBNET_MASK)
async with AsyncIPRoute() as ipr:
await ipr.addr(
"replace",
Expand Down

0 comments on commit abfc20a

Please sign in to comment.