summaryrefslogtreecommitdiffstats
path: root/include/net/kcm.h
diff options
context:
space:
mode:
authorTom Herbert <tom@herbertland.com>2016-03-07 17:11:06 -0500
committerDavid S. Miller <davem@davemloft.net>2016-03-09 16:36:14 -0500
commitab7ac4eb9832e32a09f4e8042705484d2fb0aad3 (patch)
tree386057aeaceeaa0e0365814f544989e42c484a09 /include/net/kcm.h
parent473bd239b808a8af5241ce9996a16d283d88ddff (diff)
kcm: Kernel Connection Multiplexor module
This module implements the Kernel Connection Multiplexor. Kernel Connection Multiplexor (KCM) is a facility that provides a message based interface over TCP for generic application protocols. With KCM an application can efficiently send and receive application protocol messages over TCP using datagram sockets. For more information see the included Documentation/networking/kcm.txt Signed-off-by: Tom Herbert <tom@herbertland.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/kcm.h')
-rw-r--r--include/net/kcm.h125
1 files changed, 125 insertions, 0 deletions
diff --git a/include/net/kcm.h b/include/net/kcm.h
new file mode 100644
index 000000000000..1bcae39070ec
--- /dev/null
+++ b/include/net/kcm.h
@@ -0,0 +1,125 @@
1/*
2 * Kernel Connection Multiplexor
3 *
4 * Copyright (c) 2016 Tom Herbert <tom@herbertland.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2
8 * as published by the Free Software Foundation.
9 */
10
11#ifndef __NET_KCM_H_
12#define __NET_KCM_H_
13
14#include <linux/skbuff.h>
15#include <net/sock.h>
16#include <uapi/linux/kcm.h>
17
18extern unsigned int kcm_net_id;
19
20struct kcm_tx_msg {
21 unsigned int sent;
22 unsigned int fragidx;
23 unsigned int frag_offset;
24 unsigned int msg_flags;
25 struct sk_buff *frag_skb;
26 struct sk_buff *last_skb;
27};
28
29struct kcm_rx_msg {
30 int full_len;
31 int accum_len;
32 int offset;
33};
34
35/* Socket structure for KCM client sockets */
36struct kcm_sock {
37 struct sock sk;
38 struct kcm_mux *mux;
39 struct list_head kcm_sock_list;
40 int index;
41 u32 done : 1;
42 struct work_struct done_work;
43
44 /* Transmit */
45 struct kcm_psock *tx_psock;
46 struct work_struct tx_work;
47 struct list_head wait_psock_list;
48 struct sk_buff *seq_skb;
49
50 /* Don't use bit fields here, these are set under different locks */
51 bool tx_wait;
52 bool tx_wait_more;
53
54 /* Receive */
55 struct kcm_psock *rx_psock;
56 struct list_head wait_rx_list; /* KCMs waiting for receiving */
57 bool rx_wait;
58 u32 rx_disabled : 1;
59};
60
61struct bpf_prog;
62
63/* Structure for an attached lower socket */
64struct kcm_psock {
65 struct sock *sk;
66 struct kcm_mux *mux;
67 int index;
68
69 u32 tx_stopped : 1;
70 u32 rx_stopped : 1;
71 u32 done : 1;
72 u32 unattaching : 1;
73
74 void (*save_state_change)(struct sock *sk);
75 void (*save_data_ready)(struct sock *sk);
76 void (*save_write_space)(struct sock *sk);
77
78 struct list_head psock_list;
79
80 /* Receive */
81 struct sk_buff *rx_skb_head;
82 struct sk_buff **rx_skb_nextp;
83 struct sk_buff *ready_rx_msg;
84 struct list_head psock_ready_list;
85 struct work_struct rx_work;
86 struct delayed_work rx_delayed_work;
87 struct bpf_prog *bpf_prog;
88 struct kcm_sock *rx_kcm;
89
90 /* Transmit */
91 struct kcm_sock *tx_kcm;
92 struct list_head psock_avail_list;
93};
94
95/* Per net MUX list */
96struct kcm_net {
97 struct mutex mutex;
98 struct list_head mux_list;
99 int count;
100};
101
102/* Structure for a MUX */
103struct kcm_mux {
104 struct list_head kcm_mux_list;
105 struct rcu_head rcu;
106 struct kcm_net *knet;
107
108 struct list_head kcm_socks; /* All KCM sockets on MUX */
109 int kcm_socks_cnt; /* Total KCM socket count for MUX */
110 struct list_head psocks; /* List of all psocks on MUX */
111 int psocks_cnt; /* Total attached sockets */
112
113 /* Receive */
114 spinlock_t rx_lock ____cacheline_aligned_in_smp;
115 struct list_head kcm_rx_waiters; /* KCMs waiting for receiving */
116 struct list_head psocks_ready; /* List of psocks with a msg ready */
117 struct sk_buff_head rx_hold_queue;
118
119 /* Transmit */
120 spinlock_t lock ____cacheline_aligned_in_smp; /* TX and mux locking */
121 struct list_head psocks_avail; /* List of available psocks */
122 struct list_head kcm_tx_waiters; /* KCMs waiting for a TX psock */
123};
124
125#endif /* __NET_KCM_H_ */