Changeset View
Standalone View
sys/netinet/in.c
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | SYSCTL_INT(_net_inet_ip, OID_AUTO, no_same_prefix, CTLFLAG_VNET | CTLFLAG_RW, | ||||
"Refuse to create same prefixes on different interfaces"); | "Refuse to create same prefixes on different interfaces"); | ||||
VNET_DEFINE_STATIC(bool, broadcast_lowest); | VNET_DEFINE_STATIC(bool, broadcast_lowest); | ||||
#define V_broadcast_lowest VNET(broadcast_lowest) | #define V_broadcast_lowest VNET(broadcast_lowest) | ||||
SYSCTL_BOOL(_net_inet_ip, OID_AUTO, broadcast_lowest, CTLFLAG_VNET | CTLFLAG_RW, | SYSCTL_BOOL(_net_inet_ip, OID_AUTO, broadcast_lowest, CTLFLAG_VNET | CTLFLAG_RW, | ||||
&VNET_NAME(broadcast_lowest), 0, | &VNET_NAME(broadcast_lowest), 0, | ||||
"Treat lowest address on a subnet (host 0) as broadcast"); | "Treat lowest address on a subnet (host 0) as broadcast"); | ||||
VNET_DEFINE(bool, ip_allow_net240) = false; | |||||
#define V_ip_allow_net240 VNET(ip_allow_net240) | |||||
SYSCTL_BOOL(_net_inet_ip, OID_AUTO, allow_net240, | |||||
CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip_allow_net240), 0, | |||||
"Allow use of Experimental addresses, aka Class E (240/4)"); | |||||
bz: I am almost tempted to add "according to draft-schoen-intarea-unicast-240"; if not there as a… | |||||
/* see https://datatracker.ietf.org/doc/draft-schoen-intarea-unicast-240 */ | |||||
Not Done Inline ActionsNormally we put comments above not below. And as indicated I'd only use the draft name (you already removed versions); the URLs in the past at least weren't long-term stable for drafts. bz: Normally we put comments above not below. And as indicated I'd only use the draft name (you… | |||||
Done Inline ActionsIn this case, I thought it was clearer to put the comment next to the description. I'd put the comment to the right, but there isn't room. I'm not sure what you are saying about the URL. Are you saying that only the draft-schoen-* name should appear? That would seem to be missing information; seems like we'd also need to mention the site. But these URLs point to all the recent versions. karels: In this case, I thought it was clearer to put the comment next to the description. I'd put the… | |||||
Not Done Inline ActionsBjoern is saying that only the draft-schoen-* name should appear. I would prefer the URL to the draft's page (as in the current revision) but agree with Rod that linking to a specific version is probably a bad idea at this point. bjk: Bjoern is saying that only the draft-schoen-* name should appear. I would prefer the URL to… | |||||
VNET_DEFINE(bool, ip_allow_net0) = false; | |||||
SYSCTL_BOOL(_net_inet_ip, OID_AUTO, allow_net0, | |||||
CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip_allow_net0), 0, | |||||
"Allow use of addresses in network 0/8"); | |||||
/* see https://datatracker.ietf.org/doc/draft-schoen-intarea-unicast-0 */ | |||||
Not Done Inline ActionsNot sure why your referencing a specific (and now obsolete) version of this draft, the canonical reference should be: Also above in draft-schoen-intarea-unicast-240 reference, and below in draft-schoen-intarea-unicast-127. rgrimes: Not sure why your referencing a specific (and now obsolete) version of this draft, the… | |||||
Done Inline ActionsThose were the hits I got from the IETF search for "draft-schoen"; at least they all point to the version summary. I can change if I'm making updates though. karels: Those were the hits I got from the IETF search for "draft-schoen"; at least they all point to… | |||||
VNET_DEFINE(uint32_t, in_loopback_mask) = IN_LOOPBACK_MASK_DFLT; | |||||
#define V_in_loopback_mask VNET(in_loopback_mask) | |||||
static int sysctl_loopback_prefixlen(SYSCTL_HANDLER_ARGS); | |||||
SYSCTL_PROC(_net_inet_ip, OID_AUTO, loopback_prefixlen, | |||||
CTLFLAG_VNET | CTLTYPE_INT | CTLFLAG_RW, | |||||
NULL, 0, sysctl_loopback_prefixlen, "I", | |||||
"Prefix length of address space reserved for loopback"); | |||||
/* see https://datatracker.ietf.org/doc/draft-schoen-intarea-unicast-127 */ | |||||
VNET_DECLARE(struct inpcbinfo, ripcbinfo); | VNET_DECLARE(struct inpcbinfo, ripcbinfo); | ||||
#define V_ripcbinfo VNET(ripcbinfo) | #define V_ripcbinfo VNET(ripcbinfo) | ||||
static struct sx in_control_sx; | static struct sx in_control_sx; | ||||
SX_SYSINIT(in_control_sx, &in_control_sx, "in_control"); | SX_SYSINIT(in_control_sx, &in_control_sx, "in_control"); | ||||
/* | /* | ||||
* Return 1 if an internet address is for a ``local'' host | * Return 1 if an internet address is for a ``local'' host | ||||
▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | |||||
* that may not be forwarded, or whether datagrams to that destination | * that may not be forwarded, or whether datagrams to that destination | ||||
* may be forwarded. | * may be forwarded. | ||||
*/ | */ | ||||
int | int | ||||
in_canforward(struct in_addr in) | in_canforward(struct in_addr in) | ||||
{ | { | ||||
u_long i = ntohl(in.s_addr); | u_long i = ntohl(in.s_addr); | ||||
if (IN_EXPERIMENTAL(i) || IN_MULTICAST(i) || IN_LINKLOCAL(i) || | if (IN_MULTICAST(i) || IN_LINKLOCAL(i) || IN_LOOPBACK(i)) | ||||
IN_ZERONET(i) || IN_LOOPBACK(i)) | |||||
return (0); | return (0); | ||||
if (IN_EXPERIMENTAL(i) && !V_ip_allow_net240) | |||||
return (0); | |||||
if (IN_ZERONET(i) && !V_ip_allow_net0) | |||||
Not Done Inline ActionsI'd suggest first check the boolean, then check the mask. glebius: I'd suggest first check the boolean, then check the mask. | |||||
Done Inline ActionsGiven the default setting of the boolean, that would require both conditions to be evaluated essentially always; seems like a pessimization. karels: Given the default setting of the boolean, that would require both conditions to be evaluated… | |||||
return (0); | |||||
return (1); | return (1); | ||||
} | |||||
/* | |||||
* Sysctl to manage prefix of reserved loopback network; translate | |||||
* to/from mask. The mask is always contiguous high-order 1 bits | |||||
* followed by all 0 bits. | |||||
*/ | |||||
static int | |||||
sysctl_loopback_prefixlen(SYSCTL_HANDLER_ARGS) | |||||
{ | |||||
int error, preflen; | |||||
/* ffs is 1-based; compensate. */ | |||||
preflen = 33 - ffs(V_in_loopback_mask); | |||||
error = sysctl_handle_int(oidp, &preflen, 0, req); | |||||
if (error || !req->newptr) | |||||
return (error); | |||||
if (preflen < 8 || preflen > 32) | |||||
return (EINVAL); | |||||
V_in_loopback_mask = 0xffffffff << (32 - preflen); | |||||
return (0); | |||||
} | } | ||||
/* | /* | ||||
* Trim a mask in a sockaddr | * Trim a mask in a sockaddr | ||||
*/ | */ | ||||
static void | static void | ||||
in_socktrim(struct sockaddr_in *ap) | in_socktrim(struct sockaddr_in *ap) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 1,486 Lines • Show Last 20 Lines |
I am almost tempted to add "according to draft-schoen-intarea-unicast-240"; if not there as a comment above it.
Similar for the other ones. We may have to update the names at some point if the drafts don't stay individual but that's okay.