mctp: Add MCTP base
authorJeremy Kerr <jk@codeconstruct.com.au>
Thu, 29 Jul 2021 02:20:39 +0000 (10:20 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 29 Jul 2021 14:06:49 +0000 (15:06 +0100)
Add basic Kconfig, an initial (empty) af_mctp source object, and
{AF,PF}_MCTP definitions, and the required definitions for a new
protocol type.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
12 files changed:
MAINTAINERS
include/linux/socket.h
include/uapi/linux/mctp.h [new file with mode: 0644]
net/Kconfig
net/Makefile
net/core/sock.c
net/mctp/Kconfig [new file with mode: 0644]
net/mctp/Makefile [new file with mode: 0644]
net/mctp/af_mctp.c [new file with mode: 0644]
net/socket.c
security/selinux/hooks.c
security/selinux/include/classmap.h

index 4c32a9c532b7c6bc6bc33aae44a5119c2d73d0f6..22a1ff9afd9df45a1d1ab708e963263425a8dc40 100644 (file)
@@ -11032,6 +11032,13 @@ F:     drivers/mailbox/arm_mhuv2.c
 F:     include/linux/mailbox/arm_mhuv2_message.h
 F:     Documentation/devicetree/bindings/mailbox/arm,mhuv2.yaml
 
+MANAGEMENT COMPONENT TRANSPORT PROTOCOL (MCTP)
+M:     Jeremy Kerr <jk@codeconstruct.com.au>
+M:     Matt Johnston <matt@codeconstruct.com.au>
+L:     netdev@vger.kernel.org
+S:     Maintained
+F:     net/mctp/
+
 MAN-PAGES: MANUAL PAGES FOR LINUX -- Sections 2, 3, 4, 5, and 7
 M:     Michael Kerrisk <mtk.manpages@gmail.com>
 L:     linux-man@vger.kernel.org
index 0d8e3dcb7f8816fdf60bd351b431486f773ad9c7..fd9ce51582d859525f6a41eaa4a127f3b10e6e3c 100644 (file)
@@ -223,8 +223,11 @@ struct ucred {
                                 * reuses AF_INET address family
                                 */
 #define AF_XDP         44      /* XDP sockets                  */
+#define AF_MCTP                45      /* Management component
+                                * transport protocol
+                                */
 
-#define AF_MAX         45      /* For now.. */
+#define AF_MAX         46      /* For now.. */
 
 /* Protocol families, same as address families. */
 #define PF_UNSPEC      AF_UNSPEC
@@ -274,6 +277,7 @@ struct ucred {
 #define PF_QIPCRTR     AF_QIPCRTR
 #define PF_SMC         AF_SMC
 #define PF_XDP         AF_XDP
+#define PF_MCTP                AF_MCTP
 #define PF_MAX         AF_MAX
 
 /* Maximum queue length specifiable by listen.  */
diff --git a/include/uapi/linux/mctp.h b/include/uapi/linux/mctp.h
new file mode 100644 (file)
index 0000000..2640a58
--- /dev/null
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * Management Component Transport Protocol (MCTP)
+ *
+ * Copyright (c) 2021 Code Construct
+ * Copyright (c) 2021 Google
+ */
+
+#ifndef __UAPI_MCTP_H
+#define __UAPI_MCTP_H
+
+struct sockaddr_mctp {
+};
+
+#endif /* __UAPI_MCTP_H */
index c7392c449b254b8887866711f660efd001b8e10b..fb13460c6dab37f8c6ecab0efa29c22112f8c3c2 100644 (file)
@@ -363,6 +363,7 @@ source "net/bluetooth/Kconfig"
 source "net/rxrpc/Kconfig"
 source "net/kcm/Kconfig"
 source "net/strparser/Kconfig"
+source "net/mctp/Kconfig"
 
 config FIB_RULES
        bool
index 9ca9572188feb21206b8df7e432d0ffae5ec1a5d..fbfeb8a0bb379594cfd9d4e4a3bfd314c997c39d 100644 (file)
@@ -78,3 +78,4 @@ obj-$(CONFIG_QRTR)            += qrtr/
 obj-$(CONFIG_NET_NCSI)         += ncsi/
 obj-$(CONFIG_XDP_SOCKETS)      += xdp/
 obj-$(CONFIG_MPTCP)            += mptcp/
+obj-$(CONFIG_MCTP)             += mctp/
index a3eea6e0b30a7d43793f567ffa526092c03e3546..9671c32e6ef56d3e7fe9f132bc8f36bae4ca5ece 100644 (file)
@@ -226,6 +226,7 @@ static struct lock_class_key af_family_kern_slock_keys[AF_MAX];
   x "AF_IEEE802154",   x "AF_CAIF"     ,       x "AF_ALG"      , \
   x "AF_NFC"   ,       x "AF_VSOCK"    ,       x "AF_KCM"      , \
   x "AF_QIPCRTR",      x "AF_SMC"      ,       x "AF_XDP"      , \
+  x "AF_MCTP"  , \
   x "AF_MAX"
 
 static const char *const af_family_key_strings[AF_MAX+1] = {
diff --git a/net/mctp/Kconfig b/net/mctp/Kconfig
new file mode 100644 (file)
index 0000000..2cdf3d0
--- /dev/null
@@ -0,0 +1,13 @@
+
+menuconfig MCTP
+       depends on NET
+       tristate "MCTP core protocol support"
+       help
+         Management Component Transport Protocol (MCTP) is an in-system
+         protocol for communicating between management controllers and
+         their managed devices (peripherals, host processors, etc.). The
+         protocol is defined by DMTF specification DSP0236.
+
+         This option enables core MCTP support. For communicating with other
+         devices, you'll want to enable a driver for a specific hardware
+         channel.
diff --git a/net/mctp/Makefile b/net/mctp/Makefile
new file mode 100644 (file)
index 0000000..7c056b1
--- /dev/null
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_MCTP) += mctp.o
+mctp-objs := af_mctp.o
diff --git a/net/mctp/af_mctp.c b/net/mctp/af_mctp.c
new file mode 100644 (file)
index 0000000..8f9c77e
--- /dev/null
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Management Component Transport Protocol (MCTP)
+ *
+ * Copyright (c) 2021 Code Construct
+ * Copyright (c) 2021 Google
+ */
+
+#include <linux/module.h>
+
+MODULE_DESCRIPTION("MCTP core");
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Jeremy Kerr <jk@codeconstruct.com.au>");
index 42665bd99ea4a692aa138fdbaf8172713b20a7cc..3c10504e46d9267f1b885abb208493cfa6c2e9cd 100644 (file)
@@ -212,6 +212,7 @@ static const char * const pf_family_names[] = {
        [PF_QIPCRTR]    = "PF_QIPCRTR",
        [PF_SMC]        = "PF_SMC",
        [PF_XDP]        = "PF_XDP",
+       [PF_MCTP]       = "PF_MCTP",
 };
 
 /*
index b0032c42333eb82138e1c8861d8b8874c970f394..2143f590e3d643fd4b0399b5752c437c7262ce64 100644 (file)
@@ -1330,7 +1330,9 @@ static inline u16 socket_type_to_security_class(int family, int type, int protoc
                        return SECCLASS_SMC_SOCKET;
                case PF_XDP:
                        return SECCLASS_XDP_SOCKET;
-#if PF_MAX > 45
+               case PF_MCTP:
+                       return SECCLASS_MCTP_SOCKET;
+#if PF_MAX > 46
 #error New address family defined, please update this function.
 #endif
                }
index 62d19bccf3de1fae4b64ef6d2a7aee05b0a20477..084757ff43906371bdbda842abaaa4f392aa489e 100644 (file)
@@ -246,6 +246,8 @@ struct security_class_mapping secclass_map[] = {
            NULL } },
        { "xdp_socket",
          { COMMON_SOCK_PERMS, NULL } },
+       { "mctp_socket",
+         { COMMON_SOCK_PERMS, NULL } },
        { "perf_event",
          { "open", "cpu", "kernel", "tracepoint", "read", "write", NULL } },
        { "lockdown",
@@ -255,6 +257,6 @@ struct security_class_mapping secclass_map[] = {
        { NULL }
   };
 
-#if PF_MAX > 45
+#if PF_MAX > 46
 #error New address family defined, please update secclass_map.
 #endif