Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
galthaus opened this issue Aug 17, 2017 · 1 comment
Open

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

galthaus opened this issue Aug 17, 2017 · 1 comment

Comments

@galthaus
Copy link

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.

@galthaus galthaus changed the title Reply not set to DHCP Relay Reply not sent to DHCP Relay when Broadcast flag set Aug 17, 2017
@krolaw
Copy link
Owner

krolaw commented Aug 18, 2017

Thanks galthaus, I never thought of that particular use case for this library. Please have a look at the giaddr branch and and tell me what you think of conn/giaddr.go (untested).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants