Commit 78476d31 authored by Jeremy Kerr's avatar Jeremy Kerr Committed by David S. Miller

mctp: Add flow extension to skb

This change adds a new skb extension for MCTP, to represent a
request/response flow.

The intention is to use this in a later change to allow i2c controllers
to correctly configure a multiplexer over a flow.

Since we have a cleanup function in the core path (if an extension is
present), we'll need to make CONFIG_MCTP a bool, rather than a tristate.

Includes a fix for a build warning with clang:
Reported-by: default avatarkernel test robot <lkp@intel.com>
Signed-off-by: default avatarJeremy Kerr <jk@codeconstruct.com.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 212c10c3
...@@ -4243,6 +4243,9 @@ enum skb_ext_id { ...@@ -4243,6 +4243,9 @@ enum skb_ext_id {
#endif #endif
#if IS_ENABLED(CONFIG_MPTCP) #if IS_ENABLED(CONFIG_MPTCP)
SKB_EXT_MPTCP, SKB_EXT_MPTCP,
#endif
#if IS_ENABLED(CONFIG_MCTP_FLOWS)
SKB_EXT_MCTP,
#endif #endif
SKB_EXT_NUM, /* must be last */ SKB_EXT_NUM, /* must be last */
}; };
......
...@@ -189,6 +189,13 @@ static inline struct mctp_skb_cb *mctp_cb(struct sk_buff *skb) ...@@ -189,6 +189,13 @@ static inline struct mctp_skb_cb *mctp_cb(struct sk_buff *skb)
return (void *)(skb->cb); return (void *)(skb->cb);
} }
/* If CONFIG_MCTP_FLOWS, we may add one of these as a SKB extension,
* indicating the flow to the device driver.
*/
struct mctp_flow {
struct mctp_sk_key *key;
};
/* Route definition. /* Route definition.
* *
* These are held in the pernet->mctp.routes list, with RCU protection for * These are held in the pernet->mctp.routes list, with RCU protection for
......
...@@ -70,6 +70,7 @@ ...@@ -70,6 +70,7 @@
#include <net/xfrm.h> #include <net/xfrm.h>
#include <net/mpls.h> #include <net/mpls.h>
#include <net/mptcp.h> #include <net/mptcp.h>
#include <net/mctp.h>
#include <net/page_pool.h> #include <net/page_pool.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
...@@ -4440,6 +4441,9 @@ static const u8 skb_ext_type_len[] = { ...@@ -4440,6 +4441,9 @@ static const u8 skb_ext_type_len[] = {
#if IS_ENABLED(CONFIG_MPTCP) #if IS_ENABLED(CONFIG_MPTCP)
[SKB_EXT_MPTCP] = SKB_EXT_CHUNKSIZEOF(struct mptcp_ext), [SKB_EXT_MPTCP] = SKB_EXT_CHUNKSIZEOF(struct mptcp_ext),
#endif #endif
#if IS_ENABLED(CONFIG_MCTP_FLOWS)
[SKB_EXT_MCTP] = SKB_EXT_CHUNKSIZEOF(struct mctp_flow),
#endif
}; };
static __always_inline unsigned int skb_ext_total_length(void) static __always_inline unsigned int skb_ext_total_length(void)
...@@ -4456,6 +4460,9 @@ static __always_inline unsigned int skb_ext_total_length(void) ...@@ -4456,6 +4460,9 @@ static __always_inline unsigned int skb_ext_total_length(void)
#endif #endif
#if IS_ENABLED(CONFIG_MPTCP) #if IS_ENABLED(CONFIG_MPTCP)
skb_ext_type_len[SKB_EXT_MPTCP] + skb_ext_type_len[SKB_EXT_MPTCP] +
#endif
#if IS_ENABLED(CONFIG_MCTP_FLOWS)
skb_ext_type_len[SKB_EXT_MCTP] +
#endif #endif
0; 0;
} }
...@@ -6529,6 +6536,14 @@ static void skb_ext_put_sp(struct sec_path *sp) ...@@ -6529,6 +6536,14 @@ static void skb_ext_put_sp(struct sec_path *sp)
} }
#endif #endif
#ifdef CONFIG_MCTP_FLOWS
static void skb_ext_put_mctp(struct mctp_flow *flow)
{
if (flow->key)
mctp_key_unref(flow->key);
}
#endif
void __skb_ext_del(struct sk_buff *skb, enum skb_ext_id id) void __skb_ext_del(struct sk_buff *skb, enum skb_ext_id id)
{ {
struct skb_ext *ext = skb->extensions; struct skb_ext *ext = skb->extensions;
...@@ -6564,6 +6579,10 @@ void __skb_ext_put(struct skb_ext *ext) ...@@ -6564,6 +6579,10 @@ void __skb_ext_put(struct skb_ext *ext)
if (__skb_ext_exist(ext, SKB_EXT_SEC_PATH)) if (__skb_ext_exist(ext, SKB_EXT_SEC_PATH))
skb_ext_put_sp(skb_ext_get_ptr(ext, SKB_EXT_SEC_PATH)); skb_ext_put_sp(skb_ext_get_ptr(ext, SKB_EXT_SEC_PATH));
#endif #endif
#ifdef CONFIG_MCTP_FLOWS
if (__skb_ext_exist(ext, SKB_EXT_MCTP))
skb_ext_put_mctp(skb_ext_get_ptr(ext, SKB_EXT_MCTP));
#endif
kmem_cache_free(skbuff_ext_cache, ext); kmem_cache_free(skbuff_ext_cache, ext);
} }
......
menuconfig MCTP menuconfig MCTP
depends on NET depends on NET
tristate "MCTP core protocol support" bool "MCTP core protocol support"
help help
Management Component Transport Protocol (MCTP) is an in-system Management Component Transport Protocol (MCTP) is an in-system
protocol for communicating between management controllers and protocol for communicating between management controllers and
...@@ -16,3 +16,8 @@ config MCTP_TEST ...@@ -16,3 +16,8 @@ config MCTP_TEST
bool "MCTP core tests" if !KUNIT_ALL_TESTS bool "MCTP core tests" if !KUNIT_ALL_TESTS
depends on MCTP=y && KUNIT=y depends on MCTP=y && KUNIT=y
default KUNIT_ALL_TESTS default KUNIT_ALL_TESTS
config MCTP_FLOWS
bool
depends on MCTP
select SKB_EXTENSIONS
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment