Skip to contentSkip to conversation

Add Management Controller Transport Protocol support

RFC PATCH Superseded Jeremy Kerr 2 participants 19 messages Jun 3, 2021

Subsystems (5)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
author maintainer
#11 lore raw

RFC PATCH 9/16 mctp: Add neighbour implementation

In reply to Jeremy Kerr

From: Matt Johnston <[email protected]>

Add an initial neighbour table implementation, to be used in the route output path.

---
 include/net/mctp.h       |  25 +++++++
 include/net/mctpdevice.h |   1 +
 include/net/netns/mctp.h |   4 ++
 net/mctp/Makefile        |   2 +-
 net/mctp/af_mctp.c       |   5 ++
 net/mctp/device.c        |   1 +
 net/mctp/neigh.c         | 141 +++++++++++++++++++++++++++++++++++++++
 7 files changed, 178 insertions(+), 1 deletion(-)
 create mode 100644 net/mctp/neigh.c
include/net/mctp.h +25 -0
index 131c55850853..a37f77c787a5 100644
@@ -119,6 +119,31 @@ int mctp_route_add_local(struct mctp_dev *mdev, mctp_eid_t addr);
 int mctp_route_remove_local(struct mctp_dev *mdev, mctp_eid_t addr);
 void mctp_route_remove_dev(struct mctp_dev *mdev);
 
+/* neighbour definitions */
+enum mctp_neigh_source {
+	MCTP_NEIGH_STATIC,
+	MCTP_NEIGH_DISCOVER,
+};
+
+struct mctp_neigh {
+	struct mctp_dev		*dev;
+	mctp_eid_t		eid;
+	enum mctp_neigh_source	source;
+
+	unsigned char		ha[MAX_ADDR_LEN];
+
+	struct list_head	list;
+	struct rcu_head		rcu;
+};
+
+int mctp_neigh_init(void);
+void mctp_neigh_exit(void);
+
+// ret_hwaddr may be NULL, otherwise must have space for MAX_ADDR_LEN
+int mctp_neigh_lookup(struct mctp_dev *dev, mctp_eid_t eid,
+		      void *ret_hwaddr);
+void mctp_neigh_remove_dev(struct mctp_dev *mdev);
+
 int mctp_routes_init(void);
 void mctp_routes_exit(void);
 
include/net/mctpdevice.h +1 -0
index a6ac4aee5d7b..f1ffba088d56 100644
@@ -37,5 +37,6 @@ struct mctp_dev {
 
 struct mctp_dev *mctp_dev_get_rtnl(const struct net_device *dev);
 struct mctp_dev *__mctp_dev_get(const struct net_device *dev);
+struct mctp_dev *mctp_dev_get_rtnl(const struct net_device *dev);
 
 #endif /* __NET_MCTPDEVICE_H */
include/net/netns/mctp.h +4 -0
index 508459b08a59..2f5ebeeb320e 100644
@@ -11,6 +11,10 @@
 struct netns_mctp {
 	/* Only updated under RTNL, entries freed via RCU */
 	struct list_head routes;
+
+	/* neighbour table */
+	struct mutex neigh_lock;
+	struct list_head neighbours;
 };
 
 #endif /* __NETNS_MCTP_H__ */
net/mctp/Makefile +1 -1
index b1a330e9d82a..0171333384d7 100644
@@ -1,3 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_MCTP) += mctp.o
-mctp-objs := af_mctp.o device.o route.o
+mctp-objs := af_mctp.o device.o route.o neigh.o
net/mctp/af_mctp.c +5 -0
index 081c7b8005da..227cd49203b0 100644
@@ -161,6 +161,10 @@ static __init int mctp_init(void)
 	if (rc)
 		goto err_unreg_proto;
 
+	rc = mctp_neigh_init();
+	if (rc)
+		goto err_unreg_proto;
+
 	mctp_device_init();
 
 	return 0;
