GNOME Bugzilla – Bug 603098
Support for networks where netmask is not provided by DHCP (dhclient), but not a class C
Last modified: 2010-03-02 01:49:22 UTC
Initially reported in Launchpad: https://bugs.edge.launchpad.net/ubuntu/+source/network-manager/+bug/250654 NetworkManager should be able to do "something sensible" when DHCP (through dhclient) fails to provide a netmask through 'option netmask'. Not all networks are class C's. NM currently assumes it is the case. (FIXME in src/dhcp-manager/nm-dhcp-dhclient.c) I'm suggesting guessing a reasonable netmask through the use of classful networks; providing a draft patch shortly.
Patch would be excellent; I've seen other code that does this and I'd take a patch that would do this for NM too. Thanks! Make sure you do the right ntohl()/htonl() bits; everything *internally* to NM should be in network-by-order so when calculating stuff locally you'll want to ntohl() the address, do the calculation to figure out the classful mask, and then htonl() the resulting mask.
Created attachment 153344 [details] [review] Guessing netmask according to network classes As it looks like the patch has not been issued yet, I tried to do it myself. Actually the functionality could be useful elsewhere, so I added a function to libnm-util (nm_utils_ip4_get_default_netmask).
Looks good; I'd added something similar to ifcfg-rh a few weeks back to do the same thing; want to update the patch to: 1) use the new function in ifcfg-rh's reader.c 2) put the leading '*' in front of the comment block for nm_utils_ip4_get_default_netmask(); they'll get stripped off when gtkdoc runs 3) increase libnm-util's version info in libnm-util/Makefile.am to <+1>:<no change>:<+1> as shown by: http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html (ie, increment current, set revision to 0, and increment age, which translates into a library file version of libnm-util.so.X.Y.Z+1)
Created attachment 153526 [details] [review] libnm-util: default netmask function; usage in dhcp-manager and ifcfg-rh Thanks for your comments. Updated accordingly. I didn't know the versioning scheme, thank you for the info.
0f0daf7852a0dc71a1a270e7936d2819789e7155
There's a second part to this fix too: f5f1da66b50a6b94a4f1744e0edd3d84dd0dd496 (master) e3163514e8cfc7a01eb1f576f0c1cea17de477f0 (0.7.x)