Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 262097 - sys-apps/baselayout-1.x dhcpcd module passes incorrect option to dhcpcd for nodns when compat use flag is off
Summary: sys-apps/baselayout-1.x dhcpcd module passes incorrect option to dhcpcd for n...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
: 334783 (view as bug list)
Depends on:
Blocks: 312385 334341
  Show dependency tree
 
Reported: 2009-03-11 09:58 UTC by Michael Palimaka (kensington)
Modified: 2010-09-26 21:45 UTC (History)
15 users (show)

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


Attachments
Honour "nodns" only when compat is enabled and only for major version 4. (dhcpcd.sh_nodns.patch,1.30 KB, patch)
2010-08-19 13:08 UTC, Jeremy Murphy
Details | Diff
dhcpcd.sh patch created with upstream suggestions - for baselayout 1 users (dhcpcd_nodns_base_1.patch,1.56 KB, patch)
2010-08-28 20:13 UTC, Mike Pagano
Details | Diff
updated patch for dhcpcd.sh (dhcpcd_nodns_base_1.patch,1.58 KB, patch)
2010-08-29 11:47 UTC, Mike Pagano
Details | Diff
dhcpcd.sh patch with local definition of variable (dhcpcd_nodns_base_1.patch,1.68 KB, patch)
2010-08-29 15:32 UTC, Mike Pagano
Details | Diff
Another patch to fix the dhcp_ options translation to dhcpcd options... (dhcpcd_nodns_base_1.patch,1.93 KB, patch)
2010-08-30 20:28 UTC, Gil Kloepfer
Details | Diff
Combined patch for dhcpcd.sh (dhcpcd_backport.patch,1.97 KB, patch)
2010-09-04 16:36 UTC, Mike Pagano
Details | Diff
Updated patch with test results (dhcpcd_backport.patch,2.45 KB, patch)
2010-09-04 17:58 UTC, Mike Pagano
Details | Diff
Updated Mike's patch with some minor corrections (dhcpcd_backport_up1.patch,2.50 KB, patch)
2010-09-07 14:01 UTC, Gil Kloepfer
Details | Diff
dhcpcd_backport_up2.patch (dhcpcd_backport_up2.patch,2.65 KB, patch)
2010-09-18 08:49 UTC, SpanKY
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Palimaka (kensington) gentoo-dev 2009-03-11 09:58:37 UTC
When dhcpcd-4.0.7 is compiled with USE="-compat", and /etc/conf.d/net has dhcp_eth0="nodns", starting net.eth0 fails with the message "/sbin/dhcpcd: invalid option -- 'R'".

Reproducible: Always

Steps to Reproduce:
1. emerge USE="-compat" dhcpcd-4.0.7
2. add dhcp_eth0="nodns" to /etc/conf.d/net
3. start net.eth0

Actual Results:  
dhcpcd fails to run - "/sbin/dhcpcd: invalid option -- 'R'"

Expected Results:  
dhcpcd functions correctly and obtains a lease.

The problem seems to be in /lib/rcscripts/net/dhcpcd.sh on line 76: "[[ ${d} == *" nodns "* ]] && opts="${opts} -R".
-R doesn't appear to be a valid option with compatibility turned off. The correct option seems to be "-C resolv.conf".


