-
Notifications
You must be signed in to change notification settings - Fork 404
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
DHCPv4 client #186
DHCPv4 client #186
Conversation
☔ The latest upstream changes (presumably 6c36376) made this pull request unmergeable. Please resolve the merge conflicts. |
I'm using this branch (rebased on master, which was mostly painless), and it works fine for me. The only thing I changed was to increase the discover timeout since my DHCP server was too slow in sending replies, and the sequence number of the reply never matched the last request. |
I'm sorry for the delay in review. Can you please extract the changes to |
Would this PR be a suitable starting point for implementing PXE for no_std environments? If so, do we have a estimate of when it may land? |
☔ The latest upstream changes (presumably 1fbcfb0) made this pull request unmergeable. Please resolve the merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Response inline, TLDR, as implemented other uses of DHCP are impossible.
src/dhcp/clientv4.rs
Outdated
|
||
/// Process incoming packets on the contained RawSocket, and send | ||
/// DHCP requests when timeouts are ready. | ||
pub fn poll<DeviceT: for<'d> Device<'d>>(&mut self, iface: &mut Interface<DeviceT>, sockets: &mut SocketSet, now: Instant) -> Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not returning anything here means that this code can't be used for other types of host configuration (notably: PXE, for network booting). DHCP is designed to do more than just networking parameters. Is there some reason not to return some representation of the response packet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have given it a try to return the DhcpRepr<'a>
but that is really cumbersome as it is bound to the lifetime of the packet received by raw_socket.recv()
in this function. Check my branch dhcp-return
if you would like to work on that.
Proposals are welcome. This is just a as-simple-as-possible implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Step one I'll get a proof of concept working locally (otherwise my proposal is likely to miss some important details). I'll be back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any news?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I got put onto a different thing... :-/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you say here that there is genuine commercial interest in smoltcp and embedded Rust?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why wouldn't there be?
5b82cc8
to
cd9773d
Compare
☔ The latest upstream changes (presumably 58a5473) made this pull request unmergeable. Please resolve the merge conflicts. |
Rebased this one. |
@whitequark Is there anything we (I) can do to move this forward? |
@whitequark what's the status of this PR? |
@astro I just tried this PR and it works great overall! Thanks for your work! There seems to be an issue with the renew code. It throws a Backtrace
Seems like the renew packet fails the |
I wonder if we should temporarily fork smoltcp… |
I'll take a look at this soon. |
Rebased and added logging.
Fixed this is in bc498fa and subsequently corrected some fields in the Renew packets. |
As far as I understand there are outstanding issues, so I'm not merging this yet. |
@whitequark It's unclear whether there's a problem or not, it sounds as if @phil-opp might be using it wrong. Merging "some" version would allow more people to use it and test. I'd never assume a new implementation of a messy protocol like DHCP is going to be perfect from day one but if it is not landed at some point it'll never have a chance to become perfect. |
OK, so at least this'll need to be rebased. |
I've been experimenting with this and everything but assigning the new IP address seems to work. Even not using the DHCPv4 client I am unable to change the IP address after building an EthernetInterface. We might indeed be using the API wrong, so please don't block this on us if it works for you, I'll figure it out aftewards. |
Rebased! Note that #276 added more dst_addr checks to |
☔ The latest upstream changes (presumably 5334b93) made this pull request unmergeable. Please resolve the merge conflicts. |
Rebased again.
To explain this again: We cannot filter on bound IP addresses as the DHCP responses are targeted at IP addresses that are yet to be bound. Using DHCP would depend on always running in any_ip mode. This is a consequence of moving from RawSocket to UdpSocket, as was desired in code review. Removal of the filtering code also means we would depend on running with a unique mac addr on a switched ethernet link. I suggest that we revert back to using a RawSocket for the DhcpClient, like it is being done in other implementations on other stacks. That way we can keep dst address filtering. What do you think? |
I think this is unfortunate but probably a reasonable way forward. Sorry for making you do the work twice. |
f64eb47
to
2f7efb7
Compare
Switched back to raw sockets, rebased, and squashed. Please review my changes to |
src/dhcp/clientv4.rs
Outdated
} | ||
|
||
fn egress<DeviceT: for<'d> Device<'d>>(&mut self, iface: &mut Interface<DeviceT>, raw_socket: &mut RawSocket, checksum_caps: &ChecksumCapabilities, now: Instant) -> Result<Option<Config>> { | ||
println!("DHCP egress"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you remove these debugging statements? They are hard to use on no_std
;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooops, thanks for the find!
Nice talk on saturday, btw.
☔ The latest upstream changes (presumably e7e267f) made this pull request unmergeable. Please resolve the merge conflicts. |
I think this is basically okay, and there is no reason to have it drag on any longer even if it's imperfect in minor ways. I apologize that this took so long in the first place. @m-labs-homu r+ |
📌 Commit 14695c1 has been approved by |
☀️ Test successful - status-travis |
Wow, after 13 months!
I agree. It's meant to be a basic implementation to get DHCP capabilities started. I don't believe in code ownership, so anyone is invited to overhaul this code. Mention @astro in the issues/PRs so that I know where I can help. |
Hi
This is an attempt at creating a DHCP client for IPv4. Please give feedback.
Cc: @phil-opp, this PR is uses the work merged in #75.
I've taken a completely different approach compared to #63. UDP sockets don't allow us to send and receive on unspecified/broadcast IPv4 addresses. Therefore IPv4/UDP is parsed/serialized on top of a
RawSocket
.There are still two problems withRawSocketBuffer
:How do I let the user provide storage? I have tried but failed to accept that as parameters inI've found the proper lifetime relation by now.Client::new()
.TheSee RingBuffer contiguous memory optimization #187RawSocket
is getting stuck withError::Exhausted
whencontig_window
is too small for the DHCP egress packet. Somehow it appears to behave like sent packets don't get dequeued from thetx_buffer
. Is that known? What is my code doing wrong regarding RawSocket?