frag6: small improvements
Rather than walking the mbuf chain manually use m_last() which doing exactly that for us. Defer initializing srcifp for longer as there are multiple exit paths out of the function which do not need it set. Initialize before taking the lock though. Rename the mtx lock to match the type better. MFC after: 3 weeks Sponsored by: Netflix
This commit is contained in:
parent
8194a6554c
commit
6d29bbbab8
@ -399,9 +399,6 @@ frag6_input(struct mbuf **mp, int *offp, int proto)
|
||||
return (IPPROTO_DONE);
|
||||
#endif
|
||||
|
||||
/* Store receive network interface pointer for later. */
|
||||
srcifp = m->m_pkthdr.rcvif;
|
||||
|
||||
dstifp = NULL;
|
||||
/* Find the destination interface of the packet. */
|
||||
ia6 = in6ifa_ifwithaddr(&ip6->ip6_dst, 0 /* XXX */);
|
||||
@ -461,6 +458,9 @@ frag6_input(struct mbuf **mp, int *offp, int proto)
|
||||
return (IPPROTO_DONE);
|
||||
}
|
||||
|
||||
/* Store receive network interface pointer for later. */
|
||||
srcifp = m->m_pkthdr.rcvif;
|
||||
|
||||
/* Generate a hash value for fragment bucket selection. */
|
||||
hashkeyp = hashkey;
|
||||
memcpy(hashkeyp, &ip6->ip6_src, sizeof(struct in6_addr));
|
||||
@ -739,8 +739,7 @@ frag6_input(struct mbuf **mp, int *offp, int proto)
|
||||
af6->ip6af_m->m_pkthdr.csum_data;
|
||||
|
||||
TAILQ_REMOVE(&q6->ip6q_frags, af6, ip6af_tq);
|
||||
while (t->m_next)
|
||||
t = t->m_next;
|
||||
t = m_last(t);
|
||||
m_adj(af6->ip6af_m, af6->ip6af_offset);
|
||||
m_demote_pkthdr(af6->ip6af_m);
|
||||
m_cat(t, af6->ip6af_m);
|
||||
@ -930,7 +929,7 @@ frag6_init(void)
|
||||
frag6_set_bucketsize();
|
||||
for (bucket = 0; bucket < IP6REASS_NHASH; bucket++) {
|
||||
TAILQ_INIT(IP6QB_HEAD(bucket));
|
||||
mtx_init(&V_ip6qb[bucket].lock, "ip6qlock", NULL, MTX_DEF);
|
||||
mtx_init(&V_ip6qb[bucket].lock, "ip6qb", NULL, MTX_DEF);
|
||||
V_ip6qb[bucket].count = 0;
|
||||
}
|
||||
V_ip6qb_hashseed = arc4random();
|
||||
|
Loading…
Reference in New Issue
Block a user