| version 1.191, 2003/12/07 01:18:26 |
version 1.192, 2003/12/08 02:23:27 |
| Line 243 struct pfil_head inet_pfil_hook; |
|
| Line 243 struct pfil_head inet_pfil_hook; |
|
| #define IPREASS_HASH(x,y) \ |
#define IPREASS_HASH(x,y) \ |
| (((((x) & 0xF) | ((((x) >> 8) & 0xF) << 4)) ^ (y)) & IPREASS_HMASK) |
(((((x) & 0xF) | ((((x) >> 8) & 0xF) << 4)) ^ (y)) & IPREASS_HMASK) |
| struct ipqhead ipq[IPREASS_NHASH]; |
struct ipqhead ipq[IPREASS_NHASH]; |
| #ifdef notyet |
|
| static int nipq = 0; /* total # of reass queues */ |
|
| #endif |
|
| int ipq_locked; |
int ipq_locked; |
| int ip_nfragpackets = 0; |
int ip_nfragpackets = 0; |
| int ip_maxfragpackets = 200; |
int ip_maxfragpackets = 200; |
| |
int ip_nfrags = 0; /* total fragments in reass queues */ |
| |
|
| 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)); |
|
|
| if (pr->pr_domain->dom_family == PF_INET && |
if (pr->pr_domain->dom_family == PF_INET && |
| pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW) |
pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW) |
| ip_protox[pr->pr_protocol] = pr - inetsw; |
ip_protox[pr->pr_protocol] = pr - inetsw; |
| |
|
| for (i = 0; i < IPREASS_NHASH; i++) |
for (i = 0; i < IPREASS_NHASH; i++) |
| LIST_INIT(&ipq[i]); |
LIST_INIT(&ipq[i]); |
| |
|
| Line 1005 ip_reass(ipqe, fp, ipqhead) |
|
| Line 1004 ip_reass(ipqe, fp, ipqhead) |
|
| m->m_len -= hlen; |
m->m_len -= hlen; |
| |
|
| /* |
/* |
| |
* We are about to add a fragment; increment frag count. |
| |
*/ |
| |
ip_nfrags++; |
| |
|
| |
/* |
| * If first fragment to arrive, create a reassembly queue. |
* If first fragment to arrive, create a reassembly queue. |
| */ |
*/ |
| if (fp == 0) { |
if (fp == 0) { |
| Line 1024 ip_reass(ipqe, fp, ipqhead) |
|
| Line 1028 ip_reass(ipqe, fp, ipqhead) |
|
| if (fp == NULL) |
if (fp == NULL) |
| goto dropfrag; |
goto dropfrag; |
| LIST_INSERT_HEAD(ipqhead, fp, ipq_q); |
LIST_INSERT_HEAD(ipqhead, fp, ipq_q); |
| |
fp->ipq_nfrags = 1; |
| fp->ipq_ttl = IPFRAGTTL; |
fp->ipq_ttl = IPFRAGTTL; |
| fp->ipq_p = ipqe->ipqe_ip->ip_p; |
fp->ipq_p = ipqe->ipqe_ip->ip_p; |
| fp->ipq_id = ipqe->ipqe_ip->ip_id; |
fp->ipq_id = ipqe->ipqe_ip->ip_id; |
| Line 1032 ip_reass(ipqe, fp, ipqhead) |
|
| Line 1037 ip_reass(ipqe, fp, ipqhead) |
|
| fp->ipq_dst = ipqe->ipqe_ip->ip_dst; |
fp->ipq_dst = ipqe->ipqe_ip->ip_dst; |
| p = NULL; |
p = NULL; |
| goto insert; |
goto insert; |
| |
} else { |
| |
fp->ipq_nfrags++; |
| } |
} |
| |
|
| /* |
/* |
| Line 1082 ip_reass(ipqe, fp, ipqhead) |
|
| Line 1089 ip_reass(ipqe, fp, ipqhead) |
|
| m_freem(q->ipqe_m); |
m_freem(q->ipqe_m); |
| TAILQ_REMOVE(&fp->ipq_fragq, q, ipqe_q); |
TAILQ_REMOVE(&fp->ipq_fragq, q, ipqe_q); |
| pool_put(&ipqent_pool, q); |
pool_put(&ipqent_pool, q); |
| |
fp->ipq_nfrags--; |
| |
ip_nfrags--; |
| } |
} |
| |
|
| insert: |
insert: |
|
|
| pool_put(&ipqent_pool, q); |
pool_put(&ipqent_pool, q); |
| m_cat(m, t); |
m_cat(m, t); |
| } |
} |
| |
ip_nfrags -= fp->ipq_nfrags; |
| |
|
| /* |
/* |
| * Create header for new ip packet by |
* Create header for new ip packet by |
|
|
| return (m); |
return (m); |
| |
|
| dropfrag: |
dropfrag: |
| |
if (fp != 0) |
| |
fp->ipq_nfrags--; |
| |
ip_nfrags--; |
| ipstat.ips_fragdropped++; |
ipstat.ips_fragdropped++; |
| m_freem(m); |
m_freem(m); |
| pool_put(&ipqent_pool, ipqe); |
pool_put(&ipqent_pool, ipqe); |
|
|
| struct ipq *fp; |
struct ipq *fp; |
| { |
{ |
| struct ipqent *q, *p; |
struct ipqent *q, *p; |
| |
u_int nfrags = 0; |
| |
|
| IPQ_LOCK_CHECK(); |
IPQ_LOCK_CHECK(); |
| |
|
| for (q = TAILQ_FIRST(&fp->ipq_fragq); q != NULL; q = p) { |
for (q = TAILQ_FIRST(&fp->ipq_fragq); q != NULL; q = p) { |
| p = TAILQ_NEXT(q, ipqe_q); |
p = TAILQ_NEXT(q, ipqe_q); |
| m_freem(q->ipqe_m); |
m_freem(q->ipqe_m); |
| |
nfrags++; |
| TAILQ_REMOVE(&fp->ipq_fragq, q, ipqe_q); |
TAILQ_REMOVE(&fp->ipq_fragq, q, ipqe_q); |
| pool_put(&ipqent_pool, q); |
pool_put(&ipqent_pool, q); |
| } |
} |
| |
|
| |
if (nfrags != fp->ipq_nfrags) |
| |
printf("ip_freef: nfrags %d != %d\n", fp->ipq_nfrags, nfrags); |
| |
ip_nfrags -= nfrags; |
| LIST_REMOVE(fp, ipq_q); |
LIST_REMOVE(fp, ipq_q); |
| FREE(fp, M_FTABLE); |
FREE(fp, M_FTABLE); |
| ip_nfragpackets--; |
ip_nfragpackets--; |