diff options
Diffstat (limited to 'net/batman-adv')
-rw-r--r-- | net/batman-adv/Makefile | 1 | ||||
-rw-r--r-- | net/batman-adv/distributed-arp-table.c | 270 | ||||
-rw-r--r-- | net/batman-adv/distributed-arp-table.h | 58 | ||||
-rw-r--r-- | net/batman-adv/hard-interface.c | 3 | ||||
-rw-r--r-- | net/batman-adv/main.h | 6 | ||||
-rw-r--r-- | net/batman-adv/originator.c | 2 | ||||
-rw-r--r-- | net/batman-adv/types.h | 30 | ||||
-rw-r--r-- | net/batman-adv/unicast.c | 8 | ||||
-rw-r--r-- | net/batman-adv/unicast.h | 4 |
9 files changed, 378 insertions, 4 deletions
diff --git a/net/batman-adv/Makefile b/net/batman-adv/Makefile index 8676d2b1d574..7604159e7aa5 100644 --- a/net/batman-adv/Makefile +++ b/net/batman-adv/Makefile | |||
@@ -23,6 +23,7 @@ batman-adv-y += bat_iv_ogm.o | |||
23 | batman-adv-y += bitarray.o | 23 | batman-adv-y += bitarray.o |
24 | batman-adv-$(CONFIG_BATMAN_ADV_BLA) += bridge_loop_avoidance.o | 24 | batman-adv-$(CONFIG_BATMAN_ADV_BLA) += bridge_loop_avoidance.o |
25 | batman-adv-y += debugfs.o | 25 | batman-adv-y += debugfs.o |
26 | batman-adv-y += distributed-arp-table.o | ||
26 | batman-adv-y += gateway_client.o | 27 | batman-adv-y += gateway_client.o |
27 | batman-adv-y += gateway_common.o | 28 | batman-adv-y += gateway_common.o |
28 | batman-adv-y += hard-interface.o | 29 | batman-adv-y += hard-interface.o |
diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c new file mode 100644 index 000000000000..ce39e8a5be38 --- /dev/null +++ b/net/batman-adv/distributed-arp-table.c | |||
@@ -0,0 +1,270 @@ | |||
1 | /* Copyright (C) 2011-2012 B.A.T.M.A.N. contributors: | ||
2 | * | ||
3 | * Antonio Quartulli | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of version 2 of the GNU General Public | ||
7 | * License as published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, but | ||
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | * General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | * 02110-1301, USA | ||
18 | */ | ||
19 | |||
20 | #include <linux/if_ether.h> | ||
21 | #include <linux/if_arp.h> | ||
22 | |||
23 | #include "main.h" | ||
24 | #include "distributed-arp-table.h" | ||
25 | #include "hard-interface.h" | ||
26 | #include "originator.h" | ||
27 | #include "send.h" | ||
28 | #include "types.h" | ||
29 | #include "unicast.h" | ||
30 | |||
31 | /** | ||
32 | * batadv_hash_dat - compute the hash value for an IP address | ||
33 | * @data: data to hash | ||
34 | * @size: size of the hash table | ||
35 | * | ||
36 | * Returns the selected index in the hash table for the given data | ||
37 | */ | ||
38 | static uint32_t batadv_hash_dat(const void *data, uint32_t size) | ||
39 | { | ||
40 | const unsigned char *key = data; | ||
41 | uint32_t hash = 0; | ||
42 | size_t i; | ||
43 | |||
44 | for (i = 0; i < 4; i++) { | ||
45 | hash += key[i]; | ||
46 | hash += (hash << 10); | ||
47 | hash ^= (hash >> 6); | ||
48 | } | ||
49 | |||
50 | hash += (hash << 3); | ||
51 | hash ^= (hash >> 11); | ||
52 | hash += (hash << 15); | ||
53 | |||
54 | return hash % size; | ||
55 | } | ||
56 | |||
57 | /** | ||
58 | * batadv_is_orig_node_eligible - check whether a node can be a DHT candidate | ||
59 | * @res: the array with the already selected candidates | ||
60 | * @select: number of already selected candidates | ||
61 | * @tmp_max: address of the currently evaluated node | ||
62 | * @max: current round max address | ||
63 | * @last_max: address of the last selected candidate | ||
64 | * @candidate: orig_node under evaluation | ||
65 | * @max_orig_node: last selected candidate | ||
66 | * | ||
67 | * Returns true if the node has been elected as next candidate or false othrwise | ||
68 | */ | ||
69 | static bool batadv_is_orig_node_eligible(struct batadv_dat_candidate *res, | ||
70 | int select, batadv_dat_addr_t tmp_max, | ||
71 | batadv_dat_addr_t max, | ||
72 | batadv_dat_addr_t last_max, | ||
73 | struct batadv_orig_node *candidate, | ||
74 | struct batadv_orig_node *max_orig_node) | ||
75 | { | ||
76 | bool ret = false; | ||
77 | int j; | ||
78 | |||
79 | /* Check if this node has already been selected... */ | ||
80 | for (j = 0; j < select; j++) | ||
81 | if (res[j].orig_node == candidate) | ||
82 | break; | ||
83 | /* ..and possibly skip it */ | ||
84 | if (j < select) | ||
85 | goto out; | ||
86 | /* sanity check: has it already been selected? This should not happen */ | ||
87 | if (tmp_max > last_max) | ||
88 | goto out; | ||
89 | /* check if during this iteration an originator with a closer dht | ||
90 | * address has already been found | ||
91 | */ | ||
92 | if (tmp_max < max) | ||
93 | goto out; | ||
94 | /* this is an hash collision with the temporary selected node. Choose | ||
95 | * the one with the lowest address | ||
96 | */ | ||
97 | if ((tmp_max == max) && | ||
98 | (batadv_compare_eth(candidate->orig, max_orig_node->orig) > 0)) | ||
99 | goto out; | ||
100 | |||
101 | ret = true; | ||
102 | out: | ||
103 | return ret; | ||
104 | } | ||
105 | |||
106 | /** | ||
107 | * batadv_choose_next_candidate - select the next DHT candidate | ||
108 | * @bat_priv: the bat priv with all the soft interface information | ||
109 | * @cands: candidates array | ||
110 | * @select: number of candidates already present in the array | ||
111 | * @ip_key: key to look up in the DHT | ||
112 | * @last_max: pointer where the address of the selected candidate will be saved | ||
113 | */ | ||
114 | static void batadv_choose_next_candidate(struct batadv_priv *bat_priv, | ||
115 | struct batadv_dat_candidate *cands, | ||
116 | int select, batadv_dat_addr_t ip_key, | ||
117 | batadv_dat_addr_t *last_max) | ||
118 | { | ||
119 | batadv_dat_addr_t max = 0, tmp_max = 0; | ||
120 | struct batadv_orig_node *orig_node, *max_orig_node = NULL; | ||
121 | struct batadv_hashtable *hash = bat_priv->orig_hash; | ||
122 | struct hlist_node *node; | ||
123 | struct hlist_head *head; | ||
124 | int i; | ||
125 | |||
126 | /* if no node is eligible as candidate, leave the candidate type as | ||
127 | * NOT_FOUND | ||
128 | */ | ||
129 | cands[select].type = BATADV_DAT_CANDIDATE_NOT_FOUND; | ||
130 | |||
131 | /* iterate over the originator list and find the node with closest | ||
132 | * dat_address which has not been selected yet | ||
133 | */ | ||
134 | for (i = 0; i < hash->size; i++) { | ||
135 | head = &hash->table[i]; | ||
136 | |||
137 | rcu_read_lock(); | ||
138 | hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { | ||
139 | /* the dht space is a ring and addresses are unsigned */ | ||
140 | tmp_max = BATADV_DAT_ADDR_MAX - orig_node->dat_addr + | ||
141 | ip_key; | ||
142 | |||
143 | if (!batadv_is_orig_node_eligible(cands, select, | ||
144 | tmp_max, max, | ||
145 | *last_max, orig_node, | ||
146 | max_orig_node)) | ||
147 | continue; | ||
148 | |||
149 | if (!atomic_inc_not_zero(&orig_node->refcount)) | ||
150 | continue; | ||
151 | |||
152 | max = tmp_max; | ||
153 | if (max_orig_node) | ||
154 | batadv_orig_node_free_ref(max_orig_node); | ||
155 | max_orig_node = orig_node; | ||
156 | } | ||
157 | rcu_read_unlock(); | ||
158 | } | ||
159 | if (max_orig_node) { | ||
160 | cands[select].type = BATADV_DAT_CANDIDATE_ORIG; | ||
161 | cands[select].orig_node = max_orig_node; | ||
162 | batadv_dbg(BATADV_DBG_DAT, bat_priv, | ||
163 | "dat_select_candidates() %d: selected %pM addr=%u dist=%u\n", | ||
164 | select, max_orig_node->orig, max_orig_node->dat_addr, | ||
165 | max); | ||
166 | } | ||
167 | *last_max = max; | ||
168 | } | ||
169 | |||
170 | /** | ||
171 | * batadv_dat_select_candidates - selects the nodes which the DHT message has to | ||
172 | * be sent to | ||
173 | * @bat_priv: the bat priv with all the soft interface information | ||
174 | * @ip_dst: ipv4 to look up in the DHT | ||
175 | * | ||
176 | * An originator O is selected if and only if its DHT_ID value is one of three | ||
177 | * closest values (from the LEFT, with wrap around if needed) then the hash | ||
178 | * value of the key. ip_dst is the key. | ||
179 | * | ||
180 | * Returns the candidate array of size BATADV_DAT_CANDIDATE_NUM | ||
181 | */ | ||
182 | static struct batadv_dat_candidate * | ||
183 | batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst) | ||
184 | { | ||
185 | int select; | ||
186 | batadv_dat_addr_t last_max = BATADV_DAT_ADDR_MAX, ip_key; | ||
187 | struct batadv_dat_candidate *res; | ||
188 | |||
189 | if (!bat_priv->orig_hash) | ||
190 | return NULL; | ||
191 | |||
192 | res = kmalloc(BATADV_DAT_CANDIDATES_NUM * sizeof(*res), GFP_ATOMIC); | ||
193 | if (!res) | ||
194 | return NULL; | ||
195 | |||
196 | ip_key = (batadv_dat_addr_t)batadv_hash_dat(&ip_dst, | ||
197 | BATADV_DAT_ADDR_MAX); | ||
198 | |||
199 | batadv_dbg(BATADV_DBG_DAT, bat_priv, | ||
200 | "dat_select_candidates(): IP=%pI4 hash(IP)=%u\n", &ip_dst, | ||
201 | ip_key); | ||
202 | |||
203 | for (select = 0; select < BATADV_DAT_CANDIDATES_NUM; select++) | ||
204 | batadv_choose_next_candidate(bat_priv, res, select, ip_key, | ||
205 | &last_max); | ||
206 | |||
207 | return res; | ||
208 | } | ||
209 | |||
210 | /** | ||
211 | * batadv_dat_send_data - send a payload to the selected candidates | ||
212 | * @bat_priv: the bat priv with all the soft interface information | ||
213 | * @skb: payload to send | ||
214 | * @ip: the DHT key | ||
215 | * @packet_subtype: unicast4addr packet subtype to use | ||
216 | * | ||
217 | * In this function the skb is copied by means of pskb_copy() and is sent as | ||
218 | * unicast packet to each of the selected candidates | ||
219 | * | ||
220 | * Returns true if the packet is sent to at least one candidate, false otherwise | ||
221 | */ | ||
222 | static bool batadv_dat_send_data(struct batadv_priv *bat_priv, | ||
223 | struct sk_buff *skb, __be32 ip, | ||
224 | int packet_subtype) | ||
225 | { | ||
226 | int i; | ||
227 | bool ret = false; | ||
228 | int send_status; | ||
229 | struct batadv_neigh_node *neigh_node = NULL; | ||
230 | struct sk_buff *tmp_skb; | ||
231 | struct batadv_dat_candidate *cand; | ||
232 | |||
233 | cand = batadv_dat_select_candidates(bat_priv, ip); | ||
234 | if (!cand) | ||
235 | goto out; | ||
236 | |||
237 | batadv_dbg(BATADV_DBG_DAT, bat_priv, "DHT_SEND for %pI4\n", &ip); | ||
238 | |||
239 | for (i = 0; i < BATADV_DAT_CANDIDATES_NUM; i++) { | ||
240 | if (cand[i].type == BATADV_DAT_CANDIDATE_NOT_FOUND) | ||
241 | continue; | ||
242 | |||
243 | neigh_node = batadv_orig_node_get_router(cand[i].orig_node); | ||
244 | if (!neigh_node) | ||
245 | goto free_orig; | ||
246 | |||
247 | tmp_skb = pskb_copy(skb, GFP_ATOMIC); | ||
248 | if (!batadv_unicast_4addr_prepare_skb(bat_priv, tmp_skb, | ||
249 | cand[i].orig_node, | ||
250 | packet_subtype)) { | ||
251 | kfree_skb(tmp_skb); | ||
252 | goto free_neigh; | ||
253 | } | ||
254 | |||
255 | send_status = batadv_send_skb_packet(tmp_skb, | ||
256 | neigh_node->if_incoming, | ||
257 | neigh_node->addr); | ||
258 | if (send_status == NET_XMIT_SUCCESS) | ||
259 | /* packet sent to a candidate: return true */ | ||
260 | ret = true; | ||
261 | free_neigh: | ||
262 | batadv_neigh_node_free_ref(neigh_node); | ||
263 | free_orig: | ||
264 | batadv_orig_node_free_ref(cand[i].orig_node); | ||
265 | } | ||
266 | |||
267 | out: | ||
268 | kfree(cand); | ||
269 | return ret; | ||
270 | } | ||
diff --git a/net/batman-adv/distributed-arp-table.h b/net/batman-adv/distributed-arp-table.h new file mode 100644 index 000000000000..ea9cbd806a1f --- /dev/null +++ b/net/batman-adv/distributed-arp-table.h | |||
@@ -0,0 +1,58 @@ | |||
1 | /* Copyright (C) 2011-2012 B.A.T.M.A.N. contributors: | ||
2 | * | ||
3 | * Antonio Quartulli | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of version 2 of the GNU General Public | ||
7 | * License as published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, but | ||
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | * General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | * 02110-1301, USA | ||
18 | */ | ||
19 | |||
20 | #ifndef _NET_BATMAN_ADV_ARP_H_ | ||
21 | #define _NET_BATMAN_ADV_ARP_H_ | ||
22 | |||
23 | #include "types.h" | ||
24 | #include "originator.h" | ||
25 | |||
26 | #define BATADV_DAT_ADDR_MAX ((batadv_dat_addr_t)~(batadv_dat_addr_t)0) | ||
27 | |||
28 | /** | ||
29 | * batadv_dat_init_orig_node_addr - assign a DAT address to the orig_node | ||
30 | * @orig_node: the node to assign the DAT address to | ||
31 | */ | ||
32 | static inline void | ||
33 | batadv_dat_init_orig_node_addr(struct batadv_orig_node *orig_node) | ||
34 | { | ||
35 | uint32_t addr; | ||
36 | |||
37 | addr = batadv_choose_orig(orig_node->orig, BATADV_DAT_ADDR_MAX); | ||
38 | orig_node->dat_addr = (batadv_dat_addr_t)addr; | ||
39 | } | ||
40 | |||
41 | /** | ||
42 | * batadv_dat_init_own_addr - assign a DAT address to the node itself | ||
43 | * @bat_priv: the bat priv with all the soft interface information | ||
44 | * @primary_if: a pointer to the primary interface | ||
45 | */ | ||
46 | static inline void | ||
47 | batadv_dat_init_own_addr(struct batadv_priv *bat_priv, | ||
48 | struct batadv_hard_iface *primary_if) | ||
49 | { | ||
50 | uint32_t addr; | ||
51 | |||
52 | addr = batadv_choose_orig(primary_if->net_dev->dev_addr, | ||
53 | BATADV_DAT_ADDR_MAX); | ||
54 | |||
55 | bat_priv->dat.addr = (batadv_dat_addr_t)addr; | ||
56 | } | ||
57 | |||
58 | #endif /* _NET_BATMAN_ADV_ARP_H_ */ | ||
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index fab9e4158dc2..6b7a5d3eeb77 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c | |||
@@ -18,6 +18,7 @@ | |||
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include "main.h" | 20 | #include "main.h" |
21 | #include "distributed-arp-table.h" | ||
21 | #include "hard-interface.h" | 22 | #include "hard-interface.h" |
22 | #include "soft-interface.h" | 23 | #include "soft-interface.h" |
23 | #include "send.h" | 24 | #include "send.h" |
@@ -109,6 +110,8 @@ static void batadv_primary_if_update_addr(struct batadv_priv *bat_priv, | |||
109 | if (!primary_if) | 110 | if (!primary_if) |
110 | goto out; | 111 | goto out; |
111 | 112 | ||
113 | batadv_dat_init_own_addr(bat_priv, primary_if); | ||
114 | |||
112 | skb = bat_priv->vis.my_info->skb_packet; | 115 | skb = bat_priv->vis.my_info->skb_packet; |
113 | vis_packet = (struct batadv_vis_packet *)skb->data; | 116 | vis_packet = (struct batadv_vis_packet *)skb->data; |
114 | memcpy(vis_packet->vis_orig, primary_if->net_dev->dev_addr, ETH_ALEN); | 117 | memcpy(vis_packet->vis_orig, primary_if->net_dev->dev_addr, ETH_ALEN); |
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index c08724a165b9..5699f2b3b557 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h | |||
@@ -73,6 +73,9 @@ | |||
73 | 73 | ||
74 | #define BATADV_LOG_BUF_LEN 8192 /* has to be a power of 2 */ | 74 | #define BATADV_LOG_BUF_LEN 8192 /* has to be a power of 2 */ |
75 | 75 | ||
76 | /* numbers of originator to contact for any PUT/GET DHT operation */ | ||
77 | #define BATADV_DAT_CANDIDATES_NUM 3 | ||
78 | |||
76 | #define BATADV_VIS_INTERVAL 5000 /* 5 seconds */ | 79 | #define BATADV_VIS_INTERVAL 5000 /* 5 seconds */ |
77 | 80 | ||
78 | /* how much worse secondary interfaces may be to be considered as bonding | 81 | /* how much worse secondary interfaces may be to be considered as bonding |
@@ -117,6 +120,9 @@ enum batadv_uev_type { | |||
117 | 120 | ||
118 | #define BATADV_GW_THRESHOLD 50 | 121 | #define BATADV_GW_THRESHOLD 50 |
119 | 122 | ||
123 | #define BATADV_DAT_CANDIDATE_NOT_FOUND 0 | ||
124 | #define BATADV_DAT_CANDIDATE_ORIG 1 | ||
125 | |||
120 | /* Debug Messages */ | 126 | /* Debug Messages */ |
121 | #ifdef pr_fmt | 127 | #ifdef pr_fmt |
122 | #undef pr_fmt | 128 | #undef pr_fmt |
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index d9c14b8fca0e..84930a4f5369 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c | |||
@@ -18,6 +18,7 @@ | |||
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include "main.h" | 20 | #include "main.h" |
21 | #include "distributed-arp-table.h" | ||
21 | #include "originator.h" | 22 | #include "originator.h" |
22 | #include "hash.h" | 23 | #include "hash.h" |
23 | #include "translation-table.h" | 24 | #include "translation-table.h" |
@@ -223,6 +224,7 @@ struct batadv_orig_node *batadv_get_orig_node(struct batadv_priv *bat_priv, | |||
223 | orig_node->tt_poss_change = false; | 224 | orig_node->tt_poss_change = false; |
224 | orig_node->bat_priv = bat_priv; | 225 | orig_node->bat_priv = bat_priv; |
225 | memcpy(orig_node->orig, addr, ETH_ALEN); | 226 | memcpy(orig_node->orig, addr, ETH_ALEN); |
227 | batadv_dat_init_orig_node_addr(orig_node); | ||
226 | orig_node->router = NULL; | 228 | orig_node->router = NULL; |
227 | orig_node->tt_crc = 0; | 229 | orig_node->tt_crc = 0; |
228 | atomic_set(&orig_node->last_ttvn, 0); | 230 | atomic_set(&orig_node->last_ttvn, 0); |
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index faaebd6c8140..b57d93bdafa6 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h | |||
@@ -28,6 +28,13 @@ | |||
28 | (ETH_HLEN + max(sizeof(struct batadv_unicast_packet), \ | 28 | (ETH_HLEN + max(sizeof(struct batadv_unicast_packet), \ |
29 | sizeof(struct batadv_bcast_packet))) | 29 | sizeof(struct batadv_bcast_packet))) |
30 | 30 | ||
31 | /* batadv_dat_addr_t is the type used for all DHT addresses. If it is changed, | ||
32 | * BATADV_DAT_ADDR_MAX is changed as well. | ||
33 | * | ||
34 | * *Please be careful: batadv_dat_addr_t must be UNSIGNED* | ||
35 | */ | ||
36 | #define batadv_dat_addr_t uint16_t | ||
37 | |||
31 | /** | 38 | /** |
32 | * struct batadv_hard_iface_bat_iv - per hard interface B.A.T.M.A.N. IV data | 39 | * struct batadv_hard_iface_bat_iv - per hard interface B.A.T.M.A.N. IV data |
33 | * @ogm_buff: buffer holding the OGM packet | 40 | * @ogm_buff: buffer holding the OGM packet |
@@ -73,6 +80,7 @@ struct batadv_orig_node { | |||
73 | uint8_t orig[ETH_ALEN]; | 80 | uint8_t orig[ETH_ALEN]; |
74 | uint8_t primary_addr[ETH_ALEN]; | 81 | uint8_t primary_addr[ETH_ALEN]; |
75 | struct batadv_neigh_node __rcu *router; /* rcu protected pointer */ | 82 | struct batadv_neigh_node __rcu *router; /* rcu protected pointer */ |
83 | batadv_dat_addr_t dat_addr; | ||
76 | unsigned long *bcast_own; | 84 | unsigned long *bcast_own; |
77 | uint8_t *bcast_own_sum; | 85 | uint8_t *bcast_own_sum; |
78 | unsigned long last_seen; | 86 | unsigned long last_seen; |
@@ -238,6 +246,14 @@ struct batadv_priv_vis { | |||
238 | struct batadv_vis_info *my_info; | 246 | struct batadv_vis_info *my_info; |
239 | }; | 247 | }; |
240 | 248 | ||
249 | /** | ||
250 | * struct batadv_priv_dat - per mesh interface DAT private data | ||
251 | * @addr: node DAT address | ||
252 | */ | ||
253 | struct batadv_priv_dat { | ||
254 | batadv_dat_addr_t addr; | ||
255 | }; | ||
256 | |||
241 | struct batadv_priv { | 257 | struct batadv_priv { |
242 | atomic_t mesh_state; | 258 | atomic_t mesh_state; |
243 | struct net_device_stats stats; | 259 | struct net_device_stats stats; |
@@ -275,6 +291,7 @@ struct batadv_priv { | |||
275 | struct batadv_priv_gw gw; | 291 | struct batadv_priv_gw gw; |
276 | struct batadv_priv_tt tt; | 292 | struct batadv_priv_tt tt; |
277 | struct batadv_priv_vis vis; | 293 | struct batadv_priv_vis vis; |
294 | struct batadv_priv_dat dat; | ||
278 | }; | 295 | }; |
279 | 296 | ||
280 | struct batadv_socket_client { | 297 | struct batadv_socket_client { |
@@ -447,4 +464,17 @@ struct batadv_algo_ops { | |||
447 | void (*bat_ogm_emit)(struct batadv_forw_packet *forw_packet); | 464 | void (*bat_ogm_emit)(struct batadv_forw_packet *forw_packet); |
448 | }; | 465 | }; |
449 | 466 | ||
467 | /** | ||
468 | * struct batadv_dat_candidate - candidate destination for DAT operations | ||
469 | * @type: the type of the selected candidate. It can one of the following: | ||
470 | * - BATADV_DAT_CANDIDATE_NOT_FOUND | ||
471 | * - BATADV_DAT_CANDIDATE_ORIG | ||
472 | * @orig_node: if type is BATADV_DAT_CANDIDATE_ORIG this field points to the | ||
473 | * corresponding originator node structure | ||
474 | */ | ||
475 | struct batadv_dat_candidate { | ||
476 | int type; | ||
477 | struct batadv_orig_node *orig_node; | ||
478 | }; | ||
479 | |||
450 | #endif /* _NET_BATMAN_ADV_TYPES_H_ */ | 480 | #endif /* _NET_BATMAN_ADV_TYPES_H_ */ |
diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c index c0d318b587ee..c9a1f6523c36 100644 --- a/net/batman-adv/unicast.c +++ b/net/batman-adv/unicast.c | |||
@@ -347,10 +347,10 @@ static bool batadv_unicast_prepare_skb(struct sk_buff *skb, | |||
347 | * | 347 | * |
348 | * Returns false if the payload could not be encapsulated or true otherwise | 348 | * Returns false if the payload could not be encapsulated or true otherwise |
349 | */ | 349 | */ |
350 | static bool batadv_unicast_4addr_prepare_skb(struct batadv_priv *bat_priv, | 350 | bool batadv_unicast_4addr_prepare_skb(struct batadv_priv *bat_priv, |
351 | struct sk_buff *skb, | 351 | struct sk_buff *skb, |
352 | struct batadv_orig_node *orig, | 352 | struct batadv_orig_node *orig, |
353 | int packet_subtype) | 353 | int packet_subtype) |
354 | { | 354 | { |
355 | struct batadv_hard_iface *primary_if; | 355 | struct batadv_hard_iface *primary_if; |
356 | struct batadv_unicast_4addr_packet *unicast_4addr_packet; | 356 | struct batadv_unicast_4addr_packet *unicast_4addr_packet; |
diff --git a/net/batman-adv/unicast.h b/net/batman-adv/unicast.h index a88ed2941c6a..61abba58bd8f 100644 --- a/net/batman-adv/unicast.h +++ b/net/batman-adv/unicast.h | |||
@@ -32,6 +32,10 @@ void batadv_frag_list_free(struct list_head *head); | |||
32 | int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv, | 32 | int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv, |
33 | struct batadv_hard_iface *hard_iface, | 33 | struct batadv_hard_iface *hard_iface, |
34 | const uint8_t dstaddr[]); | 34 | const uint8_t dstaddr[]); |
35 | bool batadv_unicast_4addr_prepare_skb(struct batadv_priv *bat_priv, | ||
36 | struct sk_buff *skb, | ||
37 | struct batadv_orig_node *orig_node, | ||
38 | int packet_subtype); | ||
35 | int batadv_unicast_generic_send_skb(struct batadv_priv *bat_priv, | 39 | int batadv_unicast_generic_send_skb(struct batadv_priv *bat_priv, |
36 | struct sk_buff *skb, int packet_type, | 40 | struct sk_buff *skb, int packet_type, |
37 | int packet_subtype); | 41 | int packet_subtype); |