e4f349bd | 08-May-2025 |
Andrew Jeffery <andrew@codeconstruct.com.au> |
net: mctp: Ensure keys maintain only one ref to corresponding dev
mctp_flow_prepare_output() is called in mctp_route_output(), which places outbound packets onto a given interface. The packet may re
net: mctp: Ensure keys maintain only one ref to corresponding dev
mctp_flow_prepare_output() is called in mctp_route_output(), which places outbound packets onto a given interface. The packet may represent a message fragment, in which case we provoke an unbalanced reference count to the underlying device. This causes trouble if we ever attempt to remove the interface:
[ 48.702195] usb 1-1: USB disconnect, device number 2 [ 58.883056] unregister_netdevice: waiting for mctpusb0 to become free. Usage count = 2 [ 69.022548] unregister_netdevice: waiting for mctpusb0 to become free. Usage count = 2 [ 79.172568] unregister_netdevice: waiting for mctpusb0 to become free. Usage count = 2 ...
Predicate the invocation of mctp_dev_set_key() in mctp_flow_prepare_output() on not already having associated the device with the key. It's not yet realistic to uphold the property that the key maintains only one device reference earlier in the transmission sequence as the route (and therefore the device) may not be known at the time the key is associated with the socket.
Fixes: 67737c457281 ("mctp: Pass flow data & flow release events to drivers") Acked-by: Jeremy Kerr <jk@codeconstruct.com.au> Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au> Link: https://patch.msgid.link/20250508-mctp-dev-refcount-v1-1-d4f965c67bb5@codeconstruct.com.au Signed-off-by: Jakub Kicinski <kuba@kernel.org>
show more ...
|
d192eaf5 | 19-Feb-2024 |
Jeremy Kerr <jk@codeconstruct.com.au> |
net: mctp: tests: Add a test for proper tag creation on local output
Ensure we have the correct key parameters on sending a message.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Signed-off-
net: mctp: tests: Add a test for proper tag creation on local output
Ensure we have the correct key parameters on sending a message.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
show more ...
|
109a5331 | 19-Feb-2024 |
Jeremy Kerr <jk@codeconstruct.com.au> |
net: mctp: tests: Test that outgoing skbs have flow data populated
When CONFIG_MCTP_FLOWS is enabled, outgoing skbs should have their SKB_EXT_MCTP extension set for drivers to consume.
Add two test
net: mctp: tests: Test that outgoing skbs have flow data populated
When CONFIG_MCTP_FLOWS is enabled, outgoing skbs should have their SKB_EXT_MCTP extension set for drivers to consume.
Add two tests for local-to-output routing that check for the flow extensions: one for the simple single-packet case, and one for fragmentation.
We now make MCTP_TEST select MCTP_FLOWS, so we always get coverage of these flow tests. The tests are skippable if MCTP_FLOWS is (otherwise) disabled, but that would need manual config tweaking.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
show more ...
|
1394c1de | 19-Feb-2024 |
Jeremy Kerr <jk@codeconstruct.com.au> |
net: mctp: copy skb ext data when fragmenting
If we're fragmenting on local output, the original packet may contain ext data for the MCTP flows. We'll want this in the resulting fragment skbs too.
net: mctp: copy skb ext data when fragmenting
If we're fragmenting on local output, the original packet may contain ext data for the MCTP flows. We'll want this in the resulting fragment skbs too.
So, do a skb_ext_copy() in the fragmentation path, and implement the MCTP-specific parts of an ext copy operation.
Fixes: 67737c457281 ("mctp: Pass flow data & flow release events to drivers") Reported-by: Jian Zhang <zhangjian.3032@bytedance.com> Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
show more ...
|
9acdc089 | 19-Feb-2024 |
Jeremy Kerr <jk@codeconstruct.com.au> |
net: mctp: tests: Add MCTP net isolation tests
Add a couple of tests that excersise the new net-specific sk_key and bind lookups
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Signed-off-by:
net: mctp: tests: Add MCTP net isolation tests
Add a couple of tests that excersise the new net-specific sk_key and bind lookups
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
show more ...
|
61b50531 | 19-Feb-2024 |
Jeremy Kerr <jk@codeconstruct.com.au> |
net: mctp: tests: Add netid argument to __mctp_route_test_init
We'll want to create net-specific test setups in an upcoming change, so allow the caller to provide a non-default netid.
Signed-off-by
net: mctp: tests: Add netid argument to __mctp_route_test_init
We'll want to create net-specific test setups in an upcoming change, so allow the caller to provide a non-default netid.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
show more ...
|
c16d2380 | 19-Feb-2024 |
Jeremy Kerr <jk@codeconstruct.com.au> |
net: mctp: provide a more specific tag allocation ioctl
Now that we have net-specific tags, extend the tag allocation ioctls (SIOCMCTPALLOCTAG / SIOCMCTPDROPTAG) to allow a network parameter to be p
net: mctp: provide a more specific tag allocation ioctl
Now that we have net-specific tags, extend the tag allocation ioctls (SIOCMCTPALLOCTAG / SIOCMCTPDROPTAG) to allow a network parameter to be passed to the tag allocation.
We also add a local_addr member to the ioc struct, to allow for a future finer-grained tag allocation using local EIDs too. We don't add any specific support for that now though, so require MCTP_ADDR_ANY or MCTP_ADDR_NULL for those at present.
The old ioctls will still work, but allocate for the default MCTP net. These are now marked as deprecated in the header.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
show more ...
|
43e67955 | 19-Feb-2024 |
Jeremy Kerr <jk@codeconstruct.com.au> |
net: mctp: separate key correlation across nets
Currently, we lookup sk_keys from the entire struct net_namespace, which may contain multiple MCTP net IDs. In those cases we want to distinguish betw
net: mctp: separate key correlation across nets
Currently, we lookup sk_keys from the entire struct net_namespace, which may contain multiple MCTP net IDs. In those cases we want to distinguish between endpoints with the same EID but different net ID.
Add the net ID data to the struct mctp_sk_key, populate on add and filter on this during route lookup.
For the ioctl interface, we use a default net of MCTP_INITIAL_DEFAULT_NET (ie., what will be in use for single-net configurations), but we'll extend the ioctl interface to provide net-specific tag allocation in an upcoming change.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
show more ...
|