diff mbox series

[net-next,2/3] mctp: Add flow extension to skb

Message ID 20211028061833.2390354-2-jk@codeconstruct.com.au (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net-next,1/3] mctp: Return new key from mctp_alloc_local_tag | expand

Checks

Context Check Description
netdev/cover_letter warning Series does not have a cover letter
netdev/fixes_present success Fixes tag not required for -next series
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 11 maintainers not CCed: cong.wang@bytedance.com haokexin@gmail.com jonathan.lemon@gmail.com alobakin@pm.me memxor@gmail.com pabeni@redhat.com ilias.apalodimas@linaro.org elver@google.com willemb@google.com nogikh@google.com vvs@virtuozzo.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/module_param success Was 0 now: 0
netdev/build_32bit fail Errors and warnings before: 6050 this patch: 5678
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success No Fixes tag
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 86 lines checked
netdev/build_allmodconfig_warn fail Errors and warnings before: 6114 this patch: 5459
netdev/header_inline success No static functions without inline keyword in header files

Commit Message

Jeremy Kerr Oct. 28, 2021, 6:18 a.m. UTC
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.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
---
 include/linux/skbuff.h |  3 +++
 include/net/mctp.h     |  7 +++++++
 net/core/skbuff.c      | 19 +++++++++++++++++++
 net/mctp/Kconfig       |  6 +++++-
 4 files changed, 34 insertions(+), 1 deletion(-)

Comments

kernel test robot Oct. 28, 2021, 12:02 p.m. UTC | #1
Hi Jeremy,

I love your patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Jeremy-Kerr/mctp-Return-new-key-from-mctp_alloc_local_tag/20211028-142024
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 5a48585d7ec1d0e1e83539d56846c1e513ef66ea
config: hexagon-randconfig-r005-20211027 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 5db7568a6a1fcb408eb8988abdaff2a225a8eb72)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/587328c0d21081a26183368afcf4874a210889c3
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Jeremy-Kerr/mctp-Return-new-key-from-mctp_alloc_local_tag/20211028-142024
        git checkout 587328c0d21081a26183368afcf4874a210889c3
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=hexagon 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> net/core/skbuff.c:6572:5: warning: 'CONFIG_MCTP_FLOWS' is not defined, evaluates to 0 [-Wundef]
   #if CONFIG_MCTP_FLOWS
       ^
   1 warning generated.


vim +/CONFIG_MCTP_FLOWS +6572 net/core/skbuff.c

  6556	
  6557	void __skb_ext_put(struct skb_ext *ext)
  6558	{
  6559		/* If this is last clone, nothing can increment
  6560		 * it after check passes.  Avoids one atomic op.
  6561		 */
  6562		if (refcount_read(&ext->refcnt) == 1)
  6563			goto free_now;
  6564	
  6565		if (!refcount_dec_and_test(&ext->refcnt))
  6566			return;
  6567	free_now:
  6568	#ifdef CONFIG_XFRM
  6569		if (__skb_ext_exist(ext, SKB_EXT_SEC_PATH))
  6570			skb_ext_put_sp(skb_ext_get_ptr(ext, SKB_EXT_SEC_PATH));
  6571	#endif
> 6572	#if CONFIG_MCTP_FLOWS

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
kernel test robot Oct. 28, 2021, 1:09 p.m. UTC | #2
Hi Jeremy,

I love your patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Jeremy-Kerr/mctp-Return-new-key-from-mctp_alloc_local_tag/20211028-142024
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 5a48585d7ec1d0e1e83539d56846c1e513ef66ea
config: i386-buildonly-randconfig-r005-20211027 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 5db7568a6a1fcb408eb8988abdaff2a225a8eb72)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/587328c0d21081a26183368afcf4874a210889c3
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Jeremy-Kerr/mctp-Return-new-key-from-mctp_alloc_local_tag/20211028-142024
        git checkout 587328c0d21081a26183368afcf4874a210889c3
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> net/core/skbuff.c:6572:5: error: 'CONFIG_MCTP_FLOWS' is not defined, evaluates to 0 [-Werror,-Wundef]
   #if CONFIG_MCTP_FLOWS
       ^
   1 error generated.


