NetworkConfiguration / dhcpcd

DHCP / IPv4LL / IPv6RA / DHCPv6 client.
https://roy.marples.name/projects/dhcpcd
BSD 2-Clause "Simplified" License
345 stars 111 forks source link

Using 3RDPARTY for QMI interfaces #129

Closed mtremer closed 2 years ago

mtremer commented 2 years ago

I am using dhcpcd in IPFire, which I would like to extend by supporting QMI interfaces (a new interface to talk to 4G/5G/... modems).

The process is sadly quite complicated, but it seems to be consensus to use a DHCP client when there is no actual DHCP to talk.

To make this short, I will initialise the modem with any provider specific settings and then configure it into "Raw IP" mode after which I have a Point-to-Point interface. Starting dhcpcd on this is doing nothing at all at first. I have then extended my hook scripts to use the 3RDPARTY reason to read the IP configuration that the modem would have received from the provider and then configure it to that interface using "ip addr" and "ip route".

Then, dhcpcd will consider the interface to be statically configured and call scripts accordingly.

However, there are some problems with this process. Documentation says that a default route to the PtP interface will be added. I do not see this at all and could not find where in the code that is supposed to happen.

dhcpcd exists occasionally because something has "timed out". That happens after the IP address was successfully configured and I cannot see why there would be a reason to do so. Reading the code, I considered the problem to be link detection on the PtP interface, but using "--nolink" did not have any effect.

Another slight problem is also that I cannot inform dhcpcd about a few things it normally is aware of. That is for example the default gateway, any DNS servers and the MTU. I can handle those myself, but it is a slight problem that the hook scripts won't be called again with "3RDPARTY", but only for "STATIC".

I am now just wondering whether 3RDPARTY is the way to go here. I assume the idea is that dhcpcd can detect when the interface lost link to the provider and then restart the whole initialisation with a potentially changed IP address. However, I would not expect the device driver to handle this.

I am currently on dhcpcd 9.4.1.

Is there any known implementation of this where this works well? Did I misinterpret the documentation about the default route?

rsmarples commented 2 years ago

See #75 for some more QMI details.

My understanding is that in Raw IP mode there is a DHCP server at the other end to talk to which supplies things like IP address, default route and DNS. So you should be seeing an Ethernet interface and get the BOUND/REBIND/RENEW etc messages like DHCP on any other interface.

mtremer commented 2 years ago

Hey Roy,

thanks for your swift reply.

An emulated DHCP would be absolutely perfect for me. Sadly, I didn't get that to work when I just launched dhcpcd on the interface because it did not send anything - I would have expected some request.

Are there any more configuration options that are required?

rsmarples commented 2 years ago

I don't know sorry, I don't have any QMI devices to test nor help with.

mtremer commented 2 years ago

No worries. Thanks for the information so far. I will do some more research and come back...

mtremer commented 2 years ago

You lead me to the right solution. In dhcpcd.c, STATIC mode is being enabled when the interface is either a loopback interface or PtP:

https://github.com/NetworkConfiguration/dhcpcd/blob/master/src/dhcpcd.c#L447

Passing --dhcp on the command line makes dhcpcd ask for an IP address and then things are working as usual.

Thanks for the lead! Closed.