Portage 2.1.6.7 (default/linux/x86/2008.0, gcc-4.1.2, glibc-2.8_p20080602-r1, 2.6.27-gentoo-r8 i686)
=================================================================
System uname: Linux-2.6.27-gentoo-r8-i686-06-17-with-glibc2.0
Timestamp of tree: Wed, 11 Mar 2009 06:15:01 +0000
ccache version 2.4 [disabled]
app-shells/bash:     3.2_p39
dev-java/java-config: 2.1.7
dev-lang/python:     2.5.2-r7
dev-util/ccache:     2.4-r7
sys-apps/baselayout: 1.12.11.1
sys-apps/sandbox:    1.2.18.1-r2
sys-devel/autoconf:  2.13, 2.63
sys-devel/automake:  1.5, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.2
sys-devel/binutils:  2.18-r3
sys-devel/gcc-config: 1.4.0-r4
sys-devel/libtool:   1.5.26
virtual/os-headers:  2.6.27-r2
ACCEPT_KEYWORDS="x86"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O2 -march=prescott -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/config"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/splash /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c /etc/udev/rules.d"
CXXFLAGS="-O2 -march=prescott -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="collision-protect distlocks fixpackages protect-owned sandbox sfperms strict unmerge-orphans userfetch userpriv usersandbox"
GENTOO_MIRRORS="ftp://mirror.internode.on.net/pub/gentoo/ ftp://ftp.swin.edu.au/gentoo/ ftp://mirror.aarnet.edu.au/pub/gentoo/ ftp://mirror.linux.org.au/pub/gentoo/ ftp://mirror.pacific.net.au/linux/Gentoo/ http://distfiles.gentoo.org/"
LANG="en_AU.UTF-8"
LDFLAGS="-Wl,-O1"
LINGUAS="en en_AU en_GB fr"
MAKEOPTS="-j5"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/portage/local/layman/jokey /usr/local/portage"
SYNC="rsync://rsync.au.gentoo.org/gentoo-portage"
USE="X a52 aac aalib acl acpi alsa amazon apache2 arts artswrappersuid bash-completion berkdb branding bzip2 cairo cddb cdinstall cdr chroot clamav cracklib crypt css ctype cups curl dbus djvu dri dvd dvdr encode exif fam fbcondecor ffmpeg firefox flac ftp gcj gd gdbm gecko geoip gif hal hardened iconv id3tag imagemagick ipv6 jabber jpeg kde kdeenablefinal kpathsea lame lcms libnotify live mad matroska mhash midi mikmod mjpeg mmx mng modplug mp3 mp4 mpeg mplayer msn musicbrainz mysql mysqli ncurses network nls nntp nptl nptlonly nsplugin offensive ogg opengl pam pcre pdf php png ppds prediction qt3 qt3support qt4 quicktime rdesktop readline rtsp samba schroedinger sdl sha512 smp sndfile spell sse sse2 ssl ssse3 svg symlink tcpd theora threads threadsafe tiff timidity truetype unicode userlocales vcd vdpau visualization vnc vorbis win32codecs x264 x86 xml xorg xscreensaver xulrunner xv xvid zeroconf zlib" ALSA_CARDS="intel8x0" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="alias authz_host autoindex cache deflate dir disk_cache env expires file_cache filter headers info log_config log_forensic logio mem_cache mime mime_magic negotiation proxy proxy_http rewrite setinvif speling status unique_id vhost_alias" ELIBC="glibc" INPUT_DEVICES="mouse keyboard" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en en_AU en_GB fr" USERLAND="GNU" VIDEO_CARDS="nvidia"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LC_ALL, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Rafał Mużyło 2009-03-11 14:35:47 UTC
No, the problem here is that 'nodns' with USE="-compat"
is an invalid option too.
Comment 2 Paul B. Henson 2009-08-05 04:26:15 UTC
I'm having an annoying issue where even though I have use compat and nodns in /etc/conf.d/net.eth0, occasionally when I boot dhcpcd overwrites my resolv.conf with a blank one:

# /etc/resolv.conf.head can replace this line
# /etc/resolv.conf.tail can replace this line

which basically breaks stuff. If I don't have nodns set, dhcpcd correctly updates resolv.conf. So at this point either I live with dhcp supplied dns, or manually fix random breakage. This is the only bug I found that seemed relevant, as perhaps if the initscripts were using the "current" method of telling dhcpcd not to overwrite resolv.conf instead of the "compatible" one, this wouldn't happen. The man page for dhcpcd doesn't even document the -R flag.

So, +1 for updating the initscripts. I actually tried -compat when I built (out of general principle) and added it back it when dhcpcd failed. For now, I guess I'll trying removing nodns and instead setting dhcpcd_eth0="-C resolv.conf" and seeing what happens.

Comment 3 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2009-09-05 01:20:02 UTC
Roy, can you provide input on this one? Maybe it isn't an issue with the current stable .13?
Comment 4 Roy Marples 2009-09-05 07:19:41 UTC
This is an issue with baselayout-1 really.
The nodns flag sends -R to dhcpcd, which dhcpcd-4.x only understands when compat is enabled and dhcpcd-5.x doesn't understand at all.

Someone needs to backport the dhcpcd OpenRC module to baselayout-1 for this.
Comment 5 Etaoin Shrdlu 2009-09-06 11:06:57 UTC
Btw, how does one get the same result as nodns with dhcpcd 4.x and 5.x with -compat? The documentation seems a bit terse on that. 
Thank you
Comment 6 Roy Marples 2009-09-06 11:22:49 UTC
In the case of -R, the new way is -C resolv.conf
Comment 7 William Hubbs gentoo-dev 2009-10-29 04:51:27 UTC
I am re-assigning this to base-system since this is a bug in
baselayout-1.x and not dhcpcd.
Comment 8 William Hubbs gentoo-dev 2010-08-03 21:19:52 UTC
Base-system,

I have a couple of questions about this bug:

- are you planning on backporting the dhcpcd module from openrc to fix this as suggested in comment #4?

- If not, is it safe to stabilize dhcpcd-5.x on a baselayout-1 system?

