After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 603098 - Support for networks where netmask is not provided by DHCP (dhclient), but not a class C
Support for networks where netmask is not provided by DHCP (dhclient), but no...
Status: RESOLVED FIXED
Product: NetworkManager
Classification: Platform
Component: general
git master
Other Linux
: Normal minor
: ---
Assigned To: Dan Williams
Dan Williams
Depends on:
Blocks:
 
 
Reported: 2009-11-27 00:59 UTC by Mathieu Trudel-Lapierre
Modified: 2010-03-02 01:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Guessing netmask according to network classes (3.57 KB, patch)
2010-02-09 17:08 UTC, Jiri Klimes
none Details | Review
libnm-util: default netmask function; usage in dhcp-manager and ifcfg-rh (4.92 KB, patch)
2010-02-11 12:30 UTC, Jiri Klimes
none Details | Review

Description Mathieu Trudel-Lapierre 2009-11-27 00:59:50 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.
Comment 1 Dan Williams 2009-11-29 03:24:53 UTC
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.
Comment 2 Jiri Klimes 2010-02-09 17:08:25 UTC
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).
Comment 3 Dan Williams 2010-02-10 19:05:12 UTC
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)
Comment 4 Jiri Klimes 2010-02-11 12:30:03 UTC
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.
Comment 5 Dan Williams 2010-02-26 00:54:21 UTC
0f0daf7852a0dc71a1a270e7936d2819789e7155
Comment 6 Dan Williams 2010-03-02 01:49:22 UTC
There's a second part to this fix too:

f5f1da66b50a6b94a4f1744e0edd3d84dd0dd496 (master)
e3163514e8cfc7a01eb1f576f0c1cea17de477f0 (0.7.x)