version 1.169.2.3, 2004/12/18 09:33:05 |
version 1.197.2.1, 2004/05/28 07:25:05 |
Line 200 int ipprintfs = 0; |
|
Line 200 int ipprintfs = 0; |
|
#endif |
#endif |
|
|
int ip_do_randomid = 0; |
int ip_do_randomid = 0; |
int ip_do_loopback_cksum = 1; |
|
|
|
/* |
/* |
* XXX - Setting ip_checkinterface mostly implements the receive side of |
* XXX - Setting ip_checkinterface mostly implements the receive side of |
Line 220 int ip_checkinterface = 0; |
|
Line 219 int ip_checkinterface = 0; |
|
|
|
struct rttimer_queue *ip_mtudisc_timeout_q = NULL; |
struct rttimer_queue *ip_mtudisc_timeout_q = NULL; |
|
|
|
extern struct domain inetdomain; |
int ipqmaxlen = IFQ_MAXLEN; |
int ipqmaxlen = IFQ_MAXLEN; |
u_long in_ifaddrhash; /* size of hash table - 1 */ |
u_long in_ifaddrhash; /* size of hash table - 1 */ |
int in_ifaddrentries; /* total number of addrs */ |
int in_ifaddrentries; /* total number of addrs */ |
|
|
|
|
#define IPQ_UNLOCK() ipq_unlock() |
#define IPQ_UNLOCK() ipq_unlock() |
|
|
POOL_INIT(inmulti_pool, sizeof(struct in_multi), 0, 0, 0, "inmltpl", NULL); |
struct pool inmulti_pool; |
POOL_INIT(ipqent_pool, sizeof(struct ipqent), 0, 0, 0, "ipqepl", NULL); |
struct pool ipqent_pool; |
|
|
#ifdef INET_CSUM_COUNTERS |
#ifdef INET_CSUM_COUNTERS |
#include <sys/device.h> |
#include <sys/device.h> |
Line 348 struct evcnt ip_swcsum = EVCNT_INITIALIZ |
|
Line 348 struct evcnt ip_swcsum = EVCNT_INITIALIZ |
|
|
|
#define INET_CSUM_COUNTER_INCR(ev) (ev)->ev_count++ |
#define INET_CSUM_COUNTER_INCR(ev) (ev)->ev_count++ |
|
|
EVCNT_ATTACH_STATIC(ip_hwcsum_bad); |
|
EVCNT_ATTACH_STATIC(ip_hwcsum_ok); |
|
EVCNT_ATTACH_STATIC(ip_swcsum); |
|
|
|
#else |
#else |
|
|
#define INET_CSUM_COUNTER_INCR(ev) /* nothing */ |
#define INET_CSUM_COUNTER_INCR(ev) /* nothing */ |
Line 397 ip_nmbclusters_changed(void) |
|
Line 393 ip_nmbclusters_changed(void) |
|
void |
void |
ip_init() |
ip_init() |
{ |
{ |
const struct protosw *pr; |
struct protosw *pr; |
int i; |
int i; |
|
|
|
pool_init(&inmulti_pool, sizeof(struct in_multi), 0, 0, 0, "inmltpl", |
|
NULL); |
|
pool_init(&ipqent_pool, sizeof(struct ipqent), 0, 0, 0, "ipqepl", |
|
NULL); |
|
|
pr = pffindproto(PF_INET, IPPROTO_RAW, SOCK_RAW); |
pr = pffindproto(PF_INET, IPPROTO_RAW, SOCK_RAW); |
if (pr == 0) |
if (pr == 0) |
panic("ip_init"); |
panic("ip_init"); |
|
|
"error %d\n", i); |
"error %d\n", i); |
#endif /* PFIL_HOOKS */ |
#endif /* PFIL_HOOKS */ |
|
|
|
#ifdef INET_CSUM_COUNTERS |
|
evcnt_attach_static(&ip_hwcsum_bad); |
|
evcnt_attach_static(&ip_hwcsum_ok); |
|
evcnt_attach_static(&ip_swcsum); |
|
#endif /* INET_CSUM_COUNTERS */ |
|
|
#ifdef MBUFTRACE |
#ifdef MBUFTRACE |
MOWNER_ATTACH(&ip_tx_mowner); |
MOWNER_ATTACH(&ip_tx_mowner); |
MOWNER_ATTACH(&ip_rx_mowner); |
MOWNER_ATTACH(&ip_rx_mowner); |
Line 573 ip_input(struct mbuf *m) |
|
Line 580 ip_input(struct mbuf *m) |
|
break; |
break; |
|
|
default: |
default: |
/* |
/* Must compute it ourselves. */ |
* Must compute it ourselves. Maybe skip checksum on |
INET_CSUM_COUNTER_INCR(&ip_swcsum); |
* loopback interfaces. |
if (in_cksum(m, hlen) != 0) |
*/ |
goto bad; |
if (__predict_true(!(m->m_pkthdr.rcvif->if_flags & |
|
IFF_LOOPBACK) || ip_do_loopback_cksum)) { |
|
INET_CSUM_COUNTER_INCR(&ip_swcsum); |
|
if (in_cksum(m, hlen) != 0) |
|
goto badcsum; |
|
} |
|
break; |
break; |
} |
} |
|
|
Line 656 ip_input(struct mbuf *m) |
|
Line 657 ip_input(struct mbuf *m) |
|
return; |
return; |
ip = mtod(m, struct ip *); |
ip = mtod(m, struct ip *); |
hlen = ip->ip_hl << 2; |
hlen = ip->ip_hl << 2; |
/* |
|
* XXX The setting of "srcrt" here is to prevent ip_forward() |
|
* from generating ICMP redirects for packets that have |
|
* been redirected by a hook back out on to the same LAN that |
|
* they came from and is not an indication that the packet |
|
* is being inffluenced by source routing options. This |
|
* allows things like |
|
* "rdr tlp0 0/0 port 80 -> 1.1.1.200 3128 tcp" |
|
* where tlp0 is both on the 1.1.1.0/24 network and is the |
|
* default route for hosts on 1.1.1.0/24. Of course this |
|
* also requires a "map tlp0 ..." to complete the story. |
|
* One might argue whether or not this kind of network config. |
|
* should be supported in this manner... |
|
*/ |
|
srcrt = (odst.s_addr != ip->ip_dst.s_addr); |
srcrt = (odst.s_addr != ip->ip_dst.s_addr); |
} |
} |
#endif /* PFIL_HOOKS */ |
#endif /* PFIL_HOOKS */ |
Line 759 ip_input(struct mbuf *m) |
|
Line 746 ip_input(struct mbuf *m) |
|
#ifdef MROUTING |
#ifdef MROUTING |
extern struct socket *ip_mrouter; |
extern struct socket *ip_mrouter; |
|
|
|
if (M_READONLY(m)) { |
|
if ((m = m_pullup(m, hlen)) == 0) { |
|
ipstat.ips_toosmall++; |
|
return; |
|
} |
|
ip = mtod(m, struct ip *); |
|
} |
|
|
if (ip_mrouter) { |
if (ip_mrouter) { |
/* |
/* |
* If we are acting as a multicast router, all |
* If we are acting as a multicast router, all |
|
|
* but it's not worth the time; just let them time out.) |
* but it's not worth the time; just let them time out.) |
*/ |
*/ |
if (ip->ip_off & ~htons(IP_DF|IP_RF)) { |
if (ip->ip_off & ~htons(IP_DF|IP_RF)) { |
|
if (M_READONLY(m)) { |
|
if ((m = m_pullup(m, hlen)) == NULL) { |
|
ipstat.ips_toosmall++; |
|
goto bad; |
|
} |
|
ip = mtod(m, struct ip *); |
|
} |
|
|
/* |
/* |
* Look for queue of fragments |
* Look for queue of fragments |
Line 1286 static u_int fragttl_histo[(IPFRAGTTL+1) |
|
Line 1288 static u_int fragttl_histo[(IPFRAGTTL+1) |
|
static u_int |
static u_int |
ip_reass_ttl_decr(u_int ticks) |
ip_reass_ttl_decr(u_int ticks) |
{ |
{ |
u_int nfrags, median, dropfraction, keepfraction; |
u_int i, nfrags, median; |
struct ipq *fp, *nfp; |
struct ipq *fp, *nfp; |
int i; |
u_int dropfraction, keepfraction; |
|
|
nfrags = 0; |
nfrags = 0; |
memset(fragttl_histo, 0, sizeof fragttl_histo); |
memset(fragttl_histo, 0, sizeof fragttl_histo); |
Line 2349 SYSCTL_SETUP(sysctl_net_inet_ip_setup, " |
|
Line 2351 SYSCTL_SETUP(sysctl_net_inet_ip_setup, " |
|
NULL, 0, &ip_do_randomid, 0, |
NULL, 0, &ip_do_randomid, 0, |
CTL_NET, PF_INET, IPPROTO_IP, |
CTL_NET, PF_INET, IPPROTO_IP, |
IPCTL_RANDOMID, CTL_EOL); |
IPCTL_RANDOMID, CTL_EOL); |
sysctl_createv(clog, 0, NULL, NULL, |
|
CTLFLAG_PERMANENT|CTLFLAG_READWRITE, |
|
CTLTYPE_INT, "do_loopback_cksum", |
|
SYSCTL_DESCR("Perform IP checksum on loopback"), |
|
NULL, 0, &ip_do_loopback_cksum, 0, |
|
CTL_NET, PF_INET, IPPROTO_IP, |
|
IPCTL_LOOPBACKCKSUM, CTL_EOL); |
|
} |
} |