Thanks,

William
Comment 9 Jeremy Murphy 2010-08-19 07:55:45 UTC
Come on... can anybody out there answer William's questions?  I have a tangential question related to his first: how difficult is it to backport the dhcpcd module to fix this bug?  I would like to give it a go, but I'm not quite sure where to start.  If anyone can point me in the direction then maybe we can fix this bug and close it.
Comment 10 Jeremy Murphy 2010-08-19 13:08:45 UTC
Created attachment 243553 [details, diff]
Honour "nodns" only when compat is enabled and only for major version 4.

Please take a look at this proposed patch.  If you're really keen, please test it.  :)
Comment 11 Jiri Pittner 2010-08-20 14:27:11 UTC
After a kernel update to 2.6.35 the dpcpcd 4.0.15 hanged
at 'waiting for carrier', and after an update to  5.2.7
I also experienced the nodns -R problem. I have solved it
for myself just by replacing '-R' to '-C resolv.conf' 
in /lib/rcscripts/net/dhcpcd.sh
Comment 12 Jeremy Murphy 2010-08-26 09:10:09 UTC
(In reply to comment #11)
> After a kernel update to 2.6.35 the dpcpcd 4.0.15 hanged
> at 'waiting for carrier', and after an update to  5.2.7
> I also experienced the nodns -R problem. I have solved it
> for myself just by replacing '-R' to '-C resolv.conf' 
> in /lib/rcscripts/net/dhcpcd.sh
> 

Jiri, would you mind filing a bug report for that?

Baselayout team, have you had a chance to look at my proposed patch?  It would be great to knock this bug on the head.
Comment 13 Jeremy Murphy 2010-08-27 00:37:01 UTC
And now that dhcpcd-5.2.7 has gone stable, it's a little more urgent.
Comment 14 Mike Pagano gentoo-dev 2010-08-27 15:19:14 UTC
(In reply to comment #10)

Do you think it would be better to extract the main version from the binary?

local VERSION=`/sbin/dhcpcd --version | sed -n /'dhcpcd '/s'/.*dhcpcd \([0-9]\+\).*/\1/p'`



Comment 15 Dmitri Pogosian 2010-08-27 16:38:23 UTC
(In reply to comment #10)
> Created an attachment (id=243553) [details]
> Honour "nodns" only when compat is enabled and only for major version 4.
> 
> Please take a look at this proposed patch.  If you're really keen, please test
> it.  :)
> 

Do I understand correctly that there is a similar problem with '-N' (nontp) option ?
Comment 16 Jeroen Roovers (RETIRED) gentoo-dev 2010-08-27 17:08:19 UTC
*** Bug 334783 has been marked as a duplicate of this bug. ***
Comment 17 Mark Keisler 2010-08-27 17:39:30 UTC
That is correct Dmitri:

% grep -- -N /lib/rcscripts/net/dhcpcd.sh
        [[ ${d} == *" nontp "* ]] && opts="${opts} -N"


Did a little reading and this should now (with dhcpcd 5.x) be:
Code:

        [[ ${d} == *" nontp "* ]] && opts="${opts} --nohook ntp.conf"


There needs to either be a check in there for the dhcpcd version or some sort
of ebuild dependency set up to prevent the wrong option from being used. 
Comment 18 Roy Marples 2010-08-27 18:32:43 UTC
Has anyone actually bothered to look at the dhcpcd.sh module that ships with OpenRC? The whole problem is solved there.

Hint: just copy dhcpcd_start() in OpenRC from

# Get our options down
...
# Add our route metric if not given

and replace the code within the same markers in baselayout. Then just change ${IFVAR} to ${ifvar} and ${args} to ${opts}

Job done. Now someone write that patch and stop uselessly guessing and just making more work for yourselves and more email noises for me.

Thanks
Comment 19 Roy Marples 2010-08-27 18:36:09 UTC
(In reply to comment #14)
> Do you think it would be better to extract the main version from the binary?
> 
> local VERSION=`/sbin/dhcpcd --version | sed -n /'dhcpcd '/s'/.*dhcpcd
> \([0-9]\+\).*/\1/p'`

Yes, but don't bother with a needless sed call.

case "$(dhcpcd --version)" in
"dhcpcd "[123]*) new=false;;
*) new=true;;
esac

learn2shell
Comment 20 Jeremy Murphy 2010-08-28 02:12:50 UTC
OK, so can we just pull the script from OpenRC and put it in baselayout-1 unmodified?  If yes, then let's do it.  If no, then is it easier to a) modify the baselayout-1 script to make it compatible with dhcpcd-5, or b) modify the OpenRC script to make it compatible with baselayout-1?
Comment 21 Roy Marples 2010-08-28 03:31:06 UTC
(In reply to comment #20)
> OK, so can we just pull the script from OpenRC and put it in baselayout-1
> unmodified?  If yes, then let's do it.  If no, then is it easier to a) modify
> the baselayout-1 script to make it compatible with dhcpcd-5, or b) modify the
> OpenRC script to make it compatible with baselayout-1?

I'm assuming that you're either blind, ignorant or just too plain lazy to read what I said above. If this upsets you then it's good - maybe you'll learn to read and comprehend next time.
Comment 22 Jeremy Murphy 2010-08-28 10:45:17 UTC
Ignorant, Roy.  If you had my previous posts, you'd see that I know very little about baselayout or initscripts.  I'm trying to motivate and remind the people that know something.

Also, I think your rudeness is unproductive and unprofessional.
Comment 23 Roy Marples 2010-08-28 12:42:21 UTC
(In reply to comment #22)
> Ignorant, Roy.  If you had my previous posts, you'd see that I know very little
> about baselayout or initscripts.

Then try not to post technical recommendations. What I essentially described as only vaguely technical and anyone posting here should able to comprehend what I described and what you said as conflicting.

> I'm trying to motivate and remind the people
> that know something.

Great, but this is not the way to go about it.

> Also, I think your rudeness is unproductive and unprofessional.

I think likewise of your prior post.
Comment 24 Mike Pagano gentoo-dev 2010-08-28 20:13:45 UTC
Created attachment 245173 [details, diff]
dhcpcd.sh patch created with upstream suggestions - for baselayout 1 users

Can people please review and test this patch made against dhcpcd.sh for baselayout 1.12.13
Comment 25 Jeremy Murphy 2010-08-29 01:46:14 UTC
(In reply to comment #24)
> Created an attachment (id=245173) [details]
> dhcpcd.sh patch created with upstream suggestions - for baselayout 1 users
> 
> Can people please review and test this patch made against dhcpcd.sh for
> baselayout 1.12.13
> 

Hi Mike.  I think you forgot to initialize the 'new' variable to true.
Comment 26 Mike Pagano gentoo-dev 2010-08-29 11:47:55 UTC
Created attachment 245211 [details, diff]
updated patch for dhcpcd.sh

Thanks, Jeremy. Good catch. Attaching updated patch.
Comment 27 Roy Marples 2010-08-29 14:37:24 UTC
Looks good. You may want to mark the variable local though so it does not stamp on a possible variable outside of the scope of the function.
Comment 28 Mike Pagano gentoo-dev 2010-08-29 15:32:37 UTC
Created attachment 245234 [details, diff]
dhcpcd.sh patch with local definition of variable

Thanks. Added local declaration of variable
Comment 29 Mike Pagano gentoo-dev 2010-08-30 12:42:39 UTC
Jeremy M., can you confirm that the patches fixes the issue. I will ping Mike F once you let me know it's OK. (Or anyone can confirm).

Set up a VM this weekend for BL 1 testing, but finished it late last night and didn't get a chance to test. At work now for the next (too many hours).
Comment 30 Gil Kloepfer 2010-08-30 19:36:46 UTC
Mike P.:  I am in the process of building a new system, and noticed this bug as well, so I will go ahead and test out the patch as well and will let you know how it works for my system.

Is there any reason why you removed the dhcpcd_{interface}= options?  Removing this (right after "Get our options" in the original script) prevents anyone from specifying their own dhcpcd options if they want (the patch restricts this to only those that are part of the generic dhcp options).  For example, I don't send my ISP the real name of my host, but rather the hostname I want them to see, by using dhcp_eth1="-h foobar".  Maybe I'm missing something here...
Comment 31 Gil Kloepfer 2010-08-30 19:38:08 UTC
(In reply to comment #30)
> For example, I don't
> send my ISP the real name of my host, but rather the hostname I want them to
> see, by using dhcp_eth1="-h foobar".  Maybe I'm missing something here...

argh...  I meant to say:

dhcpcd_eth1="-h foobar"

I hate when that happens!!

Comment 32 Gil Kloepfer 2010-08-30 20:28:07 UTC
I actually was able to test this, and it didn't work well at all.  There were several things that got missed, the hostname thing was one, but all I got when I tried this was a "no such interface" error because something was wrong in one of the options.

I went back to the original script, and added the meat of the logic that Mike had in his patch (which was good), and I think this one will work for everyone as it should, preserving the dhcpcd_{interface}= behavior.

Please let me know if this works...  (will submit the patch momentarily)
Comment 33 Gil Kloepfer 2010-08-30 20:28:59 UTC
Created attachment 245401 [details, diff]
Another patch to fix the dhcp_ options translation to dhcpcd options...
Comment 34 Jeremy Murphy 2010-08-31 07:23:07 UTC
I'm having trouble replicating this bug in order to test the scripts.  Where exactly should this error message about the invalid -R option appear: at the console where I start the network script or in a log file?
Comment 35 Gil Kloepfer 2010-08-31 11:14:25 UTC
I actually don't see an error message from dhcpcd like some others apparently did.  What I see is that dhcpcd ignores the invalid options, and the desired behavior does not happen.

The best way to test the script is to set-up a /etc/conf.d/net with at least one of the dhcp_eth# options and use ps to view how dhcpcd is starting.  Here's a good example (pardon the ugly appearance):

modules_eth0=( "dhcpcd" )
config_eth0=( "dhcp" )
dhcpcd_eth0="-h foobar"
dhcp_eth0="release nontp nodns nonis"

Place something into /etc/resolv.conf and then do "/etc/init.d/net.eth0 start"

The output from ps for the newer dhcpcd should have options such as "-C resolv.conf" instead of a bunch of single-letter options with no args such as "-R -N -Y" (since these are no longer valid for dhcpcd).

You should also notice whether dhcpcd's run script is modifying /etc/resolv.conf when the "nodns" dhcp_{interface} option is set (it should not modify it).  I added the "-h {hostname}" manual dhcpcd_{interface} option as a test to make sure that the manual dhcpcd configuration options still work, and that the script's default action to provide the hostname could be overridden (remove that line to make sure that the script does, indeed, perform the default action as well).

Your best bet for testing is to make sure that each of the dhcp_{interface} generic options do what they say (the "nodns" one should provide the proper option to dhcpcd that stops the appropriate "run-hook" from running, and that the resolv.conf doesn't get changed).

This bug is actually that the rcscript/net/dhcpcd.sh script didn't continue to function properly when dhcpcd's options changed at some release of dhcpcd...  I didn't notice this earlier because my primary system has multiple interfaces that cause one interface's static config to supersede the actions caused by dhcpcd (which may be another issue entirely...).
Comment 36 Toralf Förster gentoo-dev 2010-08-31 11:50:03 UTC
(In reply to comment #35)I
> didn't notice this earlier because my primary system has multiple interfaces
> that cause one interface's static config to supersede the actions caused by
> dhcpcd (which may be another issue entirely...).
> 
Well, but please consider that a config like :

config_eth0=( "dhcp" "192.168.0.254/16" )
dhcp_eth0="nontp"
dhcpcd_eth0="-L -t 37 -h <hostname>"

is supported, which means "get a DHCP address if applicable, but nevertheless assign a static address to eth0 anyway".
Comment 37 Jeremy Murphy 2010-09-01 02:04:44 UTC
Hmmm, weird, I've tried dhcpcd 4 and 5 with nodns but can't actually replicate the bug.  :\  I'll keep trying but don't wait on me for testing the new script, sorry.
Comment 38 Gil Kloepfer 2010-09-01 03:32:02 UTC
Do you have the "compat" use flag for dhcpcd?  If so, that's probably why you can't replicate the problem.

Which begs the question, the other way to fix this may be to simply have baselayout require the "compat" use flag for dhcpcd (or enable compat on dhcpcd by default), but that seems like we're moving backward, not forward...

Comment 39 Mike Pagano gentoo-dev 2010-09-04 16:36:48 UTC
Created attachment 245967 [details, diff]
Combined patch for dhcpcd.sh

Ok, I had to recreate the patch since it did not apply for me. But with the latest patch, I was able to test the changes and the results are below. Thanks for the test cases provided.

Test Case 1

modules_eth0=( "dhcpcd" )
config_eth0=( "dhcp" )
dhcpcd_eth0="-h foobar"
dhcp_eth0="release nontp nodns nonis"

Non patched dhcpcd.sh

comanche ~ # /etc/init.d/net.eth0 start
 * Caching service dependencies ...
 *  Cannot add provide 'net', as a service with the same name exists!                                                        [ ok ]
 * Starting eth0
 *   Bringing up eth0
 *     dhcp
 *       Running dhcpcd ...
/sbin/dhcpcd: invalid option -- 'R'
usage: dhcpcd [-dgknpqwxyADEGHJKLOTV] [-c script] [-f file] [-e var=val]
              [-h hostname] [-i classID ] [-l leasetime] [-m metric] [-o option]
              [-r ipaddr] [-s ipaddr] [-t timeout] [-u userclass]
              [-F none|ptr|both] [-I clientID] [-C hookscript] [-Q option]
              [-X ipaddr] <interface> 
        
Patched dhcpcd
              
comanche net # /etc/init.d/net.eth0 start
 * Starting eth0
 *   Bringing up eth0
 *     dhcp
 *       Running dhcpcd ...
dhcpcd[13533]: version 5.2.7 starting
dhcpcd[13533]: eth0: waiting for carrier
dhcpcd[13533]: eth0: carrier acquired
dhcpcd[13533]: eth0: rebinding lease of 192.168.1.12
dhcpcd[13533]: eth0: acknowledged 192.168.1.12 from 192.168.1.1
dhcpcd[13533]: eth0: checking for 192.168.1.12
dhcpcd[13533]: eth0: leased 192.168.1.12 for 86400 seconds
dhcpcd[13533]: forked to background, child pid 13540                                                                         [ ok ]
 *       eth0 received address 192.168.1.12/24


Test case 2

config_eth0=( "dhcp" "192.168.1.254/16" )
dhcp_eth0="nontp"
dhcpcd_eth0="-L -t 37 -h foobar"
              

Non Patched dhcpcd.sh
              
comanche ~ # /etc/init.d/net.eth0 start
 * Caching service dependencies ...
 *  Cannot add provide 'net', as a service with the same name exists!                                                        [ ok ]
 * Starting eth0
 *   Bringing up eth0
 *     dhcp
 *       Running dhcpcd ...
/sbin/dhcpcd: invalid option -- 'N'
usage: dhcpcd [-dgknpqwxyADEGHJKLOTV] [-c script] [-f file] [-e var=val]
              [-h hostname] [-i classID ] [-l leasetime] [-m metric] [-o option]
              [-r ipaddr] [-s ipaddr] [-t timeout] [-u userclass]
              [-F none|ptr|both] [-I clientID] [-C hookscript] [-Q option]
              [-X ipaddr] <interface>                                                                                        [ !! ]
 *     192.168.1.254/16           
 
 
Patched dhcpcd.sh
 
 comanche net # /etc/init.d/net.eth0 start 
 * Starting eth0
 *   Bringing up eth0
 *     dhcp
 *       Running dhcpcd ...
dhcpcd[14559]: version 5.2.7 starting
dhcpcd[14559]: eth0: waiting for carrier
dhcpcd[14559]: eth0: carrier acquired
dhcpcd[14559]: eth0: broadcasting for a lease
dhcpcd[14559]: eth0: offered 192.168.1.12 from 192.168.1.1
dhcpcd[14559]: eth0: acknowledged 192.168.1.12 from 192.168.1.1
dhcpcd[14559]: eth0: checking for 192.168.1.12
hostnamedhcpcd[14559]: eth0: leased 192.168.1.12 for 86400 seconds
dhcpcd[14559]: forked to background, child pid 14599                                                                         [ ok ]
 *       eth0 received address 192.168.1.12/24
 *     192.168.1.254/16   
 
If no one has any reservations or corrections, I'm going to poke Mike F to release a new BL 1 with this
Comment 40 Gil Kloepfer 2010-09-04 16:56:35 UTC
backport patch looks good with a good catch on the eval...  but...  You didn't check the ps output to see that all the options in dhcpcd_eth0 were being passed to the dhcpcd program, and I think that the change you made from my patch (after "# Get our options" from dhcpcd_ to dhcp_ will prevent the passing of the "-h foobar" option to dhcpcd, in the test cases below.

In other words, the invalid option problem is corrected, but I believe there is a regression that will prevent dhcpcd_eth0="something" from working.
Comment 41 Mike Pagano gentoo-dev 2010-09-04 16:58:40 UTC
Let me check, any change from your patch was unintentional.
Comment 42 Gil Kloepfer 2010-09-04 17:14:25 UTC
Unfortunately, I don't have my test system available to try this at the moment...  Actually, I do believe (on second thought) though that the eval isn't going to work either.  Here's a test case, directly in the shell:

--  Your patch (changing the "# Get our options") --
$ dhcpcd_eth0="-h foobar"
$ dhcpcd="-y xxxxx"
$ ifvar="eth0"
$ 
$ 
$         eval opts=\$dhcp_${ifvar}
$         opts="${dhcpcd} ${!opts}"
$ 
$ echo $opts
-y xxxxx

-- My patch (which actually left the original code alone) --
$ dhcpcd_eth0="-h foobar"
$ dhcpcd="-y xxxxx"
$ ifvar="eth0"
$ 
$         opts="dhcpcd_${ifvar}"
$         opts="${dhcpcd} ${!opts}"
$ 
$ echo $opts
-y xxxxx -h foobar


The second version is what should be happening.

Personally, I don't like the way they did this originally, because it is kind of non-intuitive ... but I was trying to change as little of the original logic as possible.

Your case statement, though, was an excellent alternative to what was there before, and it works fantastic.
Comment 43 Mike Pagano gentoo-dev 2010-09-04 17:58:14 UTC
Created attachment 246017 [details, diff]
Updated patch with test results

Ok, here's the patch with some changes, let me know what I've missed.


Test case 1

modules_eth0=( "dhcpcd" )
config_eth0=( "dhcp" )
dhcpcd_eth0="-h foobar"
dhcp_eth0="release nontp nodns nonis"


non patched:
comanche net # /etc/init.d/net.eth0 start
 * Starting eth0
 *   Bringing up eth0
 *     dhcp
 *       Running dhcpcd ...
/sbin/dhcpcd: invalid option -- 'R'
usage: dhcpcd [-dgknpqwxyADEGHJKLOTV] [-c script] [-f file] [-e var=val]
              [-h hostname] [-i classID ] [-l leasetime] [-m metric] [-o option]
              [-r ipaddr] [-s ipaddr] [-t timeout] [-u userclass]
              [-F none|ptr|both] [-I clientID] [-C hookscript] [-Q option]
              [-X ipaddr] <interface>                                                                                        [ !! ]
comanche net # ps -ef | grep dhcpcd


Patched:

comanche net # /etc/init.d/net.eth0 start
 * Starting eth0
 *   Bringing up eth0
 *     dhcp
 *       Running dhcpcd ...
dhcpcd[6969]: version 5.2.7 starting
dhcpcd[6969]: eth0: waiting for carrier
dhcpcd[6969]: eth0: carrier acquired
dhcpcd[6969]: eth0: broadcasting for a lease
dhcpcd[6969]: eth0: offered 192.168.1.12 from 192.168.1.1
dhcpcd[6969]: eth0: acknowledged 192.168.1.12 from 192.168.1.1
dhcpcd[6969]: eth0: checking for 192.168.1.12
dhcpcd[6969]: eth0: leased 192.168.1.12 for 86400 seconds
dhcpcd[6969]: forked to background, child pid 6976                                                                           [ ok ]
 *       eth0 received address 192.168.1.12/24
 
comanche net # ps -ef | grep dhcpcd
root      6976     1  0 13:55 ?        00:00:00 /sbin/dhcpcd -h foobar -C ntp.conf -C resolv.conf -C yp.conf -h  eth0

Test case 2
config_eth0=( "dhcp" "192.168.1.254/16" )
dhcp_eth0="nontp"
dhcpcd_eth0="-L -t 37 -h foobar"


non patched

comanche net # /etc/init.d/net.eth0 start
 * Caching service dependencies ...
 *  Cannot add provide 'net', as a service with the same name exists!                                                        [ ok ]
 * Starting eth0
 *   Bringing up eth0
 *     dhcp
 *       Running dhcpcd ...
/sbin/dhcpcd: invalid option -- 'N'
usage: dhcpcd [-dgknpqwxyADEGHJKLOTV] [-c script] [-f file] [-e var=val]
              [-h hostname] [-i classID ] [-l leasetime] [-m metric] [-o option]
              [-r ipaddr] [-s ipaddr] [-t timeout] [-u userclass]
              [-F none|ptr|both] [-I clientID] [-C hookscript] [-Q option]
              [-X ipaddr] <interface>                                                                                        [ !! ]
 *     192.168.1.254/16
 
 Patched
 
comanche net # /etc/init.d/net.eth0 start
 * Starting eth0
 *   Bringing up eth0
 *     dhcp
 *       Running dhcpcd ...
dhcpcd[8129]: version 5.2.7 starting
dhcpcd[8129]: eth0: waiting for carrier
dhcpcd[8129]: eth0: carrier acquired
dhcpcd[8129]: eth0: rebinding lease of 192.168.1.12
dhcpcd[8129]: eth0: acknowledged 192.168.1.12 from 192.168.1.1
dhcpcd[8129]: eth0: checking for 192.168.1.12
dhcpcd[8129]: eth0: leased 192.168.1.12 for 86400 seconds
dhcpcd[8129]: forked to background, child pid 8173                                                                           [ ok ]
 *       eth0 received address 192.168.1.12/24
 *     192.168.1.254/16                                                                                                      [ ok ]
comanche net # ps -ef | grep dhcpcd

root      8173     1  0 13:56 ?        00:00:00 /sbin/dhcpcd -L -t 37 -h foobar -C ntp.conf eth0
Comment 44 Jeremy Murphy 2010-09-05 05:05:17 UTC
OK, I solved my testing problem, so now I've quickly (not extensively) tested the latest script and it appears fine.  Good job, Mike.
Comment 45 Gil Kloepfer 2010-09-07 14:01:16 UTC
Created attachment 246357 [details, diff]
Updated Mike's patch with some minor corrections

Sorry for the delay...  I was able to test the patch, and it worked in almost all cases, except for the case where dhcpcd and dhcpcd_eth0 were both defined.  The new patch did not have the same behavior as the original script:

This: (new code)
        eval args=\$dhcpcd_${IFVAR}
        [ -z "${args}" ] && args=${dhcpcd}

does not do the same thing as this: (old code)

        # Get our options
        opts="dhcpcd_${ifvar}"
        opts="${dhcpcd} ${!opts}"

The patch I'm including here is a correction to make the behavior the same as the original (and to be consistent with the dhclient.sh script as well), commented the two option expansions, fixed a formatting issue, and replaced IFVAR with ifvar (I'm not sure why the capitalized IFVAR was used, but I don't think that was right).

This patch works fine in all the test cases I could come up with (setting dhcpcd_eth0, dhcpcd, both, and having options in dhcp (including nosendhost) and it works well.

There shouldn't be any problem applying this patch, but if there is please let me know.  I don't know why there was a problem with the last one I did...
Comment 46 SpanKY gentoo-dev 2010-09-18 08:49:36 UTC
Created attachment 247756 [details, diff]
dhcpcd_backport_up2.patch

ive updated the patch a little (tweaked style and added missing local)

make sure i didnt screw anything up before i commit it
Comment 47 Mike Pagano gentoo-dev 2010-09-18 17:54:39 UTC
Thanks, Mike. My test cases work.

Test case 1

modules_eth0=( "dhcpcd" )
config_eth0=( "dhcp" )
dhcpcd_eth0="-h foobar"
dhcp_eth0="release nontp nodns nonis"

comanche conf.d # /etc/init.d/net.eth0 start
 * Starting eth0
 *   Bringing up eth0
 *     dhcp
 *       Running dhcpcd ...
dhcpcd[10094]: version 5.2.7 starting
dhcpcd[10094]: eth0: waiting for carrier
dhcpcd[10094]: eth0: carrier acquired
dhcpcd[10094]: eth0: broadcasting for a lease
dhcpcd[10094]: eth0: offered 192.168.1.9 from 192.168.1.1
dhcpcd[10094]: eth0: acknowledged 192.168.1.9 from 192.168.1.1
dhcpcd[10094]: eth0: checking for 192.168.1.9
dhcpcd[10094]: eth0: leased 192.168.1.9 for 86400 seconds
dhcpcd[10094]: forked to background, child pid 10103                                                    [ ok ]
 *       eth0 received address 192.168.1.9/2
 
comanche conf.d # ps -ef | grep dhcpcd
root     10103     1  0 13:43 ?        00:00:00 /sbin/dhcpcd -h foobar -C ntp.conf -C resolv.conf -C yp.conf -h  eth0

Test case 2

config_eth0=( "dhcp" "192.168.1.254/16" )
dhcp_eth0="nontp"
dhcpcd_eth0="-L -t 37 -h foobar"

comanche conf.d # /etc/init.d/net.eth0 start
 * Caching service dependencies ...
 *  Cannot add provide 'net', as a service with the same name exists!                                   [ ok ]
 * Starting eth0
 *   Bringing up eth0
 *     dhcp
 *       Running dhcpcd ...
dhcpcd[11314]: version 5.2.7 starting
dhcpcd[11314]: eth0: waiting for carrier
dhcpcd[11314]: eth0: carrier acquired
dhcpcd[11314]: eth0: broadcasting for a lease
dhcpcd[11314]: eth0: offered 192.168.1.9 from 192.168.1.1
dhcpcd[11314]: eth0: acknowledged 192.168.1.9 from 192.168.1.1
dhcpcd[11314]: eth0: checking for 192.168.1.9
dhcpcd[11314]: eth0: leased 192.168.1.9 for 86400 seconds
dhcpcd[11314]: forked to background, child pid 11354                                                    [ ok ]
 *       eth0 received address 192.168.1.9/24
 *     192.168.1.254/16                                                                                 [ ok ]
comanche conf.d # ps -ef | grep dhcpcd
root     11354     1  0 13:50 ?        00:00:00 /sbin/dhcpcd -L -t 37 -h foobar -C ntp.conf eth0


Comment 48 Gil Kloepfer 2010-09-24 03:56:21 UTC
I haven't had a chance to test it, but as far as I can tell the latest patch should work as it is the same as the one I did but with a few variables made local and some style changes.  I'm fairly confident we've fixed this problem, and a bit more.