Changeset View
Standalone View
sys/netinet/ip_input.c
Show First 20 Lines • Show All 730 Lines • ▼ Show 20 Lines | #ifdef BOOTP_COMPAT | ||||
counter_u64_add(ia->ia_ifa.ifa_ibytes, | counter_u64_add(ia->ia_ifa.ifa_ibytes, | ||||
m->m_pkthdr.len); | m->m_pkthdr.len); | ||||
goto ours; | goto ours; | ||||
} | } | ||||
#endif | #endif | ||||
} | } | ||||
ia = NULL; | ia = NULL; | ||||
} | } | ||||
/* RFC 3927 2.7: Do not forward datagrams for 169.254.0.0/16. */ | |||||
if (IN_LINKLOCAL(ntohl(ip->ip_dst.s_addr))) { | |||||
IPSTAT_INC(ips_cantforward); | |||||
m_freem(m); | |||||
return; | |||||
} | |||||
if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { | if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { | ||||
if (V_ip_mrouter) { | /* RFC 3927 2.7: Do not forward datagrams 169.254.0.0/16 */ | ||||
rgrimes: Remove RFC section ref s/datagrams/packets/ add "from":
/* Do not forward packets from… | |||||
if (V_ip_mrouter && !IN_LINKLOCAL(ntohl(ip->ip_src.s_addr))) { | |||||
/* | /* | ||||
* If we are acting as a multicast router, all | * If we are acting as a multicast router, all | ||||
* incoming multicast packets are passed to the | * incoming multicast packets are passed to the | ||||
* kernel-level multicast forwarding function. | * kernel-level multicast forwarding function. | ||||
* The packet is returned (relatively) intact; if | * The packet is returned (relatively) intact; if | ||||
* ip_mforward() returns a non-zero value, the packet | * ip_mforward() returns a non-zero value, the packet | ||||
* must be discarded, else it may be accepted below. | * must be discarded, else it may be accepted below. | ||||
*/ | */ | ||||
if (ip_mforward && ip_mforward(ip, ifp, m, 0) != 0) { | if (ip_mforward && ip_mforward(ip, ifp, m, 0) != 0) { | ||||
IPSTAT_INC(ips_cantforward); | IPSTAT_INC(ips_cantforward); | ||||
Done Inline ActionsIf the source in not link local, then check for mrouter and drop it enventually. donner: If the source in **not** link local, then check for mrouter and drop it enventually.
So if the… | |||||
Done Inline ActionsIf the source is link local, it is for ours. zlei: If the source is link local, it is for ours. | |||||
Done Inline ActionsThen the condition belongs to line 740 if (V_ip_mrouter && !IN_LINKLOCAL{(ntohl(ip->ip_src.s_addr))) { donner: Then the condition belongs to line 740
if (V_ip_mrouter && !IN_LINKLOCAL{(ntohl(ip->ip_src. | |||||
m_freem(m); | m_freem(m); | ||||
return; | return; | ||||
} | } | ||||
/* | /* | ||||
* The process-level routing daemon needs to receive | * The process-level routing daemon needs to receive | ||||
* all multicast IGMP packets, whether or not this | * all multicast IGMP packets, whether or not this | ||||
* host belongs to their destination groups. | * host belongs to their destination groups. | ||||
*/ | */ | ||||
if (ip->ip_p == IPPROTO_IGMP) | if (ip->ip_p == IPPROTO_IGMP) | ||||
goto ours; | goto ours; | ||||
IPSTAT_INC(ips_forward); | IPSTAT_INC(ips_forward); | ||||
Not Done Inline ActionsIt seems wrong that ips_forward is increased unconditionally. Should increase only when ip_mforward() succeed? zlei: It seems wrong that `ips_forward` is increased unconditionally. Should increase only when… | |||||
Not Done Inline ActionsLooks like this still needs chased down. I tried to view full context in phabricator, but it totally messes up the screen layout and I can not read the code at all. I do agree that from what I can see this IPSTAT_INC looks wrong here. rgrimes: Looks like this still needs chased down. I tried to view full context in phabricator, but it… | |||||
} | } | ||||
/* | /* | ||||
* Assume the packet is for us, to avoid prematurely taking | * Assume the packet is for us, to avoid prematurely taking | ||||
* a lock on the in_multi hash. Protocols must perform | * a lock on the in_multi hash. Protocols must perform | ||||
* their own filtering and update statistics accordingly. | * their own filtering and update statistics accordingly. | ||||
*/ | */ | ||||
goto ours; | goto ours; | ||||
} | } | ||||
if (ip->ip_dst.s_addr == (u_long)INADDR_BROADCAST) | if (ip->ip_dst.s_addr == (u_long)INADDR_BROADCAST) | ||||
goto ours; | goto ours; | ||||
if (ip->ip_dst.s_addr == INADDR_ANY) | if (ip->ip_dst.s_addr == INADDR_ANY) | ||||
goto ours; | goto ours; | ||||
rgrimesUnsubmitted Done Inline ActionsExtra blank line sould be removed rgrimes: Extra blank line sould be removed | |||||
/* RFC 3927 2.7: Do not forward datagrams for 169.254.0.0/16. */ | |||||
rgrimesUnsubmitted Done Inline ActionsThree issues use of "datagrams", the other code uses "packets" and this use of the word "for" to describe to and from and RFC's change get/revised I do not see a need for specific number and secton reference here. I suggest a clearer: /* Do not forward packets to or from IN_LINKLOCAL */ rgrimes: Three issues use of "datagrams", the other code uses "packets" and this use of the word "for"… | |||||
Not Done Inline ActionsQ: given it's pretty neat /16, which splits an 32-bit address in two halves, would it be possible to come up with a macro that operates on network address, without doing ntohl()? melifaro: Q: given it's pretty neat /16, which splits an 32-bit address in two halves, would it be… | |||||
if (IN_LINKLOCAL(ntohl(ip->ip_src.s_addr)) || | |||||
IN_LINKLOCAL(ntohl(ip->ip_dst.s_addr))) { | |||||
IPSTAT_INC(ips_cantforward); | |||||
m_freem(m); | |||||
return; | |||||
} | |||||
/* | /* | ||||
* Not for us; forward if possible and desirable. | * Not for us; forward if possible and desirable. | ||||
*/ | */ | ||||
if (V_ipforwarding == 0) { | if (V_ipforwarding == 0) { | ||||
IPSTAT_INC(ips_cantforward); | IPSTAT_INC(ips_cantforward); | ||||
m_freem(m); | m_freem(m); | ||||
} else { | } else { | ||||
ip_forward(m, dchg); | ip_forward(m, dchg); | ||||
Not Done Inline ActionsMaybe here is where the IPSTAT_INC(ips_forward) belongs? rgrimes: Maybe here is where the IPSTAT_INC(ips_forward) belongs? | |||||
Done Inline ActionsNo. There's already IPSTAT_INC(ips_forward) in ip_forward() at line 1078 . zlei: No. There's already `IPSTAT_INC(ips_forward) ` in `ip_forward()` at line 1078 .
The above… | |||||
} | } | ||||
return; | return; | ||||
ours: | ours: | ||||
#ifdef IPSTEALTH | #ifdef IPSTEALTH | ||||
/* | /* | ||||
* IPSTEALTH: Process non-routing options only | * IPSTEALTH: Process non-routing options only | ||||
* if the packet is destined for us. | * if the packet is destined for us. | ||||
▲ Show 20 Lines • Show All 627 Lines • Show Last 20 Lines |
Remove RFC section ref s/datagrams/packets/ add "from":
/* Do not forward packets from IN_LINKLOCAL */