1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37#ifndef _TIPC_BEARER_H
38#define _TIPC_BEARER_H
39
40#include "netlink.h"
41#include "core.h"
42#include "msg.h"
43#include <net/genetlink.h>
44
45#define MAX_MEDIA 3
46
47
48
49
50
51
52#define TIPC_MEDIA_INFO_SIZE 32
53#define TIPC_MEDIA_TYPE_OFFSET 3
54#define TIPC_MEDIA_ADDR_OFFSET 4
55
56
57
58
59#define TIPC_MEDIA_TYPE_ETH 1
60#define TIPC_MEDIA_TYPE_IB 2
61#define TIPC_MEDIA_TYPE_UDP 3
62
63
64#define TIPC_MIN_BEARER_MTU (MAX_H_SIZE + INT_H_SIZE)
65
66
67
68#define TIPC_BROADCAST_SUPPORT 1
69#define TIPC_REPLICAST_SUPPORT 2
70
71
72
73
74
75
76
77struct tipc_media_addr {
78 u8 value[TIPC_MEDIA_INFO_SIZE];
79 u8 media_id;
80 u8 broadcast;
81};
82
83struct tipc_bearer;
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103struct tipc_media {
104 int (*send_msg)(struct net *net, struct sk_buff *buf,
105 struct tipc_bearer *b,
106 struct tipc_media_addr *dest);
107 int (*enable_media)(struct net *net, struct tipc_bearer *b,
108 struct nlattr *attr[]);
109 void (*disable_media)(struct tipc_bearer *b);
110 int (*addr2str)(struct tipc_media_addr *addr,
111 char *strbuf,
112 int bufsz);
113 int (*addr2msg)(char *msg, struct tipc_media_addr *addr);
114 int (*msg2addr)(struct tipc_bearer *b,
115 struct tipc_media_addr *addr,
116 char *msg);
117 int (*raw2addr)(struct tipc_bearer *b,
118 struct tipc_media_addr *addr,
119 char *raw);
120 u32 priority;
121 u32 tolerance;
122 u32 min_win;
123 u32 max_win;
124 u32 mtu;
125 u32 type_id;
126 u32 hwaddr_len;
127 char name[TIPC_MAX_MEDIA_NAME];
128};
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152struct tipc_bearer {
153 void __rcu *media_ptr;
154 u32 mtu;
155 struct tipc_media_addr addr;
156 char name[TIPC_MAX_BEARER_NAME];
157 struct tipc_media *media;
158 struct tipc_media_addr bcast_addr;
159 struct packet_type pt;
160 struct rcu_head rcu;
161 u32 priority;
162 u32 min_win;
163 u32 max_win;
164 u32 tolerance;
165 u32 domain;
166 u32 identity;
167 struct tipc_discoverer *disc;
168 char net_plane;
169 unsigned long up;
170 refcount_t refcnt;
171};
172
173struct tipc_bearer_names {
174 char media_name[TIPC_MAX_MEDIA_NAME];
175 char if_name[TIPC_MAX_IF_NAME];
176};
177
178
179
180
181
182void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b);
183
184
185
186
187extern struct tipc_media eth_media_info;
188
189#ifdef CONFIG_TIPC_MEDIA_IB
190extern struct tipc_media ib_media_info;
191#endif
192#ifdef CONFIG_TIPC_MEDIA_UDP
193extern struct tipc_media udp_media_info;
194#endif
195
196int tipc_nl_bearer_disable(struct sk_buff *skb, struct genl_info *info);
197int __tipc_nl_bearer_disable(struct sk_buff *skb, struct genl_info *info);
198int tipc_nl_bearer_enable(struct sk_buff *skb, struct genl_info *info);
199int __tipc_nl_bearer_enable(struct sk_buff *skb, struct genl_info *info);
200int tipc_nl_bearer_dump(struct sk_buff *skb, struct netlink_callback *cb);
201int tipc_nl_bearer_get(struct sk_buff *skb, struct genl_info *info);
202int tipc_nl_bearer_set(struct sk_buff *skb, struct genl_info *info);
203int __tipc_nl_bearer_set(struct sk_buff *skb, struct genl_info *info);
204int tipc_nl_bearer_add(struct sk_buff *skb, struct genl_info *info);
205
206int tipc_nl_media_dump(struct sk_buff *skb, struct netlink_callback *cb);
207int tipc_nl_media_get(struct sk_buff *skb, struct genl_info *info);
208int tipc_nl_media_set(struct sk_buff *skb, struct genl_info *info);
209int __tipc_nl_media_set(struct sk_buff *skb, struct genl_info *info);
210
211int tipc_media_set_priority(const char *name, u32 new_value);
212int tipc_media_set_window(const char *name, u32 new_value);
213int tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a);
214int tipc_enable_l2_media(struct net *net, struct tipc_bearer *b,
215 struct nlattr *attrs[]);
216bool tipc_bearer_hold(struct tipc_bearer *b);
217void tipc_bearer_put(struct tipc_bearer *b);
218void tipc_disable_l2_media(struct tipc_bearer *b);
219int tipc_l2_send_msg(struct net *net, struct sk_buff *buf,
220 struct tipc_bearer *b, struct tipc_media_addr *dest);
221
222void tipc_bearer_add_dest(struct net *net, u32 bearer_id, u32 dest);
223void tipc_bearer_remove_dest(struct net *net, u32 bearer_id, u32 dest);
224struct tipc_bearer *tipc_bearer_find(struct net *net, const char *name);
225int tipc_bearer_get_name(struct net *net, char *name, u32 bearer_id);
226struct tipc_media *tipc_media_find(const char *name);
227int tipc_bearer_setup(void);
228void tipc_bearer_cleanup(void);
229void tipc_bearer_stop(struct net *net);
230int tipc_bearer_mtu(struct net *net, u32 bearer_id);
231bool tipc_bearer_bcast_support(struct net *net, u32 bearer_id);
232void tipc_bearer_xmit_skb(struct net *net, u32 bearer_id,
233 struct sk_buff *skb,
234 struct tipc_media_addr *dest);
235void tipc_bearer_xmit(struct net *net, u32 bearer_id,
236 struct sk_buff_head *xmitq,
237 struct tipc_media_addr *dst,
238 struct tipc_node *__dnode);
239void tipc_bearer_bc_xmit(struct net *net, u32 bearer_id,
240 struct sk_buff_head *xmitq);
241void tipc_clone_to_loopback(struct net *net, struct sk_buff_head *pkts);
242int tipc_attach_loopback(struct net *net);
243void tipc_detach_loopback(struct net *net);
244
245static inline void tipc_loopback_trace(struct net *net,
246 struct sk_buff_head *pkts)
247{
248 if (unlikely(dev_nit_active(net->loopback_dev)))
249 tipc_clone_to_loopback(net, pkts);
250}
251
252
253static inline bool tipc_mtu_bad(struct net_device *dev, unsigned int reserve)
254{
255 if (dev->mtu >= TIPC_MIN_BEARER_MTU + reserve)
256 return false;
257 netdev_warn(dev, "MTU too low for tipc bearer\n");
258 return true;
259}
260
261#endif
262