OpenBSD Journal

n2k14 Hackathon Report: krw@ on dhcp and disk labels

Contributed by tbert on from the recording-your-next-album-on-a-new-label dept.

Kenneth Westerback writes in with his report from the n2k14 hackathon:
I came to n2k14 with two goals. The first was to fix a problem with writing disklabels on MBR partitioned disk drives with non-512-byte sectors. The second was to finish some dhclient work I started at t2k13 and some other long-standing nits in dhclient.
Due to an interesting flight scheduling issue I spent 12 hours in the Vancouver airport lounge. This allowed me to start the hackathon early and put together a series of dhclient diffs that consolidated a bunch of changes I had in a variety of trees. These diffs implemented the majority of the changes I wanted.

The first of these was to provide human readable syntax for both dhcpd and dhclient to describe dhcp option 121, a.k.a. classless static routes. The syntax for a route is '1.2.3.4/13 5.6.7.8', which says that the gateway 5.6.7.8 is the way to get to the subnet 1.2.3.4/13. Thus in dhclient.conf one can now say 'default classless-static-routes 0/0 5.6.7.9, 1.2.3.4/13 5.6.7.8;'. i.e. the default route is 5.6.7.9 and the gateway for 1.2.3.4/13 is 5.6.7.8. Similarly you can specify the value that dhcpd supplies to clients.

Note that classless-static-routes overrides the router option, and that a default route must always be specified! With this option you can easily take full control of the routing configuration of your box, overriding or supplementing the routing information supplied by the dhcp server.

The second change (or rather a number of related changes) was to clean up and fix the parsing of dhclient.conf and leases files. In particular the proper formatting of error messages so the "^" was more likely to correctly indicate the problem. I had encountered these problems in various guises so many times I finally had to fix them so I could move on to more interesting problems. :-)

The third change was to implement syntax to allow dhclient.conf to override the 'fixed-address', 'file-name', 'server-name' and 'next-server' information provided in an offered lease. dhclient.conf should now be able to modify any information provided in a lease. Which should be useful in testing values without having to change the server configuration. Along the way some issues with the leases written by the '-L' dhclient option were repaired.

With all these changes committed I moved on to the disklabel issue on '4K' disk drives. We were writing the disklabel at an address provided in 4K units but interpreted as a 512-byte address. e.g. when the disk had a single OpenBSD partition starting at sector 64 we wrote the disklabel at sector 8 rather than 64. Not a real problem since that was 'dead' space in most cases. But when the OpenBSD partition was not the first MBR partition we were writing the disklabel in the midst of other data! And vice versa. I fixed the location calculation and put in a temporary hack in that looked for a disklabel at the old, incorrect location when no label was found at the correct location. This hack means people using 4K drives should not 'lose' their disklabel. But these people should make sure to write a new disklabel on the disk 'soon' since the hack will be removed after 5.5 is released!

While at n2k14 blambert@ pointed out that MBR partitioned disks were also confusing disklabel by insisting on a particular concept of the OpenBSD area, no matter what you set those limits to be with disklabel's 'b' command. I fixed this so that changes made with 'b' are now correctly remembered and honoured when the disklabel is read from disk.

As a final filip, dlg@ tricked me into working on the scsi layer's concept of retries and timeout. This will be a post-5.5 change if it matures.

Thanks to Jim and the University of Otago for a fine hackroom and splendid accommodations. Thanks to The Good Oil Cafe for the fine coffee!

And thank you, Ken, for your work and writing about it!

(Comments are closed)


Credits

Copyright © - Daniel Hartmeier. All rights reserved. Articles and comments are copyright their respective authors, submission implies license to publish on this web site. Contents of the archive prior to as well as images and HTML templates were copied from the fabulous original deadly.org with Jose's and Jim's kind permission. This journal runs as CGI with httpd(8) on OpenBSD, the source code is BSD licensed. undeadly \Un*dead"ly\, a. Not subject to death; immortal. [Obs.]