numam-dpdk/lib/librte_ip_frag
Yicai Lu 324242fb51 ip_frag: remove padding length of fragment
In some situations, we would get several ip fragments, which total
data length is less than min_ip_len(64) and padding with zeros.
We simulated intermediate fragments by modifying the MTU.
To illustrate the problem, we simplify the packet format and
ignore the impact of the packet header.In namespace2,
a packet whose data length is 1520 is sent.
When the packet passes tap2, the packet is divided into two
fragments: fragment A and B, similar to (1520 = 1510 + 10).
When the packet passes tap3, the larger fragment packet A is
divided into two fragments A1 and A2, similar to (1510 = 1500 + 10).
Finally, the bond interface receives three fragments:
A1, A2, and B (1520 = 1500 + 10 + 10).
One fragmented packet A2 is smaller than the minimum Ethernet
frame length, so it needs to be padded.

|---------------------------------------------------|
|                      HOST                         |
| |--------------|   |----------------------------| |
| |      ns2     |   |      |--------------|      | |
| |  |--------|  |   |  |--------|    |--------|  | |
| |  |  tap1  |  |   |  |  tap2  | ns1|  tap3  |  | |
| |  |mtu=1510|  |   |  |mtu=1510|    |mtu=1500|  | |
| |--|1.1.1.1 |--|   |--|1.1.1.2 |----|2.1.1.1 |--| |
|    |--------|         |--------|    |--------|    |
|         |                 |              |        |
|         |-----------------|              |        |
|                                          |        |
|                                      |--------|   |
|                                      |  bond  |   |
|--------------------------------------|mtu=1500|---|
                                       |--------|

When processing the preceding packets above,
DPDK would aggregate fragmented packets A2 and B.
And error packets are generated, which padding(zero)
is displayed in the middle of the packet.

A2 + B:
0000   fa 16 3e 9f fb 82 fa 47 b2 57 dc 20 08 00 45 00
0010   00 33 b4 66 00 ba 3f 01 c1 a5 01 01 01 01 02 01
0020   01 02 c0 c1 c2 c3 c4 c5 c6 c7 00 00 00 00 00 00
0030   00 00 00 00 00 00 00 00 00 00 00 00 c8 c9 ca cb
0040   cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db
0050   dc dd de df e0 e1 e2 e3 e4 e5 e6

So, we would calculate the length of padding, and remove
the padding in pkt_len and data_len before aggregation.
And also we have the fix for both ipv4 and ipv6.

Fixes: 7f0983ee33 ("ip_frag: check fragment length of incoming packet")
Cc: stable@dpdk.org

Signed-off-by: Yicai Lu <luyicai@huawei.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
2021-01-15 11:31:28 +01:00
..
ip_frag_common.h ip_frag: use key length for key comparison 2018-11-06 01:58:11 +01:00
ip_frag_internal.c lib: use common macro RTE_DIM 2020-02-05 14:37:41 +01:00
meson.build build: replace license text with SPDX tag 2018-01-30 21:58:59 +01:00
rte_ip_frag_common.c remove experimental tags from all symbol definitions 2019-06-29 19:04:43 +02:00
rte_ip_frag.h ethdev: add IPv6 fragment extension header item 2020-10-16 19:48:18 +02:00
rte_ipv4_fragmentation.c ip_frag: ensure minimum v4 fragmentation length 2020-04-25 15:15:23 +02:00
rte_ipv4_reassembly.c ip_frag: remove padding length of fragment 2021-01-15 11:31:28 +01:00
rte_ipv6_fragmentation.c ip_frag: ensure minimum v6 fragmentation length 2020-04-25 15:15:27 +02:00
rte_ipv6_reassembly.c ip_frag: remove padding length of fragment 2021-01-15 11:31:28 +01:00
version.map build: remove library name from version map file name 2020-10-19 22:13:59 +02:00