structure padding in C

Whilst developing Privilege Separation in dhcpcd, I had to come up with an IPC design for it. Of course, that involves creating structures. So far, my structures in dhcpcd are long lived- or rather the scope is design to live outside of where it was created. As such they are created on the heap and are at the mercy of malloc. Generally I use calloc so that the whole area is inited to zero as uninitialised memory is bad.
Read full post

open_memstream

open_memstream is one of the more important functions added to POSIX libc of late. It’s so important because it makes the generation of strings really easy- you no longer need to care about allocating the right amount of memory as the library will do it for you. Now, there’s many functions that already help with this, such as asprintf but that’s not standard and if you want to create many strings in one area you still need to care about the size of the area.
Read full post

Red-Black Tree

Pretty much every piece of software I’ve seen uses a list of objects. When you need to easily grow and shrink this list easily you then need something like a Linked List. dhcpcd has used very popular and widely available BSD based queue(3), specifically a tailq. The main advantages of this type of list are: Very low extra memory needed for it’s implementation Fast at insertion and removal operation- both are O(1) However, it’s just a list.
Read full post

Right after all these years

So one of the main features of dhcpcd was the ability to add and remove addresses and subnets in accordance with interface preference and state. This worked very well in Linux, both for IPv4 and IPv6. When I discovered FreeBSD and then NetBSD making dhcpcd work with the same features provided troublesome. For the IPv4 case, we needed to patch the kernel so that IFA_ROUTE remained sane. For the IPv6 case it was a lot more complicated as parts of the IPv6 stack rely on the kernel processing Router Advertisements instead of a 3rd party tool.
Read full post

dhcpcd gains DHCPv6 INFORM support and other things

It’s been an eventful two years of not blogging. Mainly as I got heavily involved in playing World of Warcrat, Star Wars: The Old Republic and now Guild Wars 2 and this is a technical blog not a gaming one. Anyhoo, since GW2 is a lot more casual than the others the idea is that I have more time for working on open source stuff, like say dhcpcd. Well, I finally found some time over the past few months and put DHCPv6 INFORM support into dhcpcd.
Read full post