LCOV - code coverage report
Current view: top level - app/test - test_security_inline_proto_vectors.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 34 0.0 %
Date: 2024-04-01 19:00:53 Functions: 0 1 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 32 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(C) 2022 Marvell.
       3                 :            :  */
       4                 :            : #ifndef _TEST_INLINE_IPSEC_REASSEMBLY_VECTORS_H_
       5                 :            : #define _TEST_INLINE_IPSEC_REASSEMBLY_VECTORS_H_
       6                 :            : 
       7                 :            : #include "test_cryptodev_security_ipsec.h"
       8                 :            : 
       9                 :            : uint8_t dummy_ipv4_eth_hdr[] = {
      10                 :            :                 /* ETH */
      11                 :            :                 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1,
      12                 :            :                 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0x08, 0x00,
      13                 :            : };
      14                 :            : uint8_t dummy_ipv6_eth_hdr[] = {
      15                 :            :                 /* ETH */
      16                 :            :                 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1,
      17                 :            :                 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0x86, 0xdd,
      18                 :            : };
      19                 :            : 
      20                 :            : #define MAX_FRAG_LEN             IPSEC_TEXT_MAX_LEN
      21                 :            : #define MAX_FRAGS                6
      22                 :            : #define MAX_PKT_LEN              (MAX_FRAG_LEN * MAX_FRAGS)
      23                 :            : 
      24                 :            : struct ip_reassembly_test_packet {
      25                 :            :         uint32_t len;
      26                 :            :         uint32_t l4_offset;
      27                 :            :         uint8_t data[MAX_PKT_LEN];
      28                 :            : };
      29                 :            : 
      30                 :            : struct reassembly_vector {
      31                 :            :         /* input/output text in struct ipsec_test_data are not used */
      32                 :            :         struct ipsec_test_data *sa_data;
      33                 :            :         struct ip_reassembly_test_packet *full_pkt;
      34                 :            :         struct ip_reassembly_test_packet *frags[MAX_FRAGS];
      35                 :            :         uint16_t nb_frags;
      36                 :            :         bool burst;
      37                 :            : };
      38                 :            : 
      39                 :            : struct ip_pkt_vector {
      40                 :            :         /* input/output text in struct ipsec_test_data are not used */
      41                 :            :         struct ipsec_test_data *sa_data;
      42                 :            :         struct ip_reassembly_test_packet *full_pkt;
      43                 :            :         bool burst;
      44                 :            : };
      45                 :            : 
      46                 :            : struct sa_expiry_vector {
      47                 :            :         struct ipsec_session_data *sa_data;
      48                 :            :         enum rte_eth_event_ipsec_subtype event;
      49                 :            :         bool notify_event;
      50                 :            : };
      51                 :            : 
      52                 :            : /* The source file includes below test vectors */
      53                 :            : /* IPv6:
      54                 :            :  *
      55                 :            :  *      1) pkt_ipv6_udp_p1
      56                 :            :  *              pkt_ipv6_udp_p1_f1
      57                 :            :  *              pkt_ipv6_udp_p1_f2
      58                 :            :  *
      59                 :            :  *      2) pkt_ipv6_udp_p2
      60                 :            :  *              pkt_ipv6_udp_p2_f1
      61                 :            :  *              pkt_ipv6_udp_p2_f2
      62                 :            :  *              pkt_ipv6_udp_p2_f3
      63                 :            :  *              pkt_ipv6_udp_p2_f4
      64                 :            :  *
      65                 :            :  *      3) pkt_ipv6_udp_p3
      66                 :            :  *              pkt_ipv6_udp_p3_f1
      67                 :            :  *              pkt_ipv6_udp_p3_f2
      68                 :            :  *              pkt_ipv6_udp_p3_f3
      69                 :            :  *              pkt_ipv6_udp_p3_f4
      70                 :            :  *              pkt_ipv6_udp_p3_f5
      71                 :            :  */
      72                 :            : 
      73                 :            : /* IPv4:
      74                 :            :  *
      75                 :            :  *      1) pkt_ipv4_udp_p1
      76                 :            :  *              pkt_ipv4_udp_p1_f1
      77                 :            :  *              pkt_ipv4_udp_p1_f2
      78                 :            :  *
      79                 :            :  *      2) pkt_ipv4_udp_p2
      80                 :            :  *              pkt_ipv4_udp_p2_f1
      81                 :            :  *              pkt_ipv4_udp_p2_f2
      82                 :            :  *              pkt_ipv4_udp_p2_f3
      83                 :            :  *              pkt_ipv4_udp_p2_f4
      84                 :            :  *
      85                 :            :  *      3) pkt_ipv4_udp_p3
      86                 :            :  *              pkt_ipv4_udp_p3_f1
      87                 :            :  *              pkt_ipv4_udp_p3_f2
      88                 :            :  *              pkt_ipv4_udp_p3_f3
      89                 :            :  *              pkt_ipv4_udp_p3_f4
      90                 :            :  *              pkt_ipv4_udp_p3_f5
      91                 :            :  */
      92                 :            : 
      93                 :            : struct ip_reassembly_test_packet pkt_ipv6_udp_p1 = {
      94                 :            :         .len = 1500,
      95                 :            :         .l4_offset = 40,
      96                 :            :         .data = {
      97                 :            :                 /* IP */
      98                 :            :                 0x60, 0x00, 0x00, 0x00, 0x05, 0xb4, 0x11, 0x40,
      99                 :            :                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     100                 :            :                 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
     101                 :            :                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     102                 :            :                 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
     103                 :            : 
     104                 :            :                 /* UDP */
     105                 :            :                 0x08, 0x00, 0x27, 0x10, 0x05, 0xb4, 0x2b, 0xe8,
     106                 :            :         },
     107                 :            : };
     108                 :            : 
     109                 :            : struct ip_reassembly_test_packet pkt_ipv6_udp_p1_f1 = {
     110                 :            :         .len = 1384,
     111                 :            :         .l4_offset = 48,
     112                 :            :         .data = {
     113                 :            :                 /* IP */
     114                 :            :                 0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
     115                 :            :                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     116                 :            :                 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
     117                 :            :                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     118                 :            :                 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
     119                 :            :                 0x11, 0x00, 0x00, 0x01, 0x5c, 0x92, 0xac, 0xf1,
     120                 :            : 
     121                 :            :                 /* UDP */
     122                 :            :                 0x08, 0x00, 0x27, 0x10, 0x05, 0xb4, 0x2b, 0xe8,
     123                 :            :         },
     124                 :            : };
     125                 :            : 
     126                 :            : struct ip_reassembly_test_packet pkt_ipv6_udp_p1_f2 = {
     127                 :            :         .len = 172,
     128                 :            :         .l4_offset = 48,
     129                 :            :         .data = {
     130                 :            :                 /* IP */
     131                 :            :                 0x60, 0x00, 0x00, 0x00, 0x00, 0x84, 0x2c, 0x40,
     132                 :            :                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     133                 :            :                 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
     134                 :            :                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     135                 :            :                 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
     136                 :            :                 0x11, 0x00, 0x05, 0x38, 0x5c, 0x92, 0xac, 0xf1,
     137                 :            :         },
     138                 :            : };
     139                 :            : 
     140                 :            : struct ip_reassembly_test_packet pkt_ipv6_udp_p2 = {
     141                 :            :         .len = 4482,
     142                 :            :         .l4_offset = 40,
     143                 :            :         .data = {
     144                 :            :                 /* IP */
     145                 :            :                 0x60, 0x00, 0x00, 0x00, 0x11, 0x5a, 0x11, 0x40,
     146                 :            :                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     147                 :            :                 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
     148                 :            :                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     149                 :            :                 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
     150                 :            : 
     151                 :            :                 /* UDP */
     152                 :            :                 0x08, 0x00, 0x27, 0x10, 0x11, 0x5a, 0x8a, 0x11,
     153                 :            :         },
     154                 :            : };
     155                 :            : 
     156                 :            : struct ip_reassembly_test_packet pkt_ipv6_udp_p2_f1 = {
     157                 :            :         .len = 1384,
     158                 :            :         .l4_offset = 48,
     159                 :            :         .data = {
     160                 :            :                 /* IP */
     161                 :            :                 0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
     162                 :            :                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     163                 :            :                 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
     164                 :            :                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     165                 :            :                 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
     166                 :            :                 0x11, 0x00, 0x00, 0x01, 0x64, 0x6c, 0x68, 0x9f,
     167                 :            : 
     168                 :            :                 /* UDP */
     169                 :            :                 0x08, 0x00, 0x27, 0x10, 0x11, 0x5a, 0x8a, 0x11,
     170                 :            :         },
     171                 :            : };
     172                 :            : 
     173                 :            : struct ip_reassembly_test_packet pkt_ipv6_udp_p2_f2 = {
     174                 :            :         .len = 1384,
     175                 :            :         .l4_offset = 48,
     176                 :            :         .data = {
     177                 :            :                 /* IP */
     178                 :            :                 0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
     179                 :            :                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     180                 :            :                 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
     181                 :            :                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     182                 :            :                 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
     183                 :            :                 0x11, 0x00, 0x05, 0x39, 0x64, 0x6c, 0x68, 0x9f,
     184                 :            :         },
     185                 :            : };
     186                 :            : 
     187                 :            : struct ip_reassembly_test_packet pkt_ipv6_udp_p2_f3 = {
     188                 :            :         .len = 1384,
     189                 :            :         .l4_offset = 48,
     190                 :            :         .data = {
     191                 :            :                 /* IP */
     192                 :            :                 0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
     193                 :            :                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     194                 :            :                 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
     195                 :            :                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     196                 :            :                 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
     197                 :            :                 0x11, 0x00, 0x0a, 0x71, 0x64, 0x6c, 0x68, 0x9f,
     198                 :            :         },
     199                 :            : };
     200                 :            : 
     201                 :            : struct ip_reassembly_test_packet pkt_ipv6_udp_p2_f4 = {
     202                 :            :         .len = 482,
     203                 :            :         .l4_offset = 48,
     204                 :            :         .data = {
     205                 :            :                 /* IP */
     206                 :            :                 0x60, 0x00, 0x00, 0x00, 0x01, 0xba, 0x2c, 0x40,
     207                 :            :                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     208                 :            :                 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
     209                 :            :                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     210                 :            :                 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
     211                 :            :                 0x11, 0x00, 0x0f, 0xa8, 0x64, 0x6c, 0x68, 0x9f,
     212                 :            :         },
     213                 :            : };
     214                 :            : 
     215                 :            : struct ip_reassembly_test_packet pkt_ipv6_udp_p3 = {
     216                 :            :         .len = 5782,
     217                 :            :         .l4_offset = 40,
     218                 :            :         .data = {
     219                 :            :                 /* IP */
     220                 :            :                 0x60, 0x00, 0x00, 0x00, 0x16, 0x6e, 0x2c, 0x40,
     221                 :            :                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     222                 :            :                 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
     223                 :            :                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     224                 :            :                 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
     225                 :            : 
     226                 :            :                 /* UDP */
     227                 :            :                 0x08, 0x00, 0x27, 0x10, 0x16, 0x6e, 0x2f, 0x99,
     228                 :            :         },
     229                 :            : };
     230                 :            : 
     231                 :            : struct ip_reassembly_test_packet pkt_ipv6_udp_p3_f1 = {
     232                 :            :         .len = 1384,
     233                 :            :         .l4_offset = 48,
     234                 :            :         .data = {
     235                 :            :                 /* IP */
     236                 :            :                 0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
     237                 :            :                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     238                 :            :                 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
     239                 :            :                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     240                 :            :                 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
     241                 :            :                 0x11, 0x00, 0x00, 0x01, 0x65, 0xcf, 0x5a, 0xae,
     242                 :            : 
     243                 :            :                 /* UDP */
     244                 :            :                 0x80, 0x00, 0x27, 0x10, 0x16, 0x6e, 0x2f, 0x99,
     245                 :            :         },
     246                 :            : };
     247                 :            : 
     248                 :            : struct ip_reassembly_test_packet pkt_ipv6_udp_p3_f2 = {
     249                 :            :         .len = 1384,
     250                 :            :         .l4_offset = 48,
     251                 :            :         .data = {
     252                 :            :                 /* IP */
     253                 :            :                 0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
     254                 :            :                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     255                 :            :                 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
     256                 :            :                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     257                 :            :                 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
     258                 :            :                 0x11, 0x00, 0x05, 0x39, 0x65, 0xcf, 0x5a, 0xae,
     259                 :            :         },
     260                 :            : };
     261                 :            : 
     262                 :            : struct ip_reassembly_test_packet pkt_ipv6_udp_p3_f3 = {
     263                 :            :         .len = 1384,
     264                 :            :         .l4_offset = 48,
     265                 :            :         .data = {
     266                 :            :                 /* IP */
     267                 :            :                 0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
     268                 :            :                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     269                 :            :                 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
     270                 :            :                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     271                 :            :                 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
     272                 :            :                 0x11, 0x00, 0x0a, 0x71, 0x65, 0xcf, 0x5a, 0xae,
     273                 :            :         },
     274                 :            : };
     275                 :            : 
     276                 :            : struct ip_reassembly_test_packet pkt_ipv6_udp_p3_f4 = {
     277                 :            :         .len = 1384,
     278                 :            :         .l4_offset = 48,
     279                 :            :         .data = {
     280                 :            :                 /* IP */
     281                 :            :                 0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
     282                 :            :                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     283                 :            :                 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
     284                 :            :                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     285                 :            :                 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
     286                 :            :                 0x11, 0x00, 0x0f, 0xa9, 0x65, 0xcf, 0x5a, 0xae,
     287                 :            :         },
     288                 :            : };
     289                 :            : 
     290                 :            : struct ip_reassembly_test_packet pkt_ipv6_udp_p3_f5 = {
     291                 :            :         .len = 446,
     292                 :            :         .l4_offset = 48,
     293                 :            :         .data = {
     294                 :            :                 /* IP */
     295                 :            :                 0x60, 0x00, 0x00, 0x00, 0x01, 0x96, 0x2c, 0x40,
     296                 :            :                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     297                 :            :                 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
     298                 :            :                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     299                 :            :                 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
     300                 :            :                 0x11, 0x00, 0x14, 0xe0, 0x65, 0xcf, 0x5a, 0xae,
     301                 :            :         },
     302                 :            : };
     303                 :            : 
     304                 :            : struct ip_reassembly_test_packet pkt_ipv4_udp = {
     305                 :            :         .len = 1200,
     306                 :            :         .l4_offset = 20,
     307                 :            :         .data = {
     308                 :            :                 /* IP */
     309                 :            :                 0x45, 0x00, 0x04, 0xb0, 0x00, 0x01, 0x00, 0x00,
     310                 :            :                 0x40, 0x11, 0x66, 0x0d, 0x0d, 0x00, 0x00, 0x02,
     311                 :            :                 0x02, 0x00, 0x00, 0x02,
     312                 :            : 
     313                 :            :                 /* UDP */
     314                 :            :                 0x08, 0x00, 0x27, 0x10, 0x05, 0xc8, 0xb8, 0x4c,
     315                 :            :         },
     316                 :            : };
     317                 :            : 
     318                 :            : struct ip_reassembly_test_packet pkt_ipv4_udp_p1 = {
     319                 :            :         .len = 1500,
     320                 :            :         .l4_offset = 20,
     321                 :            :         .data = {
     322                 :            :                 /* IP */
     323                 :            :                 0x45, 0x00, 0x05, 0xdc, 0x00, 0x01, 0x00, 0x00,
     324                 :            :                 0x40, 0x11, 0x66, 0x0d, 0x0d, 0x00, 0x00, 0x02,
     325                 :            :                 0x02, 0x00, 0x00, 0x02,
     326                 :            : 
     327                 :            :                 /* UDP */
     328                 :            :                 0x08, 0x00, 0x27, 0x10, 0x05, 0xc8, 0xb8, 0x4c,
     329                 :            :         },
     330                 :            : };
     331                 :            : 
     332                 :            : struct ip_reassembly_test_packet pkt_ipv4_udp_p1_f1 = {
     333                 :            :         .len = 1420,
     334                 :            :         .l4_offset = 20,
     335                 :            :         .data = {
     336                 :            :                 /* IP */
     337                 :            :                 0x45, 0x00, 0x05, 0x8c, 0x00, 0x01, 0x20, 0x00,
     338                 :            :                 0x40, 0x11, 0x46, 0x5d, 0x0d, 0x00, 0x00, 0x02,
     339                 :            :                 0x02, 0x00, 0x00, 0x02,
     340                 :            : 
     341                 :            :                 /* UDP */
     342                 :            :                 0x08, 0x00, 0x27, 0x10, 0x05, 0xc8, 0xb8, 0x4c,
     343                 :            :         },
     344                 :            : };
     345                 :            : 
     346                 :            : struct ip_reassembly_test_packet pkt_ipv4_udp_p1_f2 = {
     347                 :            :         .len = 100,
     348                 :            :         .l4_offset = 20,
     349                 :            :         .data = {
     350                 :            :                 /* IP */
     351                 :            :                 0x45, 0x00, 0x00, 0x64, 0x00, 0x01, 0x00, 0xaf,
     352                 :            :                 0x40, 0x11, 0x6a, 0xd6, 0x0d, 0x00, 0x00, 0x02,
     353                 :            :                 0x02, 0x00, 0x00, 0x02,
     354                 :            :         },
     355                 :            : };
     356                 :            : 
     357                 :            : struct ip_reassembly_test_packet pkt_ipv4_udp_p2 = {
     358                 :            :         .len = 4482,
     359                 :            :         .l4_offset = 20,
     360                 :            :         .data = {
     361                 :            :                 /* IP */
     362                 :            :                 0x45, 0x00, 0x11, 0x82, 0x00, 0x02, 0x00, 0x00,
     363                 :            :                 0x40, 0x11, 0x5a, 0x66, 0x0d, 0x00, 0x00, 0x02,
     364                 :            :                 0x02, 0x00, 0x00, 0x02,
     365                 :            : 
     366                 :            :                 /* UDP */
     367                 :            :                 0x08, 0x00, 0x27, 0x10, 0x11, 0x6e, 0x16, 0x76,
     368                 :            :         },
     369                 :            : };
     370                 :            : 
     371                 :            : struct ip_reassembly_test_packet pkt_ipv4_udp_p2_f1 = {
     372                 :            :         .len = 1420,
     373                 :            :         .l4_offset = 20,
     374                 :            :         .data = {
     375                 :            :                 /* IP */
     376                 :            :                 0x45, 0x00, 0x05, 0x8c, 0x00, 0x02, 0x20, 0x00,
     377                 :            :                 0x40, 0x11, 0x46, 0x5c, 0x0d, 0x00, 0x00, 0x02,
     378                 :            :                 0x02, 0x00, 0x00, 0x02,
     379                 :            : 
     380                 :            :                 /* UDP */
     381                 :            :                 0x08, 0x00, 0x27, 0x10, 0x11, 0x6e, 0x16, 0x76,
     382                 :            :         },
     383                 :            : };
     384                 :            : 
     385                 :            : struct ip_reassembly_test_packet pkt_ipv4_udp_p2_f2 = {
     386                 :            :         .len = 1420,
     387                 :            :         .l4_offset = 20,
     388                 :            :         .data = {
     389                 :            :                 /* IP */
     390                 :            :                 0x45, 0x00, 0x05, 0x8c, 0x00, 0x02, 0x20, 0xaf,
     391                 :            :                 0x40, 0x11, 0x45, 0xad, 0x0d, 0x00, 0x00, 0x02,
     392                 :            :                 0x02, 0x00, 0x00, 0x02,
     393                 :            :         },
     394                 :            : };
     395                 :            : 
     396                 :            : struct ip_reassembly_test_packet pkt_ipv4_udp_p2_f3 = {
     397                 :            :         .len = 1420,
     398                 :            :         .l4_offset = 20,
     399                 :            :         .data = {
     400                 :            :                 /* IP */
     401                 :            :                 0x45, 0x00, 0x05, 0x8c, 0x00, 0x02, 0x21, 0x5e,
     402                 :            :                 0x40, 0x11, 0x44, 0xfe, 0x0d, 0x00, 0x00, 0x02,
     403                 :            :                 0x02, 0x00, 0x00, 0x02,
     404                 :            :         },
     405                 :            : };
     406                 :            : 
     407                 :            : struct ip_reassembly_test_packet pkt_ipv4_udp_p2_f4 = {
     408                 :            :         .len = 282,
     409                 :            :         .l4_offset = 20,
     410                 :            :         .data = {
     411                 :            :                 /* IP */
     412                 :            :                 0x45, 0x00, 0x01, 0x1a, 0x00, 0x02, 0x02, 0x0d,
     413                 :            :                 0x40, 0x11, 0x68, 0xc1, 0x0d, 0x00, 0x00, 0x02,
     414                 :            :                 0x02, 0x00, 0x00, 0x02,
     415                 :            :         },
     416                 :            : };
     417                 :            : 
     418                 :            : struct ip_reassembly_test_packet pkt_ipv4_udp_p3 = {
     419                 :            :         .len = 5782,
     420                 :            :         .l4_offset = 20,
     421                 :            :         .data = {
     422                 :            :                 /* IP */
     423                 :            :                 0x45, 0x00, 0x16, 0x96, 0x00, 0x03, 0x00, 0x00,
     424                 :            :                 0x40, 0x11, 0x55, 0x51, 0x0d, 0x00, 0x00, 0x02,
     425                 :            :                 0x02, 0x00, 0x00, 0x02,
     426                 :            : 
     427                 :            :                 /* UDP */
     428                 :            :                 0x08, 0x00, 0x27, 0x10, 0x16, 0x82, 0xbb, 0xfd,
     429                 :            :         },
     430                 :            : };
     431                 :            : 
     432                 :            : struct ip_reassembly_test_packet pkt_ipv4_udp_p3_f1 = {
     433                 :            :         .len = 1420,
     434                 :            :         .l4_offset = 20,
     435                 :            :         .data = {
     436                 :            :                 /* IP */
     437                 :            :                 0x45, 0x00, 0x05, 0x8c, 0x00, 0x03, 0x20, 0x00,
     438                 :            :                 0x40, 0x11, 0x46, 0x5b, 0x0d, 0x00, 0x00, 0x02,
     439                 :            :                 0x02, 0x00, 0x00, 0x02,
     440                 :            : 
     441                 :            :                 /* UDP */
     442                 :            :                 0x80, 0x00, 0x27, 0x10, 0x16, 0x82, 0xbb, 0xfd,
     443                 :            :         },
     444                 :            : };
     445                 :            : 
     446                 :            : struct ip_reassembly_test_packet pkt_ipv4_udp_p3_f2 = {
     447                 :            :         .len = 1420,
     448                 :            :         .l4_offset = 20,
     449                 :            :         .data = {
     450                 :            :                 /* IP */
     451                 :            :                 0x45, 0x00, 0x05, 0x8c, 0x00, 0x03, 0x20, 0xaf,
     452                 :            :                 0x40, 0x11, 0x45, 0xac, 0x0d, 0x00, 0x00, 0x02,
     453                 :            :                 0x02, 0x00, 0x00, 0x02,
     454                 :            :         },
     455                 :            : };
     456                 :            : 
     457                 :            : struct ip_reassembly_test_packet pkt_ipv4_udp_p3_f3 = {
     458                 :            :         .len = 1420,
     459                 :            :         .l4_offset = 20,
     460                 :            :         .data = {
     461                 :            :                 /* IP */
     462                 :            :                 0x45, 0x00, 0x05, 0x8c, 0x00, 0x03, 0x21, 0x5e,
     463                 :            :                 0x40, 0x11, 0x44, 0xfd, 0x0d, 0x00, 0x00, 0x02,
     464                 :            :                 0x02, 0x00, 0x00, 0x02,
     465                 :            :         },
     466                 :            : };
     467                 :            : 
     468                 :            : struct ip_reassembly_test_packet pkt_ipv4_udp_p3_f4 = {
     469                 :            :         .len = 1420,
     470                 :            :         .l4_offset = 20,
     471                 :            :         .data = {
     472                 :            :                 /* IP */
     473                 :            :                 0x45, 0x00, 0x05, 0x8c, 0x00, 0x03, 0x22, 0x0d,
     474                 :            :                 0x40, 0x11, 0x44, 0x4e, 0x0d, 0x00, 0x00, 0x02,
     475                 :            :                 0x02, 0x00, 0x00, 0x02,
     476                 :            :         },
     477                 :            : };
     478                 :            : 
     479                 :            : struct ip_reassembly_test_packet pkt_ipv4_udp_p3_f5 = {
     480                 :            :         .len = 182,
     481                 :            :         .l4_offset = 20,
     482                 :            :         .data = {
     483                 :            :                 /* IP */
     484                 :            :                 0x45, 0x00, 0x00, 0xb6, 0x00, 0x03, 0x02, 0xbc,
     485                 :            :                 0x40, 0x11, 0x68, 0x75, 0x0d, 0x00, 0x00, 0x02,
     486                 :            :                 0x02, 0x00, 0x00, 0x02,
     487                 :            :         },
     488                 :            : };
     489                 :            : 
     490                 :            : static inline void
     491                 :          0 : test_vector_payload_populate(struct ip_reassembly_test_packet *pkt,
     492                 :            :                              bool first_frag, uint16_t extra_data, uint16_t extra_data_sum)
     493                 :            : {
     494                 :          0 :         bool is_ipv6 = ((pkt->data[0] >> 4) == 0x6);
     495                 :          0 :         uint32_t i = pkt->l4_offset;
     496                 :            :         uint16_t len, off;
     497                 :          0 :         size_t ext_len = 0;
     498                 :            :         int proto;
     499                 :            : 
     500                 :            :         /**
     501                 :            :          * For non-fragmented packets and first frag, skip 8 bytes from
     502                 :            :          * l4_offset for UDP header.
     503                 :            :          */
     504         [ #  # ]:          0 :         if (first_frag)
     505                 :          0 :                 i += 8;
     506                 :            : 
     507                 :            :         /* Fixup header and checksum */
     508         [ #  # ]:          0 :         if (extra_data || extra_data_sum) {
     509         [ #  # ]:          0 :                 if (is_ipv6) {
     510                 :            :                         struct rte_ipv6_hdr *hdr = (struct rte_ipv6_hdr *)pkt->data;
     511                 :            :                         struct rte_ipv6_fragment_ext *frag_ext;
     512                 :            :                         uint8_t *p = pkt->data;
     513                 :            :                         uint16_t old_off;
     514                 :            : 
     515         [ #  # ]:          0 :                         len = rte_be_to_cpu_16(hdr->payload_len) + extra_data;
     516         [ #  # ]:          0 :                         hdr->payload_len = rte_cpu_to_be_16(len);
     517                 :            : 
     518                 :            :                         /* Find frag extension header to add to frag offset */
     519         [ #  # ]:          0 :                         if (extra_data_sum) {
     520                 :          0 :                                 proto = hdr->proto;
     521                 :          0 :                                 p += sizeof(struct rte_ipv6_hdr);
     522         [ #  # ]:          0 :                                 while (proto != IPPROTO_FRAGMENT &&
     523         [ #  # ]:          0 :                                        (proto = rte_ipv6_get_next_ext(p, proto, &ext_len) >= 0))
     524                 :          0 :                                         p += ext_len;
     525                 :            : 
     526                 :            :                                 /* Found fragment header, update the frag offset */
     527         [ #  # ]:          0 :                                 if (proto == IPPROTO_FRAGMENT) {
     528                 :            :                                         frag_ext = (struct rte_ipv6_fragment_ext *)p;
     529         [ #  # ]:          0 :                                         old_off = rte_be_to_cpu_16(frag_ext->frag_data);
     530                 :          0 :                                         off = old_off & 0xFFF8;
     531                 :          0 :                                         off += extra_data_sum;
     532         [ #  # ]:          0 :                                         frag_ext->frag_data = rte_cpu_to_be_16(off |
     533                 :            :                                                                                (old_off & 0x7));
     534                 :            :                                 }
     535                 :            :                         }
     536                 :            :                 } else {
     537                 :          0 :                         struct rte_ipv4_hdr *hdr = (struct rte_ipv4_hdr *)pkt->data;
     538         [ #  # ]:          0 :                         uint16_t old_off = rte_be_to_cpu_16(hdr->fragment_offset);
     539                 :            : 
     540         [ #  # ]:          0 :                         len = rte_be_to_cpu_16(hdr->total_length) + extra_data;
     541                 :          0 :                         off = old_off & 0x1FFF;
     542                 :          0 :                         off += (extra_data_sum >> 3);
     543                 :            : 
     544         [ #  # ]:          0 :                         hdr->total_length = rte_cpu_to_be_16(len);
     545         [ #  # ]:          0 :                         hdr->fragment_offset = rte_cpu_to_be_16(off | (old_off & 0xe000));
     546                 :          0 :                         hdr->hdr_checksum = 0;
     547                 :          0 :                         hdr->hdr_checksum = rte_ipv4_cksum(hdr);
     548                 :            :                 }
     549                 :          0 :                 pkt->len += extra_data;
     550                 :            :         }
     551                 :            : 
     552         [ #  # ]:          0 :         for (; i < pkt->len; i++)
     553                 :          0 :                 pkt->data[i] = 0x58;
     554                 :          0 : }
     555                 :            : 
     556                 :            : struct ipsec_test_data conf_aes_128_gcm = {
     557                 :            :         .key = {
     558                 :            :                 .data = {
     559                 :            :                         0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
     560                 :            :                         0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08
     561                 :            :                 },
     562                 :            :         },
     563                 :            : 
     564                 :            :         .salt = {
     565                 :            :                 .data = {
     566                 :            :                         0xca, 0xfe, 0xba, 0xbe
     567                 :            :                 },
     568                 :            :                 .len = 4,
     569                 :            :         },
     570                 :            : 
     571                 :            :         .iv = {
     572                 :            :                 .data = {
     573                 :            :                         0xfa, 0xce, 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88
     574                 :            :                 },
     575                 :            :         },
     576                 :            : 
     577                 :            :         .ipsec_xform = {
     578                 :            :                 .spi = 0xa5f8,
     579                 :            :                 .salt = 0xbebafeca,
     580                 :            :                 .options.esn = 0,
     581                 :            :                 .options.udp_encap = 0,
     582                 :            :                 .options.copy_dscp = 0,
     583                 :            :                 .options.copy_flabel = 0,
     584                 :            :                 .options.copy_df = 0,
     585                 :            :                 .options.dec_ttl = 0,
     586                 :            :                 .options.ecn = 0,
     587                 :            :                 .options.stats = 0,
     588                 :            :                 .options.tunnel_hdr_verify = 0,
     589                 :            :                 .options.ip_csum_enable = 0,
     590                 :            :                 .options.l4_csum_enable = 0,
     591                 :            :                 .options.ip_reassembly_en = 1,
     592                 :            :                 .direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS,
     593                 :            :                 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
     594                 :            :                 .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
     595                 :            :                 .tunnel.type = RTE_SECURITY_IPSEC_TUNNEL_IPV4,
     596                 :            :                 .replay_win_sz = 0,
     597                 :            :         },
     598                 :            : 
     599                 :            :         .aead = true,
     600                 :            : 
     601                 :            :         .xform = {
     602                 :            :                 .aead = {
     603                 :            :                         .next = NULL,
     604                 :            :                         .type = RTE_CRYPTO_SYM_XFORM_AEAD,
     605                 :            :                         .aead = {
     606                 :            :                                 .op = RTE_CRYPTO_AEAD_OP_ENCRYPT,
     607                 :            :                                 .algo = RTE_CRYPTO_AEAD_AES_GCM,
     608                 :            :                                 .key.length = 16,
     609                 :            :                                 .iv.length = 12,
     610                 :            :                                 .iv.offset = 0,
     611                 :            :                                 .digest_length = 16,
     612                 :            :                                 .aad_length = 12,
     613                 :            :                         },
     614                 :            :                 },
     615                 :            :         },
     616                 :            : };
     617                 :            : 
     618                 :            : struct ipsec_test_data conf_aes_128_gcm_v6_tunnel = {
     619                 :            :         .key = {
     620                 :            :                 .data = {
     621                 :            :                         0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
     622                 :            :                         0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08
     623                 :            :                 },
     624                 :            :         },
     625                 :            : 
     626                 :            :         .salt = {
     627                 :            :                 .data = {
     628                 :            :                         0xca, 0xfe, 0xba, 0xbe
     629                 :            :                 },
     630                 :            :                 .len = 4,
     631                 :            :         },
     632                 :            : 
     633                 :            :         .iv = {
     634                 :            :                 .data = {
     635                 :            :                         0xfa, 0xce, 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88
     636                 :            :                 },
     637                 :            :         },
     638                 :            : 
     639                 :            :         .ipsec_xform = {
     640                 :            :                 .spi = 0xa5f8,
     641                 :            :                 .salt = 0xbebafeca,
     642                 :            :                 .options.esn = 0,
     643                 :            :                 .options.udp_encap = 0,
     644                 :            :                 .options.copy_dscp = 0,
     645                 :            :                 .options.copy_flabel = 0,
     646                 :            :                 .options.copy_df = 0,
     647                 :            :                 .options.dec_ttl = 0,
     648                 :            :                 .options.ecn = 0,
     649                 :            :                 .options.stats = 0,
     650                 :            :                 .options.tunnel_hdr_verify = 0,
     651                 :            :                 .options.ip_csum_enable = 0,
     652                 :            :                 .options.l4_csum_enable = 0,
     653                 :            :                 .options.ip_reassembly_en = 1,
     654                 :            :                 .direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS,
     655                 :            :                 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
     656                 :            :                 .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
     657                 :            :                 .tunnel.type = RTE_SECURITY_IPSEC_TUNNEL_IPV4,
     658                 :            :                 .replay_win_sz = 0,
     659                 :            :         },
     660                 :            : 
     661                 :            :         .aead = true,
     662                 :            : 
     663                 :            :         .xform = {
     664                 :            :                 .aead = {
     665                 :            :                         .next = NULL,
     666                 :            :                         .type = RTE_CRYPTO_SYM_XFORM_AEAD,
     667                 :            :                         .aead = {
     668                 :            :                                 .op = RTE_CRYPTO_AEAD_OP_ENCRYPT,
     669                 :            :                                 .algo = RTE_CRYPTO_AEAD_AES_GCM,
     670                 :            :                                 .key.length = 16,
     671                 :            :                                 .iv.length = 12,
     672                 :            :                                 .iv.offset = 0,
     673                 :            :                                 .digest_length = 16,
     674                 :            :                                 .aad_length = 12,
     675                 :            :                         },
     676                 :            :                 },
     677                 :            :         },
     678                 :            : };
     679                 :            : 
     680                 :            : const struct ip_pkt_vector ipv4_vector = {
     681                 :            :         .sa_data = &conf_aes_128_gcm,
     682                 :            :         .full_pkt = &pkt_ipv4_udp,
     683                 :            :         .burst = false,
     684                 :            : };
     685                 :            : 
     686                 :            : const struct reassembly_vector ipv4_2frag_vector = {
     687                 :            :         .sa_data = &conf_aes_128_gcm,
     688                 :            :         .full_pkt = &pkt_ipv4_udp_p1,
     689                 :            :         .frags[0] = &pkt_ipv4_udp_p1_f1,
     690                 :            :         .frags[1] = &pkt_ipv4_udp_p1_f2,
     691                 :            :         .nb_frags = 2,
     692                 :            :         .burst = false,
     693                 :            : };
     694                 :            : 
     695                 :            : const struct reassembly_vector ipv6_2frag_vector = {
     696                 :            :         .sa_data = &conf_aes_128_gcm_v6_tunnel,
     697                 :            :         .full_pkt = &pkt_ipv6_udp_p1,
     698                 :            :         .frags[0] = &pkt_ipv6_udp_p1_f1,
     699                 :            :         .frags[1] = &pkt_ipv6_udp_p1_f2,
     700                 :            :         .nb_frags = 2,
     701                 :            :         .burst = false,
     702                 :            : };
     703                 :            : 
     704                 :            : const struct reassembly_vector ipv4_4frag_vector = {
     705                 :            :         .sa_data = &conf_aes_128_gcm,
     706                 :            :         .full_pkt = &pkt_ipv4_udp_p2,
     707                 :            :         .frags[0] = &pkt_ipv4_udp_p2_f1,
     708                 :            :         .frags[1] = &pkt_ipv4_udp_p2_f2,
     709                 :            :         .frags[2] = &pkt_ipv4_udp_p2_f3,
     710                 :            :         .frags[3] = &pkt_ipv4_udp_p2_f4,
     711                 :            :         .nb_frags = 4,
     712                 :            :         .burst = false,
     713                 :            : };
     714                 :            : 
     715                 :            : const struct reassembly_vector ipv6_4frag_vector = {
     716                 :            :         .sa_data = &conf_aes_128_gcm_v6_tunnel,
     717                 :            :         .full_pkt = &pkt_ipv6_udp_p2,
     718                 :            :         .frags[0] = &pkt_ipv6_udp_p2_f1,
     719                 :            :         .frags[1] = &pkt_ipv6_udp_p2_f2,
     720                 :            :         .frags[2] = &pkt_ipv6_udp_p2_f3,
     721                 :            :         .frags[3] = &pkt_ipv6_udp_p2_f4,
     722                 :            :         .nb_frags = 4,
     723                 :            :         .burst = false,
     724                 :            : };
     725                 :            : const struct reassembly_vector ipv4_5frag_vector = {
     726                 :            :         .sa_data = &conf_aes_128_gcm,
     727                 :            :         .full_pkt = &pkt_ipv4_udp_p3,
     728                 :            :         .frags[0] = &pkt_ipv4_udp_p3_f1,
     729                 :            :         .frags[1] = &pkt_ipv4_udp_p3_f2,
     730                 :            :         .frags[2] = &pkt_ipv4_udp_p3_f3,
     731                 :            :         .frags[3] = &pkt_ipv4_udp_p3_f4,
     732                 :            :         .frags[4] = &pkt_ipv4_udp_p3_f5,
     733                 :            :         .nb_frags = 5,
     734                 :            :         .burst = false,
     735                 :            : };
     736                 :            : const struct reassembly_vector ipv6_5frag_vector = {
     737                 :            :         .sa_data = &conf_aes_128_gcm_v6_tunnel,
     738                 :            :         .full_pkt = &pkt_ipv6_udp_p3,
     739                 :            :         .frags[0] = &pkt_ipv6_udp_p3_f1,
     740                 :            :         .frags[1] = &pkt_ipv6_udp_p3_f2,
     741                 :            :         .frags[2] = &pkt_ipv6_udp_p3_f3,
     742                 :            :         .frags[3] = &pkt_ipv6_udp_p3_f4,
     743                 :            :         .frags[4] = &pkt_ipv6_udp_p3_f5,
     744                 :            :         .nb_frags = 5,
     745                 :            :         .burst = false,
     746                 :            : };
     747                 :            : /* Negative test cases. */
     748                 :            : const struct reassembly_vector ipv4_incomplete_vector = {
     749                 :            :         .sa_data = &conf_aes_128_gcm,
     750                 :            :         .full_pkt = &pkt_ipv4_udp_p2,
     751                 :            :         .frags[0] = &pkt_ipv4_udp_p2_f1,
     752                 :            :         .frags[1] = &pkt_ipv4_udp_p2_f2,
     753                 :            :         .nb_frags = 2,
     754                 :            :         .burst = false,
     755                 :            : };
     756                 :            : const struct reassembly_vector ipv4_overlap_vector = {
     757                 :            :         .sa_data = &conf_aes_128_gcm,
     758                 :            :         .full_pkt = &pkt_ipv4_udp_p1,
     759                 :            :         .frags[0] = &pkt_ipv4_udp_p1_f1,
     760                 :            :         .frags[1] = &pkt_ipv4_udp_p1_f1, /* Overlap */
     761                 :            :         .frags[2] = &pkt_ipv4_udp_p1_f2,
     762                 :            :         .nb_frags = 3,
     763                 :            :         .burst = false,
     764                 :            : };
     765                 :            : const struct reassembly_vector ipv4_out_of_order_vector = {
     766                 :            :         .sa_data = &conf_aes_128_gcm,
     767                 :            :         .full_pkt = &pkt_ipv4_udp_p2,
     768                 :            :         .frags[0] = &pkt_ipv4_udp_p2_f1,
     769                 :            :         .frags[1] = &pkt_ipv4_udp_p2_f3,
     770                 :            :         .frags[2] = &pkt_ipv4_udp_p2_f4,
     771                 :            :         .frags[3] = &pkt_ipv4_udp_p2_f2, /* out of order */
     772                 :            :         .nb_frags = 4,
     773                 :            :         .burst = false,
     774                 :            : };
     775                 :            : const struct reassembly_vector ipv4_4frag_burst_vector = {
     776                 :            :         .sa_data = &conf_aes_128_gcm,
     777                 :            :         .full_pkt = &pkt_ipv4_udp_p2,
     778                 :            :         .frags[0] = &pkt_ipv4_udp_p2_f1,
     779                 :            :         .frags[1] = &pkt_ipv4_udp_p2_f2,
     780                 :            :         .frags[2] = &pkt_ipv4_udp_p2_f3,
     781                 :            :         .frags[3] = &pkt_ipv4_udp_p2_f4,
     782                 :            :         .nb_frags = 4,
     783                 :            :         .burst = true,
     784                 :            : };
     785                 :            : 
     786                 :            : #endif

Generated by: LCOV version 1.14