| version 1.130.2.1, 2001/04/09 01:58:25 |
version 1.130.2.2, 2001/06/21 20:08:37 |
|
|
| #include "opt_pfil_hooks.h" |
#include "opt_pfil_hooks.h" |
| #include "opt_ipsec.h" |
#include "opt_ipsec.h" |
| #include "opt_mrouting.h" |
#include "opt_mrouting.h" |
| |
#include "opt_inet_csum.h" |
| |
|
| #include <sys/param.h> |
#include <sys/param.h> |
| #include <sys/systm.h> |
#include <sys/systm.h> |
| Line 212 struct pfil_head inet_pfil_hook; |
|
| Line 213 struct pfil_head inet_pfil_hook; |
|
| struct ipqhead ipq; |
struct ipqhead ipq; |
| int ipq_locked; |
int ipq_locked; |
| int ip_nfragpackets = 0; |
int ip_nfragpackets = 0; |
| int ip_maxfragpackets = -1; |
int ip_maxfragpackets = 200; |
| |
|
| static __inline int ipq_lock_try __P((void)); |
static __inline int ipq_lock_try __P((void)); |
| static __inline void ipq_unlock __P((void)); |
static __inline void ipq_unlock __P((void)); |
|
|
| { |
{ |
| int s; |
int s; |
| |
|
| s = splimp(); |
/* |
| |
* Use splvm() -- we're bloking things that would cause |
| |
* mbuf allocation. |
| |
*/ |
| |
s = splvm(); |
| if (ipq_locked) { |
if (ipq_locked) { |
| splx(s); |
splx(s); |
| return (0); |
return (0); |
|
|
| { |
{ |
| int s; |
int s; |
| |
|
| s = splimp(); |
s = splvm(); |
| ipq_locked = 0; |
ipq_locked = 0; |
| splx(s); |
splx(s); |
| } |
} |
|
|
| |
|
| struct pool ipqent_pool; |
struct pool ipqent_pool; |
| |
|
| |
#ifdef INET_CSUM_COUNTERS |
| |
#include <sys/device.h> |
| |
|
| |
struct evcnt ip_hwcsum_bad = EVCNT_INITIALIZER(EVCNT_TYPE_MISC, |
| |
NULL, "inet", "hwcsum bad"); |
| |
struct evcnt ip_hwcsum_ok = EVCNT_INITIALIZER(EVCNT_TYPE_MISC, |
| |
NULL, "inet", "hwcsum ok"); |
| |
struct evcnt ip_swcsum = EVCNT_INITIALIZER(EVCNT_TYPE_MISC, |
| |
NULL, "inet", "swcsum"); |
| |
|
| |
#define INET_CSUM_COUNTER_INCR(ev) (ev)->ev_count++ |
| |
|
| |
#else |
| |
|
| |
#define INET_CSUM_COUNTER_INCR(ev) /* nothing */ |
| |
|
| |
#endif /* INET_CSUM_COUNTERS */ |
| |
|
| /* |
/* |
| * We need to save the IP options in case a protocol wants to respond |
* We need to save the IP options in case a protocol wants to respond |
| * to an incoming packet over the same route if the packet got here |
* to an incoming packet over the same route if the packet got here |
|
|
| printf("ip_init: WARNING: unable to register pfil hook, " |
printf("ip_init: WARNING: unable to register pfil hook, " |
| "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 */ |
| } |
} |
| |
|
| struct sockaddr_in ipaddr = { sizeof(ipaddr), AF_INET }; |
struct sockaddr_in ipaddr = { sizeof(ipaddr), AF_INET }; |
|
|
| struct mbuf *m; |
struct mbuf *m; |
| |
|
| while (1) { |
while (1) { |
| s = splimp(); |
s = splnet(); |
| IF_DEQUEUE(&ipintrq, m); |
IF_DEQUEUE(&ipintrq, m); |
| splx(s); |
splx(s); |
| if (m == 0) |
if (m == 0) |
| Line 429 ip_input(struct mbuf *m) |
|
| Line 458 ip_input(struct mbuf *m) |
|
| } |
} |
| } |
} |
| |
|
| if (in_cksum(m, hlen) != 0) { |
switch (m->m_pkthdr.csum_flags & |
| ipstat.ips_badsum++; |
((m->m_pkthdr.rcvif->if_csum_flags & M_CSUM_IPv4) | |
| goto bad; |
M_CSUM_IPv4_BAD)) { |
| |
case M_CSUM_IPv4|M_CSUM_IPv4_BAD: |
| |
INET_CSUM_COUNTER_INCR(&ip_hwcsum_bad); |
| |
goto badcsum; |
| |
|
| |
case M_CSUM_IPv4: |
| |
/* Checksum was okay. */ |
| |
INET_CSUM_COUNTER_INCR(&ip_hwcsum_ok); |
| |
break; |
| |
|
| |
default: |
| |
/* Must compute it ourselves. */ |
| |
INET_CSUM_COUNTER_INCR(&ip_swcsum); |
| |
if (in_cksum(m, hlen) != 0) |
| |
goto bad; |
| |
break; |
| } |
} |
| |
|
| /* Retrieve the packet length. */ |
/* Retrieve the packet length. */ |
|
|
| } |
} |
| bad: |
bad: |
| m_freem(m); |
m_freem(m); |
| |
return; |
| |
|
| |
badcsum: |
| |
ipstat.ips_badsum++; |
| |
m_freem(m); |
| } |
} |
| |
|
| /* |
/* |
| Line 1430 ip_forward(m, srcrt) |
|
| Line 1479 ip_forward(m, srcrt) |
|
| struct ifnet dummyifp; |
struct ifnet dummyifp; |
| #endif |
#endif |
| |
|
| |
/* |
| |
* Clear any in-bound checksum flags for this packet. |
| |
*/ |
| |
m->m_pkthdr.csum_flags = 0; |
| |
|
| dest = 0; |
dest = 0; |
| #ifdef DIAGNOSTIC |
#ifdef DIAGNOSTIC |
| if (ipprintfs) |
if (ipprintfs) |
| Line 1510 ip_forward(m, srcrt) |
|
| Line 1564 ip_forward(m, srcrt) |
|
| } |
} |
| |
|
| #ifdef IPSEC |
#ifdef IPSEC |
| /* Don't lookup socket in forwading case */ |
/* Don't lookup socket in forwarding case */ |
| (void)ipsec_setsocket(m, NULL); |
(void)ipsec_setsocket(m, NULL); |
| #endif |
#endif |
| error = ip_output(m, (struct mbuf *)0, &ipforward_rt, |
error = ip_output(m, (struct mbuf *)0, &ipforward_rt, |