diff options
Diffstat (limited to 'net/tipc/core.h')
-rw-r--r-- | net/tipc/core.h | 171 |
1 files changed, 39 insertions, 132 deletions
diff --git a/net/tipc/core.h b/net/tipc/core.h index 84602137ce20..3dc68c7a966d 100644 --- a/net/tipc/core.h +++ b/net/tipc/core.h | |||
@@ -37,8 +37,6 @@ | |||
37 | #ifndef _TIPC_CORE_H | 37 | #ifndef _TIPC_CORE_H |
38 | #define _TIPC_CORE_H | 38 | #define _TIPC_CORE_H |
39 | 39 | ||
40 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
41 | |||
42 | #include <linux/tipc.h> | 40 | #include <linux/tipc.h> |
43 | #include <linux/tipc_config.h> | 41 | #include <linux/tipc_config.h> |
44 | #include <linux/tipc_netlink.h> | 42 | #include <linux/tipc_netlink.h> |
@@ -59,47 +57,54 @@ | |||
59 | #include <linux/vmalloc.h> | 57 | #include <linux/vmalloc.h> |
60 | #include <linux/rtnetlink.h> | 58 | #include <linux/rtnetlink.h> |
61 | #include <linux/etherdevice.h> | 59 | #include <linux/etherdevice.h> |
60 | #include <net/netns/generic.h> | ||
61 | #include <linux/rhashtable.h> | ||
62 | |||
63 | #include "node.h" | ||
64 | #include "bearer.h" | ||
65 | #include "bcast.h" | ||
66 | #include "netlink.h" | ||
67 | #include "link.h" | ||
68 | #include "node.h" | ||
69 | #include "msg.h" | ||
62 | 70 | ||
63 | #define TIPC_MOD_VER "2.0.0" | 71 | #define TIPC_MOD_VER "2.0.0" |
64 | 72 | ||
65 | #define ULTRA_STRING_MAX_LEN 32768 | 73 | extern int tipc_net_id __read_mostly; |
66 | #define TIPC_MAX_SUBSCRIPTIONS 65535 | 74 | extern int sysctl_tipc_rmem[3] __read_mostly; |
67 | #define TIPC_MAX_PUBLICATIONS 65535 | 75 | extern int sysctl_tipc_named_timeout __read_mostly; |
68 | 76 | ||
69 | struct tipc_msg; /* msg.h */ | 77 | struct tipc_net { |
78 | u32 own_addr; | ||
79 | int net_id; | ||
80 | int random; | ||
70 | 81 | ||
71 | int tipc_snprintf(char *buf, int len, const char *fmt, ...); | 82 | /* Node table and node list */ |
83 | spinlock_t node_list_lock; | ||
84 | struct hlist_head node_htable[NODE_HTABLE_SIZE]; | ||
85 | struct list_head node_list; | ||
86 | u32 num_nodes; | ||
87 | u32 num_links; | ||
72 | 88 | ||
73 | /* | 89 | /* Bearer list */ |
74 | * TIPC-specific error codes | 90 | struct tipc_bearer __rcu *bearer_list[MAX_BEARERS + 1]; |
75 | */ | ||
76 | #define ELINKCONG EAGAIN /* link congestion <=> resource unavailable */ | ||
77 | 91 | ||
78 | /* | 92 | /* Broadcast link */ |
79 | * Global configuration variables | 93 | struct tipc_bcbearer *bcbearer; |
80 | */ | 94 | struct tipc_bclink *bclink; |
81 | extern u32 tipc_own_addr __read_mostly; | 95 | struct tipc_link *bcl; |
82 | extern int tipc_max_ports __read_mostly; | ||
83 | extern int tipc_net_id __read_mostly; | ||
84 | extern int sysctl_tipc_rmem[3] __read_mostly; | ||
85 | extern int sysctl_tipc_named_timeout __read_mostly; | ||
86 | 96 | ||
87 | /* | 97 | /* Socket hash table */ |
88 | * Other global variables | 98 | struct rhashtable sk_rht; |
89 | */ | ||
90 | extern int tipc_random __read_mostly; | ||
91 | 99 | ||
92 | /* | 100 | /* Name table */ |
93 | * Routines available to privileged subsystems | 101 | spinlock_t nametbl_lock; |
94 | */ | 102 | struct name_table *nametbl; |
95 | int tipc_netlink_start(void); | 103 | |
96 | void tipc_netlink_stop(void); | 104 | /* Topology subscription server */ |
97 | int tipc_socket_init(void); | 105 | struct tipc_server *topsrv; |
98 | void tipc_socket_stop(void); | 106 | atomic_t subscription_count; |
99 | int tipc_sock_create_local(int type, struct socket **res); | 107 | }; |
100 | void tipc_sock_release_local(struct socket *sock); | ||
101 | int tipc_sock_accept_local(struct socket *sock, struct socket **newsock, | ||
102 | int flags); | ||
103 | 108 | ||
104 | #ifdef CONFIG_SYSCTL | 109 | #ifdef CONFIG_SYSCTL |
105 | int tipc_register_sysctl(void); | 110 | int tipc_register_sysctl(void); |
@@ -108,102 +113,4 @@ void tipc_unregister_sysctl(void); | |||
108 | #define tipc_register_sysctl() 0 | 113 | #define tipc_register_sysctl() 0 |
109 | #define tipc_unregister_sysctl() | 114 | #define tipc_unregister_sysctl() |
110 | #endif | 115 | #endif |
111 | |||
112 | /* | ||
113 | * TIPC timer code | ||
114 | */ | ||
115 | typedef void (*Handler) (unsigned long); | ||
116 | |||
117 | /** | ||
118 | * k_init_timer - initialize a timer | ||
119 | * @timer: pointer to timer structure | ||
120 | * @routine: pointer to routine to invoke when timer expires | ||
121 | * @argument: value to pass to routine when timer expires | ||
122 | * | ||
123 | * Timer must be initialized before use (and terminated when no longer needed). | ||
124 | */ | ||
125 | static inline void k_init_timer(struct timer_list *timer, Handler routine, | ||
126 | unsigned long argument) | ||
127 | { | ||
128 | setup_timer(timer, routine, argument); | ||
129 | } | ||
130 | |||
131 | /** | ||
132 | * k_start_timer - start a timer | ||
133 | * @timer: pointer to timer structure | ||
134 | * @msec: time to delay (in ms) | ||
135 | * | ||
136 | * Schedules a previously initialized timer for later execution. | ||
137 | * If timer is already running, the new timeout overrides the previous request. | ||
138 | * | ||
139 | * To ensure the timer doesn't expire before the specified delay elapses, | ||
140 | * the amount of delay is rounded up when converting to the jiffies | ||
141 | * then an additional jiffy is added to account for the fact that | ||
142 | * the starting time may be in the middle of the current jiffy. | ||
143 | */ | ||
144 | static inline void k_start_timer(struct timer_list *timer, unsigned long msec) | ||
145 | { | ||
146 | mod_timer(timer, jiffies + msecs_to_jiffies(msec) + 1); | ||
147 | } | ||
148 | |||
149 | /** | ||
150 | * k_cancel_timer - cancel a timer | ||
151 | * @timer: pointer to timer structure | ||
152 | * | ||
153 | * Cancels a previously initialized timer. | ||
154 | * Can be called safely even if the timer is already inactive. | ||
155 | * | ||
156 | * WARNING: Must not be called when holding locks required by the timer's | ||
157 | * timeout routine, otherwise deadlock can occur on SMP systems! | ||
158 | */ | ||
159 | static inline void k_cancel_timer(struct timer_list *timer) | ||
160 | { | ||
161 | del_timer_sync(timer); | ||
162 | } | ||
163 | |||
164 | /** | ||
165 | * k_term_timer - terminate a timer | ||
166 | * @timer: pointer to timer structure | ||
167 | * | ||
168 | * Prevents further use of a previously initialized timer. | ||
169 | * | ||
170 | * WARNING: Caller must ensure timer isn't currently running. | ||
171 | * | ||
172 | * (Do not "enhance" this routine to automatically cancel an active timer, | ||
173 | * otherwise deadlock can arise when a timeout routine calls k_term_timer.) | ||
174 | */ | ||
175 | static inline void k_term_timer(struct timer_list *timer) | ||
176 | { | ||
177 | } | ||
178 | |||
179 | /* | ||
180 | * TIPC message buffer code | ||
181 | * | ||
182 | * TIPC message buffer headroom reserves space for the worst-case | ||
183 | * link-level device header (in case the message is sent off-node). | ||
184 | * | ||
185 | * Note: Headroom should be a multiple of 4 to ensure the TIPC header fields | ||
186 | * are word aligned for quicker access | ||
187 | */ | ||
188 | #define BUF_HEADROOM LL_MAX_HEADER | ||
189 | |||
190 | struct tipc_skb_cb { | ||
191 | void *handle; | ||
192 | struct sk_buff *tail; | ||
193 | bool deferred; | ||
194 | bool wakeup_pending; | ||
195 | bool bundling; | ||
196 | u16 chain_sz; | ||
197 | u16 chain_imp; | ||
198 | }; | ||
199 | |||
200 | #define TIPC_SKB_CB(__skb) ((struct tipc_skb_cb *)&((__skb)->cb[0])) | ||
201 | |||
202 | static inline struct tipc_msg *buf_msg(struct sk_buff *skb) | ||
203 | { | ||
204 | return (struct tipc_msg *)skb->data; | ||
205 | } | ||
206 | |||
207 | struct sk_buff *tipc_buf_acquire(u32 size); | ||
208 | |||
209 | #endif | 116 | #endif |