Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 53201 - Patch: Modified init.d/net.eth0 for fast IP assignment via DHCP for non-authoritative servers
Summary: Patch: Modified init.d/net.eth0 for fast IP assignment via DHCP for non-autho...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-07 02:12 UTC by Tim Weber
Modified: 2004-06-30 04:54 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch for /etc/init.d/net.eth0 (net.eth0.patch,1.20 KB, patch)
2004-06-07 02:13 UTC, Tim Weber
Details | Diff
Patch for /etc/conf.d/net (new variable plus comments) (net.patch,409 bytes, patch)
2004-06-07 02:13 UTC, Tim Weber
Details | Diff
Patch for /etc/init.d/net.eth0 (new version) (net.eth0.patch,1.32 KB, patch)
2004-06-07 05:19 UTC, Tim Weber
Details | Diff
Patch for /etc/init.d/net (new version) (net.patch,412 bytes, patch)
2004-06-07 05:21 UTC, Tim Weber
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Weber 2004-06-07 02:12:07 UTC
This is a patch for /etc/init.d/net.eth0 and /etc/conf.d/net to introduce an option to delete dhcpcd's cache file.

I've had some problems with non-authoritative DHCP servers. If you're coming from a DHCP network and had an IP assigned and move to another network with a non-authoritative server and your old IP can't be assigned by the new server, it takes ages to get a new IP, because the server doesn't send DHCP NAK messages.

With this patch you can set for each network device (clearip_eth?="yes") if dhcpcd's cache file (which includes the old IP) should be deleted prior to bringing the device up. dhcpcd won't ask for a specific IP address then and the assignment should take not more than 5 seconds (as opposed to 2 minutes or not at all without it).

This is my first patch ever for an Open Source project and I'm not quite sure if I did everything right. Please correct me if there's something wrong or if you need additional information.

Reproducible: Always
Steps to Reproduce:
1. Have a non-authoritative DHCP server.
2. Have had an IP address assigned that you can't get from your new DHCP server.
3. Bring the interface up.
Actual Results:  
It took ages. ;) 

Expected Results:  
It should take not more than 5 seconds.
Comment 1 Tim Weber 2004-06-07 02:13:02 UTC
Created attachment 32840 [details, diff]
Patch for /etc/init.d/net.eth0
Comment 2 Tim Weber 2004-06-07 02:13:39 UTC
Created attachment 32841 [details, diff]
Patch for /etc/conf.d/net (new variable plus comments)
Comment 3 James Slater 2004-06-07 03:51:24 UTC
It looks like your second patch is reversed.

Also "requesting" rather than "demanding" might be better? :-)
Comment 4 Tim Weber 2004-06-07 05:19:58 UTC
Created attachment 32847 [details, diff]
Patch for /etc/init.d/net.eth0 (new version)

net.eth0 changed recently, updated the patch.
Comment 5 Tim Weber 2004-06-07 05:21:36 UTC
Created attachment 32848 [details, diff]
Patch for /etc/init.d/net (new version)

You were right, the patch was reversed. Also changed "demanding" to
"requesting".
Comment 6 Tim Weber 2004-06-07 05:22:53 UTC
Comment on attachment 32840 [details, diff]
Patch for /etc/init.d/net.eth0

Forgot to change this to obsolete... Ahhh, damn.
Comment 7 Aron Griffis (RETIRED) gentoo-dev 2004-06-26 15:19:35 UTC
Hi Tim,

Thanks a bunch for the suggestion and patch.  Recent versions of baselayout (>=1.9.0) include some functions that can be defined in /etc/conf.d/net for situations like this.  I've just committed some changes to cvs to include documentation in /etc/conf.d/net for the functions.  Here is an example that would solve the problem for you:

preup() {
	einfo "Clearing cached IP for ${1}"
	if [[ -f "/var/cache/dhcpcd-${1}.cache" ]]; then
		rm "/var/cache/dhcpcd-${1}.cache"
	fi
	return 0  # important
}

Hope that helps.  I don't think this should warrant another configuration variable specifically for this purpose, though.
Comment 8 Radek Podgorny 2004-06-29 16:05:38 UTC
Why not make this a default behaviour?
Comment 9 SpanKY gentoo-dev 2004-06-29 16:15:45 UTC
because it's non-standard ?
Comment 10 Tim Weber 2004-06-30 04:54:09 UTC
Exactly, it's nonstandard and keeping the IP is quite useful in some cases (e.g. if the DHCP doesn't have fixed IPs per MAC address you can keep the same IP for a very long time).

Thanks to Aron for the information about preup(). But although I think that this function is a very good idea, forcing hundreds (or even thousands, who knows) of users to write the same commands inside their rcscripts to get IP cache clearing is IMO not the right decision, since it is not user friendly at all.

I would do it just in the other direction: Make conf.d/net more powerful by including stuff like IP cache clearing and even WEP keys in there, but don't force users to write their stuff by themselves. That way, users with less knowledge of how to script stuff will have it easier to make their changes.

Additionally, this would be good for "power users" as well, since they can rely on the fact that the stuff written in the rc-scripts is secure and can be run as root without danger.

I don't know what Gentoo's policy is on this subject, therefore I'll leave this bug closed for now. But if we should decide to become more user friendly, there is a great chance for this patch to get applied. What do you think?