connector

file: /proc/sys/kernel/connector
variable: kernel.connector
Official reference

Kernel connector - new netlink based userspace <-> kernel space easy to use communication module.

The Connector driver makes it easy to connect various agents using a netlink based network. One must register a callback and an identifier. When the driver receives a special netlink message with the appropriate identifier, the appropriate callback will be called.

From the userspace point of view it’s quite straightforward:

- socket();
- bind();
- send();
- recv();

But if kernelspace wants to use the full power of such connections, the driver writer must create special sockets, must know about struct sk_buff handling, etc… The Connector driver allows any kernelspace agents to use netlink based networking for inter-process communication in a significantly easier way::

int cn_add_callback(const struct cb_id id, char *name, void (callback) (struct cn_msg *, struct netlink_skb_parms *)); void cn_netlink_send_mult(struct cn_msg *msg, u16 len, u32 portid, u32 __group, int gfp_mask); void cn_netlink_send(struct cn_msg *msg, u32 portid, u32 __group, int gfp_mask);

struct cb_id { __u32 idx; __u32 val; };

idx and val are unique identifiers which must be registered in the connector.h header for in-kernel usage. void (*callback) (void *) is a callback function which will be called when a message with above idx.val is received by the connector core. The argument for that function must be dereferenced to struct cn_msg *::

struct cn_msg { struct cb_id id;

__u32			seq;
__u32			ack;

__u16			len;	/* Length of the following data */
__u16			flags;
__u8			data[0];   };