Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/in.c
Show First 20 Lines • Show All 443 Lines • ▼ Show 20 Lines | callout_init_rw(&ia->ia_garp_timer, &ifp->if_addr_lock, | ||||
CALLOUT_RETURNUNLOCKED); | CALLOUT_RETURNUNLOCKED); | ||||
ia->ia_ifp = ifp; | ia->ia_ifp = ifp; | ||||
ia->ia_addr = *addr; | ia->ia_addr = *addr; | ||||
if (mask->sin_len != 0) { | if (mask->sin_len != 0) { | ||||
ia->ia_sockmask = *mask; | ia->ia_sockmask = *mask; | ||||
ia->ia_subnetmask = ntohl(ia->ia_sockmask.sin_addr.s_addr); | ia->ia_subnetmask = ntohl(ia->ia_sockmask.sin_addr.s_addr); | ||||
} else { | } else { | ||||
in_addr_t i = ntohl(addr->sin_addr.s_addr); | |||||
/* | /* | ||||
* Be compatible with network classes, if netmask isn't | * If netmask isn't supplied, use default for now. | ||||
* supplied, guess it based on classes. | * This is deprecated for interfaces other than loopback | ||||
* or point-to-point; warn in other cases. In the future | |||||
* we should return an error rather than warning. | |||||
*/ | */ | ||||
if (IN_CLASSA(i)) | if ((ifp->if_flags & (IFF_POINTOPOINT | IFF_LOOPBACK)) == 0) | ||||
ia->ia_subnetmask = IN_CLASSA_NET; | printf("%s: set address: WARNING: network mask" | ||||
else if (IN_CLASSB(i)) | " should be specified; using default mask\n", | ||||
ia->ia_subnetmask = IN_CLASSB_NET; | ifp->if_xname); | ||||
else | ia->ia_subnetmask = IN_NETMASK_DEFAULT; | ||||
bz: I was going to argue that a /24 doesn't make much sense anymore these days in most places and… | |||||
Done Inline ActionsAgreed that /24 often isn't right, but /8 and /16 are less likely to be right. I'd love to make it an error not to specify a mask, but that would make some systems fail to come up suddenly. About lo0: the command listed would default to a /24, although the standard 127.0.0.1 is set by the network scripts to /8. Does it matter what the mask is on loopback? The only route is to our own address. karels: Agreed that /24 often isn't right, but /8 and /16 are less likely to be right. I'd love to… | |||||
ia->ia_subnetmask = IN_CLASSC_NET; | |||||
ia->ia_sockmask.sin_addr.s_addr = htonl(ia->ia_subnetmask); | ia->ia_sockmask.sin_addr.s_addr = htonl(ia->ia_subnetmask); | ||||
} | } | ||||
ia->ia_subnet = ntohl(addr->sin_addr.s_addr) & ia->ia_subnetmask; | ia->ia_subnet = ntohl(addr->sin_addr.s_addr) & ia->ia_subnetmask; | ||||
in_socktrim(&ia->ia_sockmask); | in_socktrim(&ia->ia_sockmask); | ||||
if (ifp->if_flags & IFF_BROADCAST) { | if (ifp->if_flags & IFF_BROADCAST) { | ||||
if (broadaddr->sin_len != 0) { | if (broadaddr->sin_len != 0) { | ||||
ia->ia_broadaddr = *broadaddr; | ia->ia_broadaddr = *broadaddr; | ||||
▲ Show 20 Lines • Show All 1,229 Lines • Show Last 20 Lines |
I was going to argue that a /24 doesn't make much sense anymore these days in most places and if one doesn't give a netmask it should probably be a /32 used here but then I saw the old "else" case above and though "okay".
One 2nd though has anyone tested
ifconfig lo0 inet 127.0.2.2 gets the correct mask? Is that handled somewhere?