Skip to content

Reply not sent to DHCP Relay when Broadcast flag set #35

Description

@galthaus

We use parts of this library with a custom handler implementation for:
https://github.com/digitalrebar/provision

We did this before some of your more recent changes to interface binding. We may re-evaluate that later to see if we can switch back out of the custom interface code we use.

Regardless, we encountered in the field an issue that appears in the current code base. A DHCP client sets the Broadcast flag bit in a request, but a DHCP relay is used to forward the packet to our server. In this case, the reply code will generate a broadcast message instead of sending back to the giaddr field as per the spec.

The issue is around line 70 in server.go. To address the issue, we do this:

                    port, _ := strconv.Atoi(portStr)
                    if req.GIAddr().Equal(net.IPv4zero) {
                            if net.ParseIP(ipStr).Equal(net.IPv4zero) || req.Broadcast() {
                                    addr = &net.UDPAddr{IP: net.IPv4bcast, Port: port}
                            }
                    } else {
                            addr = &net.UDPAddr{IP: req.GIAddr(), Port: port}
                    }

Hope this helps. Thanks for your work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions