/* helper for simple sock setup: single device, with dev_default_lladdr as its * hardware address, assigned with a local EID 8, and a route to EID 9
*/ staticvoid __mctp_sock_test_init(struct kunit *test, struct mctp_test_dev **devp, struct mctp_test_route **rtp, struct socket **sockp)
{ struct mctp_test_route *rt; struct mctp_test_dev *dev; struct socket *sock; unsignedlong flags;
u8 *addrs; int rc;
dev = mctp_test_create_dev_lladdr(sizeof(dev_default_lladdr),
dev_default_lladdr);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev);
/* Expect to see the dst configured up with the addressing data we * provide in the struct sockaddr_mctp_ext
*/
cfg.dev = dev;
cfg.halen = sizeof(haddr);
memcpy(cfg.haddr, haddr, sizeof(haddr));
/* set incoming extended address data */
cb = mctp_cb(skb);
cb->halen = sizeof(haddr);
cb->ifindex = dev->ndev->ifindex;
memcpy(cb->haddr, haddr, sizeof(haddr));
/* Deliver to socket. The route input path pulls the network header, * leaving skb data at type byte onwards. recvmsg will consume the * type for addr.smctp_type
*/
skb_pull(skb, sizeof(hdr));
rc = sock_queue_rcv_skb(sock->sk, skb);
KUNIT_ASSERT_EQ(test, rc, 0);
/* Pairs of binds and whether they will conflict */ staticconststruct mctp_bind_pair_test mctp_bind_pair_tests[] = { /* Both ADDR_ANY, conflict */
{ &bind_addrany_netdefault_type1, &bind_addrany_netdefault_type1,
EADDRINUSE }, /* Same specific EID, conflict */
{ &bind_addr8_netdefault_type1, &bind_addr8_netdefault_type1,
EADDRINUSE }, /* ADDR_ANY vs specific EID, OK */
{ &bind_addrany_netdefault_type1, &bind_addr8_netdefault_type1, 0 }, /* ADDR_ANY different types, OK */
{ &bind_addrany_net2_type2, &bind_addrany_net2_type1, 0 }, /* ADDR_ANY different nets, OK */
{ &bind_addrany_net2_type1, &bind_addrany_netdefault_type1, 0 },
/* specific EID, NET_ANY (resolves to default) * vs specific EID, explicit default net 1, conflict
*/
{ &bind_addr8_netdefault_type1, &bind_addr8_net1_type1, EADDRINUSE },
/* specific EID, net 1 vs specific EID, net 2, ok */
{ &bind_addr8_net1_type1, &bind_addr8_net2_type1, 0 },
/* ANY_ADDR, NET_ANY (doesn't resolve to default) * vs ADDR_ANY, explicit default net 1, OK
*/
{ &bind_addrany_netdefault_type1, &bind_addrany_net1_type1, 0 },
/* specific remote peer doesn't conflict with any-peer bind */
{ &bind_addrany_net2_type1_peer9, &bind_addrany_net2_type1, 0 },
/* bind() NET_ANY is allowed with a connect() net */
{ &bind_addrany_net2_type1_peer9, &bind_addrany_netdefault_type1, 0 },
};
/* swapping the calls, the second bind should still fail */
bind_errno =
mctp_test_bind_conflicts_inner(test, pair->bind2, pair->bind1);
KUNIT_EXPECT_EQ(test, -bind_errno, pair->error);
}
staticvoid mctp_test_assumptions(struct kunit *test)
{ /* check assumption of default net from bind_addr8_net1_type1 */
KUNIT_ASSERT_EQ(test, mctp_default_net(&init_net), 1);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.