~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/wireless/tests/fragmentation.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /net/wireless/tests/fragmentation.c (Version linux-6.12-rc7) and /net/wireless/tests/fragmentation.c (Version linux-6.8.12)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*                                                  2 /*
  3  * KUnit tests for element fragmentation            3  * KUnit tests for element fragmentation
  4  *                                                  4  *
  5  * Copyright (C) 2023-2024 Intel Corporation   !!   5  * Copyright (C) 2023 Intel Corporation
  6  */                                                 6  */
  7 #include <linux/ieee80211.h>                        7 #include <linux/ieee80211.h>
  8 #include <net/cfg80211.h>                           8 #include <net/cfg80211.h>
  9 #include <kunit/test.h>                             9 #include <kunit/test.h>
 10                                                    10 
 11 static void defragment_0(struct kunit *test)       11 static void defragment_0(struct kunit *test)
 12 {                                                  12 {
 13         ssize_t ret;                               13         ssize_t ret;
 14         static const u8 input[] = {                14         static const u8 input[] = {
 15                 [0] = WLAN_EID_EXTENSION,          15                 [0] = WLAN_EID_EXTENSION,
 16                 [1] = 254,                         16                 [1] = 254,
 17                 [2] = WLAN_EID_EXT_EHT_MULTI_L     17                 [2] = WLAN_EID_EXT_EHT_MULTI_LINK,
 18                 [27] = 27,                         18                 [27] = 27,
 19                 [123] = 123,                       19                 [123] = 123,
 20                 [254 + 2] = WLAN_EID_FRAGMENT,     20                 [254 + 2] = WLAN_EID_FRAGMENT,
 21                 [254 + 3] = 7,                     21                 [254 + 3] = 7,
 22                 [254 + 3 + 7] = 0, /* for size     22                 [254 + 3 + 7] = 0, /* for size */
 23         };                                         23         };
 24         u8 *data = kunit_kzalloc(test, sizeof(     24         u8 *data = kunit_kzalloc(test, sizeof(input), GFP_KERNEL);
 25                                                    25 
 26         KUNIT_ASSERT_NOT_NULL(test, data);         26         KUNIT_ASSERT_NOT_NULL(test, data);
 27                                                    27 
 28         ret = cfg80211_defragment_element((voi     28         ret = cfg80211_defragment_element((void *)input,
 29                                           inpu     29                                           input, sizeof(input),
 30                                           NULL !!  30                                           data, sizeof(input),
 31                                           WLAN << 
 32         KUNIT_EXPECT_EQ(test, ret, 253);       << 
 33         ret = cfg80211_defragment_element((voi << 
 34                                           inpu << 
 35                                           data << 
 36                                           WLAN     31                                           WLAN_EID_FRAGMENT);
 37         KUNIT_EXPECT_EQ(test, ret, 253);           32         KUNIT_EXPECT_EQ(test, ret, 253);
 38         KUNIT_EXPECT_MEMEQ(test, data, input +     33         KUNIT_EXPECT_MEMEQ(test, data, input + 3, 253);
 39 }                                                  34 }
 40                                                    35 
 41 static void defragment_1(struct kunit *test)       36 static void defragment_1(struct kunit *test)
 42 {                                                  37 {
 43         ssize_t ret;                               38         ssize_t ret;
 44         static const u8 input[] = {                39         static const u8 input[] = {
 45                 [0] = WLAN_EID_EXTENSION,          40                 [0] = WLAN_EID_EXTENSION,
 46                 [1] = 255,                         41                 [1] = 255,
 47                 [2] = WLAN_EID_EXT_EHT_MULTI_L     42                 [2] = WLAN_EID_EXT_EHT_MULTI_LINK,
 48                 [27] = 27,                         43                 [27] = 27,
 49                 [123] = 123,                       44                 [123] = 123,
 50                 [255 + 2] = WLAN_EID_FRAGMENT,     45                 [255 + 2] = WLAN_EID_FRAGMENT,
 51                 [255 + 3] = 7,                     46                 [255 + 3] = 7,
 52                 [255 + 3 + 1] = 0xaa,              47                 [255 + 3 + 1] = 0xaa,
 53                 [255 + 3 + 8] = WLAN_EID_FRAGM     48                 [255 + 3 + 8] = WLAN_EID_FRAGMENT, /* not used */
 54                 [255 + 3 + 9] = 1,                 49                 [255 + 3 + 9] = 1,
 55                 [255 + 3 + 10] = 0, /* for siz     50                 [255 + 3 + 10] = 0, /* for size */
 56         };                                         51         };
 57         u8 *data = kunit_kzalloc(test, sizeof(     52         u8 *data = kunit_kzalloc(test, sizeof(input), GFP_KERNEL);
 58         const struct element *elem;                53         const struct element *elem;
 59         int count = 0;                             54         int count = 0;
 60                                                    55 
 61         KUNIT_ASSERT_NOT_NULL(test, data);         56         KUNIT_ASSERT_NOT_NULL(test, data);
 62                                                    57 
 63         for_each_element(elem, input, sizeof(i     58         for_each_element(elem, input, sizeof(input))
 64                 count++;                           59                 count++;
 65                                                    60 
 66         /* check the elements are right */         61         /* check the elements are right */
 67         KUNIT_ASSERT_EQ(test, count, 3);           62         KUNIT_ASSERT_EQ(test, count, 3);
 68                                                    63 
 69         ret = cfg80211_defragment_element((voi     64         ret = cfg80211_defragment_element((void *)input,
 70                                           inpu     65                                           input, sizeof(input),
 71                                           NULL !!  66                                           data, sizeof(input),
 72                                           WLAN << 
 73         KUNIT_EXPECT_EQ(test, ret, 254 + 7);   << 
 74         ret = cfg80211_defragment_element((voi << 
 75                                           inpu << 
 76                                           data << 
 77                                           WLAN     67                                           WLAN_EID_FRAGMENT);
 78         /* this means the last fragment was no     68         /* this means the last fragment was not used */
 79         KUNIT_EXPECT_EQ(test, ret, 254 + 7);       69         KUNIT_EXPECT_EQ(test, ret, 254 + 7);
 80         KUNIT_EXPECT_MEMEQ(test, data, input +     70         KUNIT_EXPECT_MEMEQ(test, data, input + 3, 254);
 81         KUNIT_EXPECT_MEMEQ(test, data + 254, i     71         KUNIT_EXPECT_MEMEQ(test, data + 254, input + 255 + 4, 7);
 82 }                                                  72 }
 83                                                    73 
 84 static void defragment_2(struct kunit *test)       74 static void defragment_2(struct kunit *test)
 85 {                                                  75 {
 86         ssize_t ret;                               76         ssize_t ret;
 87         static const u8 input[] = {                77         static const u8 input[] = {
 88                 [0] = WLAN_EID_EXTENSION,          78                 [0] = WLAN_EID_EXTENSION,
 89                 [1] = 255,                         79                 [1] = 255,
 90                 [2] = WLAN_EID_EXT_EHT_MULTI_L     80                 [2] = WLAN_EID_EXT_EHT_MULTI_LINK,
 91                 [27] = 27,                         81                 [27] = 27,
 92                 [123] = 123,                       82                 [123] = 123,
 93                                                    83 
 94                 [257 + 0] = WLAN_EID_FRAGMENT,     84                 [257 + 0] = WLAN_EID_FRAGMENT,
 95                 [257 + 1] = 255,                   85                 [257 + 1] = 255,
 96                 [257 + 20] = 0xaa,                 86                 [257 + 20] = 0xaa,
 97                                                    87 
 98                 [2 * 257 + 0] = WLAN_EID_FRAGM     88                 [2 * 257 + 0] = WLAN_EID_FRAGMENT,
 99                 [2 * 257 + 1] = 1,                 89                 [2 * 257 + 1] = 1,
100                 [2 * 257 + 2] = 0xcc,              90                 [2 * 257 + 2] = 0xcc,
101                 [2 * 257 + 3] = WLAN_EID_FRAGM     91                 [2 * 257 + 3] = WLAN_EID_FRAGMENT, /* not used */
102                 [2 * 257 + 4] = 1,                 92                 [2 * 257 + 4] = 1,
103                 [2 * 257 + 5] = 0, /* for size     93                 [2 * 257 + 5] = 0, /* for size */
104         };                                         94         };
105         u8 *data = kunit_kzalloc(test, sizeof(     95         u8 *data = kunit_kzalloc(test, sizeof(input), GFP_KERNEL);
106         const struct element *elem;                96         const struct element *elem;
107         int count = 0;                             97         int count = 0;
108                                                    98 
109         KUNIT_ASSERT_NOT_NULL(test, data);         99         KUNIT_ASSERT_NOT_NULL(test, data);
110                                                   100 
111         for_each_element(elem, input, sizeof(i    101         for_each_element(elem, input, sizeof(input))
112                 count++;                          102                 count++;
113                                                   103 
114         /* check the elements are right */        104         /* check the elements are right */
115         KUNIT_ASSERT_EQ(test, count, 4);          105         KUNIT_ASSERT_EQ(test, count, 4);
116                                                   106 
117         ret = cfg80211_defragment_element((voi    107         ret = cfg80211_defragment_element((void *)input,
118                                           inpu    108                                           input, sizeof(input),
119                                           NULL !! 109                                           data, sizeof(input),
120                                           WLAN    110                                           WLAN_EID_FRAGMENT);
121         /* this means the last fragment was no    111         /* this means the last fragment was not used */
122         KUNIT_EXPECT_EQ(test, ret, 254 + 255 +    112         KUNIT_EXPECT_EQ(test, ret, 254 + 255 + 1);
123         ret = cfg80211_defragment_element((voi << 
124                                           inpu << 
125                                           data << 
126                                           WLAN << 
127         KUNIT_EXPECT_EQ(test, ret, 254 + 255 + << 
128         KUNIT_EXPECT_MEMEQ(test, data, input +    113         KUNIT_EXPECT_MEMEQ(test, data, input + 3, 254);
129         KUNIT_EXPECT_MEMEQ(test, data + 254, i    114         KUNIT_EXPECT_MEMEQ(test, data + 254, input + 257 + 2, 255);
130         KUNIT_EXPECT_MEMEQ(test, data + 254 +     115         KUNIT_EXPECT_MEMEQ(test, data + 254 + 255, input + 2 * 257 + 2, 1);
131 }                                                 116 }
132                                                   117 
133 static void defragment_at_end(struct kunit *te    118 static void defragment_at_end(struct kunit *test)
134 {                                                 119 {
135         ssize_t ret;                              120         ssize_t ret;
136         static const u8 input[] = {               121         static const u8 input[] = {
137                 [0] = WLAN_EID_EXTENSION,         122                 [0] = WLAN_EID_EXTENSION,
138                 [1] = 255,                        123                 [1] = 255,
139                 [2] = WLAN_EID_EXT_EHT_MULTI_L    124                 [2] = WLAN_EID_EXT_EHT_MULTI_LINK,
140                 [27] = 27,                        125                 [27] = 27,
141                 [123] = 123,                      126                 [123] = 123,
142                 [255 + 2] = WLAN_EID_FRAGMENT,    127                 [255 + 2] = WLAN_EID_FRAGMENT,
143                 [255 + 3] = 7,                    128                 [255 + 3] = 7,
144                 [255 + 3 + 7] = 0, /* for size    129                 [255 + 3 + 7] = 0, /* for size */
145         };                                        130         };
146         u8 *data = kunit_kzalloc(test, sizeof(    131         u8 *data = kunit_kzalloc(test, sizeof(input), GFP_KERNEL);
147                                                   132 
148         KUNIT_ASSERT_NOT_NULL(test, data);        133         KUNIT_ASSERT_NOT_NULL(test, data);
149                                                   134 
150         ret = cfg80211_defragment_element((voi    135         ret = cfg80211_defragment_element((void *)input,
151                                           inpu    136                                           input, sizeof(input),
152                                           NULL !! 137                                           data, sizeof(input),
153                                           WLAN << 
154         KUNIT_EXPECT_EQ(test, ret, 254 + 7);   << 
155         ret = cfg80211_defragment_element((voi << 
156                                           inpu << 
157                                           data << 
158                                           WLAN    138                                           WLAN_EID_FRAGMENT);
159         KUNIT_EXPECT_EQ(test, ret, 254 + 7);      139         KUNIT_EXPECT_EQ(test, ret, 254 + 7);
160         KUNIT_EXPECT_MEMEQ(test, data, input +    140         KUNIT_EXPECT_MEMEQ(test, data, input + 3, 254);
161         KUNIT_EXPECT_MEMEQ(test, data + 254, i    141         KUNIT_EXPECT_MEMEQ(test, data + 254, input + 255 + 4, 7);
162 }                                                 142 }
163                                                   143 
164 static struct kunit_case element_fragmentation    144 static struct kunit_case element_fragmentation_test_cases[] = {
165         KUNIT_CASE(defragment_0),                 145         KUNIT_CASE(defragment_0),
166         KUNIT_CASE(defragment_1),                 146         KUNIT_CASE(defragment_1),
167         KUNIT_CASE(defragment_2),                 147         KUNIT_CASE(defragment_2),
168         KUNIT_CASE(defragment_at_end),            148         KUNIT_CASE(defragment_at_end),
169         {}                                        149         {}
170 };                                                150 };
171                                                   151 
172 static struct kunit_suite element_fragmentatio    152 static struct kunit_suite element_fragmentation = {
173         .name = "cfg80211-element-defragmentat    153         .name = "cfg80211-element-defragmentation",
174         .test_cases = element_fragmentation_te    154         .test_cases = element_fragmentation_test_cases,
175 };                                                155 };
176                                                   156 
177 kunit_test_suite(element_fragmentation);          157 kunit_test_suite(element_fragmentation);
178                                                   158 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php