e6d8e7db | 10-Jul-2025 |
Matt Johnston <matt@codeconstruct.com.au> |
net: mctp: Add bind lookup test
Test the preference order of bound socket matches with a series of test packets.
Signed-off-by: Matt Johnston <matt@codeconstruct.com.au> Link: https://patch.msgid.l
net: mctp: Add bind lookup test
Test the preference order of bound socket matches with a series of test packets.
Signed-off-by: Matt Johnston <matt@codeconstruct.com.au> Link: https://patch.msgid.link/20250710-mctp-bind-v4-8-8ec2f6460c56@codeconstruct.com.au Signed-off-by: Paolo Abeni <pabeni@redhat.com>
show more ...
|
b7e28129 | 10-Jul-2025 |
Matt Johnston <matt@codeconstruct.com.au> |
net: mctp: Test conflicts of connect() with bind()
The addition of connect() adds new conflict cases to test.
Signed-off-by: Matt Johnston <matt@codeconstruct.com.au> Link: https://patch.msgid.link
net: mctp: Test conflicts of connect() with bind()
The addition of connect() adds new conflict cases to test.
Signed-off-by: Matt Johnston <matt@codeconstruct.com.au> Link: https://patch.msgid.link/20250710-mctp-bind-v4-7-8ec2f6460c56@codeconstruct.com.au Signed-off-by: Paolo Abeni <pabeni@redhat.com>
show more ...
|
3549eb08 | 10-Jul-2025 |
Matt Johnston <matt@codeconstruct.com.au> |
net: mctp: Allow limiting binds to a peer address
Prior to calling bind() a program may call connect() on a socket to restrict to a remote peer address.
Using connect() is the normal mechanism to s
net: mctp: Allow limiting binds to a peer address
Prior to calling bind() a program may call connect() on a socket to restrict to a remote peer address.
Using connect() is the normal mechanism to specify a remote network peer, so we use that here. In MCTP connect() is only used for bound sockets - send() is not available for MCTP since a tag must be provided for each message.
The smctp_type must match between connect() and bind() calls.
Signed-off-by: Matt Johnston <matt@codeconstruct.com.au> Link: https://patch.msgid.link/20250710-mctp-bind-v4-6-8ec2f6460c56@codeconstruct.com.au Signed-off-by: Paolo Abeni <pabeni@redhat.com>
show more ...
|
1aeed732 | 10-Jul-2025 |
Matt Johnston <matt@codeconstruct.com.au> |
net: mctp: Use hashtable for binds
Ensure that a specific EID (remote or local) bind will match in preference to a MCTP_ADDR_ANY bind.
This adds infrastructure for binding a socket to receive messa
net: mctp: Use hashtable for binds
Ensure that a specific EID (remote or local) bind will match in preference to a MCTP_ADDR_ANY bind.
This adds infrastructure for binding a socket to receive messages from a specific remote peer address, a future commit will expose an API for this.
Signed-off-by: Matt Johnston <matt@codeconstruct.com.au> Link: https://patch.msgid.link/20250710-mctp-bind-v4-5-8ec2f6460c56@codeconstruct.com.au Signed-off-by: Paolo Abeni <pabeni@redhat.com>
show more ...
|
4ec4b7fc | 10-Jul-2025 |
Matt Johnston <matt@codeconstruct.com.au> |
net: mctp: Add test for conflicting bind()s
Test pairwise combinations of bind addresses and types.
Signed-off-by: Matt Johnston <matt@codeconstruct.com.au> Link: https://patch.msgid.link/20250710-
net: mctp: Add test for conflicting bind()s
Test pairwise combinations of bind addresses and types.
Signed-off-by: Matt Johnston <matt@codeconstruct.com.au> Link: https://patch.msgid.link/20250710-mctp-bind-v4-4-8ec2f6460c56@codeconstruct.com.au Signed-off-by: Paolo Abeni <pabeni@redhat.com>
show more ...
|
5000268c | 10-Jul-2025 |
Matt Johnston <matt@codeconstruct.com.au> |
net: mctp: Treat MCTP_NET_ANY specially in bind()
When a specific EID is passed as a bind address, it only makes sense to interpret with an actual network ID, so resolve that to the default network
net: mctp: Treat MCTP_NET_ANY specially in bind()
When a specific EID is passed as a bind address, it only makes sense to interpret with an actual network ID, so resolve that to the default network at bind time.
For bind address of MCTP_ADDR_ANY, we want to be able to capture traffic to any network and address, so keep the current behaviour of matching traffic from any network interface (don't interpret MCTP_NET_ANY as the default network ID).
Signed-off-by: Matt Johnston <matt@codeconstruct.com.au> Link: https://patch.msgid.link/20250710-mctp-bind-v4-3-8ec2f6460c56@codeconstruct.com.au Signed-off-by: Paolo Abeni <pabeni@redhat.com>
show more ...
|
39545023 | 10-Jul-2025 |
Matt Johnston <matt@codeconstruct.com.au> |
net: mctp: Prevent duplicate binds
Disallow bind() calls that have the same arguments as existing bound sockets. Previously multiple sockets could bind() to the same type/local address, with an arb
net: mctp: Prevent duplicate binds
Disallow bind() calls that have the same arguments as existing bound sockets. Previously multiple sockets could bind() to the same type/local address, with an arbitrary socket receiving matched messages.
This is only a partial fix, a future commit will define precedence order for MCTP_ADDR_ANY versus specific EID bind(), which are allowed to exist together.
Signed-off-by: Matt Johnston <matt@codeconstruct.com.au> Link: https://patch.msgid.link/20250710-mctp-bind-v4-2-8ec2f6460c56@codeconstruct.com.au Signed-off-by: Paolo Abeni <pabeni@redhat.com>
show more ...
|
48e1736e | 02-Jul-2025 |
Jeremy Kerr <jk@codeconstruct.com.au> |
net: mctp: test: Add tests for gateway routes
Add a few kunit tests for the gateway routing. Because we have multiple route types now (direct and gateway), rename mctp_test_create_route to mctp_test
net: mctp: test: Add tests for gateway routes
Add a few kunit tests for the gateway routing. Because we have multiple route types now (direct and gateway), rename mctp_test_create_route to mctp_test_create_route_direct, and add a _gateway variant too.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Link: https://patch.msgid.link/20250702-dev-forwarding-v5-14-1468191da8a4@codeconstruct.com.au Signed-off-by: Paolo Abeni <pabeni@redhat.com>
show more ...
|
ad39c12f | 02-Jul-2025 |
Jeremy Kerr <jk@codeconstruct.com.au> |
net: mctp: add gateway routing support
This change allows for gateway routing, where a route table entry may reference a routable endpoint (by network and EID), instead of routing directly to a netd
net: mctp: add gateway routing support
This change allows for gateway routing, where a route table entry may reference a routable endpoint (by network and EID), instead of routing directly to a netdevice.
We add support for a RTM_GATEWAY attribute for netlink route updates, with an attribute format of:
struct mctp_fq_addr { unsigned int net; mctp_eid_t eid; }
- we need the net here to uniquely identify the target EID, as we no longer have the device reference directly (which would provide the net id in the case of direct routes).
This makes route lookups recursive, as a route lookup that returns a gateway route must be resolved into a direct route (ie, to a device) eventually. We provide a limit to the route lookups, to prevent infinite loop routing.
The route lookup populates a new 'nexthop' field in the dst structure, which now specifies the key for the neighbour table lookup on device output, rather than using the packet destination address directly.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Link: https://patch.msgid.link/20250702-dev-forwarding-v5-13-1468191da8a4@codeconstruct.com.au Signed-off-by: Paolo Abeni <pabeni@redhat.com>
show more ...
|
28ddbb2a | 02-Jul-2025 |
Jeremy Kerr <jk@codeconstruct.com.au> |
net: mctp: allow NL parsing directly into a struct mctp_route
The netlink route parsing functions end up setting a bunch of output variables from the rt attributes. This will get messy when the rout
net: mctp: allow NL parsing directly into a struct mctp_route
The netlink route parsing functions end up setting a bunch of output variables from the rt attributes. This will get messy when the routes become more complex.
So, split the rt parsing into two types: a lookup (returning route target data suitable for a route lookup, like when deleting a route) and a populate (setting fields of a struct mctp_route).
In doing this, we need to separate the route allocation from mctp_route_add, so add some comments on the lifetime semantics for the latter.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Link: https://patch.msgid.link/20250702-dev-forwarding-v5-12-1468191da8a4@codeconstruct.com.au Signed-off-by: Paolo Abeni <pabeni@redhat.com>
show more ...
|
4a1de053 | 02-Jul-2025 |
Jeremy Kerr <jk@codeconstruct.com.au> |
net: mctp: remove routes by netid, not by device
In upcoming changes, a route may not have a device associated. Since the route is matched on the (network, eid) tuple, pass the netid itself into mct
net: mctp: remove routes by netid, not by device
In upcoming changes, a route may not have a device associated. Since the route is matched on the (network, eid) tuple, pass the netid itself into mctp_route_remove.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Link: https://patch.msgid.link/20250702-dev-forwarding-v5-11-1468191da8a4@codeconstruct.com.au Signed-off-by: Paolo Abeni <pabeni@redhat.com>
show more ...
|
48e6aa60 | 02-Jul-2025 |
Jeremy Kerr <jk@codeconstruct.com.au> |
net: mctp: pass net into route creation
We may not have a mdev pointer, from which we currently extract the net.
Instead, pass the net directly.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au
net: mctp: pass net into route creation
We may not have a mdev pointer, from which we currently extract the net.
Instead, pass the net directly.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Link: https://patch.msgid.link/20250702-dev-forwarding-v5-10-1468191da8a4@codeconstruct.com.au Signed-off-by: Paolo Abeni <pabeni@redhat.com>
show more ...
|
9b4a8c38 | 02-Jul-2025 |
Jeremy Kerr <jk@codeconstruct.com.au> |
net: mctp: test: Add initial socket tests
Recent changes have modified the extaddr path a little, so add a couple of kunit tests to af-mctp.c. These check that we're correctly passing lladdr data be
net: mctp: test: Add initial socket tests
Recent changes have modified the extaddr path a little, so add a couple of kunit tests to af-mctp.c. These check that we're correctly passing lladdr data between sendmsg/recvmsg and the routing layer.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Link: https://patch.msgid.link/20250702-dev-forwarding-v5-9-1468191da8a4@codeconstruct.com.au Signed-off-by: Paolo Abeni <pabeni@redhat.com>
show more ...
|
19396179 | 02-Jul-2025 |
Jeremy Kerr <jk@codeconstruct.com.au> |
net: mctp: test: add sock test infrastructure
Add a new test object, for use with the af_mctp socket code. This is intially empty, but we'll start populating actual tests in an upcoming change.
Sig
net: mctp: test: add sock test infrastructure
Add a new test object, for use with the af_mctp socket code. This is intially empty, but we'll start populating actual tests in an upcoming change.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Link: https://patch.msgid.link/20250702-dev-forwarding-v5-8-1468191da8a4@codeconstruct.com.au Signed-off-by: Paolo Abeni <pabeni@redhat.com>
show more ...
|
80bcf05e | 02-Jul-2025 |
Jeremy Kerr <jk@codeconstruct.com.au> |
net: mctp: test: move functions into utils.[ch]
A future change will add another mctp test .c file, so move some of the common test setup from route.c into the utils object.
Signed-off-by: Jeremy K
net: mctp: test: move functions into utils.[ch]
A future change will add another mctp test .c file, so move some of the common test setup from route.c into the utils object.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Link: https://patch.msgid.link/20250702-dev-forwarding-v5-7-1468191da8a4@codeconstruct.com.au Signed-off-by: Paolo Abeni <pabeni@redhat.com>
show more ...
|
46ee1646 | 02-Jul-2025 |
Jeremy Kerr <jk@codeconstruct.com.au> |
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>
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>
show more ...
|
96b341a8 | 02-Jul-2025 |
Jeremy Kerr <jk@codeconstruct.com.au> |
net: mctp: test: Add an addressed device constructor
Upcoming tests will check semantics of hardware addressing, which require a dev with ->addr_len != 0. Add a constructor to create a MCTP interfac
net: mctp: test: Add an addressed device constructor
Upcoming tests will check semantics of hardware addressing, which require a dev with ->addr_len != 0. Add a constructor to create a MCTP interface using a physically-addressed bus type.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Link: https://patch.msgid.link/20250702-dev-forwarding-v5-5-1468191da8a4@codeconstruct.com.au Signed-off-by: Paolo Abeni <pabeni@redhat.com>
show more ...
|
3007f90e | 02-Jul-2025 |
Jeremy Kerr <jk@codeconstruct.com.au> |
net: mctp: separate cb from direct-addressing routing
Now that we have the dst->haddr populated by sendmsg (when extended addressing is in use), we no longer need to stash the link-layer address in
net: mctp: separate cb from direct-addressing routing
Now that we have the dst->haddr populated by sendmsg (when extended addressing is in use), we no longer need to stash the link-layer address in the skb->cb.
Instead, only use skb->cb for incoming lladdr data.
While we're at it: remove cb->src, as was never used.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Link: https://patch.msgid.link/20250702-dev-forwarding-v5-4-1468191da8a4@codeconstruct.com.au Signed-off-by: Paolo Abeni <pabeni@redhat.com>
show more ...
|
269936db | 02-Jul-2025 |
Jeremy Kerr <jk@codeconstruct.com.au> |
net: mctp: separate routing database from routing operations
This change adds a struct mctp_dst, representing the result of a routing lookup. This decouples the struct mctp_route from the actual imp
net: mctp: separate routing database from routing operations
This change adds a struct mctp_dst, representing the result of a routing lookup. This decouples the struct mctp_route from the actual implementation of a routing operation.
This will allow for future routing changes which may require more involved lookup logic, such as gateway routing - which may require multiple traversals of the routing table.
Since we only use the struct mctp_route at lookup time, we no longer hold routes over a routing operation, as we only need it to populate the dst. However, we do hold the dev while the dst is active.
This requires some changes to the route test infrastructure, as we no longer have a mock route to handle the route output operation, and transient dsts are created by the routing code, so we can't override them as easily.
Instead, we use kunit->priv to stash a packet queue, and a custom dst_output function queues into that packet queue, which we can use for later expectations.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Link: https://patch.msgid.link/20250702-dev-forwarding-v5-3-1468191da8a4@codeconstruct.com.au Signed-off-by: Paolo Abeni <pabeni@redhat.com>
show more ...
|
fc2b87d0 | 02-Jul-2025 |
Jeremy Kerr <jk@codeconstruct.com.au> |
net: mctp: test: make cloned_frag buffers more appropriately-sized
In our input_cloned_frag test, we currently allocate our test buffers arbitrarily-sized at 100 bytes.
We only expect to receive a
net: mctp: test: make cloned_frag buffers more appropriately-sized
In our input_cloned_frag test, we currently allocate our test buffers arbitrarily-sized at 100 bytes.
We only expect to receive a max of 15 bytes from the socket, so reduce to a more appropriate size. There are some upcoming changes to the routing code which hit a frame-size limit on s390, so reduce the usage before that lands.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au> Link: https://patch.msgid.link/20250702-dev-forwarding-v5-2-1468191da8a4@codeconstruct.com.au Signed-off-by: Paolo Abeni <pabeni@redhat.com>
show more ...
|
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 ...
|