version 1.319.6.1, 2018/02/09 14:06:25 |
version 1.326, 2016/01/08 03:55:39 |
|
|
#include <sys/cdefs.h> |
#include <sys/cdefs.h> |
__KERNEL_RCSID(0, "$NetBSD$"); |
__KERNEL_RCSID(0, "$NetBSD$"); |
|
|
|
#ifdef _KERNEL_OPT |
#include "opt_inet.h" |
#include "opt_inet.h" |
#include "opt_compat_netbsd.h" |
#include "opt_compat_netbsd.h" |
#include "opt_gateway.h" |
#include "opt_gateway.h" |
Line 100 __KERNEL_RCSID(0, "$NetBSD$"); |
|
Line 101 __KERNEL_RCSID(0, "$NetBSD$"); |
|
#include "opt_mrouting.h" |
#include "opt_mrouting.h" |
#include "opt_mbuftrace.h" |
#include "opt_mbuftrace.h" |
#include "opt_inet_csum.h" |
#include "opt_inet_csum.h" |
|
#endif |
|
|
|
#include "arp.h" |
|
|
#include <sys/param.h> |
#include <sys/param.h> |
#include <sys/systm.h> |
#include <sys/systm.h> |
Line 157 __KERNEL_RCSID(0, "$NetBSD$"); |
|
Line 161 __KERNEL_RCSID(0, "$NetBSD$"); |
|
#define IPSENDREDIRECTS 1 |
#define IPSENDREDIRECTS 1 |
#endif |
#endif |
#ifndef IPFORWSRCRT |
#ifndef IPFORWSRCRT |
#define IPFORWSRCRT 0 /* forward source-routed packets */ |
#define IPFORWSRCRT 1 /* forward source-routed packets */ |
#endif |
#endif |
#ifndef IPALLOWSRCRT |
#ifndef IPALLOWSRCRT |
#define IPALLOWSRCRT 0 /* allow source-routed packets */ |
#define IPALLOWSRCRT 1 /* allow source-routed packets */ |
#endif |
#endif |
#ifndef IPMTUDISC |
#ifndef IPMTUDISC |
#define IPMTUDISC 1 |
#define IPMTUDISC 1 |
|
|
ip_reass_init(); |
ip_reass_init(); |
|
|
ip_ids = ip_id_init(); |
ip_ids = ip_id_init(); |
ip_id = time_second & 0xfffff; |
ip_id = time_uptime & 0xfffff; |
|
|
ip_mtudisc_timeout_q = rt_timer_queue_create(ip_mtudisc_timeout); |
ip_mtudisc_timeout_q = rt_timer_queue_create(ip_mtudisc_timeout); |
#ifdef GATEWAY |
#ifdef GATEWAY |
Line 593 ip_input(struct mbuf *m) |
|
Line 597 ip_input(struct mbuf *m) |
|
* |
* |
* Traditional 4.4BSD did not consult IFF_UP at all. |
* Traditional 4.4BSD did not consult IFF_UP at all. |
* The behavior here is to treat addresses on !IFF_UP interface |
* The behavior here is to treat addresses on !IFF_UP interface |
* as not mine. |
* or IN_IFF_NOTREADY addresses as not mine. |
*/ |
*/ |
downmatch = 0; |
downmatch = 0; |
LIST_FOREACH(ia, &IN_IFADDR_HASH(ip->ip_dst.s_addr), ia_hash) { |
LIST_FOREACH(ia, &IN_IFADDR_HASH(ip->ip_dst.s_addr), ia_hash) { |
if (in_hosteq(ia->ia_addr.sin_addr, ip->ip_dst)) { |
if (in_hosteq(ia->ia_addr.sin_addr, ip->ip_dst)) { |
|
if (ia->ia4_flags & IN_IFF_NOTREADY) |
|
continue; |
if (checkif && ia->ia_ifp != ifp) |
if (checkif && ia->ia_ifp != ifp) |
continue; |
continue; |
if ((ia->ia_ifp->if_flags & IFF_UP) != 0) |
if ((ia->ia_ifp->if_flags & IFF_UP) != 0) |
Line 613 ip_input(struct mbuf *m) |
|
Line 619 ip_input(struct mbuf *m) |
|
if (ifa->ifa_addr->sa_family != AF_INET) |
if (ifa->ifa_addr->sa_family != AF_INET) |
continue; |
continue; |
ia = ifatoia(ifa); |
ia = ifatoia(ifa); |
|
if (ia->ia4_flags & IN_IFF_NOTREADY) |
|
continue; |
if (in_hosteq(ip->ip_dst, ia->ia_broadaddr.sin_addr) || |
if (in_hosteq(ip->ip_dst, ia->ia_broadaddr.sin_addr) || |
in_hosteq(ip->ip_dst, ia->ia_netbroadcast) || |
in_hosteq(ip->ip_dst, ia->ia_netbroadcast) || |
/* |
/* |
Line 1189 ip_forward(struct mbuf *m, int srcrt) |
|
Line 1197 ip_forward(struct mbuf *m, int srcrt) |
|
struct sockaddr dst; |
struct sockaddr dst; |
struct sockaddr_in dst4; |
struct sockaddr_in dst4; |
} u; |
} u; |
|
uint64_t *ips; |
|
|
KASSERTMSG(cpu_softintr_p(), "ip_forward: not in the software " |
KASSERTMSG(cpu_softintr_p(), "ip_forward: not in the software " |
"interrupt handler; synchronization assumptions violated"); |
"interrupt handler; synchronization assumptions violated"); |
Line 1269 ip_forward(struct mbuf *m, int srcrt) |
|
Line 1278 ip_forward(struct mbuf *m, int srcrt) |
|
(IP_FORWARDING | (ip_directedbcast ? IP_ALLOWBROADCAST : 0)), |
(IP_FORWARDING | (ip_directedbcast ? IP_ALLOWBROADCAST : 0)), |
NULL, NULL); |
NULL, NULL); |
|
|
if (error) |
if (error) { |
IP_STATINC(IP_STAT_CANTFORWARD); |
IP_STATINC(IP_STAT_CANTFORWARD); |
else { |
goto error; |
uint64_t *ips = IP_STAT_GETREF(); |
} |
ips[IP_STAT_FORWARD]++; |
|
if (type) { |
ips = IP_STAT_GETREF(); |
ips[IP_STAT_REDIRECTSENT]++; |
ips[IP_STAT_FORWARD]++; |
IP_STAT_PUTREF(); |
|
} else { |
if (type) { |
IP_STAT_PUTREF(); |
ips[IP_STAT_REDIRECTSENT]++; |
if (mcopy) { |
IP_STAT_PUTREF(); |
|
goto redirect; |
|
} |
|
|
|
IP_STAT_PUTREF(); |
|
if (mcopy) { |
#ifdef GATEWAY |
#ifdef GATEWAY |
if (mcopy->m_flags & M_CANFASTFWD) |
if (mcopy->m_flags & M_CANFASTFWD) |
ipflow_create(&ipforward_rt, mcopy); |
ipflow_create(&ipforward_rt, mcopy); |
#endif |
#endif |
m_freem(mcopy); |
m_freem(mcopy); |
} |
|
SOFTNET_UNLOCK(); |
|
return; |
|
} |
|
} |
} |
|
|
|
SOFTNET_UNLOCK(); |
|
return; |
|
|
|
redirect: |
|
error: |
if (mcopy == NULL) { |
if (mcopy == NULL) { |
SOFTNET_UNLOCK(); |
SOFTNET_UNLOCK(); |
return; |
return; |
Line 1568 sysctl_net_inet_ip_setup(struct sysctllo |
|
Line 1584 sysctl_net_inet_ip_setup(struct sysctllo |
|
sysctl_net_inet_ip_pmtudto, 0, (void *)&ip_mtudisc_timeout, 0, |
sysctl_net_inet_ip_pmtudto, 0, (void *)&ip_mtudisc_timeout, 0, |
CTL_NET, PF_INET, IPPROTO_IP, |
CTL_NET, PF_INET, IPPROTO_IP, |
IPCTL_MTUDISCTIMEOUT, CTL_EOL); |
IPCTL_MTUDISCTIMEOUT, CTL_EOL); |
#if NGIF > 0 |
|
sysctl_createv(clog, 0, NULL, NULL, |
|
CTLFLAG_PERMANENT|CTLFLAG_READWRITE, |
|
CTLTYPE_INT, "gifttl", |
|
SYSCTL_DESCR("Default TTL for a gif tunnel datagram"), |
|
NULL, 0, &ip_gif_ttl, 0, |
|
CTL_NET, PF_INET, IPPROTO_IP, |
|
IPCTL_GIF_TTL, CTL_EOL); |
|
#endif /* NGIF */ |
|
#ifndef IPNOPRIVPORTS |
#ifndef IPNOPRIVPORTS |
sysctl_createv(clog, 0, NULL, NULL, |
sysctl_createv(clog, 0, NULL, NULL, |
CTLFLAG_PERMANENT|CTLFLAG_READWRITE, |
CTLFLAG_PERMANENT|CTLFLAG_READWRITE, |
Line 1633 sysctl_net_inet_ip_setup(struct sysctllo |
|
Line 1640 sysctl_net_inet_ip_setup(struct sysctllo |
|
sysctl_net_inet_ip_stats, 0, NULL, 0, |
sysctl_net_inet_ip_stats, 0, NULL, 0, |
CTL_NET, PF_INET, IPPROTO_IP, IPCTL_STATS, |
CTL_NET, PF_INET, IPPROTO_IP, IPCTL_STATS, |
CTL_EOL); |
CTL_EOL); |
|
#if NARP |
|
sysctl_createv(clog, 0, NULL, NULL, |
|
CTLFLAG_PERMANENT|CTLFLAG_READWRITE, |
|
CTLTYPE_INT, "dad_count", |
|
SYSCTL_DESCR("Number of Duplicate Address Detection " |
|
"probes to send"), |
|
NULL, 0, &ip_dad_count, 0, |
|
CTL_NET, PF_INET, IPPROTO_IP, |
|
IPCTL_DAD_COUNT, CTL_EOL); |
|
#endif |
|
|
/* anonportalgo RFC6056 subtree */ |
/* anonportalgo RFC6056 subtree */ |
const struct sysctlnode *portalgo_node; |
const struct sysctlnode *portalgo_node; |