vim +/CONFIG_MCTP_FLOWS +6572 net/core/skbuff.c

  6556	
  6557	void __skb_ext_put(struct skb_ext *ext)
  6558	{
  6559		/* If this is last clone, nothing can increment
  6560		 * it after check passes.  Avoids one atomic op.
  6561		 */
  6562		if (refcount_read(&ext->refcnt) == 1)
  6563			goto free_now;
  6564	
  6565		if (!refcount_dec_and_test(&ext->refcnt))
  6566			return;
  6567	free_now:
  6568	#ifdef CONFIG_XFRM
  6569		if (__skb_ext_exist(ext, SKB_EXT_SEC_PATH))
  6570			skb_ext_put_sp(skb_ext_get_ptr(ext, SKB_EXT_SEC_PATH));
  6571	#endif
> 6572	#if CONFIG_MCTP_FLOWS

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index cb96f1e6460c..0bd6520329f6 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -4243,6 +4243,9 @@  enum skb_ext_id {
 #endif
 #if IS_ENABLED(CONFIG_MPTCP)
 	SKB_EXT_MPTCP,
+#endif
+#if IS_ENABLED(CONFIG_MCTP_FLOWS)
+	SKB_EXT_MCTP,
 #endif
 	SKB_EXT_NUM, /* must be last */
 };
diff --git a/include/net/mctp.h b/include/net/mctp.h
index 23bec708f4c7..7a5ba801703c 100644
--- a/include/net/mctp.h
+++ b/include/net/mctp.h
@@ -189,6 +189,13 @@  static inline struct mctp_skb_cb *mctp_cb(struct sk_buff *skb)
 	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.
  *
  * These are held in the pernet->mctp.routes list, with RCU protection for
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 74601bbc56ac..2505e1845f57 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -70,6 +70,7 @@ 
 #include <net/xfrm.h>
 #include <net/mpls.h>
 #include <net/mptcp.h>
+#include <net/mctp.h>
 #include <net/page_pool.h>
 
 #include <linux/uaccess.h>
@@ -4430,6 +4431,9 @@  static const u8 skb_ext_type_len[] = {
 #if IS_ENABLED(CONFIG_MPTCP)
 	[SKB_EXT_MPTCP] = SKB_EXT_CHUNKSIZEOF(struct mptcp_ext),
 #endif
+#if IS_ENABLED(CONFIG_MCTP)
+	[SKB_EXT_MCTP] = SKB_EXT_CHUNKSIZEOF(struct mctp_flow),
+#endif
 };
 
 static __always_inline unsigned int skb_ext_total_length(void)
@@ -4446,6 +4450,9 @@  static __always_inline unsigned int skb_ext_total_length(void)
 #endif
 #if IS_ENABLED(CONFIG_MPTCP)
 		skb_ext_type_len[SKB_EXT_MPTCP] +
+#endif
+#if IS_ENABLED(CONFIG_MCTP)
+		skb_ext_type_len[SKB_EXT_MCTP] +
 #endif
 		0;
 }
@@ -6519,6 +6526,14 @@  static void skb_ext_put_sp(struct sec_path *sp)
 }
 #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)
 {
 	struct skb_ext *ext = skb->extensions;
@@ -6554,6 +6569,10 @@  void __skb_ext_put(struct skb_ext *ext)
 	if (__skb_ext_exist(ext, SKB_EXT_SEC_PATH))
 		skb_ext_put_sp(skb_ext_get_ptr(ext, SKB_EXT_SEC_PATH));
 #endif
+#if 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);
 }
diff --git a/net/mctp/Kconfig b/net/mctp/Kconfig
index 868c92272cbd..de739f49c40c 100644
--- a/net/mctp/Kconfig
+++ b/net/mctp/Kconfig
@@ -1,7 +1,7 @@ 
 
 menuconfig MCTP
 	depends on NET
-	tristate "MCTP core protocol support"
+	bool "MCTP core protocol support"
 	help
 	  Management Component Transport Protocol (MCTP) is an in-system
 	  protocol for communicating between management controllers and
@@ -16,3 +16,7 @@  config MCTP_TEST
         bool "MCTP core tests" if !KUNIT_ALL_TESTS
         depends on MCTP=y && KUNIT=y
         default KUNIT_ALL_TESTS
+
+config MCTP_FLOWS
+	bool
+	select SKB_EXTENSIONS