summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbms <bms@FreeBSD.org>2009-04-04 15:32:23 +0000
committerbms <bms@FreeBSD.org>2009-04-04 15:32:23 +0000
commitd3a98ed39c23ba1b216f968857850cec58aa14bb (patch)
tree2bf57e2496e8542c96be7eaddace1fbdf0882997
parentb8d7b83e60ca996de5011a38220cc06453f67a26 (diff)
downloadFreeBSD-src-d3a98ed39c23ba1b216f968857850cec58aa14bb.zip
FreeBSD-src-d3a98ed39c23ba1b216f968857850cec58aa14bb.tar.gz
Fix mbuf chain layout pessimization:
in the case where a single mbuf is allocated due to m_getcl() returning NULL, we already call MH_ALIGN, so do not increment m->m_data in this case. Found during MLDv2 port.
-rw-r--r--sys/netinet/igmp.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c
index e9da57a..6b46d55 100644
--- a/sys/netinet/igmp.c
+++ b/sys/netinet/igmp.c
@@ -2784,8 +2784,11 @@ igmp_v3_enqueue_group_record(struct ifqueue *ifq, struct in_multi *inm,
m = NULL;
m0srcs = (ifp->if_mtu - IGMP_LEADINGSPACE -
sizeof(struct igmp_grouprec)) / sizeof(in_addr_t);
- if (!is_state_change && !is_group_query)
+ if (!is_state_change && !is_group_query) {
m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
+ if (m)
+ m->m_data += IGMP_LEADINGSPACE;
+ }
if (m == NULL) {
m = m_gethdr(M_DONTWAIT, MT_DATA);
if (m)
@@ -2793,7 +2796,6 @@ igmp_v3_enqueue_group_record(struct ifqueue *ifq, struct in_multi *inm,
}
if (m == NULL)
return (-ENOMEM);
- m->m_data += IGMP_LEADINGSPACE;
igmp_save_context(m, ifp);
@@ -2909,6 +2911,8 @@ igmp_v3_enqueue_group_record(struct ifqueue *ifq, struct in_multi *inm,
return (-ENOMEM);
}
m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
+ if (m)
+ m->m_data += IGMP_LEADINGSPACE;
if (m == NULL) {
m = m_gethdr(M_DONTWAIT, MT_DATA);
if (m)
@@ -2917,7 +2921,6 @@ igmp_v3_enqueue_group_record(struct ifqueue *ifq, struct in_multi *inm,
if (m == NULL)
return (-ENOMEM);
igmp_save_context(m, ifp);
- m->m_data += IGMP_LEADINGSPACE;
md = m_getptr(m, 0, &off);
pig = (struct igmp_grouprec *)(mtod(md, uint8_t *) + off);
CTR1(KTR_IGMPV3, "%s: allocated next packet", __func__);
@@ -3063,6 +3066,8 @@ igmp_v3_enqueue_filter_change(struct ifqueue *ifq, struct in_multi *inm)
"%s: use previous packet", __func__);
} else {
m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
+ if (m)
+ m->m_data += IGMP_LEADINGSPACE;
if (m == NULL) {
m = m_gethdr(M_DONTWAIT, MT_DATA);
if (m)
@@ -3075,7 +3080,6 @@ igmp_v3_enqueue_filter_change(struct ifqueue *ifq, struct in_multi *inm)
}
m->m_pkthdr.PH_vt.vt_nrecs = 0;
igmp_save_context(m, ifp);
- m->m_data += IGMP_LEADINGSPACE;
m0srcs = (ifp->if_mtu - IGMP_LEADINGSPACE -
sizeof(struct igmp_grouprec)) /
sizeof(in_addr_t);
OpenPOWER on IntegriCloud