summaryrefslogtreecommitdiff
path: root/lib/librte_ip_frag
diff options
context:
space:
mode:
authorSimon Kagstrom <simon.kagstrom@netinsight.net>2015-10-15 09:01:46 +0200
committerThomas Monjalon <thomas.monjalon@6wind.com>2015-10-25 00:00:34 +0200
commit139debc42dc0a320dad40f5295b74d2e3ab8a7f9 (patch)
tree00ef2b907496a1281a8e93179b512376bcd8f839 /lib/librte_ip_frag
parentfd4b6f78adcb85b437450be0d560773bdbb71f69 (diff)
downloaddpdk-139debc42dc0a320dad40f5295b74d2e3ab8a7f9.zip
dpdk-139debc42dc0a320dad40f5295b74d2e3ab8a7f9.tar.gz
dpdk-139debc42dc0a320dad40f5295b74d2e3ab8a7f9.tar.xz
mbuf: move chaining from ip_frag library
Chaining/segmenting mbufs can be useful in many places, so make it global. Signed-off-by: Simon Kagstrom <simon.kagstrom@netinsight.net> Signed-off-by: Johan Faltstrom <johan.faltstrom@netinsight.net> Acked-by: Olivier Matz <olivier.matz@6wind.com>
Diffstat (limited to 'lib/librte_ip_frag')
-rw-r--r--lib/librte_ip_frag/ip_frag_common.h23
-rw-r--r--lib/librte_ip_frag/rte_ipv4_reassembly.c7
-rw-r--r--lib/librte_ip_frag/rte_ipv6_reassembly.c7
3 files changed, 10 insertions, 27 deletions
diff --git a/lib/librte_ip_frag/ip_frag_common.h b/lib/librte_ip_frag/ip_frag_common.h
index 6b2acee..cde6ed4 100644
--- a/lib/librte_ip_frag/ip_frag_common.h
+++ b/lib/librte_ip_frag/ip_frag_common.h
@@ -166,27 +166,4 @@ ip_frag_reset(struct ip_frag_pkt *fp, uint64_t tms)
fp->frags[IP_FIRST_FRAG_IDX] = zero_frag;
}
-/* chain two mbufs */
-static inline void
-ip_frag_chain(struct rte_mbuf *mn, struct rte_mbuf *mp)
-{
- struct rte_mbuf *ms;
-
- /* adjust start of the last fragment data. */
- rte_pktmbuf_adj(mp, (uint16_t)(mp->l2_len + mp->l3_len));
-
- /* chain two fragments. */
- ms = rte_pktmbuf_lastseg(mn);
- ms->next = mp;
-
- /* accumulate number of segments and total length. */
- mn->nb_segs = (uint8_t)(mn->nb_segs + mp->nb_segs);
- mn->pkt_len += mp->pkt_len;
-
- /* reset pkt_len and nb_segs for chained fragment. */
- mp->pkt_len = mp->data_len;
- mp->nb_segs = 1;
-}
-
-
#endif /* _IP_FRAG_COMMON_H_ */
diff --git a/lib/librte_ip_frag/rte_ipv4_reassembly.c b/lib/librte_ip_frag/rte_ipv4_reassembly.c
index 5d24843..26d07f9 100644
--- a/lib/librte_ip_frag/rte_ipv4_reassembly.c
+++ b/lib/librte_ip_frag/rte_ipv4_reassembly.c
@@ -63,7 +63,9 @@ ipv4_frag_reassemble(const struct ip_frag_pkt *fp)
/* previous fragment found. */
if(fp->frags[i].ofs + fp->frags[i].len == ofs) {
- ip_frag_chain(fp->frags[i].mb, m);
+ /* adjust start of the last fragment data. */
+ rte_pktmbuf_adj(m, (uint16_t)(m->l2_len + m->l3_len));
+ rte_pktmbuf_chain(fp->frags[i].mb, m);
/* update our last fragment and offset. */
m = fp->frags[i].mb;
@@ -78,7 +80,8 @@ ipv4_frag_reassemble(const struct ip_frag_pkt *fp)
}
/* chain with the first fragment. */
- ip_frag_chain(fp->frags[IP_FIRST_FRAG_IDX].mb, m);
+ rte_pktmbuf_adj(m, (uint16_t)(m->l2_len + m->l3_len));
+ rte_pktmbuf_chain(fp->frags[IP_FIRST_FRAG_IDX].mb, m);
m = fp->frags[IP_FIRST_FRAG_IDX].mb;
/* update mbuf fields for reassembled packet. */
diff --git a/lib/librte_ip_frag/rte_ipv6_reassembly.c b/lib/librte_ip_frag/rte_ipv6_reassembly.c
index 8b4ef8a..d29cb1d 100644
--- a/lib/librte_ip_frag/rte_ipv6_reassembly.c
+++ b/lib/librte_ip_frag/rte_ipv6_reassembly.c
@@ -86,7 +86,9 @@ ipv6_frag_reassemble(const struct ip_frag_pkt *fp)
/* previous fragment found. */
if (fp->frags[i].ofs + fp->frags[i].len == ofs) {
- ip_frag_chain(fp->frags[i].mb, m);
+ /* adjust start of the last fragment data. */
+ rte_pktmbuf_adj(m, (uint16_t)(m->l2_len + m->l3_len));
+ rte_pktmbuf_chain(fp->frags[i].mb, m);
/* update our last fragment and offset. */
m = fp->frags[i].mb;
@@ -101,7 +103,8 @@ ipv6_frag_reassemble(const struct ip_frag_pkt *fp)
}
/* chain with the first fragment. */
- ip_frag_chain(fp->frags[IP_FIRST_FRAG_IDX].mb, m);
+ rte_pktmbuf_adj(m, (uint16_t)(m->l2_len + m->l3_len));
+ rte_pktmbuf_chain(fp->frags[IP_FIRST_FRAG_IDX].mb, m);
m = fp->frags[IP_FIRST_FRAG_IDX].mb;
/* update mbuf fields for reassembled packet. */