Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: mctp: test: Add extaddr routing output test

Test that the routing code preserves the haddr data in a skb through an
input route operation.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Link: https://patch.msgid.link/20250702-dev-forwarding-v5-6-1468191da8a4@codeconstruct.com.au
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Jeremy Kerr and committed by
Paolo Abeni
46ee1646 96b341a8

+53
+53
net/mctp/test/route-test.c
··· 1294 1294 mctp_test_destroy_dev(dev); 1295 1295 } 1296 1296 1297 + static void mctp_test_route_extaddr_input(struct kunit *test) 1298 + { 1299 + static const unsigned char haddr[] = { 0xaa, 0x55 }; 1300 + struct mctp_test_pktqueue tpq; 1301 + struct mctp_skb_cb *cb, *cb2; 1302 + const unsigned int len = 40; 1303 + struct mctp_test_dev *dev; 1304 + struct sk_buff *skb, *skb2; 1305 + struct mctp_dst dst; 1306 + struct mctp_hdr hdr; 1307 + struct socket *sock; 1308 + int rc; 1309 + 1310 + hdr.ver = 1; 1311 + hdr.src = 10; 1312 + hdr.dest = 8; 1313 + hdr.flags_seq_tag = FL_S | FL_E | FL_TO; 1314 + 1315 + __mctp_route_test_init(test, &dev, &dst, &tpq, &sock, MCTP_NET_ANY); 1316 + 1317 + skb = mctp_test_create_skb(&hdr, len); 1318 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, skb); 1319 + 1320 + /* set our hardware addressing data */ 1321 + cb = mctp_cb(skb); 1322 + memcpy(cb->haddr, haddr, sizeof(haddr)); 1323 + cb->halen = sizeof(haddr); 1324 + 1325 + mctp_test_skb_set_dev(skb, dev); 1326 + 1327 + rc = mctp_dst_input(&dst, skb); 1328 + KUNIT_ASSERT_EQ(test, rc, 0); 1329 + 1330 + mctp_test_dst_release(&dst, &tpq); 1331 + 1332 + skb2 = skb_recv_datagram(sock->sk, MSG_DONTWAIT, &rc); 1333 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, skb2); 1334 + KUNIT_ASSERT_EQ(test, skb2->len, len); 1335 + 1336 + cb2 = mctp_cb(skb2); 1337 + 1338 + /* Received SKB should have the hardware addressing as set above. 1339 + * We're likely to have the same actual cb here (ie., cb == cb2), 1340 + * but it's the comparison that we care about 1341 + */ 1342 + KUNIT_EXPECT_EQ(test, cb2->halen, sizeof(haddr)); 1343 + KUNIT_EXPECT_MEMEQ(test, cb2->haddr, haddr, sizeof(haddr)); 1344 + 1345 + skb_free_datagram(sock->sk, skb2); 1346 + mctp_test_destroy_dev(dev); 1347 + } 1348 + 1297 1349 static struct kunit_case mctp_test_cases[] = { 1298 1350 KUNIT_CASE_PARAM(mctp_test_fragment, mctp_frag_gen_params), 1299 1351 KUNIT_CASE_PARAM(mctp_test_rx_input, mctp_rx_input_gen_params), ··· 1362 1310 KUNIT_CASE(mctp_test_fragment_flow), 1363 1311 KUNIT_CASE(mctp_test_route_output_key_create), 1364 1312 KUNIT_CASE(mctp_test_route_input_cloned_frag), 1313 + KUNIT_CASE(mctp_test_route_extaddr_input), 1365 1314 {} 1366 1315 }; 1367 1316