@@ -176,6 +180,7 @@ static __init int mctp_init(void)
 static __exit void mctp_exit(void)
 {
 	mctp_device_exit();
+	mctp_neigh_exit();
 	mctp_routes_exit();
 	proto_unregister(&mctp_proto);
 	sock_unregister(PF_MCTP);
net/mctp/device.c +1 -0
index 273041ed2d3e..d3ca9f664b30 100644
@@ -285,6 +285,7 @@ static void mctp_unregister(struct net_device *dev)
 	RCU_INIT_POINTER(mdev->dev->mctp_ptr, NULL);
 
 	mctp_route_remove_dev(mdev);
+	mctp_neigh_remove_dev(mdev);
 	list_for_each_entry_safe(ifa, tmp, &mdev->addrs, dev_list) {
 		list_del_rcu(&ifa->dev_list);
 		kfree_rcu(ifa, rcu);
net/mctp/neigh.c new file +141 -0

141 lines not on this page · raw message

Signature · 1 line
2.30.2
author maintainer
#1 lore raw

RFC PATCH 1/16 mctp: Add MCTP base

In reply to Jeremy Kerr

Add basic Kconfig, an initial (empty) af_mctp source object, and {AF,PF}_MCTP definitions.

---
 MAINTAINERS               |  7 +++++++
 include/linux/socket.h    |  6 +++++-
 include/uapi/linux/mctp.h | 15 +++++++++++++++
 net/Kconfig               |  1 +
 net/Makefile              |  1 +
 net/mctp/Kconfig          | 13 +++++++++++++
 net/mctp/Makefile         |  3 +++
 net/mctp/af_mctp.c        |  7 +++++++
 8 files changed, 52 insertions(+), 1 deletion(-)
 create mode 100644 include/uapi/linux/mctp.h
 create mode 100644 net/mctp/Kconfig
 create mode 100644 net/mctp/Makefile
 create mode 100644 net/mctp/af_mctp.c
MAINTAINERS +7 -0
index 503fd21901f1..5041ea78ab97 100644
@@ -10869,6 +10869,13 @@ F:	drivers/mailbox/arm_mhuv2.c
 F:	include/linux/mailbox/arm_mhuv2_message.h
 F:	Documentation/devicetree/bindings/mailbox/arm,mhuv2.yaml
 
+MANAGEMENT CONTROLLER TRANSPORT PROTOCOL (MCTP)
+M:	Jeremy Kerr <[email protected]>
+M:	Matt Johnston <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	net/mctp/
+
 MAN-PAGES: MANUAL PAGES FOR LINUX -- Sections 2, 3, 4, 5, and 7
 M:	Michael Kerrisk <[email protected]>
 L:	[email protected]
include/linux/socket.h +5 -1
index b8fc5c53ba6f..40f866575d3d 100644
@@ -223,8 +223,11 @@ struct ucred {
 				 * reuses AF_INET address family
 				 */
 #define AF_XDP		44	/* XDP sockets			*/
+#define AF_MCTP		45	/* Management controller
+				 * 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.  */
include/uapi/linux/mctp.h new file +15 -0
new file mode 100644
index 000000000000..eec6715143a0
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Management Controller 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 */
net/Kconfig +1 -0
index c7392c449b25..fb13460c6dab 100644
@@ -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
net/Makefile +1 -0
index 9ca9572188fe..fbfeb8a0bb37 100644
@@ -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/
net/mctp/Kconfig new file +13 -0
new file mode 100644
index 000000000000..259aca76da60
@@ -0,0 +1,13 @@
+
+menuconfig MCTP
+	depends on NET
+	tristate "MCTP core protocol support"
+	help
+	  Management Controller 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.
net/mctp/Makefile new file +3 -0
new file mode 100644
index 000000000000..7c056b1b7939
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_MCTP) += mctp.o
+mctp-objs := af_mctp.o
net/mctp/af_mctp.c new file +7 -0
new file mode 100644
index 000000000000..87823fd3a11e
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Management Controller Transport Protocol (MCTP)
+ *
+ * Copyright (c) 2021 Code Construct
+ * Copyright (c) 2021 Google
+ */
Signature · 1 line
2.30.2
author maintainer
#18 lore raw

RFC PATCH 16/16 mctp: Add MCTP overview document

In reply to Jeremy Kerr

This change adds a brief document about the sockets API provided for sending and receiving MCTP messages from userspace.

This is roughly based on the OpenBMC design document, at:

https://github.com/openbmc/docs/blob/master/designs/mctp/mctp-kernel.md

---
 Documentation/networking/index.rst |   1 +
 Documentation/networking/mctp.rst  | 213 +++++++++++++++++++++++++++++
 MAINTAINERS                        |   1 +
 3 files changed, 215 insertions(+)
 create mode 100644 Documentation/networking/mctp.rst
Documentation/networking/index.rst +1 -0
index e9ce55992aa9..eea3a79f4ea0 100644
@@ -68,6 +68,7 @@ Contents:
    l2tp
    lapb-module
    mac80211-injection
+   mctp
    mpls-sysctl
    mptcp-sysctl
    multiqueue
Documentation/networking/mctp.rst new file +213 -0

213 lines not on this page · raw message

MAINTAINERS +1 -0
index d1fd014f9484..3a735d9f830d 100644
@@ -10874,6 +10874,7 @@ M:	Jeremy Kerr <[email protected]>
 M:	Matt Johnston <[email protected]>
 L:	[email protected]
 S:	Maintained
+F:	Documentation/networking/mctp.rst
 F:	drivers/net/mctp/
 F:	include/net/mctp.h
 F:	include/net/mctpdevice.h
Signature · 1 line
2.30.2
author maintainer
#10 lore raw

RFC PATCH 8/16 mctp: Add netlink route management

In reply to Jeremy Kerr

From: Matt Johnston <[email protected]>

This change adds RTM_GETROUTE, RTM_NEWROUTE & RTM_DELROUTE handlers, allowing management of the MCTP route table.

Includes changes from Jeremy Kerr <[email protected]>.

---
 include/net/mctp.h |   4 +
 net/mctp/route.c   | 252 +++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 247 insertions(+), 9 deletions(-)
include/net/mctp.h +4 -0
index 79ac1202f8e5..131c55850853 100644
@@ -111,6 +111,10 @@ int mctp_local_output(struct sock *sk, struct mctp_route *rt,
 		      struct sk_buff *skb, mctp_eid_t daddr, u8 req_tag);
 
 /* routing <--> device interface */
+int mctp_route_add(struct mctp_dev *mdev, mctp_eid_t daddr_start,
+		   unsigned int daddr_extent, unsigned int mtu, bool is_local);
+int mctp_route_remove(struct mctp_dev *mdev, mctp_eid_t daddr_start,
+		      unsigned int daddr_extent);
 int mctp_route_add_local(struct mctp_dev *mdev, mctp_eid_t addr);
 int mctp_route_remove_local(struct mctp_dev *mdev, mctp_eid_t addr);
 void mctp_route_remove_dev(struct mctp_dev *mdev);
net/mctp/route.c +243 -9

316 lines not on this page · raw message

Signature · 1 line
2.30.2
author maintainer
#12 lore raw

RFC PATCH 10/16 mctp: Add neighbour netlink interface

In reply to Jeremy Kerr

From: Matt Johnston <[email protected]>

This change adds the netlink interfaces for manipulating the MCTP neighbour table.

---
 net/mctp/neigh.c | 207 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 204 insertions(+), 3 deletions(-)
net/mctp/neigh.c +204 -3
index acf4f38c878b..5fb3cbaa03ac 100644
@@ -21,9 +21,9 @@
 #include <net/netlink.h>
 #include <net/sock.h>
 
-static int __always_unused mctp_neigh_add(struct mctp_dev *mdev, mctp_eid_t eid,
-					  enum mctp_neigh_source source,
-					  size_t lladdr_len, const void *lladdr)
+static int mctp_neigh_add(struct mctp_dev *mdev, mctp_eid_t eid,
+			  enum mctp_neigh_source source,
+			  size_t lladdr_len, const void *lladdr)
 {
 	struct net *net = dev_net(mdev->dev);
 	struct mctp_neigh *neigh;
@@ -85,6 +85,196 @@ void mctp_neigh_remove_dev(struct mctp_dev *mdev)
 	mutex_unlock(&net->mctp.neigh_lock);
 }
 
+// TODO: add a "source" flag so netlink can only delete static neighbours?
+static int mctp_neigh_remove(struct mctp_dev *mdev, mctp_eid_t eid)
+{
+	struct net *net = dev_net(mdev->dev);
+	struct mctp_neigh *neigh, *tmp;
+	bool dropped = false;
+
+	mutex_lock(&net->mctp.neigh_lock);
+	list_for_each_entry_safe(neigh, tmp, &net->mctp.neighbours, list) {
+		if (neigh->dev == mdev && neigh->eid == eid) {
+			list_del_rcu(&neigh->list);
+			/* TODO: immediate RTM_DELNEIGH */
+			call_rcu(&neigh->rcu, __mctp_neigh_free);
+			dropped = true;
+		}
+	}
+
+	mutex_unlock(&net->mctp.neigh_lock);
+	return dropped ? 0 : -ENOENT;
+}
+
+static const struct nla_policy nd_mctp_policy[NDA_MAX + 1] = {
+	[NDA_DST]		= { .type = NLA_U8 },
+	[NDA_LLADDR]		= { .type = NLA_BINARY, .len = MAX_ADDR_LEN },
+};
+
+static int mctp_rtm_newneigh(struct sk_buff *skb, struct nlmsghdr *nlh,
+			     struct netlink_ext_ack *extack)
+{
+	struct net *net = sock_net(skb->sk);
+	struct net_device *dev;
+	struct mctp_dev *mdev;
+	struct ndmsg *ndm;
+	struct nlattr *tb[NDA_MAX + 1];
+	int rc;
+	mctp_eid_t eid;
+	void *lladdr;
+	int lladdr_len;
+
+	rc = nlmsg_parse(nlh, sizeof(*ndm), tb, NDA_MAX, nd_mctp_policy,
+			 extack);
+	if (rc < 0) {
+		NL_SET_ERR_MSG(extack, "lladdr too large?");
+		return rc;
+	}
+
+	if (!tb[NDA_DST]) {
+		NL_SET_ERR_MSG(extack, "Neighbour EID must be specified");
+		return -EINVAL;
+	}
+
+	if (!tb[NDA_LLADDR]) {
+		NL_SET_ERR_MSG(extack, "Neighbour lladdr must be specified");
+		return -EINVAL;
+	}
+
+	eid = nla_get_u8(tb[NDA_DST]);
+	if (!mctp_address_ok(eid)) {
+		NL_SET_ERR_MSG(extack, "Invalid neighbour EID");
+		return -EINVAL;
+	}
+
+	lladdr = nla_data(tb[NDA_LLADDR]);
+	lladdr_len = nla_len(tb[NDA_LLADDR]);
+
+	ndm = nlmsg_data(nlh);
+
+	dev = __dev_get_by_index(net, ndm->ndm_ifindex);
+	if (!dev)
+		return -ENODEV;
+
+	mdev = mctp_dev_get_rtnl(dev);
+	if (!mdev)
+		return -ENODEV;
+
+	if (lladdr_len != dev->addr_len) {
+		NL_SET_ERR_MSG(extack, "Wrong lladdr length");
+		return -EINVAL;
+	}
+
+	return mctp_neigh_add(mdev, eid, MCTP_NEIGH_STATIC,
+			lladdr_len, lladdr);
+}
+
+static int mctp_rtm_delneigh(struct sk_buff *skb, struct nlmsghdr *nlh,
+			     struct netlink_ext_ack *extack)
+{
+	struct net *net = sock_net(skb->sk);
+	struct nlattr *tb[NDA_MAX + 1];
+	struct net_device *dev;
+	struct mctp_dev *mdev;
+	struct ndmsg *ndm;
+	int rc;
+	mctp_eid_t eid;
+
+	rc = nlmsg_parse(nlh, sizeof(*ndm), tb, NDA_MAX, nd_mctp_policy,
+			 extack);
+	if (rc < 0) {
+		NL_SET_ERR_MSG(extack, "incorrect format");
+		return rc;
+	}
+
+	if (!tb[NDA_DST]) {
+		NL_SET_ERR_MSG(extack, "Neighbour EID must be specified");
+		return -EINVAL;
+	}
+	eid = nla_get_u8(tb[NDA_DST]);
+
+	ndm = nlmsg_data(nlh);
+	dev = __dev_get_by_index(net, ndm->ndm_ifindex);
+	if (!dev)
+		return -ENODEV;
+
+	mdev = mctp_dev_get_rtnl(dev);
+	if (!mdev)
+		return -ENODEV;
+
+	return mctp_neigh_remove(mdev, eid);
+}
+
+static int mctp_fill_neigh(struct sk_buff *skb, u32 portid, u32 seq, int event,
+			   unsigned int flags, struct mctp_neigh *neigh)
+{
+	struct net_device *dev = neigh->dev->dev;
+	struct nlmsghdr *nlh;
+	struct ndmsg *hdr;
+
+	nlh = nlmsg_put(skb, portid, seq, event, sizeof(*hdr), flags);
+	if (!nlh)
+		return -EMSGSIZE;
+
+	hdr = nlmsg_data(nlh);
+	hdr->ndm_family = AF_MCTP;
+	hdr->ndm_ifindex = dev->ifindex;
+	hdr->ndm_state = 0; // TODO other state bits?
+	if (neigh->source == MCTP_NEIGH_STATIC)
+		hdr->ndm_state |= NUD_PERMANENT;
+	hdr->ndm_flags = 0;
+	hdr->ndm_type = RTN_UNICAST; // TODO: is loopback RTN_LOCAL?
+
+	if (nla_put_u8(skb, NDA_DST, neigh->eid))
+		goto cancel;
+
+	if (nla_put(skb, NDA_LLADDR, dev->addr_len, neigh->ha))
+		goto cancel;
+
+	nlmsg_end(skb, nlh);
+
+	return 0;
+cancel:
+	nlmsg_cancel(skb, nlh);
+	return -EMSGSIZE;
+}
+
+static int mctp_rtm_getneigh(struct sk_buff *skb, struct netlink_callback *cb)
+{
+	struct net *net = sock_net(skb->sk);
+	int rc, idx, req_ifindex;
+	struct mctp_neigh *neigh;
+	struct ndmsg *ndmsg;
+	struct {
+		int idx;
+	} *cbctx = (void *)cb->ctx;
+
+	ndmsg = nlmsg_data(cb->nlh);
+	req_ifindex = ndmsg->ndm_ifindex;
+
+	idx = 0;
+	rcu_read_lock();
+	list_for_each_entry_rcu(neigh, &net->mctp.neighbours, list) {
+		if (idx < cbctx->idx)
+			goto cont;
+
+		rc = 0;
+		if (req_ifindex == 0 || req_ifindex == neigh->dev->dev->ifindex)
+			rc = mctp_fill_neigh(skb, NETLINK_CB(cb->skb).portid,
+					     cb->nlh->nlmsg_seq,
+					     RTM_NEWNEIGH, NLM_F_MULTI, neigh);
+
+		if (rc)
+			break;
+cont:
+		idx++;
+	}
+	rcu_read_unlock();
+
+	cbctx->idx = idx;
+	return skb->len;
+}
+
 int mctp_neigh_lookup(struct mctp_dev *mdev, mctp_eid_t eid, void *ret_hwaddr)
 {
 	struct net *net = dev_net(mdev->dev);
@@ -111,6 +301,7 @@ static int __net_init mctp_neigh_net_init(struct net *net)
 	struct netns_mctp *ns = &net->mctp;
 
 	INIT_LIST_HEAD(&ns->neighbours);
+	mutex_init(&ns->neigh_lock);
 	return 0;
 }
 
@@ -132,10 +323,20 @@ static struct pernet_operations mctp_net_ops = {
 
 int __init mctp_neigh_init(void)
 {
+	rtnl_register_module(THIS_MODULE, PF_MCTP, RTM_NEWNEIGH,
+			     mctp_rtm_newneigh, NULL, 0);
+	rtnl_register_module(THIS_MODULE, PF_MCTP, RTM_DELNEIGH,
+			     mctp_rtm_delneigh, NULL, 0);
+	rtnl_register_module(THIS_MODULE, PF_MCTP, RTM_GETNEIGH,
+			     NULL, mctp_rtm_getneigh, 0);
+
 	return register_pernet_subsys(&mctp_net_ops);
 }
 
 void __exit mctp_neigh_exit(void)
 {
 	unregister_pernet_subsys(&mctp_net_ops);
+	rtnl_unregister(PF_MCTP, RTM_GETNEIGH);
+	rtnl_unregister(PF_MCTP, RTM_DELNEIGH);
+	rtnl_unregister(PF_MCTP, RTM_NEWNEIGH);
 }
Signature · 1 line
2.30.2
author maintainer
#17 lore raw

RFC PATCH 15/16 mctp: Allow MCTP on tun devices

In reply to Jeremy Kerr

From: Matt Johnston <[email protected]>

Allowing TUN is useful for testing, to route packets to userspace or to tunnel between machines.

---
 net/mctp/device.c |  7 +++++--
 net/mctp/route.c  | 13 ++++++++-----
 2 files changed, 13 insertions(+), 7 deletions(-)
net/mctp/device.c +5 -2
index 4c9932de56d9..031950f39c06 100644
@@ -302,9 +302,12 @@ static int mctp_register(struct net_device *dev)
 	if (rtnl_dereference(dev->mctp_ptr))
 		return 0;
 
-	/* only register specific types; MCTP-specific and loopback for now */
-	if (dev->type != ARPHRD_MCTP && dev->type != ARPHRD_LOOPBACK)
+	/* only register specific types (inc. NONE for TUN devices) */
+	if (!(dev->type == ARPHRD_MCTP ||
+	      dev->type == ARPHRD_LOOPBACK ||
+	      dev->type == ARPHRD_NONE)) {
 		return 0;
+	}
 
 	mdev = mctp_add_dev(dev);
 	if (IS_ERR(mdev))
net/mctp/route.c +8 -5
index e29b1dd0f176..61d4715eba93 100644
@@ -792,13 +792,18 @@ static int mctp_pkttype_receive(struct sk_buff *skb, struct net_device *dev,
 				struct net_device *orig_dev)
 {
 	struct net *net = dev_net(dev);
+	struct mctp_dev *mdev;
 	struct mctp_skb_cb *cb;
 	struct mctp_route *rt;
 	struct mctp_hdr *mh;
 
-	/* basic non-data sanity checks */
-	if (dev->type != ARPHRD_MCTP)
+	rcu_read_lock();
+	mdev = __mctp_dev_get(dev);
+	rcu_read_unlock();
+	if (!mdev) {
+		/* basic non-data sanity checks */
 		goto err_drop;
+	}
 
 	if (!pskb_may_pull(skb, sizeof(struct mctp_hdr)))
 		goto err_drop;
@@ -812,9 +817,7 @@ static int mctp_pkttype_receive(struct sk_buff *skb, struct net_device *dev,
 		goto err_drop;
 
 	cb = __mctp_cb(skb);
-	rcu_read_lock();
-	cb->net = READ_ONCE(__mctp_dev_get(dev)->net);
-	rcu_read_unlock();
+	cb->net = READ_ONCE(mdev->net);
 
 	rt = mctp_route_lookup(net, cb->net, mh->dest);
 	if (!rt)
Signature · 1 line
2.30.2
author maintainer
#16 lore raw

RFC PATCH 14/16 mctp: Allow per-netns default networks

In reply to Jeremy Kerr

From: Matt Johnston <[email protected]>

Currently we have a compile-time default network (MCTP_INITIAL_DEFAULT_NET). This change introduces a default_net field on the net namespace, allowing future configuration for new interfaces.

---
 include/net/mctp.h        |  4 ++++
 include/net/netns/mctp.h  |  3 +++
 include/uapi/linux/mctp.h |  1 -
 net/mctp/af_mctp.c        |  3 +++
 net/mctp/device.c         |  2 +-
 net/mctp/route.c          | 14 ++++++++++++++
 6 files changed, 25 insertions(+), 2 deletions(-)
include/net/mctp.h +4 -0
index 9366e2d942bf..d8d29b638603 100644
@@ -37,6 +37,8 @@ struct mctp_hdr {
 
 #define MCTP_HEADER_MAXLEN	4
 
+#define MCTP_INITIAL_DEFAULT_NET	1
+
 static inline bool mctp_address_ok(mctp_eid_t eid)
 {
 	return eid >= 8 && eid < 255;
@@ -189,6 +191,8 @@ int mctp_local_output(struct sock *sk, struct mctp_route *rt,
 		      struct sk_buff *skb, mctp_eid_t daddr, u8 req_tag);
 
 /* routing <--> device interface */
+unsigned int mctp_default_net(struct net *net);
+int mctp_default_net_set(struct net *net, unsigned int index);
 int mctp_route_add(struct mctp_dev *mdev, mctp_eid_t daddr_start,
 		   unsigned int daddr_extent, unsigned int mtu, bool is_local);
 int mctp_route_remove(struct mctp_dev *mdev, mctp_eid_t daddr_start,
include/net/netns/mctp.h +3 -0
index 14ae6d37e52a..acedef12a35e 100644
@@ -25,6 +25,9 @@ struct netns_mctp {
 	spinlock_t keys_lock;
 	struct hlist_head keys;
 
+	/* MCTP network */
+	unsigned int default_net;
+
 	/* neighbour table */
 	struct mutex neigh_lock;
 	struct list_head neighbours;
include/uapi/linux/mctp.h +0 -1
index f973e9bb5d4e..a9f6c6744b27 100644
@@ -26,7 +26,6 @@ struct sockaddr_mctp {
 };
 
 #define MCTP_NET_ANY		0x0
-#define MCTP_NET_DEFAULT	0x0
 
 #define MCTP_ADDR_ANY		0xff
 
net/mctp/af_mctp.c +3 -0
index 1097722b0e88..76d0f4cadd05 100644
@@ -87,6 +87,9 @@ static int mctp_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
 		return -EDESTADDRREQ;
 	}
 
+	if (addr->smctp_network == MCTP_NET_ANY)
+		addr->smctp_network = mctp_default_net(sock_net(sk));
+
 	rt = mctp_route_lookup(sock_net(sk), addr->smctp_network,
 			       addr->smctp_addr.s_addr);
 	if (!rt)
net/mctp/device.c +1 -1
index d3ca9f664b30..4c9932de56d9 100644
@@ -208,7 +208,7 @@ static struct mctp_dev *mctp_add_dev(struct net_device *dev)
 
 	INIT_LIST_HEAD(&mdev->addrs);
 
-	mdev->net = MCTP_INITIAL_DEFAULT_NET;
+	mdev->net = mctp_default_net(dev_net(dev));
 
 	/* associate to net_device */
 	rcu_assign_pointer(dev->mctp_ptr, mdev);
net/mctp/route.c +14 -0
index 58aeb5927ade..e29b1dd0f176 100644
@@ -426,6 +426,19 @@ static struct mctp_route *mctp_route_alloc(void)
 	return rt;
 }
 
+unsigned int mctp_default_net(struct net *net)
+{
+	return READ_ONCE(net->mctp.default_net);
+}
+
+int mctp_default_net_set(struct net *net, unsigned int index)
+{
+	if (index == 0)
+		return -EINVAL;
+	WRITE_ONCE(net->mctp.default_net, index);
+	return 0;
+}
+
 /* tag management */
 static void mctp_reserve_tag(struct net *net, struct mctp_sk_key *key,
 			     struct mctp_sock *msk)
@@ -1024,6 +1037,7 @@ static int __net_init mctp_routes_net_init(struct net *net)
 	mutex_init(&ns->bind_lock);
 	INIT_HLIST_HEAD(&ns->keys);
 	spin_lock_init(&ns->keys_lock);
+	WARN_ON(mctp_default_net_set(net, MCTP_INITIAL_DEFAULT_NET));
 	return 0;
 }
 
Signature · 1 line
2.30.2

Jeremy Kerr

author maintainer
#0 lore raw

cover Add Management Controller Transport Protocol support

This (RFC) series adds core MCTP support to the kernel. From the Kconfig description:

Management Controller Transport Protocol (MCTP) is an in-system protocol for communicating between management controllers and their managed devices (perihperals, 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.

This implementation allows a sockets-based API for sending and receiving MCTP messages via sendmsg/recvmsg on SOCK_DGRAM sockets. Kernel stack control is all via netlink, using existing RTM_* messages. The userspace ABI change is fairly small; just the necessary AF_/ETH_P_/ARPHDR_ constants, a new sockaddr, and a new netlink attribute.

For MAINTAINERS, I've just included netdev@ as the list entry. I'm happy to alter this based on preferences here - an alternative would be the OpenBMC list (the main user of the MCTP interface), or we can create a new list entirely.

We have a couple of interface drivers almost ready to go at the moment, but those can wait until the core code has some review.

Review, comments, questions etc. are most welcome.

Cheers,

Jeremy

---

Jeremy Kerr (10):
mctp: Add MCTP base
mctp: Add base socket/protocol definitions
mctp: Add base packet definitions
mctp: Add sockaddr_mctp to uapi
mctp: Add initial driver infrastructure
mctp: Add device handling and netlink interface
mctp: Add initial routing framework
mctp: Populate socket implementation
mctp: Implement message fragmentation & reassembly
mctp: Add MCTP overview document

Matt Johnston (6):
mctp: Add netlink route management
mctp: Add neighbour implementation
mctp: Add neighbour netlink interface
mctp: Add dest neighbour lladdr to route output
mctp: Allow per-netns default networks
mctp: Allow MCTP on tun devices

 Documentation/networking/index.rst |    1 +
 Documentation/networking/mctp.rst  |  213 ++++++
 MAINTAINERS                        |   12 +
 drivers/net/Kconfig                |    2 +
 drivers/net/Makefile               |    1 +
 drivers/net/mctp/Kconfig           |    8 +
 drivers/net/mctp/Makefile          |    0
 include/linux/netdevice.h          |    3 +
 include/linux/socket.h             |    6 +-
 include/net/mctp.h                 |  235 ++++++
 include/net/mctpdevice.h           |   42 ++
 include/net/net_namespace.h        |    4 +
 include/net/netns/mctp.h           |   36 +
 include/uapi/linux/if_arp.h        |    1 +
 include/uapi/linux/if_ether.h      |    3 +
 include/uapi/linux/if_link.h       |   10 +
 include/uapi/linux/mctp.h          |   32 +
 net/Kconfig                        |    1 +
 net/Makefile                       |    1 +
 net/mctp/Kconfig                   |   13 +
 net/mctp/Makefile                  |    3 +
 net/mctp/af_mctp.c                 |  385 ++++++++++
 net/mctp/device.c                  |  370 ++++++++++
 net/mctp/neigh.c                   |  342 +++++++++
 net/mctp/route.c                   | 1081 ++++++++++++++++++++++++++++
 25 files changed, 2804 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/networking/mctp.rst
 create mode 100644 drivers/net/mctp/Kconfig
 create mode 100644 drivers/net/mctp/Makefile
 create mode 100644 include/net/mctp.h
 create mode 100644 include/net/mctpdevice.h
 create mode 100644 include/net/netns/mctp.h
 create mode 100644 include/uapi/linux/mctp.h
 create mode 100644 net/mctp/Kconfig
 create mode 100644 net/mctp/Makefile
 create mode 100644 net/mctp/af_mctp.c
 create mode 100644 net/mctp/device.c
 create mode 100644 net/mctp/neigh.c
 create mode 100644 net/mctp/route.c
Signature · 1 line
2.30.2
author maintainer
#6 lore raw

RFC PATCH 4/16 mctp: Add sockaddr_mctp to uapi

This change introduces the user-visible MCTP header, containing the protocol-specific addressing definitions.

---
 include/uapi/linux/mctp.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
include/uapi/linux/mctp.h +17 -0
index eec6715143a0..a9f6c6744b27 100644
@@ -9,7 +9,24 @@
 #ifndef __UAPI_MCTP_H
 #define __UAPI_MCTP_H
 
+#include <linux/types.h>
+
+typedef __u8			mctp_eid_t;
+
+struct mctp_addr {
+	mctp_eid_t		s_addr;
+};
+
 struct sockaddr_mctp {
+	unsigned short int	smctp_family;
+	int			smctp_network;
+	struct mctp_addr	smctp_addr;
+	__u8			smctp_type;
+	__u8			smctp_tag;
 };
 
+#define MCTP_NET_ANY		0x0
+
+#define MCTP_ADDR_ANY		0xff
+
 #endif /* __UAPI_MCTP_H */
Signature · 1 line
2.30.2
author maintainer
#13 lore raw

RFC PATCH 11/16 mctp: Populate socket implementation

In reply to Jeremy Kerr

Start filling-out the socket syscalls: bind, sendmsg & recvmsg.

This requires an input route implementation, so we add to mctp_route_input, allowing lookups on binds & message tags. This just handles single-packet messages at present, we will add fragmentation in a future change.

---
 include/net/mctp.h       |  59 ++++++++++
 include/net/netns/mctp.h |  13 +++
 net/mctp/af_mctp.c       | 192 +++++++++++++++++++++++++++++++--
 net/mctp/route.c         | 227 ++++++++++++++++++++++++++++++++++++++-
 4 files changed, 481 insertions(+), 10 deletions(-)
include/net/mctp.h +59 -0
index a37f77c787a5..dcc0ae06ed5c 100644
@@ -12,6 +12,7 @@
 #include <linux/bits.h>
 #include <linux/mctp.h>
 #include <net/net_namespace.h>
+#include <net/sock.h>
 
 /* MCTP packet definitions */
 struct mctp_hdr {
@@ -46,6 +47,64 @@ static inline struct mctp_hdr *mctp_hdr(struct sk_buff *skb)
 	return (struct mctp_hdr *)skb_network_header(skb);
 }
 
+/* socket implementation */
+struct mctp_sock {
+	struct sock	sk;
+
+	/* bind() params */
+	int		bind_net;
+	mctp_eid_t	bind_addr;
+	__u8		bind_type;
+
+	/* list of mctp_sk_key, for incoming tag lookup. updates protected
+	 * by sk->net->keys_lock
+	 */
+	struct hlist_head __rcu keys;
+};
+
+/* Key for matching incoming packets to sockets or reassembly contexts.
+ * Packets are matched on (src,dest,tag).
+ *
+ * Lifetime requirements:
+ *
+ *  - keys are free()ed via RCU
+ *
+ *  - a mctp_sk_key contains a reference to a struct sock; this is valid
+ *    for the life of the key. On sock destruction (through unhash), the key is
+ *    removed from lists (see below), and will not be observable after a RCU
+ *    grace period.
+ *
+ *    any RX occuring within that grace period may still queue to the socket,
+ *    but will hit the SOCK_DEAD case before the socket is freed.
+ *
+ * - these mctp_sk_keys appear on two lists:
+ *     1) the struct mctp_sock->keys list
+ *     2) the struct netns_mctp->keys list
+ *
+ *        updates to either list are performed under the netns_mctp->keys
+ *        lock.
+ *
+ * - there is a single destruction path for a mctp_sk_key - through socket
+ *   unhash (see mctp_sk_unhash). This performs performs the list removal under
+ *   keys_lock.
+ */
+struct mctp_sk_key {
+	mctp_eid_t	peer_addr;
+	mctp_eid_t	local_addr;
+	__u8		tag; /* incoming tag match; invert TO for local */
+
+	/* we hold a ref to sk when set */
+	struct sock	*sk;
+
+	/* routing lookup list */
+	struct hlist_node hlist;
+
+	/* per-socket list */
+	struct hlist_node sklist;
+
+	struct rcu_head	rcu;
+};
+
 struct mctp_skb_cb {
 	unsigned int	magic;
 	unsigned int	net;
include/net/netns/mctp.h +13 -0
index 2f5ebeeb320e..14ae6d37e52a 100644
@@ -12,6 +12,19 @@ struct netns_mctp {
 	/* Only updated under RTNL, entries freed via RCU */
 	struct list_head routes;
 
+	/* Bound sockets: list of sockets bound by type.
+	 * This list is updated from non-atomic contexts (under bind_lock),
+	 * and read (under rcu) in packet rx
+	 */
+	struct mutex bind_lock;
+	struct hlist_head binds;
+
+	/* tag allocations. This list is read and updated from atomic contexts,
+	 * but elements are free()ed after a RCU grace-period
+	 */
+	spinlock_t keys_lock;
+	struct hlist_head keys;
+
 	/* neighbour table */
 	struct mutex neigh_lock;
 	struct list_head neighbours;
net/mctp/af_mctp.c +185 -7

229 lines not on this page · raw message

net/mctp/route.c +224 -3

269 lines not on this page · raw message

Signature · 1 line
2.30.2
author maintainer
#9 lore raw

RFC PATCH 7/16 mctp: Add initial routing framework

In reply to Jeremy Kerr

Add a simple routing table, and a couple of route output handlers, and the mctp packet_type & handler.

Includes changes from Matt Johnston <[email protected]>.

---
 MAINTAINERS                 |   1 +
 include/net/mctp.h          |  75 +++++++++
 include/net/net_namespace.h |   4 +
 include/net/netns/mctp.h    |  16 ++
 net/mctp/Makefile           |   2 +-
 net/mctp/af_mctp.c          |   7 +
 net/mctp/device.c           |   7 +-
 net/mctp/route.c            | 320 ++++++++++++++++++++++++++++++++++++
 8 files changed, 427 insertions(+), 5 deletions(-)
 create mode 100644 include/net/netns/mctp.h
 create mode 100644 net/mctp/route.c
MAINTAINERS +1 -0
index 2a12c7386986..d1fd014f9484 100644
@@ -10877,6 +10877,7 @@ S:	Maintained
 F:	drivers/net/mctp/
 F:	include/net/mctp.h
 F:	include/net/mctpdevice.h
+F:	include/net/netns/mctp.h
 F:	net/mctp/
 
 MAN-PAGES: MANUAL PAGES FOR LINUX -- Sections 2, 3, 4, 5, and 7
include/net/mctp.h +75 -0

93 lines not on this page · raw message

include/net/net_namespace.h +4 -0
index fa5887143f0d..71fce3086fc3 100644
@@ -33,6 +33,7 @@
 #include <net/netns/can.h>
 #include <net/netns/xdp.h>
 #include <net/netns/bpf.h>
+#include <net/netns/mctp.h>
 #include <linux/ns_common.h>
 #include <linux/idr.h>
 #include <linux/skbuff.h>
@@ -166,6 +167,9 @@ struct net {
 #ifdef CONFIG_XDP_SOCKETS
 	struct netns_xdp	xdp;
 #endif
+#if IS_ENABLED(CONFIG_MCTP)
+	struct netns_mctp	mctp;
+#endif
 #if IS_ENABLED(CONFIG_CRYPTO_USER)
 	struct sock		*crypto_nlsk;
 #endif
include/net/netns/mctp.h new file +16 -0
new file mode 100644
index 000000000000..508459b08a59
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * MCTP per-net structures
+ */
+
+#ifndef __NETNS_MCTP_H__
+#define __NETNS_MCTP_H__
+
+#include <linux/types.h>
+
+struct netns_mctp {
+	/* Only updated under RTNL, entries freed via RCU */
+	struct list_head routes;
+};
+
+#endif /* __NETNS_MCTP_H__ */
net/mctp/Makefile +1 -1
index 2ea98c27b262..b1a330e9d82a 100644
@@ -1,3 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_MCTP) += mctp.o
-mctp-objs := af_mctp.o device.o
+mctp-objs := af_mctp.o device.o route.o
net/mctp/af_mctp.c +7 -0
index d77955eee21b..081c7b8005da 100644
@@ -157,10 +157,16 @@ static __init int mctp_init(void)
 	if (rc)
 		goto err_unreg_sock;
 
+	rc = mctp_routes_init();
+	if (rc)
+		goto err_unreg_proto;
+
 	mctp_device_init();
 
 	return 0;
 
+err_unreg_proto:
+	proto_unregister(&mctp_proto);
 err_unreg_sock:
 	sock_unregister(PF_MCTP);
 
@@ -170,6 +176,7 @@ static __init int mctp_init(void)
 static __exit void mctp_exit(void)
 {
 	mctp_device_exit();
+	mctp_routes_exit();
 	proto_unregister(&mctp_proto);
 	sock_unregister(PF_MCTP);
 }
net/mctp/device.c +3 -4
index 988936936693..273041ed2d3e 100644
@@ -191,6 +191,8 @@ static int mctp_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh,
 	ifaddr->dev = mdev;
 	list_add(&ifaddr->dev_list, &mdev->addrs);
 
+	mctp_route_add_local(mdev, addr->s_addr);
+
 	return 0;
 }
 
@@ -282,10 +284,7 @@ static void mctp_unregister(struct net_device *dev)
 
 	RCU_INIT_POINTER(mdev->dev->mctp_ptr, NULL);
 
-	/* TODO: drop routes, to the point where we can dev_put(); requires
-	 * coordination with the route layer; each route should hold a dev
-	 * reference. We should only need to synchronize_rcu() once for this.
-	 */
+	mctp_route_remove_dev(mdev);
 	list_for_each_entry_safe(ifa, tmp, &mdev->addrs, dev_list) {
 		list_del_rcu(&ifa->dev_list);
 		kfree_rcu(ifa, rcu);
net/mctp/route.c new file +320 -0

320 lines not on this page · raw message

Signature · 1 line
2.30.2
author maintainer
#4 lore raw

RFC PATCH 2/16 mctp: Add base socket/protocol definitions

In reply to Jeremy Kerr

Add an empty socket implementation, plus initialisation/destruction handlers.

---
 net/mctp/af_mctp.c | 169 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 169 insertions(+)
net/mctp/af_mctp.c +169 -0
index 87823fd3a11e..3946e5dbe12d 100644
@@ -5,3 +5,172 @@
  * Copyright (c) 2021 Code Construct
  * Copyright (c) 2021 Google
  */
+
+#include <linux/net.h>
+#include <linux/mctp.h>
+#include <linux/module.h>
+#include <linux/socket.h>
+
+#include <net/sock.h>
+
+struct mctp_sock {
+	struct sock	sk;
+};
+
+static int mctp_release(struct socket *sock)
+{
+	struct sock *sk = sock->sk;
+
+	if (sk) {
+		sock->sk = NULL;
+		sk->sk_prot->close(sk, 0);
+	}
+
+	return 0;
+}
+
+static int mctp_bind(struct socket *sock, struct sockaddr *addr, int addrlen)
+{
+	return 0;
+}
+
+static int mctp_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
+{
+	return 0;
+}
+
+static int mctp_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
+			int flags)
+{
+	return 0;
+}
+
+static int mctp_setsockopt(struct socket *sock, int level, int optname,
+			   sockptr_t optval, unsigned int optlen)
+{
+	return -EINVAL;
+}
+
+static int mctp_getsockopt(struct socket *sock, int level, int optname,
+			   char __user *optval, int __user *optlen)
+{
+	return -EINVAL;
+}
+
+static const struct proto_ops mctp_dgram_ops = {
+	.family		= PF_MCTP,
+	.release	= mctp_release,
+	.bind		= mctp_bind,
+	.connect	= sock_no_connect,
+	.socketpair	= sock_no_socketpair,
+	.accept		= sock_no_accept,
+	.getname	= sock_no_getname,
+	.poll		= datagram_poll,
+	.ioctl		= sock_no_ioctl,
+	.gettstamp	= sock_gettstamp,
+	.listen		= sock_no_listen,
+	.shutdown	= sock_no_shutdown,
+	.setsockopt	= mctp_setsockopt,
+	.getsockopt	= mctp_getsockopt,
+	.sendmsg	= mctp_sendmsg,
+	.recvmsg	= mctp_recvmsg,
+	.mmap		= sock_no_mmap,
+	.sendpage	= sock_no_sendpage,
+};
+
+static void mctp_sk_close(struct sock *sk, long timeout)
+{
+	sk_common_release(sk);
+}
+
+static struct proto mctp_proto = {
+	.name		= "MCTP",
+	.owner		= THIS_MODULE,
+	.obj_size	= sizeof(struct mctp_sock),
+	.close		= mctp_sk_close,
+};
+
+static int mctp_pf_create(struct net *net, struct socket *sock,
+			  int protocol, int kern)
+{
+	const struct proto_ops *ops;
+	struct proto *proto;
+	struct sock *sk;
+	int rc;
+
+	if (protocol)
+		return -EPROTONOSUPPORT;
+
+	/* only datagram sockets are supported */
+	if (sock->type != SOCK_DGRAM)
+		return -ESOCKTNOSUPPORT;
+
+	proto = &mctp_proto;
+	ops = &mctp_dgram_ops;
+
+	sock->state = SS_UNCONNECTED;
+	sock->ops = ops;
+
+	sk = sk_alloc(net, PF_MCTP, GFP_KERNEL, proto, kern);
+	if (!sk)
+		return -ENOMEM;
+
+	sock_init_data(sock, sk);
+
+	rc = 0;
+	if (sk->sk_prot->init)
+		rc = sk->sk_prot->init(sk);
+
+	if (rc)
+		goto err_sk_put;
+
+	return 0;
+
+err_sk_put:
+	sock_orphan(sk);
+	sock_put(sk);
+	return rc;
+}
+
+static struct net_proto_family mctp_pf = {
+	.family = PF_MCTP,
+	.create = mctp_pf_create,
+	.owner = THIS_MODULE,
+};
+
+static __init int mctp_init(void)
+{
+	int rc;
+
+	pr_info("mctp: management controller transport protocol core\n");
+
+	rc = sock_register(&mctp_pf);
+	if (rc)
+		return rc;
+
+	rc = proto_register(&mctp_proto, 0);
+	if (rc)
+		goto err_unreg_sock;
+
+	return 0;
+
+err_unreg_sock:
+	sock_unregister(PF_MCTP);
+
+	return rc;
+}
+
+static __exit void mctp_exit(void)
+{
+	proto_unregister(&mctp_proto);
+	sock_unregister(PF_MCTP);
+}
+
+module_init(mctp_init);
+module_exit(mctp_exit);
+
+MODULE_DESCRIPTION("MCTP core");
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Jeremy Kerr <[email protected]>");
+
+MODULE_ALIAS_NETPROTO(PF_MCTP);
Signature · 1 line
2.30.2
author maintainer
#15 lore raw

RFC PATCH 13/16 mctp: Implement message fragmentation & reassembly

In reply to Jeremy Kerr

This change implements MCTP fragmentation (based on route & device MTU), and corresponding reassembly.

The MCTP specification only allows for fragmentation on the originating message endpoint, and reassembly on the destination endpoint - intermediate nodes do not need to reassemble/refragment. Consequently, we only fragment in the local transmit path, and reassemble locally-bound packets. Messages are required to be in-order, so we simply cancel reassembly on out-of-order or missing packets.

In the fragmentation path, we just break up the message into MTU-sized fragments; the skb structure is a simple copy for now, which we can later improve with a shared data implementation.

For reassembly, we keep track of incoming message fragments using the existing tag infrastructure, allocating a key on the (src,dest,tag) tuple, and reassembles matching fragments into a skb->frag_list.

---
 include/net/mctp.h |  25 +++-
 net/mctp/af_mctp.c |   8 +
 net/mctp/route.c   | 365 ++++++++++++++++++++++++++++++++++++++++-----
 3 files changed, 354 insertions(+), 44 deletions(-)
include/net/mctp.h +22 -3
index dcc0ae06ed5c..9366e2d942bf 100644
@@ -84,9 +84,21 @@ struct mctp_sock {
  *        updates to either list are performed under the netns_mctp->keys
  *        lock.
  *
- * - there is a single destruction path for a mctp_sk_key - through socket
- *   unhash (see mctp_sk_unhash). This performs performs the list removal under
- *   keys_lock.
+ * - a key may have a sk_buff attached as part of an in-progress message
+ *   reassembly (->reasm_head). The reassembly context is protected by
+ *   reasm_lock, which may be acquired with the keys lock (above) held, if
+ *   necessary. Consequently, keys lock *cannot* be acquired with the
+ *   reasm_lock held.
+ *
+ * - there are two destruction paths for a mctp_sk_key:
+ *
+ *    - through socket unhash (see mctp_sk_unhash). This performs performs the
+ *      list removal under keys_lock.
+ *
+ *    - where a key is established to receive a reply message: after receiving
+ *      the (complete) reply, or during reassembly errors. Here, we clean up
+ *      the reassembly context (marking reasm_dead, to prevent another from
+ *      starting), and remove the socket from the netns & socket lists.
  */
 struct mctp_sk_key {
 	mctp_eid_t	peer_addr;
@@ -102,6 +114,13 @@ struct mctp_sk_key {
 	/* per-socket list */
 	struct hlist_node sklist;
 
+	/* incoming fragment reassembly context */
+	spinlock_t	reasm_lock;
+	struct sk_buff	*reasm_head;
+	struct sk_buff	**reasm_tailp;
+	bool		reasm_dead;
+	u8		last_seq;
+
 	struct rcu_head	rcu;
 };
 
net/mctp/af_mctp.c +8 -0
index c607187de24d..1097722b0e88 100644
@@ -256,6 +256,14 @@ static void mctp_sk_unhash(struct sock *sk)
 	hlist_for_each_entry_safe(key, tmp, &msk->keys, sklist) {
 		hlist_del_rcu(&key->sklist);
 		hlist_del_rcu(&key->hlist);
+
+		spin_lock(&key->reasm_lock);
+		if (key->reasm_head)
+			kfree_skb(key->reasm_head);
+		key->reasm_head = NULL;
+		key->reasm_dead = true;
+		spin_unlock(&key->reasm_lock);
+
 		kfree_rcu(key, rcu);
 	}
 	spin_unlock_irqrestore(&net->mctp.keys_lock, flags);
net/mctp/route.c +324 -41

445 lines not on this page · raw message

Signature · 1 line
2.30.2
author maintainer
#8 lore raw

RFC PATCH 6/16 mctp: Add device handling and netlink interface

In reply to Jeremy Kerr

This change adds the infrastructure for managing MCTP netdevices; we add a pointer to the AF_MCTP-specific data to struct netdevice, and hook up the rtnetlink operations for adding and removing addresses.

Includes changes from Matt Johnston <[email protected]>.

---
 MAINTAINERS                   |   1 +
 include/linux/netdevice.h     |   3 +
 include/net/mctp.h            |  14 ++
 include/net/mctpdevice.h      |  41 ++++
 include/uapi/linux/if_ether.h |   3 +
 include/uapi/linux/if_link.h  |  10 +
 include/uapi/linux/mctp.h     |   1 +
 net/mctp/Makefile             |   2 +-
 net/mctp/af_mctp.c            |   8 +
 net/mctp/device.c             | 367 ++++++++++++++++++++++++++++++++++
 10 files changed, 449 insertions(+), 1 deletion(-)
 create mode 100644 include/net/mctpdevice.h
 create mode 100644 net/mctp/device.c
MAINTAINERS +1 -0
index d3114697601b..2a12c7386986 100644
@@ -10876,6 +10876,7 @@ L:	[email protected]
 S:	Maintained
 F:	drivers/net/mctp/
 F:	include/net/mctp.h
+F:	include/net/mctpdevice.h
 F:	net/mctp/
 
 MAN-PAGES: MANUAL PAGES FOR LINUX -- Sections 2, 3, 4, 5, and 7
include/linux/netdevice.h +3 -0
index 5cbc950b34df..a37e119460fe 100644
@@ -2092,6 +2092,9 @@ struct net_device {
 #if IS_ENABLED(CONFIG_MPLS_ROUTING)
 	struct mpls_dev __rcu	*mpls_ptr;
 #endif
+#if IS_ENABLED(CONFIG_MCTP)
+	struct mctp_dev __rcu	*mctp_ptr;
+#endif
 
 /*
  * Cache lines mostly used on receive path (including eth_type_trans())
include/net/mctp.h +14 -0
index 757304d98c0a..24d02fa96425 100644
@@ -10,6 +10,7 @@
 #define __NET_MCTP_H
 
 #include <linux/bits.h>
+#include <linux/mctp.h>
 
 /* MCTP packet definitions */
 struct mctp_hdr {
@@ -32,4 +33,17 @@ struct mctp_hdr {
 #define MCTP_HDR_TAG_SHIFT	0
 #define MCTP_HDR_TAG_MASK	GENMASK(2, 0)
 
+static inline bool mctp_address_ok(mctp_eid_t eid)
+{
+	return eid >= 8 && eid < 255;
+}
+
+static inline struct mctp_hdr *mctp_hdr(struct sk_buff *skb)
+{
+	return (struct mctp_hdr *)skb_network_header(skb);
+}
+
+void mctp_device_init(void);
+void mctp_device_exit(void);
+
 #endif /* __NET_MCTP_H */
include/net/mctpdevice.h new file +41 -0

41 lines not on this page · raw message

include/uapi/linux/if_ether.h +3 -0
index a0b637911d3c..cf3fbfec716a 100644
@@ -151,6 +151,9 @@
 #define ETH_P_MAP	0x00F9		/* Qualcomm multiplexing and
 					 * aggregation protocol
 					 */
+#define ETH_P_MCTP	0x00FA		/* Management controller transport
+					 * protocol packets
+					 */
 
 /*
  *	This is an Ethernet frame header.
include/uapi/linux/if_link.h +10 -0
index cd5b382a4138..a4543ddf98f4 100644
@@ -1251,4 +1251,14 @@ struct ifla_rmnet_flags {
 	__u32	mask;
 };
 
+/* MCTP section */
+
+enum {
+	IFLA_MCTP_UNSPEC,
+	IFLA_MCTP_NET,
+	__IFLA_MCTP_MAX,
+};
+
+#define IFLA_MCTP_MAX (__IFLA_MCTP_MAX - 1)
+
 #endif /* _UAPI_LINUX_IF_LINK_H */
include/uapi/linux/mctp.h +1 -0
index a9f6c6744b27..f973e9bb5d4e 100644
@@ -26,6 +26,7 @@ struct sockaddr_mctp {
 };
 
 #define MCTP_NET_ANY		0x0
+#define MCTP_NET_DEFAULT	0x0
 
 #define MCTP_ADDR_ANY		0xff
 
net/mctp/Makefile +1 -1
index 7c056b1b7939..2ea98c27b262 100644
@@ -1,3 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_MCTP) += mctp.o
-mctp-objs := af_mctp.o
+mctp-objs := af_mctp.o device.o
net/mctp/af_mctp.c +8 -0
index 3946e5dbe12d..d77955eee21b 100644
@@ -6,13 +6,18 @@
  * Copyright (c) 2021 Google
  */
 
+#include <linux/if_arp.h>
 #include <linux/net.h>
 #include <linux/mctp.h>
 #include <linux/module.h>
 #include <linux/socket.h>
 
+#include <net/mctp.h>
+#include <net/mctpdevice.h>
 #include <net/sock.h>
 
+/* socket implementation */
+
 struct mctp_sock {
 	struct sock	sk;
 };
@@ -152,6 +157,8 @@ static __init int mctp_init(void)
 	if (rc)
 		goto err_unreg_sock;
 
+	mctp_device_init();
+
 	return 0;
 
 err_unreg_sock:
@@ -162,6 +169,7 @@ static __init int mctp_init(void)
 
 static __exit void mctp_exit(void)
 {
+	mctp_device_exit();
 	proto_unregister(&mctp_proto);
 	sock_unregister(PF_MCTP);
 }
net/mctp/device.c new file +367 -0

367 lines not on this page · raw message

Signature · 1 line
2.30.2
author maintainer
#5 lore raw

RFC PATCH 3/16 mctp: Add base packet definitions

In reply to Jeremy Kerr

Simple packet header format as defined by DMTF DSP0236.

---
 MAINTAINERS        |  1 +
 include/net/mctp.h | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)
 create mode 100644 include/net/mctp.h
MAINTAINERS +1 -0
index 5041ea78ab97..262451188c46 100644
@@ -10874,6 +10874,7 @@ M:	Jeremy Kerr <[email protected]>
 M:	Matt Johnston <[email protected]>
 L:	[email protected]
 S:	Maintained
+F:	include/net/mctp.h
 F:	net/mctp/
 
 MAN-PAGES: MANUAL PAGES FOR LINUX -- Sections 2, 3, 4, 5, and 7
include/net/mctp.h new file +35 -0
new file mode 100644
index 000000000000..757304d98c0a
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Management Controller Transport Protocol (MCTP)
+ *
+ * Copyright (c) 2021 Code Construct
+ * Copyright (c) 2021 Google
+ */
+
+#ifndef __NET_MCTP_H
+#define __NET_MCTP_H
+
+#include <linux/bits.h>
+
+/* MCTP packet definitions */
+struct mctp_hdr {
+	u8	ver;
+	u8	dest;
+	u8	src;
+	u8	flags_seq_tag;
+};
+
+#define MCTP_VER_MIN	1
+#define MCTP_VER_MAX	1
+
+/* Definitions for flags_seq_tag field */
+#define MCTP_HDR_FLAG_SOM	BIT(7)
+#define MCTP_HDR_FLAG_EOM	BIT(6)
+#define MCTP_HDR_FLAG_TO	BIT(3)
+#define MCTP_HDR_FLAGS		GENMASK(5, 3)
+#define MCTP_HDR_SEQ_SHIFT	4
+#define MCTP_HDR_SEQ_MASK	GENMASK(1, 0)
+#define MCTP_HDR_TAG_SHIFT	0
+#define MCTP_HDR_TAG_MASK	GENMASK(2, 0)
+
+#endif /* __NET_MCTP_H */
Signature · 1 line
2.30.2
author maintainer
#7 lore raw

RFC PATCH 5/16 mctp: Add initial driver infrastructure

In reply to Jeremy Kerr

Add an empty drivers/net/mctp/, for future interface drivers.

---
 MAINTAINERS                 | 1 +
 drivers/net/Kconfig         | 2 ++
 drivers/net/Makefile        | 1 +
 drivers/net/mctp/Kconfig    | 8 ++++++++
 drivers/net/mctp/Makefile   | 0
 include/uapi/linux/if_arp.h | 1 +
 6 files changed, 13 insertions(+)
 create mode 100644 drivers/net/mctp/Kconfig
 create mode 100644 drivers/net/mctp/Makefile
MAINTAINERS +1 -0
index 262451188c46..d3114697601b 100644
@@ -10874,6 +10874,7 @@ M:	Jeremy Kerr <[email protected]>
 M:	Matt Johnston <[email protected]>
 L:	[email protected]
 S:	Maintained
+F:	drivers/net/mctp/
 F:	include/net/mctp.h
 F:	net/mctp/
 
drivers/net/Kconfig +2 -0
index 74dc8e249faa..fd4f15709d5d 100644
@@ -482,6 +482,8 @@ config NET_SB1000
 
 source "drivers/net/phy/Kconfig"
 
+source "drivers/net/mctp/Kconfig"
+
 source "drivers/net/mdio/Kconfig"
 
 source "drivers/net/pcs/Kconfig"
drivers/net/Makefile +1 -0
index 7ffd2d03efaf..a48a664605a3 100644
@@ -69,6 +69,7 @@ obj-$(CONFIG_WAN) += wan/
 obj-$(CONFIG_WLAN) += wireless/
 obj-$(CONFIG_IEEE802154) += ieee802154/
 obj-$(CONFIG_WWAN) += wwan/
+obj-$(CONFIG_MCTP) += mctp/
 
 obj-$(CONFIG_VMXNET3) += vmxnet3/
 obj-$(CONFIG_XEN_NETDEV_FRONTEND) += xen-netfront.o
drivers/net/mctp/Kconfig new file +8 -0
new file mode 100644
index 000000000000..d8f966cedc89
@@ -0,0 +1,8 @@
+
+if MCTP
+
+menu "MCTP Device Drivers"
+
+endmenu
+
+endif
drivers/net/mctp/Makefile new file +0 -0
new file mode 100644
index 000000000000..e69de29bb2d1
include/uapi/linux/if_arp.h +1 -0
index c3cc5a9e5eaf..4783af9fe520 100644
@@ -54,6 +54,7 @@
 #define ARPHRD_X25	271		/* CCITT X.25			*/
 #define ARPHRD_HWX25	272		/* Boards with X.25 in firmware	*/
 #define ARPHRD_CAN	280		/* Controller Area Network      */
+#define ARPHRD_MCTP	290
 #define ARPHRD_PPP	512
 #define ARPHRD_CISCO	513		/* Cisco HDLC	 		*/
 #define ARPHRD_HDLC	ARPHRD_CISCO
Signature · 1 line
2.30.2
author maintainer
#14 lore raw

RFC PATCH 12/16 mctp: Add dest neighbour lladdr to route output

In reply to Jeremy Kerr

From: Matt Johnston <[email protected]>

Now that we have a neighbour implementation, hook it up to the output path to set the dest hardware address for outgoing packets.

---
 net/mctp/route.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
net/mctp/route.c +8 -2
index 1f65cd6128a8..e5031b374b93 100644
@@ -169,6 +169,9 @@ static int mctp_route_input(struct mctp_route *route, struct sk_buff *skb)
 
 static int mctp_route_output(struct mctp_route *route, struct sk_buff *skb)
 {
+	struct mctp_hdr *hdr = mctp_hdr(skb);
+	char daddr_buf[MAX_ADDR_LEN];
+	char *daddr = NULL;
 	unsigned int mtu;
 	int rc;
 
@@ -180,9 +183,12 @@ static int mctp_route_output(struct mctp_route *route, struct sk_buff *skb)
 		return -EMSGSIZE;
 	}
 
-	/* TODO: daddr (from rt->neigh), saddr (from device?)  */
+	/* If lookup fails let the device handle daddr==NULL */
+	if (mctp_neigh_lookup(route->dev, hdr->dest, daddr_buf) == 0)
+		daddr = daddr_buf;
+
 	rc = dev_hard_header(skb, skb->dev, ntohs(skb->protocol),
-			     NULL, NULL, skb->len);
+			     daddr, skb->dev->dev_addr, skb->len);
 	if (rc) {
 		kfree_skb(skb);
 		return -EHOSTUNREACH;
Signature · 1 line
2.30.2
#2 lore raw

Re: [PATCH RFC net-next 01/16] mctp: Add MCTP base

In reply to Jeremy Kerr
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 #…

Hi Jeremy,

[FYI, it's a private test report for your RFC patch.] [auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Jeremy-Kerr/Add-Management-Controller-Transport-Protocol-support/20210603-150138
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 270d47dc1fc4756a0158778084a236bc83c156d2
config: arc-randconfig-r034-20210603 (attached as .config)
compiler: arc-elf-gcc (GCC) 9.3.0

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/4ce09506b18df61db33f182daf3111f060da64fd
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jeremy-Kerr/Add-Management-Controller-Transport-Protocol-support/20210603-150138 git checkout 4ce09506b18df61db33f182daf3111f060da64fd
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arc

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

arch/arc/Makefile:27: ** WARNING ** CONFIG_ARC_TUNE_MCPU flag '' is unknown, fallback to ''

>> error: include/uapi/linux/mctp.h: missing "WITH Linux-syscall-note" for SPDX-License-Identifier

make[2]: *** [scripts/Makefile.headersinst:63: usr/include/linux/mctp.h] Error 1 make[2]: Target '__headers' not remade because of errors.
make[1]: *** [Makefile:1333: headers] Error 2
make[1]: Target 'headers_install' not remade because of errors.
make: *** [Makefile:215: __sub-make] Error 2
make: Target 'headers_install' not remade because of errors.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#3 lore raw

Re: [PATCH RFC net-next 01/16] mctp: Add MCTP base

In reply to Jeremy Kerr
reproduce (this is a W=1 build):

Hi Jeremy,

[FYI, it's a private test report for your RFC patch.] [auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Jeremy-Kerr/Add-Management-Controller-Transport-Protocol-support/20210603-150138
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 270d47dc1fc4756a0158778084a236bc83c156d2
config: i386-defconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/4ce09506b18df61db33f182daf3111f060da64fd
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Jeremy-Kerr/Add-Management-Controller-Transport-Protocol-support/20210603-150138
        git checkout 4ce09506b18df61db33f182daf3111f060da64fd
        # save the attached .config to linux build tree
        make W=1 ARCH=i386 

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

In file included from security/selinux/avc.c:32:

>> security/selinux/include/classmap.h:259:2: error: #error New address family defined, please update secclass_map.

259 | #error New address family defined, please update secclass_map.
| ^~~~~

vim +259 security/selinux/include/classmap.h

3322d0d64f4e94 Stephen Smalley         2016-11-18   36  
4bc6c2d5d83868 Harry Ciao              2011-03-02   37  /*
4bc6c2d5d83868 Harry Ciao              2011-03-02   38   * Note: The name for any socket class should be suffixed by "socket",
4bc6c2d5d83868 Harry Ciao              2011-03-02   39   *	 and doesn't contain more than one substr of "socket".
4bc6c2d5d83868 Harry Ciao              2011-03-02   40   */
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   41  struct security_class_mapping secclass_map[] = {
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   42  	{ "security",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   43  	  { "compute_av", "compute_create", "compute_member",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   44  	    "check_context", "load_policy", "compute_relabel",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   45  	    "compute_user", "setenforce", "setbool", "setsecparam",
f9df6458218f4f Andrew Perepechko       2015-12-24   46  	    "setcheckreqprot", "read_policy", "validate_trans", NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   47  	{ "process",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   48  	  { "fork", "transition", "sigchld", "sigkill",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   49  	    "sigstop", "signull", "signal", "ptrace", "getsched", "setsched",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   50  	    "getsession", "getpgid", "setpgid", "getcap", "setcap", "share",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   51  	    "getattr", "setexec", "setfscreate", "noatsecure", "siginh",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   52  	    "setrlimit", "rlimitinh", "dyntransition", "setcurrent",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   53  	    "execmem", "execstack", "execheap", "setkeycreate",
791ec491c372f4 Stephen Smalley         2017-02-17   54  	    "setsockcreate", "getrlimit", NULL } },
af63f4193f9fbb Stephen Smalley         2017-07-31   55  	{ "process2",
af63f4193f9fbb Stephen Smalley         2017-07-31   56  	  { "nnp_transition", "nosuid_transition", NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   57  	{ "system",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   58  	  { "ipc_info", "syslog_read", "syslog_mod",
61d612ea731e57 Jeff Vander Stoep       2016-04-05   59  	    "syslog_console", "module_request", "module_load", NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   60  	{ "capability",
8e4ff6f228e472 Stephen Smalley         2016-04-08   61  	  { COMMON_CAP_PERMS, NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   62  	{ "filesystem",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   63  	  { "mount", "remount", "unmount", "getattr",
42a9699a9fa179 Stephen Smalley         2015-06-04   64  	    "relabelfrom", "relabelto", "associate", "quotamod",
ac5656d8a4cdd9 Aaron Goidel            2019-08-12   65  	    "quotaget", "watch", NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   66  	{ "file",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   67  	  { COMMON_FILE_PERMS,
b424485abe2b16 Eric Paris              2010-07-23   68  	    "execute_no_trans", "entrypoint", NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   69  	{ "dir",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   70  	  { COMMON_FILE_PERMS, "add_name", "remove_name",
49b7b8de46d293 Eric Paris              2010-07-23   71  	    "reparent", "search", "rmdir", NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   72  	{ "fd", { "use", NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   73  	{ "lnk_file",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   74  	  { COMMON_FILE_PERMS, NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   75  	{ "chr_file",
b424485abe2b16 Eric Paris              2010-07-23   76  	  { COMMON_FILE_PERMS, NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   77  	{ "blk_file",
49b7b8de46d293 Eric Paris              2010-07-23   78  	  { COMMON_FILE_PERMS, NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   79  	{ "sock_file",
49b7b8de46d293 Eric Paris              2010-07-23   80  	  { COMMON_FILE_PERMS, NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   81  	{ "fifo_file",
49b7b8de46d293 Eric Paris              2010-07-23   82  	  { COMMON_FILE_PERMS, NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   83  	{ "socket",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   84  	  { COMMON_SOCK_PERMS, NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   85  	{ "tcp_socket",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   86  	  { COMMON_SOCK_PERMS,
42a9699a9fa179 Stephen Smalley         2015-06-04   87  	    "node_bind", "name_connect",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   88  	    NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   89  	{ "udp_socket",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   90  	  { COMMON_SOCK_PERMS,
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   91  	    "node_bind", NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   92  	{ "rawip_socket",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   93  	  { COMMON_SOCK_PERMS,
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   94  	    "node_bind", NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   95  	{ "node",
42a9699a9fa179 Stephen Smalley         2015-06-04   96  	  { "recvfrom", "sendto", NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   97  	{ "netif",
42a9699a9fa179 Stephen Smalley         2015-06-04   98  	  { "ingress", "egress", NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30   99  	{ "netlink_socket",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  100  	  { COMMON_SOCK_PERMS, NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  101  	{ "packet_socket",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  102  	  { COMMON_SOCK_PERMS, NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  103  	{ "key_socket",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  104  	  { COMMON_SOCK_PERMS, NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  105  	{ "unix_stream_socket",
42a9699a9fa179 Stephen Smalley         2015-06-04  106  	  { COMMON_SOCK_PERMS, "connectto", NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  107  	{ "unix_dgram_socket",
42a9699a9fa179 Stephen Smalley         2015-06-04  108  	  { COMMON_SOCK_PERMS, NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  109  	{ "sem",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  110  	  { COMMON_IPC_PERMS, NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  111  	{ "msg", { "send", "receive", NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  112  	{ "msgq",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  113  	  { COMMON_IPC_PERMS, "enqueue", NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  114  	{ "shm",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  115  	  { COMMON_IPC_PERMS, "lock", NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  116  	{ "ipc",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  117  	  { COMMON_IPC_PERMS, NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  118  	{ "netlink_route_socket",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  119  	  { COMMON_SOCK_PERMS,
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  120  	    "nlmsg_read", "nlmsg_write", NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  121  	{ "netlink_tcpdiag_socket",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  122  	  { COMMON_SOCK_PERMS,
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  123  	    "nlmsg_read", "nlmsg_write", NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  124  	{ "netlink_nflog_socket",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  125  	  { COMMON_SOCK_PERMS, NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  126  	{ "netlink_xfrm_socket",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  127  	  { COMMON_SOCK_PERMS,
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  128  	    "nlmsg_read", "nlmsg_write", NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  129  	{ "netlink_selinux_socket",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  130  	  { COMMON_SOCK_PERMS, NULL } },
6c6d2e9bde1c1c Stephen Smalley         2015-06-04  131  	{ "netlink_iscsi_socket",
6c6d2e9bde1c1c Stephen Smalley         2015-06-04  132  	  { COMMON_SOCK_PERMS, NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  133  	{ "netlink_audit_socket",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  134  	  { COMMON_SOCK_PERMS,
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  135  	    "nlmsg_read", "nlmsg_write", "nlmsg_relay", "nlmsg_readpriv",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  136  	    "nlmsg_tty_audit", NULL } },
6c6d2e9bde1c1c Stephen Smalley         2015-06-04  137  	{ "netlink_fib_lookup_socket",
6c6d2e9bde1c1c Stephen Smalley         2015-06-04  138  	  { COMMON_SOCK_PERMS, NULL } },
6c6d2e9bde1c1c Stephen Smalley         2015-06-04  139  	{ "netlink_connector_socket",
6c6d2e9bde1c1c Stephen Smalley         2015-06-04  140  	  { COMMON_SOCK_PERMS, NULL } },
6c6d2e9bde1c1c Stephen Smalley         2015-06-04  141  	{ "netlink_netfilter_socket",
6c6d2e9bde1c1c Stephen Smalley         2015-06-04  142  	  { COMMON_SOCK_PERMS, NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  143  	{ "netlink_dnrt_socket",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  144  	  { COMMON_SOCK_PERMS, NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  145  	{ "association",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  146  	  { "sendto", "recvfrom", "setcontext", "polmatch", NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  147  	{ "netlink_kobject_uevent_socket",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  148  	  { COMMON_SOCK_PERMS, NULL } },
6c6d2e9bde1c1c Stephen Smalley         2015-06-04  149  	{ "netlink_generic_socket",
6c6d2e9bde1c1c Stephen Smalley         2015-06-04  150  	  { COMMON_SOCK_PERMS, NULL } },
6c6d2e9bde1c1c Stephen Smalley         2015-06-04  151  	{ "netlink_scsitransport_socket",
6c6d2e9bde1c1c Stephen Smalley         2015-06-04  152  	  { COMMON_SOCK_PERMS, NULL } },
6c6d2e9bde1c1c Stephen Smalley         2015-06-04  153  	{ "netlink_rdma_socket",
6c6d2e9bde1c1c Stephen Smalley         2015-06-04  154  	  { COMMON_SOCK_PERMS, NULL } },
6c6d2e9bde1c1c Stephen Smalley         2015-06-04  155  	{ "netlink_crypto_socket",
6c6d2e9bde1c1c Stephen Smalley         2015-06-04  156  	  { COMMON_SOCK_PERMS, NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  157  	{ "appletalk_socket",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  158  	  { COMMON_SOCK_PERMS, NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  159  	{ "packet",
47ac19ea429aee Eric Paris              2011-02-25  160  	  { "send", "recv", "relabelto", "forward_in", "forward_out", NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  161  	{ "key",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  162  	  { "view", "read", "write", "search", "link", "setattr", "create",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  163  	    NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  164  	{ "dccp_socket",
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  165  	  { COMMON_SOCK_PERMS,
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  166  	    "node_bind", "name_connect", NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  167  	{ "memprotect", { "mmap_zero", NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  168  	{ "peer", { "recv", NULL } },
64919e60915c51 Eric Paris              2012-07-06  169  	{ "capability2",
8e4ff6f228e472 Stephen Smalley         2016-04-08  170  	  { COMMON_CAP2_PERMS, NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  171  	{ "kernel_service", { "use_as_override", "create_files_as", NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  172  	{ "tun_socket",
6f96c142f77c96 Paul Moore              2013-01-14  173  	  { COMMON_SOCK_PERMS, "attach_queue", NULL } },
79af73079d753b Stephen Smalley         2015-01-21  174  	{ "binder", { "impersonate", "call", "set_context_mgr", "transfer",
79af73079d753b Stephen Smalley         2015-01-21  175  		      NULL } },
8e4ff6f228e472 Stephen Smalley         2016-04-08  176  	{ "cap_userns",
8e4ff6f228e472 Stephen Smalley         2016-04-08  177  	  { COMMON_CAP_PERMS, NULL } },
8e4ff6f228e472 Stephen Smalley         2016-04-08  178  	{ "cap2_userns",
8e4ff6f228e472 Stephen Smalley         2016-04-08  179  	  { COMMON_CAP2_PERMS, NULL } },
da69a5306ab92e Stephen Smalley         2017-01-09  180  	{ "sctp_socket",
da69a5306ab92e Stephen Smalley         2017-01-09  181  	  { COMMON_SOCK_PERMS,
d452930fd3b903 Richard Haines          2018-02-13  182  	    "node_bind", "name_connect", "association", NULL } },
da69a5306ab92e Stephen Smalley         2017-01-09  183  	{ "icmp_socket",
da69a5306ab92e Stephen Smalley         2017-01-09  184  	  { COMMON_SOCK_PERMS,
da69a5306ab92e Stephen Smalley         2017-01-09  185  	    "node_bind", NULL } },
da69a5306ab92e Stephen Smalley         2017-01-09  186  	{ "ax25_socket",
da69a5306ab92e Stephen Smalley         2017-01-09  187  	  { COMMON_SOCK_PERMS, NULL } },
da69a5306ab92e Stephen Smalley         2017-01-09  188  	{ "ipx_socket",
da69a5306ab92e Stephen Smalley         2017-01-09  189  	  { COMMON_SOCK_PERMS, NULL } },
da69a5306ab92e Stephen Smalley         2017-01-09  190  	{ "netrom_socket",
da69a5306ab92e Stephen Smalley         2017-01-09  191  	  { COMMON_SOCK_PERMS, NULL } },
da69a5306ab92e Stephen Smalley         2017-01-09  192  	{ "atmpvc_socket",
da69a5306ab92e Stephen Smalley         2017-01-09  193  	  { COMMON_SOCK_PERMS, NULL } },
da69a5306ab92e Stephen Smalley         2017-01-09  194  	{ "x25_socket",
da69a5306ab92e Stephen Smalley         2017-01-09  195  	  { COMMON_SOCK_PERMS, NULL } },
da69a5306ab92e Stephen Smalley         2017-01-09  196  	{ "rose_socket",
da69a5306ab92e Stephen Smalley         2017-01-09  197  	  { COMMON_SOCK_PERMS, NULL } },
da69a5306ab92e Stephen Smalley         2017-01-09  198  	{ "decnet_socket",
da69a5306ab92e Stephen Smalley         2017-01-09  199  	  { COMMON_SOCK_PERMS, NULL } },
da69a5306ab92e Stephen Smalley         2017-01-09  200  	{ "atmsvc_socket",
da69a5306ab92e Stephen Smalley         2017-01-09  201  	  { COMMON_SOCK_PERMS, NULL } },
da69a5306ab92e Stephen Smalley         2017-01-09  202  	{ "rds_socket",
da69a5306ab92e Stephen Smalley         2017-01-09  203  	  { COMMON_SOCK_PERMS, NULL } },
da69a5306ab92e Stephen Smalley         2017-01-09  204  	{ "irda_socket",
da69a5306ab92e Stephen Smalley         2017-01-09  205  	  { COMMON_SOCK_PERMS, NULL } },
da69a5306ab92e Stephen Smalley         2017-01-09  206  	{ "pppox_socket",
da69a5306ab92e Stephen Smalley         2017-01-09  207  	  { COMMON_SOCK_PERMS, NULL } },
da69a5306ab92e Stephen Smalley         2017-01-09  208  	{ "llc_socket",
da69a5306ab92e Stephen Smalley         2017-01-09  209  	  { COMMON_SOCK_PERMS, NULL } },
da69a5306ab92e Stephen Smalley         2017-01-09  210  	{ "can_socket",
da69a5306ab92e Stephen Smalley         2017-01-09  211  	  { COMMON_SOCK_PERMS, NULL } },
da69a5306ab92e Stephen Smalley         2017-01-09  212  	{ "tipc_socket",
da69a5306ab92e Stephen Smalley         2017-01-09  213  	  { COMMON_SOCK_PERMS, NULL } },
da69a5306ab92e Stephen Smalley         2017-01-09  214  	{ "bluetooth_socket",
da69a5306ab92e Stephen Smalley         2017-01-09  215  	  { COMMON_SOCK_PERMS, NULL } },
da69a5306ab92e Stephen Smalley         2017-01-09  216  	{ "iucv_socket",
da69a5306ab92e Stephen Smalley         2017-01-09  217  	  { COMMON_SOCK_PERMS, NULL } },
da69a5306ab92e Stephen Smalley         2017-01-09  218  	{ "rxrpc_socket",
da69a5306ab92e Stephen Smalley         2017-01-09  219  	  { COMMON_SOCK_PERMS, NULL } },
da69a5306ab92e Stephen Smalley         2017-01-09  220  	{ "isdn_socket",
da69a5306ab92e Stephen Smalley         2017-01-09  221  	  { COMMON_SOCK_PERMS, NULL } },
da69a5306ab92e Stephen Smalley         2017-01-09  222  	{ "phonet_socket",
da69a5306ab92e Stephen Smalley         2017-01-09  223  	  { COMMON_SOCK_PERMS, NULL } },
da69a5306ab92e Stephen Smalley         2017-01-09  224  	{ "ieee802154_socket",
da69a5306ab92e Stephen Smalley         2017-01-09  225  	  { COMMON_SOCK_PERMS, NULL } },
da69a5306ab92e Stephen Smalley         2017-01-09  226  	{ "caif_socket",
da69a5306ab92e Stephen Smalley         2017-01-09  227  	  { COMMON_SOCK_PERMS, NULL } },
da69a5306ab92e Stephen Smalley         2017-01-09  228  	{ "alg_socket",
da69a5306ab92e Stephen Smalley         2017-01-09  229  	  { COMMON_SOCK_PERMS, NULL } },
da69a5306ab92e Stephen Smalley         2017-01-09  230  	{ "nfc_socket",
da69a5306ab92e Stephen Smalley         2017-01-09  231  	  { COMMON_SOCK_PERMS, NULL } },
da69a5306ab92e Stephen Smalley         2017-01-09  232  	{ "vsock_socket",
da69a5306ab92e Stephen Smalley         2017-01-09  233  	  { COMMON_SOCK_PERMS, NULL } },
da69a5306ab92e Stephen Smalley         2017-01-09  234  	{ "kcm_socket",
da69a5306ab92e Stephen Smalley         2017-01-09  235  	  { COMMON_SOCK_PERMS, NULL } },
da69a5306ab92e Stephen Smalley         2017-01-09  236  	{ "qipcrtr_socket",
da69a5306ab92e Stephen Smalley         2017-01-09  237  	  { COMMON_SOCK_PERMS, NULL } },
3051bf36c25d51 Linus Torvalds          2017-02-22  238  	{ "smc_socket",
3051bf36c25d51 Linus Torvalds          2017-02-22  239  	  { COMMON_SOCK_PERMS, NULL } },
cfc4d882d41780 Daniel Jurgens          2017-05-19  240  	{ "infiniband_pkey",
cfc4d882d41780 Daniel Jurgens          2017-05-19  241  	  { "access", NULL } },
ab861dfca1652a Daniel Jurgens          2017-05-19  242  	{ "infiniband_endport",
ab861dfca1652a Daniel Jurgens          2017-05-19  243  	  { "manage_subnet", NULL } },
ec27c3568a34c7 Chenbo Feng             2017-10-18  244  	{ "bpf",
e4c82eafb609c2 Paul Moore              2021-04-21  245  	  { "map_create", "map_read", "map_write", "prog_load", "prog_run",
e4c82eafb609c2 Paul Moore              2021-04-21  246  	    NULL } },
68e8b849b221b3 Björn Töpel             2018-05-02  247  	{ "xdp_socket",
68e8b849b221b3 Björn Töpel             2018-05-02  248  	  { COMMON_SOCK_PERMS, NULL } },
da97e18458fb42 Joel Fernandes (Google  2019-10-14  249) 	{ "perf_event",
e4c82eafb609c2 Paul Moore              2021-04-21  250  	  { "open", "cpu", "kernel", "tracepoint", "read", "write", NULL } },
59438b46471ae6 Stephen Smalley         2019-11-27  251  	{ "lockdown",
59438b46471ae6 Stephen Smalley         2019-11-27  252  	  { "integrity", "confidentiality", NULL } },
29cd6591ab6fee Daniel Colascione       2021-01-08  253  	{ "anon_inode",
29cd6591ab6fee Daniel Colascione       2021-01-08  254  	  { COMMON_FILE_PERMS, NULL } },
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  255  	{ NULL }
c6d3aaa4e35c71 Stephen Smalley         2009-09-30  256    };
da69a5306ab92e Stephen Smalley         2017-01-09  257  

68e8b849b221b3 Björn Töpel 2018-05-02 258 #if PF_MAX > 45
da69a5306ab92e Stephen Smalley 2017-01-09 @259 #error New address family defined, please update secclass_map.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org