Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 122521 - udhcpc-ifconfig always takes down network interface even when the new ip/netmask is same as the old.
Summary: udhcpc-ifconfig always takes down network interface even when the new ip/netm...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: x86 Linux
: High minor (vote)
Assignee: Roy Marples (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-11 19:34 UTC by Magnus
Modified: 2006-02-16 02:26 UTC (History)
0 users

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


Attachments
fixes udhcpc-ifconfig (udhcpc-ifconfig.patch,902 bytes, patch)
2006-02-12 12:16 UTC, Roy Marples (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Magnus 2006-02-11 19:34:41 UTC
Hello!
Found two stuff in /lib/rcscripts/net.modules.d/helpers.d/udhcpc-ifconfig, belonging to the package: sys-apps/baselayout-1.11.14-r3
Number one I'm sure is wrong, number two I'm not sure....here we go...


**1**
The code on line 40 sets the variable 'cur' to be 'ip broadcast' instead of what I believe should be 'ip netmask'. This causes 'cur' to always differ from 'ip subnet' on line 41, thus causing the code inside the 'if' statement to always be executed.
Me thinks that the first print on line 40 should be: "print $2,$4"

LINE 40: cur=$( ifconfig ${interface} | grep 'inet ' | awk -F: '{ print $2,$3 }' | awk '{ print $1,$3 }' )
LINE 41: if [[ ${cur} != "${ip} ${subnet}" || ${action} == deconfig ]]; then


**2**
Maybe line 71 should be "route del default" instead of "route del 0.0.0.0". If I run 'route del 0.0.0.0' on my computer I get an error and the route is still there.

> route del 0.0.0.0
SIOCDELRT: No such process

If I run 'route del default' the route dissapears like it should.

LINE 71: /sbin/route del 0.0.0.0 2>/dev/null || break

*****
> ls -l /etc/make.profile
lrwxrwxrwx  1 root root 48 Feb  5 02:17 /etc/make.profile -> ../usr/portage/profiles/default-linux/x86/2006.0

> route --version
net-tools 1.60
route 1.98 (2001-04-15)

> ifconfig --version
net-tools 1.60
ifconfig 1.42 (2001-04-13)

> awk --version
GNU Awk 3.1.4

> grep --version
grep (GNU grep) 2.5.1
Comment 1 Roy Marples (RETIRED) gentoo-dev 2006-02-12 12:16:33 UTC
Created attachment 79597 [details, diff]
fixes udhcpc-ifconfig

Your changes are valid, so here's a patch for you to test.
Comment 2 Magnus 2006-02-12 20:22:45 UTC
> Your changes are valid, so here's a patch for you to test.

I was looking more into the router configuration and there seems to be another issue. The current code deletes all default routers for all interfaces. Since it is possible to have a default route configured for each interface I propose that the code should instead only delete the default route for the interface it is configuring.
Following code is my proposal. I removed the innermost while true loop since it is not needed anymore, and I changed one comment.

if [[ ${dhcp} != *' nogateway '* ]]; then
    # Configure default route for the interface.
    for r in ${router}; do
	/sbin/route del default dev ${interface} 2>/dev/null

	# We can only have one default route!
	/sbin/route add default gw ${r} dev ${interface} && break
    done
fi
Comment 3 Roy Marples (RETIRED) gentoo-dev 2006-02-13 02:55:21 UTC
Sorry, not going todo that.

We have code to handle that in 1.12.0_pre15 already.
Comment 4 Magnus 2006-02-13 14:03:00 UTC
nice :)
ok..the patch applies fine, and my original problem with loosing my iptables state tables every half hour when dhcp kicks in is gone with the wind now. Thanks for your fast response. Gentoo rocks :) I'll read up on the FAQ so I don't violate the rules next time I send a bug report :).....only the 'cur' stuff was related to my problem, the 'del default' stuff I just found as a bonus while looking for the solution to the 'cur' bug. I'm unsure what to do now, if I should change the status of the bug or something, or leave it like it is, so I guess I will just leave it like it is.
Continue the good work of producing the best Linux distribution, the portage system is what makes the difference!
Comment 5 Magnus 2006-02-13 14:05:58 UTC
> ok..the patch applies fine, and my original problem with loosing my iptables
> state tables every half hour when dhcp kicks in is gone with the wind now.
Ooops. It should read iptables connection tracking states. Sorry for spamming the comment section :)

Comment 6 Roy Marples (RETIRED) gentoo-dev 2006-02-16 02:26:28 UTC
Fixed in baselayout-1.11.14-r5