summaryrefslogtreecommitdiff
path: root/net/mctp/test
AgeCommit message (Collapse)AuthorFilesLines
2022-03-18mctp: make __mctp_dev_get() take a refcount holdMatt Johnston1-1/+0
Previously there was a race that could allow the mctp_dev refcount to hit zero: rcu_read_lock(); mdev = __mctp_dev_get(dev); // mctp_unregister() happens here, mdev->refs hits zero mctp_dev_hold(dev); rcu_read_unlock(); Now we make __mctp_dev_get() take the hold itself. It is safe to test against the zero refcount because __mctp_dev_get() is called holding rcu_read_lock and mctp_dev uses kfree_rcu(). OpenBMC-Staging-Count: 1 Reported-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Matt Johnston <matt@codeconstruct.com.au> Signed-off-by: David S. Miller <davem@davemloft.net> (cherry picked from commit dc121c0084910db985cf1c8ba6fce5d8c307cc02) Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-03-18mctp: Allow keys matching any local addressJeremy Kerr1-0/+8
Currently, we require an exact match on an incoming packet's dest address, and the key's local_addr field. In a future change, we may want to set up a key before packets are routed, meaning we have no local address to match on. This change allows key lookups to match on local_addr = MCTP_ADDR_ANY. OpenBMC-Staging-Count: 1 Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Signed-off-by: David S. Miller <davem@davemloft.net> (cherry picked from commit 0de55a7d1133d0ab1acad5d91eea6ccd8cf6d448) Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-03-18mctp: tests: Add key state testsJeremy Kerr1-0/+137
This change adds a few more tests to check the key/tag lookups on route input. We add a specific entry to the keys lists, route a packet with specific header values, and check for key match/mismatch. OpenBMC-Staging-Count: 1 Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Signed-off-by: David S. Miller <davem@davemloft.net> (cherry picked from commit c5755214623dd7aaafc5204458a0a30b7469850c) Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-03-18mctp: tests: Rename FL_T macro to FL_TOJeremy Kerr1-6/+6
This is a definition for the tag-owner flag, which has TO as a standard abbreviation. We'll want to add a helper for the actual tag value in a future change. OpenBMC-Staging-Count: 1 Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Signed-off-by: David S. Miller <davem@davemloft.net> (cherry picked from commit 62a2b005c6d639b6bd7a63fe2f0a96eaf06f0057) Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-03-18mctp: test: zero out sockaddrMatt Johnston1-1/+1
MCTP now requires that padding bytes are zero. OpenBMC-Staging-Count: 1 Signed-off-by: Matt Johnston <matt@codeconstruct.com.au> Fixes: 1e4b50f06d97 ("mctp: handle the struct sockaddr_mctp padding fields") Link: https://lore.kernel.org/r/20220110021806.2343023-1-matt@codeconstruct.com.au Signed-off-by: Jakub Kicinski <kuba@kernel.org> (cherry picked from commit 9d5e9e549ba4a02e515001a41c2b0a30ccd5f477) Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-03-18mctp: test: fix skb free in test device txJeremy Kerr1-1/+1
In our test device, we're currently freeing skbs in the transmit path with kfree(), rather than kfree_skb(). This change uses the correct kfree_skb() instead. OpenBMC-Staging-Count: 1 Fixes: ded21b722995 ("mctp: Add test utils") Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Signed-off-by: David S. Miller <davem@davemloft.net> (cherry picked from commit d8519565447078f141c58ba4193d820f2cdf1914) Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-03-18mctp/test: Update refcount checking in route fragment testsJeremy Kerr1-5/+0
In 99ce45d5e, we moved a route refcount decrement from mctp_do_fragment_route into the caller. This invalidates the assumption that the route test makes about refcount behaviour, so the route tests fail. This change fixes the test case to suit the new refcount behaviour. OpenBMC-Staging-Count: 1 Fixes: 99ce45d5e7db ("mctp: Implement extended addressing") Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Signed-off-by: David S. Miller <davem@davemloft.net> (cherry picked from commit f6ef47e5bdc6f652176e433b02317fc83049f8d7) Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-03-18mctp: Add input reassembly testsJeremy Kerr1-0/+134
Add multi-packet route input tests, for message reassembly. These will feed packets to be received by a bound socket, or dropped. OpenBMC-Staging-Count: 1 Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Signed-off-by: David S. Miller <davem@davemloft.net> (cherry picked from commit 1e5e9250d4224e3ed77846bd8d29ac66fbe6f05d) Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-03-18mctp: Add route input to socket testsJeremy Kerr1-0/+132
Add a few tests for single-packet route inputs, testing the mctp_route_input function. OpenBMC-Staging-Count: 1 Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Signed-off-by: David S. Miller <davem@davemloft.net> (cherry picked from commit 8892c0490779d6de921eb684e5504708fdbbcb68) Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-03-18mctp: Add packet rx testsJeremy Kerr1-3/+64
Add a few tests for the initial packet ingress through mctp_pkttype_receive function; mainly packet header sanity checks. Full input routing checks will be added as a separate change. OpenBMC-Staging-Count: 1 Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Signed-off-by: David S. Miller <davem@davemloft.net> (cherry picked from commit b504db408c34e01d791f69c61ee256a8c7eec62f) Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-03-18mctp: Add test utilsJeremy Kerr2-0/+87
Add a new object for shared test utilities OpenBMC-Staging-Count: 1 Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Signed-off-by: David S. Miller <davem@davemloft.net> (cherry picked from commit ded21b72299529cc143a4213ea0ec4b0c620b8eb) Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-03-18mctp: Add initial test structure and fragmentation testJeremy Kerr1-0/+217
This change adds the first kunit test for the mctp subsystem, and an initial test for the fragmentation path. We're adding tests under a new net/mctp/test/ directory. Incorporates a fix for module configs: Reported-by: kernel test robot <lkp@intel.com> OpenBMC-Staging-Count: 1 Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Signed-off-by: David S. Miller <davem@davemloft.net> (cherry picked from commit 161eba50e183ed4ca20f6d8dec19bdc526d2b2b9) Signed-off-by: Joel Stanley <joel@jms.id.au>