summaryrefslogtreecommitdiff
path: root/net/mctp/device.c
AgeCommit message (Collapse)AuthorFilesLines
2022-03-18mctp: Avoid warning if unregister notifies twiceMatt Johnston1-4/+4
Previously if an unregister notify handler ran twice (waiting for netdev to be released) it would print a warning in mctp_unregister() every subsequent time the unregister notify occured. Instead we only need to worry about the case where a mctp_ptr is set on an unknown device type. OpenBMC-Staging-Count: 1 Signed-off-by: Matt Johnston <matt@codeconstruct.com.au> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-03-18mctp: Fix warnings reported by clang-analyzerMatt Johnston1-1/+1
net/mctp/device.c:140:11: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign] mcb->idx = idx; - Not a real problem due to how the callback runs, fix the warning. net/mctp/route.c:458:4: warning: Value stored to 'msk' is never read [clang-analyzer-deadcode.DeadStores] msk = container_of(key->sk, struct mctp_sock, sk); - 'msk' dead assignment can be removed here. OpenBMC-Staging-Count: 1 Signed-off-by: Matt Johnston <matt@codeconstruct.com.au> Signed-off-by: David S. Miller <davem@davemloft.net> (cherry picked from commit 8d783197f06d905e5e7a89342e815ef5aeaa1731) Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-03-18mctp: make __mctp_dev_get() take a refcount holdMatt Johnston1-3/+18
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: replace mctp_address_ok with more fine-grained helpersJeremy Kerr1-1/+1
Currently, we have mctp_address_ok(), which checks if an EID is in the "valid" range of 8-254 inclusive. However, 0 and 255 may also be valid addresses, depending on context. 0 is the NULL EID, which may be set when physical addressing is used. 255 is valid as a destination address for broadcasts. This change renames mctp_address_ok to mctp_address_unicast, and adds similar helpers for broadcast and null EIDs, which will be used in an upcoming commit. OpenBMC-Staging-Count: 1 Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Signed-off-by: Jakub Kicinski <kuba@kernel.org> (cherry picked from commit cb196b725936f6b776ad1d073f66fbe92aa798fa) Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-03-18mctp: emit RTM_NEWADDR and RTM_DELADDRMatt Johnston1-5/+48
Userspace can receive notification of MCTP address changes via RTNLGRP_MCTP_IFADDR rtnetlink multicast group. OpenBMC-Staging-Count: 1 Signed-off-by: Matt Johnston <matt@codeconstruct.com.au> Link: https://lore.kernel.org/r/20211220023104.1965509-1-matt@codeconstruct.com.au Signed-off-by: Jakub Kicinski <kuba@kernel.org> (cherry picked from commit dbcefdeb2a58039f4c81d0361056fbdd9be906a1) Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-03-18mctp: Pass flow data & flow release events to driversJeremy Kerr1-0/+51
Now that we have an extension for MCTP data in skbs, populate the flow when a key has been created for the packet, and add a device driver operation to inform of flow destruction. Includes a fix for a warning with test builds: 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 67737c457281dd199ceb9e31b6ba7efd3bfe566d) Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-03-18mctp: Warn if pointer is set for a wrong dev typeMatt Johnston1-7/+24
Should not occur but is a sanity check. May help tracking down Trinity reported issue https://lore.kernel.org/lkml/20210913030701.GA5926@xsang-OptiPlex-9020/ OpenBMC-Staging-Count: 1 Signed-off-by: Matt Johnston <matt@codeconstruct.com.au> Signed-off-by: David S. Miller <davem@davemloft.net> (cherry picked from commit 7b1871af75f30d9d88184fff42698718fa157dcf) Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-03-18mctp: Add refcounts to mctp_devJeremy Kerr1-9/+16
Currently, we tie the struct mctp_dev lifetime to the underlying struct net_device, and hold/put that device as a proxy for a separate mctp_dev refcount. This works because we're not holding any references to the mctp_dev that are different from the netdev lifetime. In a future change we'll break that assumption though, as we'll need to hold mctp_dev references in a workqueue, which might live past the netdev unregister notification. In order to support that, this change introduces a refcount on the mctp_dev, currently taken by the net_device->mctp_ptr reference, and released on netdev unregister events. We can then use this for future references that might outlast the net device. 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 43f55f23f70881e9c397557f15c8090b368d0af2) Signed-off-by: Joel Stanley <joel@jms.id.au>
2022-03-18mctp: Allow MCTP on tun devicesMatt Johnston1-2/+5
Allowing TUN is useful for testing, to route packets to userspace or to tunnel between machines. OpenBMC-Staging-Count: 1 Signed-off-by: Matt Johnston <matt@codeconstruct.com.au> Signed-off-by: David S. Miller <davem@davemloft.net> (cherry picked from commit f364dd71d92fe6722fe5d47803be974dc0c40762) Signed-off-by: Joel Stanley <joel@jms.id.au>
2021-07-29mctp: Allow per-netns default networksMatt Johnston1-1/+1
Currently we have a compile-time default network (MCTP_INITIAL_DEFAULT_NET). This change introduces a default_net field on the net namespace, allowing future configuration for new interfaces. Signed-off-by: Matt Johnston <matt@codeconstruct.com.au> Signed-off-by: David S. Miller <davem@davemloft.net>
2021-07-29mctp: Add neighbour implementationMatt Johnston1-0/+1
Add an initial neighbour table implementation, to be used in the route output path. Signed-off-by: Matt Johnston <matt@codeconstruct.com.au> Signed-off-by: David S. Miller <davem@davemloft.net>
2021-07-29mctp: Add initial routing frameworkJeremy Kerr1-0/+8
Add a simple routing table, and a couple of route output handlers, and the mctp packet_type & handler. Includes changes from Matt Johnston <matt@codeconstruct.com.au>. Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Signed-off-by: David S. Miller <davem@davemloft.net>
2021-07-29mctp: Add device handling and netlink interfaceJeremy Kerr1-0/+414
This change adds the infrastructure for managing MCTP netdevices; we add a pointer to the AF_MCTP-specific data to struct netdevice, and hook up the rtnetlink operations for adding and removing addresses. Includes changes from Matt Johnston <matt@codeconstruct.com.au>. Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Signed-off-by: David S. Miller <davem@davemloft.net>