[patch] [rfc] udhcpc eating too much cpu

Cristian Ionescu-Idbohrn cristian.ionescu-idbohrn at axis.com
Thu Jan 17 15:49:57 UTC 2008


On Thu, 17 Jan 2008, Stefan Rompf wrote:

> Am Mittwoch, 16. Januar 2008 23:28 schrieb Cristian Ionescu-Idbohrn:
>
> It's perfectly fine with me if you use this code in udhcpc, also
> with later versions of the GPL as your license allows.

Great.  Thanks.

> One minor nitpick:
>
> > +       if (setsockopt(fd, SOL_SOCKET, SO_ATTACH_FILTER, &filter_prog,
> > +                               sizeof(filter_prog)) < 0)
> > +               bb_perror_msg_and_die("setsockopt");
> > +       DEBUG("attached filter to raw socket fdr %d", fd);
>
> I remember that is has been possible to configure older kernels
> withouth BPF. 2.6.? now always includes BPF, but 2.4.32 still has
> the CONFIG_FILTER option. Depending on how much backward
> compatibility you want this should fail more gracefully and not
> terminate the client if errno is ENOPROTOOPT.

Good point.  Than something like this:

	if (setsockopt(fd, SOL_SOCKET, SO_ATTACH_FILTER, &filter_prog,
		       sizeof(filter_prog)) < 0) {
		if (errno != ENOPROTOOPT)
			bb_perror_msg_and_die("setsockopt");
		bb_perror_msg("setsockopt filter");
	} else
		DEBUG("attached filter to raw socket fdr %d", fd);

should take care of that, shouldn't it?

My turn now.  Nitpicks, that is ;)

dhcpclient-snap_20071104/sockets.c latest available release,
setsockopt is called like this:

  (void)setsockopt(sock, SOL_SOCKET, SO_ATTACH_FILTER, &filter, sizeof(filter));

No error checking at all.

> > In my big comment inside networking/udhcp/clientsocket.c I'm also
> > trying to pinpoint some ideas that I'm very fond of and Stefan
> > puts words on.  I think those ideas (if implemented in busybox)
> > would be a big lift for this project,
>
> Once you get used to that features, you can't imagine that you
> needed a manual ifdown/ifup sequence on network change before.

And not only ifupdown, but many more.

> Just note that the netlink notifications are 2.6 only stuff and can
> break the client on 2.4.

Right.


Cheers,

-- 
Cristian



More information about the busybox mailing list