Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'batman-adv-for-davem' of git://git.open-mesh.org/linux-merge

Included changes:
- The last batch of patches aimed to clean the batman-adv namespace
- a couple of style fixes
- a fix for the ethtool support
- a fix to prevent sending unicast packets with an uninitialised header
field

Signed-off-by: David S. Miller <davem@davemloft.net>

+2010 -1843
+2 -2
net/batman-adv/Makefile
··· 19 19 # 20 20 21 21 obj-$(CONFIG_BATMAN_ADV) += batman-adv.o 22 - batman-adv-y += bat_debugfs.o 23 22 batman-adv-y += bat_iv_ogm.o 24 - batman-adv-y += bat_sysfs.o 25 23 batman-adv-y += bitarray.o 26 24 batman-adv-$(CONFIG_BATMAN_ADV_BLA) += bridge_loop_avoidance.o 25 + batman-adv-y += debugfs.o 27 26 batman-adv-y += gateway_client.o 28 27 batman-adv-y += gateway_common.o 29 28 batman-adv-y += hard-interface.o ··· 34 35 batman-adv-y += routing.o 35 36 batman-adv-y += send.o 36 37 batman-adv-y += soft-interface.o 38 + batman-adv-y += sysfs.o 37 39 batman-adv-y += translation-table.o 38 40 batman-adv-y += unicast.o 39 41 batman-adv-y += vis.o
+46 -30
net/batman-adv/bat_debugfs.c net/batman-adv/debugfs.c
··· 21 21 22 22 #include <linux/debugfs.h> 23 23 24 - #include "bat_debugfs.h" 24 + #include "debugfs.h" 25 25 #include "translation-table.h" 26 26 #include "originator.h" 27 27 #include "hard-interface.h" ··· 36 36 37 37 #ifdef CONFIG_BATMAN_ADV_DEBUG 38 38 #define BATADV_LOG_BUFF_MASK (batadv_log_buff_len - 1) 39 - #define BATADV_LOG_BUFF(idx) (debug_log->log_buff[(idx) & BATADV_LOG_BUFF_MASK]) 40 39 41 - static int batadv_log_buff_len = BATADV_LOG_BUF_LEN; 40 + static const int batadv_log_buff_len = BATADV_LOG_BUF_LEN; 42 41 43 - static void batadv_emit_log_char(struct debug_log *debug_log, char c) 42 + static char *batadv_log_char_addr(struct batadv_debug_log *debug_log, 43 + size_t idx) 44 44 { 45 - BATADV_LOG_BUFF(debug_log->log_end) = c; 45 + return &debug_log->log_buff[idx & BATADV_LOG_BUFF_MASK]; 46 + } 47 + 48 + static void batadv_emit_log_char(struct batadv_debug_log *debug_log, char c) 49 + { 50 + char *char_addr; 51 + 52 + char_addr = batadv_log_char_addr(debug_log, debug_log->log_end); 53 + *char_addr = c; 46 54 debug_log->log_end++; 47 55 48 56 if (debug_log->log_end - debug_log->log_start > batadv_log_buff_len) ··· 58 50 } 59 51 60 52 __printf(2, 3) 61 - static int batadv_fdebug_log(struct debug_log *debug_log, const char *fmt, ...) 53 + static int batadv_fdebug_log(struct batadv_debug_log *debug_log, 54 + const char *fmt, ...) 62 55 { 63 56 va_list args; 64 57 static char debug_log_buf[256]; ··· 83 74 return 0; 84 75 } 85 76 86 - int batadv_debug_log(struct bat_priv *bat_priv, const char *fmt, ...) 77 + int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...) 87 78 { 88 79 va_list args; 89 80 char tmp_log_buf[256]; ··· 111 102 return 0; 112 103 } 113 104 105 + static int batadv_log_empty(struct batadv_debug_log *debug_log) 106 + { 107 + return !(debug_log->log_start - debug_log->log_end); 108 + } 109 + 114 110 static ssize_t batadv_log_read(struct file *file, char __user *buf, 115 111 size_t count, loff_t *ppos) 116 112 { 117 - struct bat_priv *bat_priv = file->private_data; 118 - struct debug_log *debug_log = bat_priv->debug_log; 113 + struct batadv_priv *bat_priv = file->private_data; 114 + struct batadv_debug_log *debug_log = bat_priv->debug_log; 119 115 int error, i = 0; 116 + char *char_addr; 120 117 char c; 121 118 122 - if ((file->f_flags & O_NONBLOCK) && 123 - !(debug_log->log_end - debug_log->log_start)) 119 + if ((file->f_flags & O_NONBLOCK) && batadv_log_empty(debug_log)) 124 120 return -EAGAIN; 125 121 126 122 if (!buf) ··· 138 124 return -EFAULT; 139 125 140 126 error = wait_event_interruptible(debug_log->queue_wait, 141 - (debug_log->log_start - debug_log->log_end)); 127 + (!batadv_log_empty(debug_log))); 142 128 143 129 if (error) 144 130 return error; ··· 147 133 148 134 while ((!error) && (i < count) && 149 135 (debug_log->log_start != debug_log->log_end)) { 150 - c = BATADV_LOG_BUFF(debug_log->log_start); 136 + char_addr = batadv_log_char_addr(debug_log, 137 + debug_log->log_start); 138 + c = *char_addr; 151 139 152 140 debug_log->log_start++; 153 141 ··· 174 158 175 159 static unsigned int batadv_log_poll(struct file *file, poll_table *wait) 176 160 { 177 - struct bat_priv *bat_priv = file->private_data; 178 - struct debug_log *debug_log = bat_priv->debug_log; 161 + struct batadv_priv *bat_priv = file->private_data; 162 + struct batadv_debug_log *debug_log = bat_priv->debug_log; 179 163 180 164 poll_wait(file, &debug_log->queue_wait, wait); 181 165 182 - if (debug_log->log_end - debug_log->log_start) 166 + if (!batadv_log_empty(debug_log)) 183 167 return POLLIN | POLLRDNORM; 184 168 185 169 return 0; ··· 193 177 .llseek = no_llseek, 194 178 }; 195 179 196 - static int batadv_debug_log_setup(struct bat_priv *bat_priv) 180 + static int batadv_debug_log_setup(struct batadv_priv *bat_priv) 197 181 { 198 182 struct dentry *d; 199 183 ··· 219 203 return -ENOMEM; 220 204 } 221 205 222 - static void batadv_debug_log_cleanup(struct bat_priv *bat_priv) 206 + static void batadv_debug_log_cleanup(struct batadv_priv *bat_priv) 223 207 { 224 208 kfree(bat_priv->debug_log); 225 209 bat_priv->debug_log = NULL; 226 210 } 227 211 #else /* CONFIG_BATMAN_ADV_DEBUG */ 228 - static int batadv_debug_log_setup(struct bat_priv *bat_priv) 212 + static int batadv_debug_log_setup(struct batadv_priv *bat_priv) 229 213 { 230 214 bat_priv->debug_log = NULL; 231 215 return 0; 232 216 } 233 217 234 - static void batadv_debug_log_cleanup(struct bat_priv *bat_priv) 218 + static void batadv_debug_log_cleanup(struct batadv_priv *bat_priv) 235 219 { 236 220 return; 237 221 } ··· 281 265 return single_open(file, batadv_vis_seq_print_text, net_dev); 282 266 } 283 267 284 - struct bat_debuginfo { 268 + struct batadv_debuginfo { 285 269 struct attribute attr; 286 270 const struct file_operations fops; 287 271 }; 288 272 289 273 #define BATADV_DEBUGINFO(_name, _mode, _open) \ 290 - struct bat_debuginfo batadv_debuginfo_##_name = { \ 274 + struct batadv_debuginfo batadv_debuginfo_##_name = { \ 291 275 .attr = { .name = __stringify(_name), \ 292 276 .mode = _mode, }, \ 293 277 .fops = { .owner = THIS_MODULE, \ ··· 310 294 batadv_transtable_local_open); 311 295 static BATADV_DEBUGINFO(vis_data, S_IRUGO, batadv_vis_data_open); 312 296 313 - static struct bat_debuginfo *batadv_mesh_debuginfos[] = { 297 + static struct batadv_debuginfo *batadv_mesh_debuginfos[] = { 314 298 &batadv_debuginfo_originators, 315 299 &batadv_debuginfo_gateways, 316 300 &batadv_debuginfo_transtable_global, ··· 324 308 325 309 void batadv_debugfs_init(void) 326 310 { 327 - struct bat_debuginfo *bat_debug; 311 + struct batadv_debuginfo *bat_debug; 328 312 struct dentry *file; 329 313 330 314 batadv_debugfs = debugfs_create_dir(BATADV_DEBUGFS_SUBDIR, NULL); ··· 355 339 356 340 int batadv_debugfs_add_meshif(struct net_device *dev) 357 341 { 358 - struct bat_priv *bat_priv = netdev_priv(dev); 359 - struct bat_debuginfo **bat_debug; 342 + struct batadv_priv *bat_priv = netdev_priv(dev); 343 + struct batadv_debuginfo **bat_debug; 360 344 struct dentry *file; 361 345 362 346 if (!batadv_debugfs) ··· 374 358 375 359 for (bat_debug = batadv_mesh_debuginfos; *bat_debug; ++bat_debug) { 376 360 file = debugfs_create_file(((*bat_debug)->attr).name, 377 - S_IFREG | ((*bat_debug)->attr).mode, 378 - bat_priv->debug_dir, 379 - dev, &(*bat_debug)->fops); 361 + S_IFREG | ((*bat_debug)->attr).mode, 362 + bat_priv->debug_dir, 363 + dev, &(*bat_debug)->fops); 380 364 if (!file) { 381 365 batadv_err(dev, "Can't add debugfs file: %s/%s\n", 382 366 dev->name, ((*bat_debug)->attr).name); ··· 398 382 399 383 void batadv_debugfs_del_meshif(struct net_device *dev) 400 384 { 401 - struct bat_priv *bat_priv = netdev_priv(dev); 385 + struct batadv_priv *bat_priv = netdev_priv(dev); 402 386 403 387 batadv_debug_log_cleanup(bat_priv); 404 388
net/batman-adv/bat_debugfs.h net/batman-adv/debugfs.h
+233 -226
net/batman-adv/bat_iv_ogm.c
··· 28 28 #include "send.h" 29 29 #include "bat_algo.h" 30 30 31 - static struct neigh_node *batadv_iv_ogm_neigh_new(struct hard_iface *hard_iface, 32 - const uint8_t *neigh_addr, 33 - struct orig_node *orig_node, 34 - struct orig_node *orig_neigh, 35 - __be32 seqno) 31 + static struct batadv_neigh_node * 32 + batadv_iv_ogm_neigh_new(struct batadv_hard_iface *hard_iface, 33 + const uint8_t *neigh_addr, 34 + struct batadv_orig_node *orig_node, 35 + struct batadv_orig_node *orig_neigh, __be32 seqno) 36 36 { 37 - struct neigh_node *neigh_node; 37 + struct batadv_neigh_node *neigh_node; 38 38 39 39 neigh_node = batadv_neigh_node_new(hard_iface, neigh_addr, 40 40 ntohl(seqno)); ··· 54 54 return neigh_node; 55 55 } 56 56 57 - static int batadv_iv_ogm_iface_enable(struct hard_iface *hard_iface) 57 + static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface) 58 58 { 59 - struct batman_ogm_packet *batman_ogm_packet; 59 + struct batadv_ogm_packet *batadv_ogm_packet; 60 60 uint32_t random_seqno; 61 61 int res = -ENOMEM; 62 62 ··· 70 70 if (!hard_iface->packet_buff) 71 71 goto out; 72 72 73 - batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff; 74 - batman_ogm_packet->header.packet_type = BAT_IV_OGM; 75 - batman_ogm_packet->header.version = BATADV_COMPAT_VERSION; 76 - batman_ogm_packet->header.ttl = 2; 77 - batman_ogm_packet->flags = BATADV_NO_FLAGS; 78 - batman_ogm_packet->tq = BATADV_TQ_MAX_VALUE; 79 - batman_ogm_packet->tt_num_changes = 0; 80 - batman_ogm_packet->ttvn = 0; 73 + batadv_ogm_packet = (struct batadv_ogm_packet *)hard_iface->packet_buff; 74 + batadv_ogm_packet->header.packet_type = BATADV_IV_OGM; 75 + batadv_ogm_packet->header.version = BATADV_COMPAT_VERSION; 76 + batadv_ogm_packet->header.ttl = 2; 77 + batadv_ogm_packet->flags = BATADV_NO_FLAGS; 78 + batadv_ogm_packet->tq = BATADV_TQ_MAX_VALUE; 79 + batadv_ogm_packet->tt_num_changes = 0; 80 + batadv_ogm_packet->ttvn = 0; 81 81 82 82 res = 0; 83 83 ··· 85 85 return res; 86 86 } 87 87 88 - static void batadv_iv_ogm_iface_disable(struct hard_iface *hard_iface) 88 + static void batadv_iv_ogm_iface_disable(struct batadv_hard_iface *hard_iface) 89 89 { 90 90 kfree(hard_iface->packet_buff); 91 91 hard_iface->packet_buff = NULL; 92 92 } 93 93 94 - static void batadv_iv_ogm_iface_update_mac(struct hard_iface *hard_iface) 94 + static void batadv_iv_ogm_iface_update_mac(struct batadv_hard_iface *hard_iface) 95 95 { 96 - struct batman_ogm_packet *batman_ogm_packet; 96 + struct batadv_ogm_packet *batadv_ogm_packet; 97 97 98 - batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff; 99 - memcpy(batman_ogm_packet->orig, 98 + batadv_ogm_packet = (struct batadv_ogm_packet *)hard_iface->packet_buff; 99 + memcpy(batadv_ogm_packet->orig, 100 100 hard_iface->net_dev->dev_addr, ETH_ALEN); 101 - memcpy(batman_ogm_packet->prev_sender, 101 + memcpy(batadv_ogm_packet->prev_sender, 102 102 hard_iface->net_dev->dev_addr, ETH_ALEN); 103 103 } 104 104 105 - static void batadv_iv_ogm_primary_iface_set(struct hard_iface *hard_iface) 105 + static void 106 + batadv_iv_ogm_primary_iface_set(struct batadv_hard_iface *hard_iface) 106 107 { 107 - struct batman_ogm_packet *batman_ogm_packet; 108 + struct batadv_ogm_packet *batadv_ogm_packet; 108 109 109 - batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff; 110 - batman_ogm_packet->flags = PRIMARIES_FIRST_HOP; 111 - batman_ogm_packet->header.ttl = BATADV_TTL; 110 + batadv_ogm_packet = (struct batadv_ogm_packet *)hard_iface->packet_buff; 111 + batadv_ogm_packet->flags = BATADV_PRIMARIES_FIRST_HOP; 112 + batadv_ogm_packet->header.ttl = BATADV_TTL; 112 113 } 113 114 114 115 /* when do we schedule our own ogm to be sent */ 115 116 static unsigned long 116 - batadv_iv_ogm_emit_send_time(const struct bat_priv *bat_priv) 117 + batadv_iv_ogm_emit_send_time(const struct batadv_priv *bat_priv) 117 118 { 118 119 unsigned int msecs; 119 120 ··· 131 130 } 132 131 133 132 /* apply hop penalty for a normal link */ 134 - static uint8_t batadv_hop_penalty(uint8_t tq, const struct bat_priv *bat_priv) 133 + static uint8_t batadv_hop_penalty(uint8_t tq, 134 + const struct batadv_priv *bat_priv) 135 135 { 136 136 int hop_penalty = atomic_read(&bat_priv->hop_penalty); 137 137 int new_tq; ··· 157 155 } 158 156 159 157 /* send a batman ogm to a given interface */ 160 - static void batadv_iv_ogm_send_to_if(struct forw_packet *forw_packet, 161 - struct hard_iface *hard_iface) 158 + static void batadv_iv_ogm_send_to_if(struct batadv_forw_packet *forw_packet, 159 + struct batadv_hard_iface *hard_iface) 162 160 { 163 - struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 161 + struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 164 162 char *fwd_str; 165 163 uint8_t packet_num; 166 164 int16_t buff_pos; 167 - struct batman_ogm_packet *batman_ogm_packet; 165 + struct batadv_ogm_packet *batadv_ogm_packet; 168 166 struct sk_buff *skb; 169 167 170 - if (hard_iface->if_status != IF_ACTIVE) 168 + if (hard_iface->if_status != BATADV_IF_ACTIVE) 171 169 return; 172 170 173 171 packet_num = 0; 174 172 buff_pos = 0; 175 - batman_ogm_packet = (struct batman_ogm_packet *)forw_packet->skb->data; 173 + batadv_ogm_packet = (struct batadv_ogm_packet *)forw_packet->skb->data; 176 174 177 175 /* adjust all flags and log packets */ 178 176 while (batadv_iv_ogm_aggr_packet(buff_pos, forw_packet->packet_len, 179 - batman_ogm_packet->tt_num_changes)) { 177 + batadv_ogm_packet->tt_num_changes)) { 180 178 181 179 /* we might have aggregated direct link packets with an 182 180 * ordinary base packet 183 181 */ 184 182 if ((forw_packet->direct_link_flags & (1 << packet_num)) && 185 183 (forw_packet->if_incoming == hard_iface)) 186 - batman_ogm_packet->flags |= DIRECTLINK; 184 + batadv_ogm_packet->flags |= BATADV_DIRECTLINK; 187 185 else 188 - batman_ogm_packet->flags &= ~DIRECTLINK; 186 + batadv_ogm_packet->flags &= ~BATADV_DIRECTLINK; 189 187 190 188 fwd_str = (packet_num > 0 ? "Forwarding" : (forw_packet->own ? 191 189 "Sending own" : 192 190 "Forwarding")); 193 - batadv_dbg(DBG_BATMAN, bat_priv, 191 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 194 192 "%s %spacket (originator %pM, seqno %u, TQ %d, TTL %d, IDF %s, ttvn %d) on interface %s [%pM]\n", 195 193 fwd_str, (packet_num > 0 ? "aggregated " : ""), 196 - batman_ogm_packet->orig, 197 - ntohl(batman_ogm_packet->seqno), 198 - batman_ogm_packet->tq, batman_ogm_packet->header.ttl, 199 - (batman_ogm_packet->flags & DIRECTLINK ? 194 + batadv_ogm_packet->orig, 195 + ntohl(batadv_ogm_packet->seqno), 196 + batadv_ogm_packet->tq, batadv_ogm_packet->header.ttl, 197 + (batadv_ogm_packet->flags & BATADV_DIRECTLINK ? 200 198 "on" : "off"), 201 - batman_ogm_packet->ttvn, hard_iface->net_dev->name, 199 + batadv_ogm_packet->ttvn, hard_iface->net_dev->name, 202 200 hard_iface->net_dev->dev_addr); 203 201 204 202 buff_pos += BATADV_OGM_HLEN; 205 - buff_pos += batadv_tt_len(batman_ogm_packet->tt_num_changes); 203 + buff_pos += batadv_tt_len(batadv_ogm_packet->tt_num_changes); 206 204 packet_num++; 207 - batman_ogm_packet = (struct batman_ogm_packet *) 205 + batadv_ogm_packet = (struct batadv_ogm_packet *) 208 206 (forw_packet->skb->data + buff_pos); 209 207 } 210 208 211 209 /* create clone because function is called more than once */ 212 210 skb = skb_clone(forw_packet->skb, GFP_ATOMIC); 213 211 if (skb) { 214 - batadv_inc_counter(bat_priv, BAT_CNT_MGMT_TX); 215 - batadv_add_counter(bat_priv, BAT_CNT_MGMT_TX_BYTES, 212 + batadv_inc_counter(bat_priv, BATADV_CNT_MGMT_TX); 213 + batadv_add_counter(bat_priv, BATADV_CNT_MGMT_TX_BYTES, 216 214 skb->len + ETH_HLEN); 217 215 batadv_send_skb_packet(skb, hard_iface, batadv_broadcast_addr); 218 216 } 219 217 } 220 218 221 219 /* send a batman ogm packet */ 222 - static void batadv_iv_ogm_emit(struct forw_packet *forw_packet) 220 + static void batadv_iv_ogm_emit(struct batadv_forw_packet *forw_packet) 223 221 { 224 - struct hard_iface *hard_iface; 222 + struct batadv_hard_iface *hard_iface; 225 223 struct net_device *soft_iface; 226 - struct bat_priv *bat_priv; 227 - struct hard_iface *primary_if = NULL; 228 - struct batman_ogm_packet *batman_ogm_packet; 224 + struct batadv_priv *bat_priv; 225 + struct batadv_hard_iface *primary_if = NULL; 226 + struct batadv_ogm_packet *batadv_ogm_packet; 229 227 unsigned char directlink; 230 228 231 - batman_ogm_packet = (struct batman_ogm_packet *) 229 + batadv_ogm_packet = (struct batadv_ogm_packet *) 232 230 (forw_packet->skb->data); 233 - directlink = (batman_ogm_packet->flags & DIRECTLINK ? 1 : 0); 231 + directlink = (batadv_ogm_packet->flags & BATADV_DIRECTLINK ? 1 : 0); 234 232 235 233 if (!forw_packet->if_incoming) { 236 234 pr_err("Error - can't forward packet: incoming iface not specified\n"); ··· 240 238 soft_iface = forw_packet->if_incoming->soft_iface; 241 239 bat_priv = netdev_priv(soft_iface); 242 240 243 - if (forw_packet->if_incoming->if_status != IF_ACTIVE) 241 + if (forw_packet->if_incoming->if_status != BATADV_IF_ACTIVE) 244 242 goto out; 245 243 246 244 primary_if = batadv_primary_if_get_selected(bat_priv); ··· 250 248 /* multihomed peer assumed 251 249 * non-primary OGMs are only broadcasted on their interface 252 250 */ 253 - if ((directlink && (batman_ogm_packet->header.ttl == 1)) || 251 + if ((directlink && (batadv_ogm_packet->header.ttl == 1)) || 254 252 (forw_packet->own && (forw_packet->if_incoming != primary_if))) { 255 253 256 254 /* FIXME: what about aggregated packets ? */ 257 - batadv_dbg(DBG_BATMAN, bat_priv, 255 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 258 256 "%s packet (originator %pM, seqno %u, TTL %d) on interface %s [%pM]\n", 259 257 (forw_packet->own ? "Sending own" : "Forwarding"), 260 - batman_ogm_packet->orig, 261 - ntohl(batman_ogm_packet->seqno), 262 - batman_ogm_packet->header.ttl, 258 + batadv_ogm_packet->orig, 259 + ntohl(batadv_ogm_packet->seqno), 260 + batadv_ogm_packet->header.ttl, 263 261 forw_packet->if_incoming->net_dev->name, 264 262 forw_packet->if_incoming->net_dev->dev_addr); 265 263 ··· 289 287 290 288 /* return true if new_packet can be aggregated with forw_packet */ 291 289 static bool 292 - batadv_iv_ogm_can_aggregate(const struct batman_ogm_packet *new_bat_ogm_packet, 293 - struct bat_priv *bat_priv, 290 + batadv_iv_ogm_can_aggregate(const struct batadv_ogm_packet *new_bat_ogm_packet, 291 + struct batadv_priv *bat_priv, 294 292 int packet_len, unsigned long send_time, 295 293 bool directlink, 296 - const struct hard_iface *if_incoming, 297 - const struct forw_packet *forw_packet) 294 + const struct batadv_hard_iface *if_incoming, 295 + const struct batadv_forw_packet *forw_packet) 298 296 { 299 - struct batman_ogm_packet *batman_ogm_packet; 297 + struct batadv_ogm_packet *batadv_ogm_packet; 300 298 int aggregated_bytes = forw_packet->packet_len + packet_len; 301 - struct hard_iface *primary_if = NULL; 299 + struct batadv_hard_iface *primary_if = NULL; 302 300 bool res = false; 303 301 unsigned long aggregation_end_time; 304 302 305 - batman_ogm_packet = (struct batman_ogm_packet *)forw_packet->skb->data; 303 + batadv_ogm_packet = (struct batadv_ogm_packet *)forw_packet->skb->data; 306 304 aggregation_end_time = send_time; 307 305 aggregation_end_time += msecs_to_jiffies(BATADV_MAX_AGGREGATION_MS); 308 306 ··· 332 330 * are flooded through the net 333 331 */ 334 332 if ((!directlink) && 335 - (!(batman_ogm_packet->flags & DIRECTLINK)) && 336 - (batman_ogm_packet->header.ttl != 1) && 333 + (!(batadv_ogm_packet->flags & BATADV_DIRECTLINK)) && 334 + (batadv_ogm_packet->header.ttl != 1) && 337 335 338 336 /* own packets originating non-primary 339 337 * interfaces leave only that interface ··· 355 353 * own secondary interface packets 356 354 * (= secondary interface packets in general) 357 355 */ 358 - (batman_ogm_packet->flags & DIRECTLINK || 356 + (batadv_ogm_packet->flags & BATADV_DIRECTLINK || 359 357 (forw_packet->own && 360 358 forw_packet->if_incoming != primary_if))) { 361 359 res = true; ··· 373 371 static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff, 374 372 int packet_len, unsigned long send_time, 375 373 bool direct_link, 376 - struct hard_iface *if_incoming, 374 + struct batadv_hard_iface *if_incoming, 377 375 int own_packet) 378 376 { 379 - struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 380 - struct forw_packet *forw_packet_aggr; 377 + struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 378 + struct batadv_forw_packet *forw_packet_aggr; 381 379 unsigned char *skb_buff; 382 380 unsigned int skb_size; 383 381 ··· 387 385 /* own packet should always be scheduled */ 388 386 if (!own_packet) { 389 387 if (!batadv_atomic_dec_not_zero(&bat_priv->batman_queue_left)) { 390 - batadv_dbg(DBG_BATMAN, bat_priv, 388 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 391 389 "batman packet queue full\n"); 392 390 goto out; 393 391 } ··· 449 447 } 450 448 451 449 /* aggregate a new packet into the existing ogm packet */ 452 - static void batadv_iv_ogm_aggregate(struct forw_packet *forw_packet_aggr, 450 + static void batadv_iv_ogm_aggregate(struct batadv_forw_packet *forw_packet_aggr, 453 451 const unsigned char *packet_buff, 454 452 int packet_len, bool direct_link) 455 453 { ··· 466 464 (1 << forw_packet_aggr->num_packets); 467 465 } 468 466 469 - static void batadv_iv_ogm_queue_add(struct bat_priv *bat_priv, 467 + static void batadv_iv_ogm_queue_add(struct batadv_priv *bat_priv, 470 468 unsigned char *packet_buff, 471 469 int packet_len, 472 - struct hard_iface *if_incoming, 470 + struct batadv_hard_iface *if_incoming, 473 471 int own_packet, unsigned long send_time) 474 472 { 475 473 /* _aggr -> pointer to the packet we want to aggregate with 476 474 * _pos -> pointer to the position in the queue 477 475 */ 478 - struct forw_packet *forw_packet_aggr = NULL, *forw_packet_pos = NULL; 476 + struct batadv_forw_packet *forw_packet_aggr = NULL; 477 + struct batadv_forw_packet *forw_packet_pos = NULL; 479 478 struct hlist_node *tmp_node; 480 - struct batman_ogm_packet *batman_ogm_packet; 479 + struct batadv_ogm_packet *batadv_ogm_packet; 481 480 bool direct_link; 482 481 unsigned long max_aggregation_jiffies; 483 482 484 - batman_ogm_packet = (struct batman_ogm_packet *)packet_buff; 485 - direct_link = batman_ogm_packet->flags & DIRECTLINK ? 1 : 0; 483 + batadv_ogm_packet = (struct batadv_ogm_packet *)packet_buff; 484 + direct_link = batadv_ogm_packet->flags & BATADV_DIRECTLINK ? 1 : 0; 486 485 max_aggregation_jiffies = msecs_to_jiffies(BATADV_MAX_AGGREGATION_MS); 487 486 488 487 /* find position for the packet in the forward queue */ ··· 492 489 if ((atomic_read(&bat_priv->aggregated_ogms)) && (!own_packet)) { 493 490 hlist_for_each_entry(forw_packet_pos, tmp_node, 494 491 &bat_priv->forw_bat_list, list) { 495 - if (batadv_iv_ogm_can_aggregate(batman_ogm_packet, 492 + if (batadv_iv_ogm_can_aggregate(batadv_ogm_packet, 496 493 bat_priv, packet_len, 497 494 send_time, direct_link, 498 495 if_incoming, ··· 527 524 } 528 525 } 529 526 530 - static void batadv_iv_ogm_forward(struct orig_node *orig_node, 527 + static void batadv_iv_ogm_forward(struct batadv_orig_node *orig_node, 531 528 const struct ethhdr *ethhdr, 532 - struct batman_ogm_packet *batman_ogm_packet, 529 + struct batadv_ogm_packet *batadv_ogm_packet, 533 530 bool is_single_hop_neigh, 534 531 bool is_from_best_next_hop, 535 - struct hard_iface *if_incoming) 532 + struct batadv_hard_iface *if_incoming) 536 533 { 537 - struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 534 + struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 538 535 uint8_t tt_num_changes; 539 536 540 - if (batman_ogm_packet->header.ttl <= 1) { 541 - batadv_dbg(DBG_BATMAN, bat_priv, "ttl exceeded\n"); 537 + if (batadv_ogm_packet->header.ttl <= 1) { 538 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "ttl exceeded\n"); 542 539 return; 543 540 } 544 541 ··· 550 547 * simply drop the ogm. 551 548 */ 552 549 if (is_single_hop_neigh) 553 - batman_ogm_packet->flags |= NOT_BEST_NEXT_HOP; 550 + batadv_ogm_packet->flags |= BATADV_NOT_BEST_NEXT_HOP; 554 551 else 555 552 return; 556 553 } 557 554 558 - tt_num_changes = batman_ogm_packet->tt_num_changes; 555 + tt_num_changes = batadv_ogm_packet->tt_num_changes; 559 556 560 - batman_ogm_packet->header.ttl--; 561 - memcpy(batman_ogm_packet->prev_sender, ethhdr->h_source, ETH_ALEN); 557 + batadv_ogm_packet->header.ttl--; 558 + memcpy(batadv_ogm_packet->prev_sender, ethhdr->h_source, ETH_ALEN); 562 559 563 560 /* apply hop penalty */ 564 - batman_ogm_packet->tq = batadv_hop_penalty(batman_ogm_packet->tq, 561 + batadv_ogm_packet->tq = batadv_hop_penalty(batadv_ogm_packet->tq, 565 562 bat_priv); 566 563 567 - batadv_dbg(DBG_BATMAN, bat_priv, 564 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 568 565 "Forwarding packet: tq: %i, ttl: %i\n", 569 - batman_ogm_packet->tq, batman_ogm_packet->header.ttl); 566 + batadv_ogm_packet->tq, batadv_ogm_packet->header.ttl); 570 567 571 568 /* switch of primaries first hop flag when forwarding */ 572 - batman_ogm_packet->flags &= ~PRIMARIES_FIRST_HOP; 569 + batadv_ogm_packet->flags &= ~BATADV_PRIMARIES_FIRST_HOP; 573 570 if (is_single_hop_neigh) 574 - batman_ogm_packet->flags |= DIRECTLINK; 571 + batadv_ogm_packet->flags |= BATADV_DIRECTLINK; 575 572 else 576 - batman_ogm_packet->flags &= ~DIRECTLINK; 573 + batadv_ogm_packet->flags &= ~BATADV_DIRECTLINK; 577 574 578 - batadv_iv_ogm_queue_add(bat_priv, (unsigned char *)batman_ogm_packet, 575 + batadv_iv_ogm_queue_add(bat_priv, (unsigned char *)batadv_ogm_packet, 579 576 BATADV_OGM_HLEN + batadv_tt_len(tt_num_changes), 580 577 if_incoming, 0, batadv_iv_ogm_fwd_send_time()); 581 578 } 582 579 583 - static void batadv_iv_ogm_schedule(struct hard_iface *hard_iface) 580 + static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface) 584 581 { 585 - struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 586 - struct batman_ogm_packet *batman_ogm_packet; 587 - struct hard_iface *primary_if; 582 + struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 583 + struct batadv_ogm_packet *batadv_ogm_packet; 584 + struct batadv_hard_iface *primary_if; 588 585 int vis_server, tt_num_changes = 0; 589 586 590 587 vis_server = atomic_read(&bat_priv->vis_mode); ··· 596 593 &hard_iface->packet_len, 597 594 BATADV_OGM_HLEN); 598 595 599 - batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff; 596 + batadv_ogm_packet = (struct batadv_ogm_packet *)hard_iface->packet_buff; 600 597 601 598 /* change sequence number to network order */ 602 - batman_ogm_packet->seqno = 599 + batadv_ogm_packet->seqno = 603 600 htonl((uint32_t)atomic_read(&hard_iface->seqno)); 604 601 atomic_inc(&hard_iface->seqno); 605 602 606 - batman_ogm_packet->ttvn = atomic_read(&bat_priv->ttvn); 607 - batman_ogm_packet->tt_crc = htons(bat_priv->tt_crc); 603 + batadv_ogm_packet->ttvn = atomic_read(&bat_priv->ttvn); 604 + batadv_ogm_packet->tt_crc = htons(bat_priv->tt_crc); 608 605 if (tt_num_changes >= 0) 609 - batman_ogm_packet->tt_num_changes = tt_num_changes; 606 + batadv_ogm_packet->tt_num_changes = tt_num_changes; 610 607 611 - if (vis_server == VIS_TYPE_SERVER_SYNC) 612 - batman_ogm_packet->flags |= VIS_SERVER; 608 + if (vis_server == BATADV_VIS_TYPE_SERVER_SYNC) 609 + batadv_ogm_packet->flags |= BATADV_VIS_SERVER; 613 610 else 614 - batman_ogm_packet->flags &= ~VIS_SERVER; 611 + batadv_ogm_packet->flags &= ~BATADV_VIS_SERVER; 615 612 616 613 if ((hard_iface == primary_if) && 617 - (atomic_read(&bat_priv->gw_mode) == GW_MODE_SERVER)) 618 - batman_ogm_packet->gw_flags = 614 + (atomic_read(&bat_priv->gw_mode) == BATADV_GW_MODE_SERVER)) 615 + batadv_ogm_packet->gw_flags = 619 616 (uint8_t)atomic_read(&bat_priv->gw_bandwidth); 620 617 else 621 - batman_ogm_packet->gw_flags = BATADV_NO_FLAGS; 618 + batadv_ogm_packet->gw_flags = BATADV_NO_FLAGS; 622 619 623 620 batadv_slide_own_bcast_window(hard_iface); 624 621 batadv_iv_ogm_queue_add(bat_priv, hard_iface->packet_buff, ··· 630 627 } 631 628 632 629 static void 633 - batadv_iv_ogm_orig_update(struct bat_priv *bat_priv, 634 - struct orig_node *orig_node, 630 + batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv, 631 + struct batadv_orig_node *orig_node, 635 632 const struct ethhdr *ethhdr, 636 - const struct batman_ogm_packet *batman_ogm_packet, 637 - struct hard_iface *if_incoming, 633 + const struct batadv_ogm_packet *batadv_ogm_packet, 634 + struct batadv_hard_iface *if_incoming, 638 635 const unsigned char *tt_buff, 639 636 int is_duplicate) 640 637 { 641 - struct neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL; 642 - struct neigh_node *router = NULL; 643 - struct orig_node *orig_node_tmp; 638 + struct batadv_neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL; 639 + struct batadv_neigh_node *router = NULL; 640 + struct batadv_orig_node *orig_node_tmp; 644 641 struct hlist_node *node; 645 642 uint8_t bcast_own_sum_orig, bcast_own_sum_neigh; 646 643 uint8_t *neigh_addr; 647 644 648 - batadv_dbg(DBG_BATMAN, bat_priv, 645 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 649 646 "update_originator(): Searching and updating originator entry of received packet\n"); 650 647 651 648 rcu_read_lock(); ··· 673 670 } 674 671 675 672 if (!neigh_node) { 676 - struct orig_node *orig_tmp; 673 + struct batadv_orig_node *orig_tmp; 677 674 678 675 orig_tmp = batadv_get_orig_node(bat_priv, ethhdr->h_source); 679 676 if (!orig_tmp) ··· 682 679 neigh_node = batadv_iv_ogm_neigh_new(if_incoming, 683 680 ethhdr->h_source, 684 681 orig_node, orig_tmp, 685 - batman_ogm_packet->seqno); 682 + batadv_ogm_packet->seqno); 686 683 687 684 batadv_orig_node_free_ref(orig_tmp); 688 685 if (!neigh_node) 689 686 goto unlock; 690 687 } else 691 - batadv_dbg(DBG_BATMAN, bat_priv, 688 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 692 689 "Updating existing last-hop neighbor of originator\n"); 693 690 694 691 rcu_read_unlock(); 695 692 696 - orig_node->flags = batman_ogm_packet->flags; 693 + orig_node->flags = batadv_ogm_packet->flags; 697 694 neigh_node->last_seen = jiffies; 698 695 699 696 spin_lock_bh(&neigh_node->lq_update_lock); 700 697 batadv_ring_buffer_set(neigh_node->tq_recv, 701 698 &neigh_node->tq_index, 702 - batman_ogm_packet->tq); 699 + batadv_ogm_packet->tq); 703 700 neigh_node->tq_avg = batadv_ring_buffer_avg(neigh_node->tq_recv); 704 701 spin_unlock_bh(&neigh_node->lq_update_lock); 705 702 706 703 if (!is_duplicate) { 707 - orig_node->last_ttl = batman_ogm_packet->header.ttl; 708 - neigh_node->last_ttl = batman_ogm_packet->header.ttl; 704 + orig_node->last_ttl = batadv_ogm_packet->header.ttl; 705 + neigh_node->last_ttl = batadv_ogm_packet->header.ttl; 709 706 } 710 707 711 708 batadv_bonding_candidate_add(orig_node, neigh_node); ··· 747 744 /* I have to check for transtable changes only if the OGM has been 748 745 * sent through a primary interface 749 746 */ 750 - if (((batman_ogm_packet->orig != ethhdr->h_source) && 751 - (batman_ogm_packet->header.ttl > 2)) || 752 - (batman_ogm_packet->flags & PRIMARIES_FIRST_HOP)) 747 + if (((batadv_ogm_packet->orig != ethhdr->h_source) && 748 + (batadv_ogm_packet->header.ttl > 2)) || 749 + (batadv_ogm_packet->flags & BATADV_PRIMARIES_FIRST_HOP)) 753 750 batadv_tt_update_orig(bat_priv, orig_node, tt_buff, 754 - batman_ogm_packet->tt_num_changes, 755 - batman_ogm_packet->ttvn, 756 - ntohs(batman_ogm_packet->tt_crc)); 751 + batadv_ogm_packet->tt_num_changes, 752 + batadv_ogm_packet->ttvn, 753 + ntohs(batadv_ogm_packet->tt_crc)); 757 754 758 - if (orig_node->gw_flags != batman_ogm_packet->gw_flags) 755 + if (orig_node->gw_flags != batadv_ogm_packet->gw_flags) 759 756 batadv_gw_node_update(bat_priv, orig_node, 760 - batman_ogm_packet->gw_flags); 757 + batadv_ogm_packet->gw_flags); 761 758 762 - orig_node->gw_flags = batman_ogm_packet->gw_flags; 759 + orig_node->gw_flags = batadv_ogm_packet->gw_flags; 763 760 764 761 /* restart gateway selection if fast or late switching was enabled */ 765 762 if ((orig_node->gw_flags) && 766 - (atomic_read(&bat_priv->gw_mode) == GW_MODE_CLIENT) && 763 + (atomic_read(&bat_priv->gw_mode) == BATADV_GW_MODE_CLIENT) && 767 764 (atomic_read(&bat_priv->gw_sel_class) > 2)) 768 765 batadv_gw_check_election(bat_priv, orig_node); 769 766 ··· 778 775 batadv_neigh_node_free_ref(router); 779 776 } 780 777 781 - static int batadv_iv_ogm_calc_tq(struct orig_node *orig_node, 782 - struct orig_node *orig_neigh_node, 783 - struct batman_ogm_packet *batman_ogm_packet, 784 - struct hard_iface *if_incoming) 778 + static int batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node, 779 + struct batadv_orig_node *orig_neigh_node, 780 + struct batadv_ogm_packet *batadv_ogm_packet, 781 + struct batadv_hard_iface *if_incoming) 785 782 { 786 - struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 787 - struct neigh_node *neigh_node = NULL, *tmp_neigh_node; 783 + struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 784 + struct batadv_neigh_node *neigh_node = NULL, *tmp_neigh_node; 788 785 struct hlist_node *node; 789 786 uint8_t total_count; 790 787 uint8_t orig_eq_count, neigh_rq_count, neigh_rq_inv, tq_own; ··· 817 814 orig_neigh_node->orig, 818 815 orig_neigh_node, 819 816 orig_neigh_node, 820 - batman_ogm_packet->seqno); 817 + batadv_ogm_packet->seqno); 821 818 822 819 if (!neigh_node) 823 820 goto out; ··· 865 862 inv_asym_penalty /= neigh_rq_max_cube; 866 863 tq_asym_penalty = BATADV_TQ_MAX_VALUE - inv_asym_penalty; 867 864 868 - combined_tq = batman_ogm_packet->tq * tq_own * tq_asym_penalty; 865 + combined_tq = batadv_ogm_packet->tq * tq_own * tq_asym_penalty; 869 866 combined_tq /= BATADV_TQ_MAX_VALUE * BATADV_TQ_MAX_VALUE; 870 - batman_ogm_packet->tq = combined_tq; 867 + batadv_ogm_packet->tq = combined_tq; 871 868 872 - batadv_dbg(DBG_BATMAN, bat_priv, 869 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 873 870 "bidirectional: orig = %-15pM neigh = %-15pM => own_bcast = %2i, real recv = %2i, local tq: %3i, asym_penalty: %3i, total tq: %3i\n", 874 871 orig_node->orig, orig_neigh_node->orig, total_count, 875 872 neigh_rq_count, tq_own, 876 - tq_asym_penalty, batman_ogm_packet->tq); 873 + tq_asym_penalty, batadv_ogm_packet->tq); 877 874 878 875 /* if link has the minimum required transmission quality 879 876 * consider it bidirectional 880 877 */ 881 - if (batman_ogm_packet->tq >= BATADV_TQ_TOTAL_BIDRECT_LIMIT) 878 + if (batadv_ogm_packet->tq >= BATADV_TQ_TOTAL_BIDRECT_LIMIT) 882 879 ret = 1; 883 880 884 881 out: ··· 897 894 */ 898 895 static int 899 896 batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr, 900 - const struct batman_ogm_packet *batman_ogm_packet, 901 - const struct hard_iface *if_incoming) 897 + const struct batadv_ogm_packet *batadv_ogm_packet, 898 + const struct batadv_hard_iface *if_incoming) 902 899 { 903 - struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 904 - struct orig_node *orig_node; 905 - struct neigh_node *tmp_neigh_node; 900 + struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 901 + struct batadv_orig_node *orig_node; 902 + struct batadv_neigh_node *tmp_neigh_node; 906 903 struct hlist_node *node; 907 904 int is_duplicate = 0; 908 905 int32_t seq_diff; 909 906 int need_update = 0; 910 907 int set_mark, ret = -1; 911 - uint32_t seqno = ntohl(batman_ogm_packet->seqno); 908 + uint32_t seqno = ntohl(batadv_ogm_packet->seqno); 912 909 uint8_t *neigh_addr; 913 910 914 - orig_node = batadv_get_orig_node(bat_priv, batman_ogm_packet->orig); 911 + orig_node = batadv_get_orig_node(bat_priv, batadv_ogm_packet->orig); 915 912 if (!orig_node) 916 913 return 0; 917 914 ··· 951 948 rcu_read_unlock(); 952 949 953 950 if (need_update) { 954 - batadv_dbg(DBG_BATMAN, bat_priv, 951 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 955 952 "updating last_seqno: old %u, new %u\n", 956 953 orig_node->last_real_seqno, seqno); 957 954 orig_node->last_real_seqno = seqno; ··· 966 963 } 967 964 968 965 static void batadv_iv_ogm_process(const struct ethhdr *ethhdr, 969 - struct batman_ogm_packet *batman_ogm_packet, 966 + struct batadv_ogm_packet *batadv_ogm_packet, 970 967 const unsigned char *tt_buff, 971 - struct hard_iface *if_incoming) 968 + struct batadv_hard_iface *if_incoming) 972 969 { 973 - struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 974 - struct hard_iface *hard_iface; 975 - struct orig_node *orig_neigh_node, *orig_node; 976 - struct neigh_node *router = NULL, *router_router = NULL; 977 - struct neigh_node *orig_neigh_router = NULL; 970 + struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 971 + struct batadv_hard_iface *hard_iface; 972 + struct batadv_orig_node *orig_neigh_node, *orig_node; 973 + struct batadv_neigh_node *router = NULL, *router_router = NULL; 974 + struct batadv_neigh_node *orig_neigh_router = NULL; 978 975 int has_directlink_flag; 979 976 int is_my_addr = 0, is_my_orig = 0, is_my_oldorig = 0; 980 977 int is_broadcast = 0, is_bidirect; ··· 992 989 * it as an additional length. 993 990 * 994 991 * TODO: A more sane solution would be to have a bit in the 995 - * batman_ogm_packet to detect whether the packet is the last 992 + * batadv_ogm_packet to detect whether the packet is the last 996 993 * packet in an aggregation. Here we expect that the padding 997 994 * is always zero (or not 0x01) 998 995 */ 999 - if (batman_ogm_packet->header.packet_type != BAT_IV_OGM) 996 + if (batadv_ogm_packet->header.packet_type != BATADV_IV_OGM) 1000 997 return; 1001 998 1002 999 /* could be changed by schedule_own_packet() */ 1003 1000 if_incoming_seqno = atomic_read(&if_incoming->seqno); 1004 1001 1005 - has_directlink_flag = (batman_ogm_packet->flags & DIRECTLINK ? 1 : 0); 1002 + if (batadv_ogm_packet->flags & BATADV_DIRECTLINK) 1003 + has_directlink_flag = 1; 1004 + else 1005 + has_directlink_flag = 0; 1006 1006 1007 - if (batadv_compare_eth(ethhdr->h_source, batman_ogm_packet->orig)) 1007 + if (batadv_compare_eth(ethhdr->h_source, batadv_ogm_packet->orig)) 1008 1008 is_single_hop_neigh = true; 1009 1009 1010 - batadv_dbg(DBG_BATMAN, bat_priv, 1010 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 1011 1011 "Received BATMAN packet via NB: %pM, IF: %s [%pM] (from OG: %pM, via prev OG: %pM, seqno %u, ttvn %u, crc %u, changes %u, td %d, TTL %d, V %d, IDF %d)\n", 1012 1012 ethhdr->h_source, if_incoming->net_dev->name, 1013 - if_incoming->net_dev->dev_addr, batman_ogm_packet->orig, 1014 - batman_ogm_packet->prev_sender, 1015 - ntohl(batman_ogm_packet->seqno), batman_ogm_packet->ttvn, 1016 - ntohs(batman_ogm_packet->tt_crc), 1017 - batman_ogm_packet->tt_num_changes, batman_ogm_packet->tq, 1018 - batman_ogm_packet->header.ttl, 1019 - batman_ogm_packet->header.version, has_directlink_flag); 1013 + if_incoming->net_dev->dev_addr, batadv_ogm_packet->orig, 1014 + batadv_ogm_packet->prev_sender, 1015 + ntohl(batadv_ogm_packet->seqno), batadv_ogm_packet->ttvn, 1016 + ntohs(batadv_ogm_packet->tt_crc), 1017 + batadv_ogm_packet->tt_num_changes, batadv_ogm_packet->tq, 1018 + batadv_ogm_packet->header.ttl, 1019 + batadv_ogm_packet->header.version, has_directlink_flag); 1020 1020 1021 1021 rcu_read_lock(); 1022 1022 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { 1023 - if (hard_iface->if_status != IF_ACTIVE) 1023 + if (hard_iface->if_status != BATADV_IF_ACTIVE) 1024 1024 continue; 1025 1025 1026 1026 if (hard_iface->soft_iface != if_incoming->soft_iface) ··· 1033 1027 hard_iface->net_dev->dev_addr)) 1034 1028 is_my_addr = 1; 1035 1029 1036 - if (batadv_compare_eth(batman_ogm_packet->orig, 1030 + if (batadv_compare_eth(batadv_ogm_packet->orig, 1037 1031 hard_iface->net_dev->dev_addr)) 1038 1032 is_my_orig = 1; 1039 1033 1040 - if (batadv_compare_eth(batman_ogm_packet->prev_sender, 1034 + if (batadv_compare_eth(batadv_ogm_packet->prev_sender, 1041 1035 hard_iface->net_dev->dev_addr)) 1042 1036 is_my_oldorig = 1; 1043 1037 ··· 1046 1040 } 1047 1041 rcu_read_unlock(); 1048 1042 1049 - if (batman_ogm_packet->header.version != BATADV_COMPAT_VERSION) { 1050 - batadv_dbg(DBG_BATMAN, bat_priv, 1043 + if (batadv_ogm_packet->header.version != BATADV_COMPAT_VERSION) { 1044 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 1051 1045 "Drop packet: incompatible batman version (%i)\n", 1052 - batman_ogm_packet->header.version); 1046 + batadv_ogm_packet->header.version); 1053 1047 return; 1054 1048 } 1055 1049 1056 1050 if (is_my_addr) { 1057 - batadv_dbg(DBG_BATMAN, bat_priv, 1051 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 1058 1052 "Drop packet: received my own broadcast (sender: %pM)\n", 1059 1053 ethhdr->h_source); 1060 1054 return; 1061 1055 } 1062 1056 1063 1057 if (is_broadcast) { 1064 - batadv_dbg(DBG_BATMAN, bat_priv, 1058 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 1065 1059 "Drop packet: ignoring all packets with broadcast source addr (sender: %pM)\n", 1066 1060 ethhdr->h_source); 1067 1061 return; ··· 1085 1079 */ 1086 1080 if (has_directlink_flag && 1087 1081 batadv_compare_eth(if_incoming->net_dev->dev_addr, 1088 - batman_ogm_packet->orig)) { 1082 + batadv_ogm_packet->orig)) { 1089 1083 if_num = if_incoming->if_num; 1090 1084 offset = if_num * BATADV_NUM_WORDS; 1091 1085 1092 1086 spin_lock_bh(&orig_neigh_node->ogm_cnt_lock); 1093 1087 word = &(orig_neigh_node->bcast_own[offset]); 1094 1088 bit_pos = if_incoming_seqno - 2; 1095 - bit_pos -= ntohl(batman_ogm_packet->seqno); 1089 + bit_pos -= ntohl(batadv_ogm_packet->seqno); 1096 1090 batadv_set_bit(word, bit_pos); 1097 1091 weight = &orig_neigh_node->bcast_own_sum[if_num]; 1098 1092 *weight = bitmap_weight(word, ··· 1100 1094 spin_unlock_bh(&orig_neigh_node->ogm_cnt_lock); 1101 1095 } 1102 1096 1103 - batadv_dbg(DBG_BATMAN, bat_priv, 1097 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 1104 1098 "Drop packet: originator packet from myself (via neighbor)\n"); 1105 1099 batadv_orig_node_free_ref(orig_neigh_node); 1106 1100 return; 1107 1101 } 1108 1102 1109 1103 if (is_my_oldorig) { 1110 - batadv_dbg(DBG_BATMAN, bat_priv, 1104 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 1111 1105 "Drop packet: ignoring all rebroadcast echos (sender: %pM)\n", 1112 1106 ethhdr->h_source); 1113 1107 return; 1114 1108 } 1115 1109 1116 - if (batman_ogm_packet->flags & NOT_BEST_NEXT_HOP) { 1117 - batadv_dbg(DBG_BATMAN, bat_priv, 1110 + if (batadv_ogm_packet->flags & BATADV_NOT_BEST_NEXT_HOP) { 1111 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 1118 1112 "Drop packet: ignoring all packets not forwarded from the best next hop (sender: %pM)\n", 1119 1113 ethhdr->h_source); 1120 1114 return; 1121 1115 } 1122 1116 1123 - orig_node = batadv_get_orig_node(bat_priv, batman_ogm_packet->orig); 1117 + orig_node = batadv_get_orig_node(bat_priv, batadv_ogm_packet->orig); 1124 1118 if (!orig_node) 1125 1119 return; 1126 1120 1127 - is_duplicate = batadv_iv_ogm_update_seqnos(ethhdr, batman_ogm_packet, 1121 + is_duplicate = batadv_iv_ogm_update_seqnos(ethhdr, batadv_ogm_packet, 1128 1122 if_incoming); 1129 1123 1130 1124 if (is_duplicate == -1) { 1131 - batadv_dbg(DBG_BATMAN, bat_priv, 1125 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 1132 1126 "Drop packet: packet within seqno protection time (sender: %pM)\n", 1133 1127 ethhdr->h_source); 1134 1128 goto out; 1135 1129 } 1136 1130 1137 - if (batman_ogm_packet->tq == 0) { 1138 - batadv_dbg(DBG_BATMAN, bat_priv, 1131 + if (batadv_ogm_packet->tq == 0) { 1132 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 1139 1133 "Drop packet: originator packet with tq equal 0\n"); 1140 1134 goto out; 1141 1135 } ··· 1148 1142 (batadv_compare_eth(router->addr, ethhdr->h_source))) 1149 1143 is_from_best_next_hop = true; 1150 1144 1151 - prev_sender = batman_ogm_packet->prev_sender; 1145 + prev_sender = batadv_ogm_packet->prev_sender; 1152 1146 /* avoid temporary routing loops */ 1153 1147 if (router && router_router && 1154 1148 (batadv_compare_eth(router->addr, prev_sender)) && 1155 - !(batadv_compare_eth(batman_ogm_packet->orig, prev_sender)) && 1149 + !(batadv_compare_eth(batadv_ogm_packet->orig, prev_sender)) && 1156 1150 (batadv_compare_eth(router->addr, router_router->addr))) { 1157 - batadv_dbg(DBG_BATMAN, bat_priv, 1151 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 1158 1152 "Drop packet: ignoring all rebroadcast packets that may make me loop (sender: %pM)\n", 1159 1153 ethhdr->h_source); 1160 1154 goto out; ··· 1175 1169 * don't route towards it 1176 1170 */ 1177 1171 if (!is_single_hop_neigh && (!orig_neigh_router)) { 1178 - batadv_dbg(DBG_BATMAN, bat_priv, 1172 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 1179 1173 "Drop packet: OGM via unknown neighbor!\n"); 1180 1174 goto out_neigh; 1181 1175 } 1182 1176 1183 1177 is_bidirect = batadv_iv_ogm_calc_tq(orig_node, orig_neigh_node, 1184 - batman_ogm_packet, if_incoming); 1178 + batadv_ogm_packet, if_incoming); 1185 1179 1186 1180 batadv_bonding_save_primary(orig_node, orig_neigh_node, 1187 - batman_ogm_packet); 1181 + batadv_ogm_packet); 1188 1182 1189 1183 /* update ranking if it is not a duplicate or has the same 1190 1184 * seqno and similar ttl as the non-duplicate 1191 1185 */ 1192 - sameseq = orig_node->last_real_seqno == ntohl(batman_ogm_packet->seqno); 1193 - simlar_ttl = orig_node->last_ttl - 3 <= batman_ogm_packet->header.ttl; 1186 + sameseq = orig_node->last_real_seqno == ntohl(batadv_ogm_packet->seqno); 1187 + simlar_ttl = orig_node->last_ttl - 3 <= batadv_ogm_packet->header.ttl; 1194 1188 if (is_bidirect && (!is_duplicate || (sameseq && simlar_ttl))) 1195 1189 batadv_iv_ogm_orig_update(bat_priv, orig_node, ethhdr, 1196 - batman_ogm_packet, if_incoming, 1190 + batadv_ogm_packet, if_incoming, 1197 1191 tt_buff, is_duplicate); 1198 1192 1199 1193 /* is single hop (direct) neighbor */ 1200 1194 if (is_single_hop_neigh) { 1201 1195 1202 1196 /* mark direct link on incoming interface */ 1203 - batadv_iv_ogm_forward(orig_node, ethhdr, batman_ogm_packet, 1197 + batadv_iv_ogm_forward(orig_node, ethhdr, batadv_ogm_packet, 1204 1198 is_single_hop_neigh, 1205 1199 is_from_best_next_hop, if_incoming); 1206 1200 1207 - batadv_dbg(DBG_BATMAN, bat_priv, 1201 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 1208 1202 "Forwarding packet: rebroadcast neighbor packet with direct link flag\n"); 1209 1203 goto out_neigh; 1210 1204 } 1211 1205 1212 1206 /* multihop originator */ 1213 1207 if (!is_bidirect) { 1214 - batadv_dbg(DBG_BATMAN, bat_priv, 1208 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 1215 1209 "Drop packet: not received via bidirectional link\n"); 1216 1210 goto out_neigh; 1217 1211 } 1218 1212 1219 1213 if (is_duplicate) { 1220 - batadv_dbg(DBG_BATMAN, bat_priv, 1214 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 1221 1215 "Drop packet: duplicate packet received\n"); 1222 1216 goto out_neigh; 1223 1217 } 1224 1218 1225 - batadv_dbg(DBG_BATMAN, bat_priv, 1219 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 1226 1220 "Forwarding packet: rebroadcast originator packet\n"); 1227 - batadv_iv_ogm_forward(orig_node, ethhdr, batman_ogm_packet, 1221 + batadv_iv_ogm_forward(orig_node, ethhdr, batadv_ogm_packet, 1228 1222 is_single_hop_neigh, is_from_best_next_hop, 1229 1223 if_incoming); 1230 1224 ··· 1243 1237 } 1244 1238 1245 1239 static int batadv_iv_ogm_receive(struct sk_buff *skb, 1246 - struct hard_iface *if_incoming) 1240 + struct batadv_hard_iface *if_incoming) 1247 1241 { 1248 - struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 1249 - struct batman_ogm_packet *batman_ogm_packet; 1242 + struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 1243 + struct batadv_ogm_packet *batadv_ogm_packet; 1250 1244 struct ethhdr *ethhdr; 1251 1245 int buff_pos = 0, packet_len; 1252 1246 unsigned char *tt_buff, *packet_buff; ··· 1262 1256 if (bat_priv->bat_algo_ops->bat_ogm_emit != batadv_iv_ogm_emit) 1263 1257 return NET_RX_DROP; 1264 1258 1265 - batadv_inc_counter(bat_priv, BAT_CNT_MGMT_RX); 1266 - batadv_add_counter(bat_priv, BAT_CNT_MGMT_RX_BYTES, 1259 + batadv_inc_counter(bat_priv, BATADV_CNT_MGMT_RX); 1260 + batadv_add_counter(bat_priv, BATADV_CNT_MGMT_RX_BYTES, 1267 1261 skb->len + ETH_HLEN); 1268 1262 1269 1263 packet_len = skb_headlen(skb); 1270 1264 ethhdr = (struct ethhdr *)skb_mac_header(skb); 1271 1265 packet_buff = skb->data; 1272 - batman_ogm_packet = (struct batman_ogm_packet *)packet_buff; 1266 + batadv_ogm_packet = (struct batadv_ogm_packet *)packet_buff; 1273 1267 1274 1268 /* unpack the aggregated packets and process them one by one */ 1275 1269 do { 1276 1270 tt_buff = packet_buff + buff_pos + BATADV_OGM_HLEN; 1277 1271 1278 - batadv_iv_ogm_process(ethhdr, batman_ogm_packet, tt_buff, 1272 + batadv_iv_ogm_process(ethhdr, batadv_ogm_packet, tt_buff, 1279 1273 if_incoming); 1280 1274 1281 1275 buff_pos += BATADV_OGM_HLEN; 1282 - buff_pos += batadv_tt_len(batman_ogm_packet->tt_num_changes); 1276 + buff_pos += batadv_tt_len(batadv_ogm_packet->tt_num_changes); 1283 1277 1284 - batman_ogm_packet = (struct batman_ogm_packet *) 1278 + batadv_ogm_packet = (struct batadv_ogm_packet *) 1285 1279 (packet_buff + buff_pos); 1286 1280 } while (batadv_iv_ogm_aggr_packet(buff_pos, packet_len, 1287 - batman_ogm_packet->tt_num_changes)); 1281 + batadv_ogm_packet->tt_num_changes)); 1288 1282 1289 1283 kfree_skb(skb); 1290 1284 return NET_RX_SUCCESS; 1291 1285 } 1292 1286 1293 - static struct bat_algo_ops batadv_batman_iv __read_mostly = { 1287 + static struct batadv_algo_ops batadv_batman_iv __read_mostly = { 1294 1288 .name = "BATMAN_IV", 1295 1289 .bat_iface_enable = batadv_iv_ogm_iface_enable, 1296 1290 .bat_iface_disable = batadv_iv_ogm_iface_disable, ··· 1305 1299 int ret; 1306 1300 1307 1301 /* batman originator packet */ 1308 - ret = batadv_recv_handler_register(BAT_IV_OGM, batadv_iv_ogm_receive); 1302 + ret = batadv_recv_handler_register(BATADV_IV_OGM, 1303 + batadv_iv_ogm_receive); 1309 1304 if (ret < 0) 1310 1305 goto out; 1311 1306 ··· 1317 1310 goto out; 1318 1311 1319 1312 handler_unregister: 1320 - batadv_recv_handler_unregister(BAT_IV_OGM); 1313 + batadv_recv_handler_unregister(BATADV_IV_OGM); 1321 1314 out: 1322 1315 return ret; 1323 1316 }
+74 -60
net/batman-adv/bat_sysfs.c net/batman-adv/sysfs.c
··· 18 18 */ 19 19 20 20 #include "main.h" 21 - #include "bat_sysfs.h" 21 + #include "sysfs.h" 22 22 #include "translation-table.h" 23 23 #include "originator.h" 24 24 #include "hard-interface.h" ··· 32 32 return to_net_dev(dev); 33 33 } 34 34 35 - static struct bat_priv *batadv_kobj_to_batpriv(struct kobject *obj) 35 + static struct batadv_priv *batadv_kobj_to_batpriv(struct kobject *obj) 36 36 { 37 37 struct net_device *net_dev = batadv_kobj_to_netdev(obj); 38 38 return netdev_priv(net_dev); ··· 54 54 55 55 /* Use this, if you have customized show and store functions */ 56 56 #define BATADV_ATTR(_name, _mode, _show, _store) \ 57 - struct bat_attribute batadv_attr_##_name = { \ 57 + struct batadv_attribute batadv_attr_##_name = { \ 58 58 .attr = {.name = __stringify(_name), \ 59 59 .mode = _mode }, \ 60 60 .show = _show, \ ··· 67 67 size_t count) \ 68 68 { \ 69 69 struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \ 70 - struct bat_priv *bat_priv = netdev_priv(net_dev); \ 70 + struct batadv_priv *bat_priv = netdev_priv(net_dev); \ 71 71 return __batadv_store_bool_attr(buff, count, _post_func, attr, \ 72 72 &bat_priv->_name, net_dev); \ 73 73 } ··· 76 76 ssize_t batadv_show_##_name(struct kobject *kobj, \ 77 77 struct attribute *attr, char *buff) \ 78 78 { \ 79 - struct bat_priv *bat_priv = batadv_kobj_to_batpriv(kobj); \ 79 + struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj); \ 80 80 return sprintf(buff, "%s\n", \ 81 81 atomic_read(&bat_priv->_name) == 0 ? \ 82 82 "disabled" : "enabled"); \ ··· 98 98 size_t count) \ 99 99 { \ 100 100 struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \ 101 - struct bat_priv *bat_priv = netdev_priv(net_dev); \ 101 + struct batadv_priv *bat_priv = netdev_priv(net_dev); \ 102 102 return __batadv_store_uint_attr(buff, count, _min, _max, \ 103 103 _post_func, attr, \ 104 104 &bat_priv->_name, net_dev); \ ··· 108 108 ssize_t batadv_show_##_name(struct kobject *kobj, \ 109 109 struct attribute *attr, char *buff) \ 110 110 { \ 111 - struct bat_priv *bat_priv = batadv_kobj_to_batpriv(kobj); \ 111 + struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj); \ 112 112 return sprintf(buff, "%i\n", atomic_read(&bat_priv->_name)); \ 113 113 } \ 114 114 ··· 128 128 size_t count) \ 129 129 { \ 130 130 struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \ 131 - struct hard_iface *hard_iface; \ 131 + struct batadv_hard_iface *hard_iface; \ 132 132 ssize_t length; \ 133 133 \ 134 134 hard_iface = batadv_hardif_get_by_netdev(net_dev); \ ··· 148 148 struct attribute *attr, char *buff) \ 149 149 { \ 150 150 struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \ 151 - struct hard_iface *hard_iface; \ 151 + struct batadv_hard_iface *hard_iface; \ 152 152 ssize_t length; \ 153 153 \ 154 154 hard_iface = batadv_hardif_get_by_netdev(net_dev); \ ··· 281 281 static ssize_t batadv_show_vis_mode(struct kobject *kobj, 282 282 struct attribute *attr, char *buff) 283 283 { 284 - struct bat_priv *bat_priv = batadv_kobj_to_batpriv(kobj); 284 + struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj); 285 285 int vis_mode = atomic_read(&bat_priv->vis_mode); 286 + const char *mode; 286 287 287 - return sprintf(buff, "%s\n", 288 - vis_mode == VIS_TYPE_CLIENT_UPDATE ? 289 - "client" : "server"); 288 + if (vis_mode == BATADV_VIS_TYPE_CLIENT_UPDATE) 289 + mode = "client"; 290 + else 291 + mode = "server"; 292 + 293 + return sprintf(buff, "%s\n", mode); 290 294 } 291 295 292 296 static ssize_t batadv_store_vis_mode(struct kobject *kobj, ··· 298 294 size_t count) 299 295 { 300 296 struct net_device *net_dev = batadv_kobj_to_netdev(kobj); 301 - struct bat_priv *bat_priv = netdev_priv(net_dev); 297 + struct batadv_priv *bat_priv = netdev_priv(net_dev); 302 298 unsigned long val; 303 299 int ret, vis_mode_tmp = -1; 304 300 const char *old_mode, *new_mode; 305 301 306 302 ret = kstrtoul(buff, 10, &val); 307 303 308 - if (((count == 2) && (!ret) && (val == VIS_TYPE_CLIENT_UPDATE)) || 304 + if (((count == 2) && (!ret) && 305 + (val == BATADV_VIS_TYPE_CLIENT_UPDATE)) || 309 306 (strncmp(buff, "client", 6) == 0) || 310 307 (strncmp(buff, "off", 3) == 0)) 311 - vis_mode_tmp = VIS_TYPE_CLIENT_UPDATE; 308 + vis_mode_tmp = BATADV_VIS_TYPE_CLIENT_UPDATE; 312 309 313 - if (((count == 2) && (!ret) && (val == VIS_TYPE_SERVER_SYNC)) || 310 + if (((count == 2) && (!ret) && 311 + (val == BATADV_VIS_TYPE_SERVER_SYNC)) || 314 312 (strncmp(buff, "server", 6) == 0)) 315 - vis_mode_tmp = VIS_TYPE_SERVER_SYNC; 313 + vis_mode_tmp = BATADV_VIS_TYPE_SERVER_SYNC; 316 314 317 315 if (vis_mode_tmp < 0) { 318 316 if (buff[count - 1] == '\n') ··· 329 323 if (atomic_read(&bat_priv->vis_mode) == vis_mode_tmp) 330 324 return count; 331 325 332 - if (atomic_read(&bat_priv->vis_mode) == VIS_TYPE_CLIENT_UPDATE) 326 + if (atomic_read(&bat_priv->vis_mode) == BATADV_VIS_TYPE_CLIENT_UPDATE) 333 327 old_mode = "client"; 334 328 else 335 329 old_mode = "server"; 336 330 337 - if (vis_mode_tmp == VIS_TYPE_CLIENT_UPDATE) 331 + if (vis_mode_tmp == BATADV_VIS_TYPE_CLIENT_UPDATE) 338 332 new_mode = "client"; 339 333 else 340 334 new_mode = "server"; ··· 349 343 static ssize_t batadv_show_bat_algo(struct kobject *kobj, 350 344 struct attribute *attr, char *buff) 351 345 { 352 - struct bat_priv *bat_priv = batadv_kobj_to_batpriv(kobj); 346 + struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj); 353 347 return sprintf(buff, "%s\n", bat_priv->bat_algo_ops->name); 354 348 } 355 349 356 350 static void batadv_post_gw_deselect(struct net_device *net_dev) 357 351 { 358 - struct bat_priv *bat_priv = netdev_priv(net_dev); 352 + struct batadv_priv *bat_priv = netdev_priv(net_dev); 359 353 batadv_gw_deselect(bat_priv); 360 354 } 361 355 362 356 static ssize_t batadv_show_gw_mode(struct kobject *kobj, struct attribute *attr, 363 357 char *buff) 364 358 { 365 - struct bat_priv *bat_priv = batadv_kobj_to_batpriv(kobj); 359 + struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj); 366 360 int bytes_written; 367 361 368 362 switch (atomic_read(&bat_priv->gw_mode)) { 369 - case GW_MODE_CLIENT: 363 + case BATADV_GW_MODE_CLIENT: 370 364 bytes_written = sprintf(buff, "%s\n", 371 365 BATADV_GW_MODE_CLIENT_NAME); 372 366 break; 373 - case GW_MODE_SERVER: 367 + case BATADV_GW_MODE_SERVER: 374 368 bytes_written = sprintf(buff, "%s\n", 375 369 BATADV_GW_MODE_SERVER_NAME); 376 370 break; ··· 388 382 size_t count) 389 383 { 390 384 struct net_device *net_dev = batadv_kobj_to_netdev(kobj); 391 - struct bat_priv *bat_priv = netdev_priv(net_dev); 385 + struct batadv_priv *bat_priv = netdev_priv(net_dev); 392 386 char *curr_gw_mode_str; 393 387 int gw_mode_tmp = -1; 394 388 ··· 397 391 398 392 if (strncmp(buff, BATADV_GW_MODE_OFF_NAME, 399 393 strlen(BATADV_GW_MODE_OFF_NAME)) == 0) 400 - gw_mode_tmp = GW_MODE_OFF; 394 + gw_mode_tmp = BATADV_GW_MODE_OFF; 401 395 402 396 if (strncmp(buff, BATADV_GW_MODE_CLIENT_NAME, 403 397 strlen(BATADV_GW_MODE_CLIENT_NAME)) == 0) 404 - gw_mode_tmp = GW_MODE_CLIENT; 398 + gw_mode_tmp = BATADV_GW_MODE_CLIENT; 405 399 406 400 if (strncmp(buff, BATADV_GW_MODE_SERVER_NAME, 407 401 strlen(BATADV_GW_MODE_SERVER_NAME)) == 0) 408 - gw_mode_tmp = GW_MODE_SERVER; 402 + gw_mode_tmp = BATADV_GW_MODE_SERVER; 409 403 410 404 if (gw_mode_tmp < 0) { 411 405 batadv_info(net_dev, ··· 418 412 return count; 419 413 420 414 switch (atomic_read(&bat_priv->gw_mode)) { 421 - case GW_MODE_CLIENT: 415 + case BATADV_GW_MODE_CLIENT: 422 416 curr_gw_mode_str = BATADV_GW_MODE_CLIENT_NAME; 423 417 break; 424 - case GW_MODE_SERVER: 418 + case BATADV_GW_MODE_SERVER: 425 419 curr_gw_mode_str = BATADV_GW_MODE_SERVER_NAME; 426 420 break; 427 421 default: ··· 440 434 static ssize_t batadv_show_gw_bwidth(struct kobject *kobj, 441 435 struct attribute *attr, char *buff) 442 436 { 443 - struct bat_priv *bat_priv = batadv_kobj_to_batpriv(kobj); 437 + struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj); 444 438 int down, up; 445 439 int gw_bandwidth = atomic_read(&bat_priv->gw_bandwidth); 446 440 ··· 485 479 static BATADV_ATTR(gw_bandwidth, S_IRUGO | S_IWUSR, batadv_show_gw_bwidth, 486 480 batadv_store_gw_bwidth); 487 481 #ifdef CONFIG_BATMAN_ADV_DEBUG 488 - BATADV_ATTR_SIF_UINT(log_level, S_IRUGO | S_IWUSR, 0, DBG_ALL, NULL); 482 + BATADV_ATTR_SIF_UINT(log_level, S_IRUGO | S_IWUSR, 0, BATADV_DBG_ALL, NULL); 489 483 #endif 490 484 491 - static struct bat_attribute *batadv_mesh_attrs[] = { 485 + static struct batadv_attribute *batadv_mesh_attrs[] = { 492 486 &batadv_attr_aggregated_ogms, 493 487 &batadv_attr_bonding, 494 488 #ifdef CONFIG_BATMAN_ADV_BLA ··· 512 506 int batadv_sysfs_add_meshif(struct net_device *dev) 513 507 { 514 508 struct kobject *batif_kobject = &dev->dev.kobj; 515 - struct bat_priv *bat_priv = netdev_priv(dev); 516 - struct bat_attribute **bat_attr; 509 + struct batadv_priv *bat_priv = netdev_priv(dev); 510 + struct batadv_attribute **bat_attr; 517 511 int err; 518 512 519 513 bat_priv->mesh_obj = kobject_create_and_add(BATADV_SYSFS_IF_MESH_SUBDIR, ··· 549 543 550 544 void batadv_sysfs_del_meshif(struct net_device *dev) 551 545 { 552 - struct bat_priv *bat_priv = netdev_priv(dev); 553 - struct bat_attribute **bat_attr; 546 + struct batadv_priv *bat_priv = netdev_priv(dev); 547 + struct batadv_attribute **bat_attr; 554 548 555 549 for (bat_attr = batadv_mesh_attrs; *bat_attr; ++bat_attr) 556 550 sysfs_remove_file(bat_priv->mesh_obj, &((*bat_attr)->attr)); ··· 563 557 struct attribute *attr, char *buff) 564 558 { 565 559 struct net_device *net_dev = batadv_kobj_to_netdev(kobj); 566 - struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev); 560 + struct batadv_hard_iface *hard_iface; 567 561 ssize_t length; 562 + const char *ifname; 568 563 564 + hard_iface = batadv_hardif_get_by_netdev(net_dev); 569 565 if (!hard_iface) 570 566 return 0; 571 567 572 - length = sprintf(buff, "%s\n", hard_iface->if_status == IF_NOT_IN_USE ? 573 - "none" : hard_iface->soft_iface->name); 568 + if (hard_iface->if_status == BATADV_IF_NOT_IN_USE) 569 + ifname = "none"; 570 + else 571 + ifname = hard_iface->soft_iface->name; 572 + 573 + length = sprintf(buff, "%s\n", ifname); 574 574 575 575 batadv_hardif_free_ref(hard_iface); 576 576 ··· 588 576 size_t count) 589 577 { 590 578 struct net_device *net_dev = batadv_kobj_to_netdev(kobj); 591 - struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev); 579 + struct batadv_hard_iface *hard_iface; 592 580 int status_tmp = -1; 593 581 int ret = count; 594 582 583 + hard_iface = batadv_hardif_get_by_netdev(net_dev); 595 584 if (!hard_iface) 596 585 return count; 597 586 ··· 607 594 } 608 595 609 596 if (strncmp(buff, "none", 4) == 0) 610 - status_tmp = IF_NOT_IN_USE; 597 + status_tmp = BATADV_IF_NOT_IN_USE; 611 598 else 612 - status_tmp = IF_I_WANT_YOU; 599 + status_tmp = BATADV_IF_I_WANT_YOU; 613 600 614 601 if (hard_iface->if_status == status_tmp) 615 602 goto out; ··· 623 610 goto out; 624 611 } 625 612 626 - if (status_tmp == IF_NOT_IN_USE) { 613 + if (status_tmp == BATADV_IF_NOT_IN_USE) { 627 614 batadv_hardif_disable_interface(hard_iface); 628 615 goto unlock; 629 616 } 630 617 631 618 /* if the interface already is in use */ 632 - if (hard_iface->if_status != IF_NOT_IN_USE) 619 + if (hard_iface->if_status != BATADV_IF_NOT_IN_USE) 633 620 batadv_hardif_disable_interface(hard_iface); 634 621 635 622 ret = batadv_hardif_enable_interface(hard_iface, buff); ··· 645 632 struct attribute *attr, char *buff) 646 633 { 647 634 struct net_device *net_dev = batadv_kobj_to_netdev(kobj); 648 - struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev); 635 + struct batadv_hard_iface *hard_iface; 649 636 ssize_t length; 650 637 638 + hard_iface = batadv_hardif_get_by_netdev(net_dev); 651 639 if (!hard_iface) 652 640 return 0; 653 641 654 642 switch (hard_iface->if_status) { 655 - case IF_TO_BE_REMOVED: 643 + case BATADV_IF_TO_BE_REMOVED: 656 644 length = sprintf(buff, "disabling\n"); 657 645 break; 658 - case IF_INACTIVE: 646 + case BATADV_IF_INACTIVE: 659 647 length = sprintf(buff, "inactive\n"); 660 648 break; 661 - case IF_ACTIVE: 649 + case BATADV_IF_ACTIVE: 662 650 length = sprintf(buff, "active\n"); 663 651 break; 664 - case IF_TO_BE_ACTIVATED: 652 + case BATADV_IF_TO_BE_ACTIVATED: 665 653 length = sprintf(buff, "enabling\n"); 666 654 break; 667 - case IF_NOT_IN_USE: 655 + case BATADV_IF_NOT_IN_USE: 668 656 default: 669 657 length = sprintf(buff, "not in use\n"); 670 658 break; ··· 680 666 batadv_store_mesh_iface); 681 667 static BATADV_ATTR(iface_status, S_IRUGO, batadv_show_iface_status, NULL); 682 668 683 - static struct bat_attribute *batadv_batman_attrs[] = { 669 + static struct batadv_attribute *batadv_batman_attrs[] = { 684 670 &batadv_attr_mesh_iface, 685 671 &batadv_attr_iface_status, 686 672 NULL, ··· 689 675 int batadv_sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev) 690 676 { 691 677 struct kobject *hardif_kobject = &dev->dev.kobj; 692 - struct bat_attribute **bat_attr; 678 + struct batadv_attribute **bat_attr; 693 679 int err; 694 680 695 681 *hardif_obj = kobject_create_and_add(BATADV_SYSFS_IF_BAT_SUBDIR, ··· 726 712 *hardif_obj = NULL; 727 713 } 728 714 729 - int batadv_throw_uevent(struct bat_priv *bat_priv, enum uev_type type, 730 - enum uev_action action, const char *data) 715 + int batadv_throw_uevent(struct batadv_priv *bat_priv, enum batadv_uev_type type, 716 + enum batadv_uev_action action, const char *data) 731 717 { 732 718 int ret = -ENOMEM; 733 - struct hard_iface *primary_if = NULL; 719 + struct batadv_hard_iface *primary_if = NULL; 734 720 struct kobject *bat_kobj; 735 721 char *uevent_env[4] = { NULL, NULL, NULL, NULL }; 736 722 ··· 759 745 batadv_uev_action_str[action]); 760 746 761 747 /* If the event is DEL, ignore the data field */ 762 - if (action != UEV_DEL) { 748 + if (action != BATADV_UEV_DEL) { 763 749 uevent_env[2] = kmalloc(strlen(BATADV_UEV_DATA_VAR) + 764 750 strlen(data) + 1, GFP_ATOMIC); 765 751 if (!uevent_env[2]) ··· 778 764 batadv_hardif_free_ref(primary_if); 779 765 780 766 if (ret) 781 - batadv_dbg(DBG_BATMAN, bat_priv, 767 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 782 768 "Impossible to send uevent for (%s,%s,%s) event (err: %d)\n", 783 769 batadv_uev_type_str[type], 784 770 batadv_uev_action_str[action], 785 - (action == UEV_DEL ? "NULL" : data), ret); 771 + (action == BATADV_UEV_DEL ? "NULL" : data), ret); 786 772 return ret; 787 773 }
+3 -3
net/batman-adv/bat_sysfs.h net/batman-adv/sysfs.h
··· 23 23 #define BATADV_SYSFS_IF_MESH_SUBDIR "mesh" 24 24 #define BATADV_SYSFS_IF_BAT_SUBDIR "batman_adv" 25 25 26 - struct bat_attribute { 26 + struct batadv_attribute { 27 27 struct attribute attr; 28 28 ssize_t (*show)(struct kobject *kobj, struct attribute *attr, 29 29 char *buf); ··· 36 36 int batadv_sysfs_add_hardif(struct kobject **hardif_obj, 37 37 struct net_device *dev); 38 38 void batadv_sysfs_del_hardif(struct kobject **hardif_obj); 39 - int batadv_throw_uevent(struct bat_priv *bat_priv, enum uev_type type, 40 - enum uev_action action, const char *data); 39 + int batadv_throw_uevent(struct batadv_priv *bat_priv, enum batadv_uev_type type, 40 + enum batadv_uev_action action, const char *data); 41 41 42 42 #endif /* _NET_BATMAN_ADV_SYSFS_H_ */
+3 -3
net/batman-adv/bitarray.c
··· 41 41 int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, 42 42 int32_t seq_num_diff, int set_mark) 43 43 { 44 - struct bat_priv *bat_priv = priv; 44 + struct batadv_priv *bat_priv = priv; 45 45 46 46 /* sequence number is slightly older. We already got a sequence number 47 47 * higher than this one, so we just mark it. ··· 66 66 /* sequence number is much newer, probably missed a lot of packets */ 67 67 if (seq_num_diff >= BATADV_TQ_LOCAL_WINDOW_SIZE && 68 68 seq_num_diff < BATADV_EXPECTED_SEQNO_RANGE) { 69 - batadv_dbg(DBG_BATMAN, bat_priv, 69 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 70 70 "We missed a lot of packets (%i) !\n", 71 71 seq_num_diff - 1); 72 72 bitmap_zero(seq_bits, BATADV_TQ_LOCAL_WINDOW_SIZE); ··· 83 83 if (seq_num_diff <= -BATADV_TQ_LOCAL_WINDOW_SIZE || 84 84 seq_num_diff >= BATADV_EXPECTED_SEQNO_RANGE) { 85 85 86 - batadv_dbg(DBG_BATMAN, bat_priv, 86 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 87 87 "Other host probably restarted!\n"); 88 88 89 89 bitmap_zero(seq_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
+154 -148
net/batman-adv/bridge_loop_avoidance.c
··· 34 34 static const uint8_t batadv_announce_mac[4] = {0x43, 0x05, 0x43, 0x05}; 35 35 36 36 static void batadv_bla_periodic_work(struct work_struct *work); 37 - static void batadv_bla_send_announce(struct bat_priv *bat_priv, 38 - struct backbone_gw *backbone_gw); 37 + static void batadv_bla_send_announce(struct batadv_priv *bat_priv, 38 + struct batadv_backbone_gw *backbone_gw); 39 39 40 40 /* return the index of the claim */ 41 41 static inline uint32_t batadv_choose_claim(const void *data, uint32_t size) ··· 83 83 static int batadv_compare_backbone_gw(const struct hlist_node *node, 84 84 const void *data2) 85 85 { 86 - const void *data1 = container_of(node, struct backbone_gw, 86 + const void *data1 = container_of(node, struct batadv_backbone_gw, 87 87 hash_entry); 88 88 89 89 return (memcmp(data1, data2, ETH_ALEN + sizeof(short)) == 0 ? 1 : 0); ··· 93 93 static int batadv_compare_claim(const struct hlist_node *node, 94 94 const void *data2) 95 95 { 96 - const void *data1 = container_of(node, struct claim, 96 + const void *data1 = container_of(node, struct batadv_claim, 97 97 hash_entry); 98 98 99 99 return (memcmp(data1, data2, ETH_ALEN + sizeof(short)) == 0 ? 1 : 0); 100 100 } 101 101 102 102 /* free a backbone gw */ 103 - static void batadv_backbone_gw_free_ref(struct backbone_gw *backbone_gw) 103 + static void batadv_backbone_gw_free_ref(struct batadv_backbone_gw *backbone_gw) 104 104 { 105 105 if (atomic_dec_and_test(&backbone_gw->refcount)) 106 106 kfree_rcu(backbone_gw, rcu); ··· 109 109 /* finally deinitialize the claim */ 110 110 static void batadv_claim_free_rcu(struct rcu_head *rcu) 111 111 { 112 - struct claim *claim; 112 + struct batadv_claim *claim; 113 113 114 - claim = container_of(rcu, struct claim, rcu); 114 + claim = container_of(rcu, struct batadv_claim, rcu); 115 115 116 116 batadv_backbone_gw_free_ref(claim->backbone_gw); 117 117 kfree(claim); 118 118 } 119 119 120 120 /* free a claim, call claim_free_rcu if its the last reference */ 121 - static void batadv_claim_free_ref(struct claim *claim) 121 + static void batadv_claim_free_ref(struct batadv_claim *claim) 122 122 { 123 123 if (atomic_dec_and_test(&claim->refcount)) 124 124 call_rcu(&claim->rcu, batadv_claim_free_rcu); ··· 130 130 * looks for a claim in the hash, and returns it if found 131 131 * or NULL otherwise. 132 132 */ 133 - static struct claim *batadv_claim_hash_find(struct bat_priv *bat_priv, 134 - struct claim *data) 133 + static struct batadv_claim *batadv_claim_hash_find(struct batadv_priv *bat_priv, 134 + struct batadv_claim *data) 135 135 { 136 - struct hashtable_t *hash = bat_priv->claim_hash; 136 + struct batadv_hashtable *hash = bat_priv->claim_hash; 137 137 struct hlist_head *head; 138 138 struct hlist_node *node; 139 - struct claim *claim; 140 - struct claim *claim_tmp = NULL; 139 + struct batadv_claim *claim; 140 + struct batadv_claim *claim_tmp = NULL; 141 141 int index; 142 142 143 143 if (!hash) ··· 169 169 * looks for a claim in the hash, and returns it if found 170 170 * or NULL otherwise. 171 171 */ 172 - static struct backbone_gw *batadv_backbone_hash_find(struct bat_priv *bat_priv, 173 - uint8_t *addr, short vid) 172 + static struct batadv_backbone_gw * 173 + batadv_backbone_hash_find(struct batadv_priv *bat_priv, 174 + uint8_t *addr, short vid) 174 175 { 175 - struct hashtable_t *hash = bat_priv->backbone_hash; 176 + struct batadv_hashtable *hash = bat_priv->backbone_hash; 176 177 struct hlist_head *head; 177 178 struct hlist_node *node; 178 - struct backbone_gw search_entry, *backbone_gw; 179 - struct backbone_gw *backbone_gw_tmp = NULL; 179 + struct batadv_backbone_gw search_entry, *backbone_gw; 180 + struct batadv_backbone_gw *backbone_gw_tmp = NULL; 180 181 int index; 181 182 182 183 if (!hash) ··· 207 206 } 208 207 209 208 /* delete all claims for a backbone */ 210 - static void batadv_bla_del_backbone_claims(struct backbone_gw *backbone_gw) 209 + static void 210 + batadv_bla_del_backbone_claims(struct batadv_backbone_gw *backbone_gw) 211 211 { 212 - struct hashtable_t *hash; 212 + struct batadv_hashtable *hash; 213 213 struct hlist_node *node, *node_tmp; 214 214 struct hlist_head *head; 215 - struct claim *claim; 215 + struct batadv_claim *claim; 216 216 int i; 217 217 spinlock_t *list_lock; /* protects write access to the hash lists */ 218 218 ··· 249 247 * 250 248 * sends a claim frame according to the provided info. 251 249 */ 252 - static void batadv_bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac, 250 + static void batadv_bla_send_claim(struct batadv_priv *bat_priv, uint8_t *mac, 253 251 short vid, int claimtype) 254 252 { 255 253 struct sk_buff *skb; 256 254 struct ethhdr *ethhdr; 257 - struct hard_iface *primary_if; 255 + struct batadv_hard_iface *primary_if; 258 256 struct net_device *soft_iface; 259 257 uint8_t *hw_src; 260 - struct bla_claim_dst local_claim_dest; 258 + struct batadv_bla_claim_dst local_claim_dest; 261 259 __be32 zeroip = 0; 262 260 263 261 primary_if = batadv_primary_if_get_selected(bat_priv); ··· 294 292 295 293 /* now we pretend that the client would have sent this ... */ 296 294 switch (claimtype) { 297 - case CLAIM_TYPE_ADD: 295 + case BATADV_CLAIM_TYPE_ADD: 298 296 /* normal claim frame 299 297 * set Ethernet SRC to the clients mac 300 298 */ 301 299 memcpy(ethhdr->h_source, mac, ETH_ALEN); 302 - batadv_dbg(DBG_BLA, bat_priv, 300 + batadv_dbg(BATADV_DBG_BLA, bat_priv, 303 301 "bla_send_claim(): CLAIM %pM on vid %d\n", mac, vid); 304 302 break; 305 - case CLAIM_TYPE_DEL: 303 + case BATADV_CLAIM_TYPE_DEL: 306 304 /* unclaim frame 307 305 * set HW SRC to the clients mac 308 306 */ 309 307 memcpy(hw_src, mac, ETH_ALEN); 310 - batadv_dbg(DBG_BLA, bat_priv, 308 + batadv_dbg(BATADV_DBG_BLA, bat_priv, 311 309 "bla_send_claim(): UNCLAIM %pM on vid %d\n", mac, 312 310 vid); 313 311 break; 314 - case CLAIM_TYPE_ANNOUNCE: 312 + case BATADV_CLAIM_TYPE_ANNOUNCE: 315 313 /* announcement frame 316 314 * set HW SRC to the special mac containg the crc 317 315 */ 318 316 memcpy(hw_src, mac, ETH_ALEN); 319 - batadv_dbg(DBG_BLA, bat_priv, 317 + batadv_dbg(BATADV_DBG_BLA, bat_priv, 320 318 "bla_send_claim(): ANNOUNCE of %pM on vid %d\n", 321 319 ethhdr->h_source, vid); 322 320 break; 323 - case CLAIM_TYPE_REQUEST: 321 + case BATADV_CLAIM_TYPE_REQUEST: 324 322 /* request frame 325 323 * set HW SRC to the special mac containg the crc 326 324 */ 327 325 memcpy(hw_src, mac, ETH_ALEN); 328 326 memcpy(ethhdr->h_dest, mac, ETH_ALEN); 329 - batadv_dbg(DBG_BLA, bat_priv, 327 + batadv_dbg(BATADV_DBG_BLA, bat_priv, 330 328 "bla_send_claim(): REQUEST of %pM to %pMon vid %d\n", 331 329 ethhdr->h_source, ethhdr->h_dest, vid); 332 330 break; ··· 355 353 * searches for the backbone gw or creates a new one if it could not 356 354 * be found. 357 355 */ 358 - static struct backbone_gw *batadv_bla_get_backbone_gw(struct bat_priv *bat_priv, 359 - uint8_t *orig, short vid) 356 + static struct batadv_backbone_gw * 357 + batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, uint8_t *orig, 358 + short vid) 360 359 { 361 - struct backbone_gw *entry; 362 - struct orig_node *orig_node; 360 + struct batadv_backbone_gw *entry; 361 + struct batadv_orig_node *orig_node; 363 362 int hash_added; 364 363 365 364 entry = batadv_backbone_hash_find(bat_priv, orig, vid); ··· 368 365 if (entry) 369 366 return entry; 370 367 371 - batadv_dbg(DBG_BLA, bat_priv, 368 + batadv_dbg(BATADV_DBG_BLA, bat_priv, 372 369 "bla_get_backbone_gw(): not found (%pM, %d), creating new entry\n", 373 370 orig, vid); 374 371 ··· 410 407 /* update or add the own backbone gw to make sure we announce 411 408 * where we receive other backbone gws 412 409 */ 413 - static void batadv_bla_update_own_backbone_gw(struct bat_priv *bat_priv, 414 - struct hard_iface *primary_if, 415 - short vid) 410 + static void 411 + batadv_bla_update_own_backbone_gw(struct batadv_priv *bat_priv, 412 + struct batadv_hard_iface *primary_if, 413 + short vid) 416 414 { 417 - struct backbone_gw *backbone_gw; 415 + struct batadv_backbone_gw *backbone_gw; 418 416 419 417 backbone_gw = batadv_bla_get_backbone_gw(bat_priv, 420 418 primary_if->net_dev->dev_addr, ··· 433 429 * Repeat all of our own claims, and finally send an ANNOUNCE frame 434 430 * to allow the requester another check if the CRC is correct now. 435 431 */ 436 - static void batadv_bla_answer_request(struct bat_priv *bat_priv, 437 - struct hard_iface *primary_if, short vid) 432 + static void batadv_bla_answer_request(struct batadv_priv *bat_priv, 433 + struct batadv_hard_iface *primary_if, 434 + short vid) 438 435 { 439 436 struct hlist_node *node; 440 437 struct hlist_head *head; 441 - struct hashtable_t *hash; 442 - struct claim *claim; 443 - struct backbone_gw *backbone_gw; 438 + struct batadv_hashtable *hash; 439 + struct batadv_claim *claim; 440 + struct batadv_backbone_gw *backbone_gw; 444 441 int i; 445 442 446 - batadv_dbg(DBG_BLA, bat_priv, 443 + batadv_dbg(BATADV_DBG_BLA, bat_priv, 447 444 "bla_answer_request(): received a claim request, send all of our own claims again\n"); 448 445 449 446 backbone_gw = batadv_backbone_hash_find(bat_priv, ··· 464 459 continue; 465 460 466 461 batadv_bla_send_claim(bat_priv, claim->addr, claim->vid, 467 - CLAIM_TYPE_ADD); 462 + BATADV_CLAIM_TYPE_ADD); 468 463 } 469 464 rcu_read_unlock(); 470 465 } ··· 480 475 * After the request, it will repeat all of his own claims and finally 481 476 * send an announcement claim with which we can check again. 482 477 */ 483 - static void batadv_bla_send_request(struct backbone_gw *backbone_gw) 478 + static void batadv_bla_send_request(struct batadv_backbone_gw *backbone_gw) 484 479 { 485 480 /* first, remove all old entries */ 486 481 batadv_bla_del_backbone_claims(backbone_gw); 487 482 488 - batadv_dbg(DBG_BLA, backbone_gw->bat_priv, "Sending REQUEST to %pM\n", 489 - backbone_gw->orig); 483 + batadv_dbg(BATADV_DBG_BLA, backbone_gw->bat_priv, 484 + "Sending REQUEST to %pM\n", backbone_gw->orig); 490 485 491 486 /* send request */ 492 487 batadv_bla_send_claim(backbone_gw->bat_priv, backbone_gw->orig, 493 - backbone_gw->vid, CLAIM_TYPE_REQUEST); 488 + backbone_gw->vid, BATADV_CLAIM_TYPE_REQUEST); 494 489 495 490 /* no local broadcasts should be sent or received, for now. */ 496 491 if (!atomic_read(&backbone_gw->request_sent)) { ··· 505 500 * This function sends an announcement. It is called from multiple 506 501 * places. 507 502 */ 508 - static void batadv_bla_send_announce(struct bat_priv *bat_priv, 509 - struct backbone_gw *backbone_gw) 503 + static void batadv_bla_send_announce(struct batadv_priv *bat_priv, 504 + struct batadv_backbone_gw *backbone_gw) 510 505 { 511 506 uint8_t mac[ETH_ALEN]; 512 507 __be16 crc; ··· 516 511 memcpy(&mac[4], &crc, 2); 517 512 518 513 batadv_bla_send_claim(bat_priv, mac, backbone_gw->vid, 519 - CLAIM_TYPE_ANNOUNCE); 514 + BATADV_CLAIM_TYPE_ANNOUNCE); 520 515 521 516 } 522 517 ··· 527 522 * 528 523 * Adds a claim in the claim hash. 529 524 */ 530 - static void batadv_bla_add_claim(struct bat_priv *bat_priv, const uint8_t *mac, 531 - const short vid, 532 - struct backbone_gw *backbone_gw) 525 + static void batadv_bla_add_claim(struct batadv_priv *bat_priv, 526 + const uint8_t *mac, const short vid, 527 + struct batadv_backbone_gw *backbone_gw) 533 528 { 534 - struct claim *claim; 535 - struct claim search_claim; 529 + struct batadv_claim *claim; 530 + struct batadv_claim search_claim; 536 531 int hash_added; 537 532 538 533 memcpy(search_claim.addr, mac, ETH_ALEN); ··· 551 546 claim->backbone_gw = backbone_gw; 552 547 553 548 atomic_set(&claim->refcount, 2); 554 - batadv_dbg(DBG_BLA, bat_priv, 549 + batadv_dbg(BATADV_DBG_BLA, bat_priv, 555 550 "bla_add_claim(): adding new entry %pM, vid %d to hash ...\n", 556 551 mac, vid); 557 552 hash_added = batadv_hash_add(bat_priv->claim_hash, ··· 570 565 /* no need to register a new backbone */ 571 566 goto claim_free_ref; 572 567 573 - batadv_dbg(DBG_BLA, bat_priv, 568 + batadv_dbg(BATADV_DBG_BLA, bat_priv, 574 569 "bla_add_claim(): changing ownership for %pM, vid %d\n", 575 570 mac, vid); 576 571 ··· 593 588 /* Delete a claim from the claim hash which has the 594 589 * given mac address and vid. 595 590 */ 596 - static void batadv_bla_del_claim(struct bat_priv *bat_priv, const uint8_t *mac, 597 - const short vid) 591 + static void batadv_bla_del_claim(struct batadv_priv *bat_priv, 592 + const uint8_t *mac, const short vid) 598 593 { 599 - struct claim search_claim, *claim; 594 + struct batadv_claim search_claim, *claim; 600 595 601 596 memcpy(search_claim.addr, mac, ETH_ALEN); 602 597 search_claim.vid = vid; ··· 604 599 if (!claim) 605 600 return; 606 601 607 - batadv_dbg(DBG_BLA, bat_priv, "bla_del_claim(): %pM, vid %d\n", mac, 608 - vid); 602 + batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla_del_claim(): %pM, vid %d\n", 603 + mac, vid); 609 604 610 605 batadv_hash_remove(bat_priv->claim_hash, batadv_compare_claim, 611 606 batadv_choose_claim, claim); ··· 618 613 } 619 614 620 615 /* check for ANNOUNCE frame, return 1 if handled */ 621 - static int batadv_handle_announce(struct bat_priv *bat_priv, 616 + static int batadv_handle_announce(struct batadv_priv *bat_priv, 622 617 uint8_t *an_addr, uint8_t *backbone_addr, 623 618 short vid) 624 619 { 625 - struct backbone_gw *backbone_gw; 620 + struct batadv_backbone_gw *backbone_gw; 626 621 uint16_t crc; 627 622 628 623 if (memcmp(an_addr, batadv_announce_mac, 4) != 0) ··· 638 633 backbone_gw->lasttime = jiffies; 639 634 crc = ntohs(*((__be16 *)(&an_addr[4]))); 640 635 641 - batadv_dbg(DBG_BLA, bat_priv, 636 + batadv_dbg(BATADV_DBG_BLA, bat_priv, 642 637 "handle_announce(): ANNOUNCE vid %d (sent by %pM)... CRC = %04x\n", 643 638 vid, backbone_gw->orig, crc); 644 639 645 640 if (backbone_gw->crc != crc) { 646 - batadv_dbg(DBG_BLA, backbone_gw->bat_priv, 641 + batadv_dbg(BATADV_DBG_BLA, backbone_gw->bat_priv, 647 642 "handle_announce(): CRC FAILED for %pM/%d (my = %04x, sent = %04x)\n", 648 643 backbone_gw->orig, backbone_gw->vid, 649 644 backbone_gw->crc, crc); ··· 664 659 } 665 660 666 661 /* check for REQUEST frame, return 1 if handled */ 667 - static int batadv_handle_request(struct bat_priv *bat_priv, 668 - struct hard_iface *primary_if, 662 + static int batadv_handle_request(struct batadv_priv *bat_priv, 663 + struct batadv_hard_iface *primary_if, 669 664 uint8_t *backbone_addr, 670 665 struct ethhdr *ethhdr, short vid) 671 666 { ··· 679 674 if (!batadv_compare_eth(ethhdr->h_dest, primary_if->net_dev->dev_addr)) 680 675 return 1; 681 676 682 - batadv_dbg(DBG_BLA, bat_priv, 677 + batadv_dbg(BATADV_DBG_BLA, bat_priv, 683 678 "handle_request(): REQUEST vid %d (sent by %pM)...\n", 684 679 vid, ethhdr->h_source); 685 680 ··· 688 683 } 689 684 690 685 /* check for UNCLAIM frame, return 1 if handled */ 691 - static int batadv_handle_unclaim(struct bat_priv *bat_priv, 692 - struct hard_iface *primary_if, 686 + static int batadv_handle_unclaim(struct batadv_priv *bat_priv, 687 + struct batadv_hard_iface *primary_if, 693 688 uint8_t *backbone_addr, 694 689 uint8_t *claim_addr, short vid) 695 690 { 696 - struct backbone_gw *backbone_gw; 691 + struct batadv_backbone_gw *backbone_gw; 697 692 698 693 /* unclaim in any case if it is our own */ 699 694 if (primary_if && batadv_compare_eth(backbone_addr, 700 695 primary_if->net_dev->dev_addr)) 701 696 batadv_bla_send_claim(bat_priv, claim_addr, vid, 702 - CLAIM_TYPE_DEL); 697 + BATADV_CLAIM_TYPE_DEL); 703 698 704 699 backbone_gw = batadv_backbone_hash_find(bat_priv, backbone_addr, vid); 705 700 ··· 707 702 return 1; 708 703 709 704 /* this must be an UNCLAIM frame */ 710 - batadv_dbg(DBG_BLA, bat_priv, 705 + batadv_dbg(BATADV_DBG_BLA, bat_priv, 711 706 "handle_unclaim(): UNCLAIM %pM on vid %d (sent by %pM)...\n", 712 707 claim_addr, vid, backbone_gw->orig); 713 708 ··· 717 712 } 718 713 719 714 /* check for CLAIM frame, return 1 if handled */ 720 - static int batadv_handle_claim(struct bat_priv *bat_priv, 721 - struct hard_iface *primary_if, 715 + static int batadv_handle_claim(struct batadv_priv *bat_priv, 716 + struct batadv_hard_iface *primary_if, 722 717 uint8_t *backbone_addr, uint8_t *claim_addr, 723 718 short vid) 724 719 { 725 - struct backbone_gw *backbone_gw; 720 + struct batadv_backbone_gw *backbone_gw; 726 721 727 722 /* register the gateway if not yet available, and add the claim. */ 728 723 ··· 735 730 batadv_bla_add_claim(bat_priv, claim_addr, vid, backbone_gw); 736 731 if (batadv_compare_eth(backbone_addr, primary_if->net_dev->dev_addr)) 737 732 batadv_bla_send_claim(bat_priv, claim_addr, vid, 738 - CLAIM_TYPE_ADD); 733 + BATADV_CLAIM_TYPE_ADD); 739 734 740 735 /* TODO: we could call something like tt_local_del() here. */ 741 736 ··· 757 752 * 1 - if is a claim packet from another group 758 753 * 0 - if it is not a claim packet 759 754 */ 760 - static int batadv_check_claim_group(struct bat_priv *bat_priv, 761 - struct hard_iface *primary_if, 755 + static int batadv_check_claim_group(struct batadv_priv *bat_priv, 756 + struct batadv_hard_iface *primary_if, 762 757 uint8_t *hw_src, uint8_t *hw_dst, 763 758 struct ethhdr *ethhdr) 764 759 { 765 760 uint8_t *backbone_addr; 766 - struct orig_node *orig_node; 767 - struct bla_claim_dst *bla_dst, *bla_dst_own; 761 + struct batadv_orig_node *orig_node; 762 + struct batadv_bla_claim_dst *bla_dst, *bla_dst_own; 768 763 769 - bla_dst = (struct bla_claim_dst *)hw_dst; 764 + bla_dst = (struct batadv_bla_claim_dst *)hw_dst; 770 765 bla_dst_own = &bat_priv->claim_dest; 771 766 772 767 /* check if it is a claim packet in general */ ··· 778 773 * otherwise assume it is in the hw_src 779 774 */ 780 775 switch (bla_dst->type) { 781 - case CLAIM_TYPE_ADD: 776 + case BATADV_CLAIM_TYPE_ADD: 782 777 backbone_addr = hw_src; 783 778 break; 784 - case CLAIM_TYPE_REQUEST: 785 - case CLAIM_TYPE_ANNOUNCE: 786 - case CLAIM_TYPE_DEL: 779 + case BATADV_CLAIM_TYPE_REQUEST: 780 + case BATADV_CLAIM_TYPE_ANNOUNCE: 781 + case BATADV_CLAIM_TYPE_DEL: 787 782 backbone_addr = ethhdr->h_source; 788 783 break; 789 784 default: ··· 809 804 810 805 /* if our mesh friends mac is bigger, use it for ourselves. */ 811 806 if (ntohs(bla_dst->group) > ntohs(bla_dst_own->group)) { 812 - batadv_dbg(DBG_BLA, bat_priv, 807 + batadv_dbg(BATADV_DBG_BLA, bat_priv, 813 808 "taking other backbones claim group: %04x\n", 814 809 ntohs(bla_dst->group)); 815 810 bla_dst_own->group = bla_dst->group; ··· 829 824 * returns 1 if it was a claim frame, otherwise return 0 to 830 825 * tell the callee that it can use the frame on its own. 831 826 */ 832 - static int batadv_bla_process_claim(struct bat_priv *bat_priv, 833 - struct hard_iface *primary_if, 827 + static int batadv_bla_process_claim(struct batadv_priv *bat_priv, 828 + struct batadv_hard_iface *primary_if, 834 829 struct sk_buff *skb) 835 830 { 836 831 struct ethhdr *ethhdr; 837 832 struct vlan_ethhdr *vhdr; 838 833 struct arphdr *arphdr; 839 834 uint8_t *hw_src, *hw_dst; 840 - struct bla_claim_dst *bla_dst; 835 + struct batadv_bla_claim_dst *bla_dst; 841 836 uint16_t proto; 842 837 int headlen; 843 838 short vid = -1; ··· 881 876 882 877 hw_src = (uint8_t *)arphdr + sizeof(struct arphdr); 883 878 hw_dst = hw_src + ETH_ALEN + 4; 884 - bla_dst = (struct bla_claim_dst *)hw_dst; 879 + bla_dst = (struct batadv_bla_claim_dst *)hw_dst; 885 880 886 881 /* check if it is a claim frame. */ 887 882 ret = batadv_check_claim_group(bat_priv, primary_if, hw_src, hw_dst, 888 883 ethhdr); 889 884 if (ret == 1) 890 - batadv_dbg(DBG_BLA, bat_priv, 885 + batadv_dbg(BATADV_DBG_BLA, bat_priv, 891 886 "bla_process_claim(): received a claim frame from another group. From: %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n", 892 887 ethhdr->h_source, vid, hw_src, hw_dst); 893 888 ··· 899 894 900 895 /* check for the different types of claim frames ... */ 901 896 switch (bla_dst->type) { 902 - case CLAIM_TYPE_ADD: 897 + case BATADV_CLAIM_TYPE_ADD: 903 898 if (batadv_handle_claim(bat_priv, primary_if, hw_src, 904 899 ethhdr->h_source, vid)) 905 900 return 1; 906 901 break; 907 - case CLAIM_TYPE_DEL: 902 + case BATADV_CLAIM_TYPE_DEL: 908 903 if (batadv_handle_unclaim(bat_priv, primary_if, 909 904 ethhdr->h_source, hw_src, vid)) 910 905 return 1; 911 906 break; 912 907 913 - case CLAIM_TYPE_ANNOUNCE: 908 + case BATADV_CLAIM_TYPE_ANNOUNCE: 914 909 if (batadv_handle_announce(bat_priv, hw_src, ethhdr->h_source, 915 910 vid)) 916 911 return 1; 917 912 break; 918 - case CLAIM_TYPE_REQUEST: 913 + case BATADV_CLAIM_TYPE_REQUEST: 919 914 if (batadv_handle_request(bat_priv, primary_if, hw_src, ethhdr, 920 915 vid)) 921 916 return 1; 922 917 break; 923 918 } 924 919 925 - batadv_dbg(DBG_BLA, bat_priv, 920 + batadv_dbg(BATADV_DBG_BLA, bat_priv, 926 921 "bla_process_claim(): ERROR - this looks like a claim frame, but is useless. eth src %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n", 927 922 ethhdr->h_source, vid, hw_src, hw_dst); 928 923 return 1; ··· 931 926 /* Check when we last heard from other nodes, and remove them in case of 932 927 * a time out, or clean all backbone gws if now is set. 933 928 */ 934 - static void batadv_bla_purge_backbone_gw(struct bat_priv *bat_priv, int now) 929 + static void batadv_bla_purge_backbone_gw(struct batadv_priv *bat_priv, int now) 935 930 { 936 - struct backbone_gw *backbone_gw; 931 + struct batadv_backbone_gw *backbone_gw; 937 932 struct hlist_node *node, *node_tmp; 938 933 struct hlist_head *head; 939 - struct hashtable_t *hash; 934 + struct batadv_hashtable *hash; 940 935 spinlock_t *list_lock; /* protects write access to the hash lists */ 941 936 int i; 942 937 ··· 957 952 BATADV_BLA_BACKBONE_TIMEOUT)) 958 953 continue; 959 954 960 - batadv_dbg(DBG_BLA, backbone_gw->bat_priv, 955 + batadv_dbg(BATADV_DBG_BLA, backbone_gw->bat_priv, 961 956 "bla_purge_backbone_gw(): backbone gw %pM timed out\n", 962 957 backbone_gw->orig); 963 958 ··· 982 977 * Check when we heard last time from our own claims, and remove them in case of 983 978 * a time out, or clean all claims if now is set 984 979 */ 985 - static void batadv_bla_purge_claims(struct bat_priv *bat_priv, 986 - struct hard_iface *primary_if, int now) 980 + static void batadv_bla_purge_claims(struct batadv_priv *bat_priv, 981 + struct batadv_hard_iface *primary_if, 982 + int now) 987 983 { 988 - struct claim *claim; 984 + struct batadv_claim *claim; 989 985 struct hlist_node *node; 990 986 struct hlist_head *head; 991 - struct hashtable_t *hash; 987 + struct batadv_hashtable *hash; 992 988 int i; 993 989 994 990 hash = bat_priv->claim_hash; ··· 1010 1004 BATADV_BLA_CLAIM_TIMEOUT)) 1011 1005 continue; 1012 1006 1013 - batadv_dbg(DBG_BLA, bat_priv, 1007 + batadv_dbg(BATADV_DBG_BLA, bat_priv, 1014 1008 "bla_purge_claims(): %pM, vid %d, time out\n", 1015 1009 claim->addr, claim->vid); 1016 1010 ··· 1029 1023 * 1030 1024 * Update the backbone gateways when the own orig address changes. 1031 1025 */ 1032 - void batadv_bla_update_orig_address(struct bat_priv *bat_priv, 1033 - struct hard_iface *primary_if, 1034 - struct hard_iface *oldif) 1026 + void batadv_bla_update_orig_address(struct batadv_priv *bat_priv, 1027 + struct batadv_hard_iface *primary_if, 1028 + struct batadv_hard_iface *oldif) 1035 1029 { 1036 - struct backbone_gw *backbone_gw; 1030 + struct batadv_backbone_gw *backbone_gw; 1037 1031 struct hlist_node *node; 1038 1032 struct hlist_head *head; 1039 - struct hashtable_t *hash; 1033 + struct batadv_hashtable *hash; 1040 1034 int i; 1041 1035 1042 1036 /* reset bridge loop avoidance group id */ ··· 1077 1071 1078 1072 1079 1073 /* (re)start the timer */ 1080 - static void batadv_bla_start_timer(struct bat_priv *bat_priv) 1074 + static void batadv_bla_start_timer(struct batadv_priv *bat_priv) 1081 1075 { 1082 1076 INIT_DELAYED_WORK(&bat_priv->bla_work, batadv_bla_periodic_work); 1083 1077 queue_delayed_work(batadv_event_workqueue, &bat_priv->bla_work, ··· 1092 1086 { 1093 1087 struct delayed_work *delayed_work = 1094 1088 container_of(work, struct delayed_work, work); 1095 - struct bat_priv *bat_priv = 1096 - container_of(delayed_work, struct bat_priv, bla_work); 1089 + struct batadv_priv *bat_priv; 1097 1090 struct hlist_node *node; 1098 1091 struct hlist_head *head; 1099 - struct backbone_gw *backbone_gw; 1100 - struct hashtable_t *hash; 1101 - struct hard_iface *primary_if; 1092 + struct batadv_backbone_gw *backbone_gw; 1093 + struct batadv_hashtable *hash; 1094 + struct batadv_hard_iface *primary_if; 1102 1095 int i; 1103 1096 1097 + bat_priv = container_of(delayed_work, struct batadv_priv, bla_work); 1104 1098 primary_if = batadv_primary_if_get_selected(bat_priv); 1105 1099 if (!primary_if) 1106 1100 goto out; ··· 1146 1140 static struct lock_class_key batadv_backbone_hash_lock_class_key; 1147 1141 1148 1142 /* initialize all bla structures */ 1149 - int batadv_bla_init(struct bat_priv *bat_priv) 1143 + int batadv_bla_init(struct batadv_priv *bat_priv) 1150 1144 { 1151 1145 int i; 1152 1146 uint8_t claim_dest[ETH_ALEN] = {0xff, 0x43, 0x05, 0x00, 0x00, 0x00}; 1153 - struct hard_iface *primary_if; 1147 + struct batadv_hard_iface *primary_if; 1154 1148 1155 - batadv_dbg(DBG_BLA, bat_priv, "bla hash registering\n"); 1149 + batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla hash registering\n"); 1156 1150 1157 1151 /* setting claim destination address */ 1158 1152 memcpy(&bat_priv->claim_dest.magic, claim_dest, 3); ··· 1187 1181 batadv_hash_set_lock_class(bat_priv->backbone_hash, 1188 1182 &batadv_backbone_hash_lock_class_key); 1189 1183 1190 - batadv_dbg(DBG_BLA, bat_priv, "bla hashes initialized\n"); 1184 + batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla hashes initialized\n"); 1191 1185 1192 1186 batadv_bla_start_timer(bat_priv); 1193 1187 return 0; ··· 1206 1200 * sent by another host, drop it. We allow equal packets from 1207 1201 * the same host however as this might be intended. 1208 1202 */ 1209 - int batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv, 1210 - struct bcast_packet *bcast_packet, 1203 + int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, 1204 + struct batadv_bcast_packet *bcast_packet, 1211 1205 int hdr_size) 1212 1206 { 1213 1207 int i, length, curr; 1214 1208 uint8_t *content; 1215 1209 uint16_t crc; 1216 - struct bcast_duplist_entry *entry; 1210 + struct batadv_bcast_duplist_entry *entry; 1217 1211 1218 1212 length = hdr_size - sizeof(*bcast_packet); 1219 1213 content = (uint8_t *)bcast_packet; ··· 1266 1260 * 1267 1261 * returns 1 if it is found, 0 otherwise 1268 1262 */ 1269 - int batadv_bla_is_backbone_gw_orig(struct bat_priv *bat_priv, uint8_t *orig) 1263 + int batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, uint8_t *orig) 1270 1264 { 1271 - struct hashtable_t *hash = bat_priv->backbone_hash; 1265 + struct batadv_hashtable *hash = bat_priv->backbone_hash; 1272 1266 struct hlist_head *head; 1273 1267 struct hlist_node *node; 1274 - struct backbone_gw *backbone_gw; 1268 + struct batadv_backbone_gw *backbone_gw; 1275 1269 int i; 1276 1270 1277 1271 if (!atomic_read(&bat_priv->bridge_loop_avoidance)) ··· 1306 1300 * returns 0. 1307 1301 */ 1308 1302 int batadv_bla_is_backbone_gw(struct sk_buff *skb, 1309 - struct orig_node *orig_node, int hdr_size) 1303 + struct batadv_orig_node *orig_node, int hdr_size) 1310 1304 { 1311 1305 struct ethhdr *ethhdr; 1312 1306 struct vlan_ethhdr *vhdr; 1313 - struct backbone_gw *backbone_gw; 1307 + struct batadv_backbone_gw *backbone_gw; 1314 1308 short vid = -1; 1315 1309 1316 1310 if (!atomic_read(&orig_node->bat_priv->bridge_loop_avoidance)) ··· 1342 1336 } 1343 1337 1344 1338 /* free all bla structures (for softinterface free or module unload) */ 1345 - void batadv_bla_free(struct bat_priv *bat_priv) 1339 + void batadv_bla_free(struct batadv_priv *bat_priv) 1346 1340 { 1347 - struct hard_iface *primary_if; 1341 + struct batadv_hard_iface *primary_if; 1348 1342 1349 1343 cancel_delayed_work_sync(&bat_priv->bla_work); 1350 1344 primary_if = batadv_primary_if_get_selected(bat_priv); ··· 1375 1369 * returns 1, otherwise it returns 0 and the caller shall further 1376 1370 * process the skb. 1377 1371 */ 1378 - int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid) 1372 + int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid) 1379 1373 { 1380 1374 struct ethhdr *ethhdr; 1381 - struct claim search_claim, *claim = NULL; 1382 - struct hard_iface *primary_if; 1375 + struct batadv_claim search_claim, *claim = NULL; 1376 + struct batadv_hard_iface *primary_if; 1383 1377 int ret; 1384 1378 1385 1379 ethhdr = (struct ethhdr *)skb_mac_header(skb); ··· 1462 1456 * returns 1, otherwise it returns 0 and the caller shall further 1463 1457 * process the skb. 1464 1458 */ 1465 - int batadv_bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid) 1459 + int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid) 1466 1460 { 1467 1461 struct ethhdr *ethhdr; 1468 - struct claim search_claim, *claim = NULL; 1469 - struct hard_iface *primary_if; 1462 + struct batadv_claim search_claim, *claim = NULL; 1463 + struct batadv_hard_iface *primary_if; 1470 1464 int ret = 0; 1471 1465 1472 1466 primary_if = batadv_primary_if_get_selected(bat_priv); ··· 1539 1533 int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset) 1540 1534 { 1541 1535 struct net_device *net_dev = (struct net_device *)seq->private; 1542 - struct bat_priv *bat_priv = netdev_priv(net_dev); 1543 - struct hashtable_t *hash = bat_priv->claim_hash; 1544 - struct claim *claim; 1545 - struct hard_iface *primary_if; 1536 + struct batadv_priv *bat_priv = netdev_priv(net_dev); 1537 + struct batadv_hashtable *hash = bat_priv->claim_hash; 1538 + struct batadv_claim *claim; 1539 + struct batadv_hard_iface *primary_if; 1546 1540 struct hlist_node *node; 1547 1541 struct hlist_head *head; 1548 1542 uint32_t i; ··· 1558 1552 goto out; 1559 1553 } 1560 1554 1561 - if (primary_if->if_status != IF_ACTIVE) { 1555 + if (primary_if->if_status != BATADV_IF_ACTIVE) { 1562 1556 ret = seq_printf(seq, 1563 1557 "BATMAN mesh %s disabled - primary interface not active\n", 1564 1558 net_dev->name);
+24 -24
net/batman-adv/bridge_loop_avoidance.h
··· 21 21 #define _NET_BATMAN_ADV_BLA_H_ 22 22 23 23 #ifdef CONFIG_BATMAN_ADV_BLA 24 - int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid); 25 - int batadv_bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, short vid); 24 + int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid); 25 + int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid); 26 26 int batadv_bla_is_backbone_gw(struct sk_buff *skb, 27 - struct orig_node *orig_node, int hdr_size); 27 + struct batadv_orig_node *orig_node, int hdr_size); 28 28 int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset); 29 - int batadv_bla_is_backbone_gw_orig(struct bat_priv *bat_priv, uint8_t *orig); 30 - int batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv, 31 - struct bcast_packet *bcast_packet, 29 + int batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, uint8_t *orig); 30 + int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, 31 + struct batadv_bcast_packet *bcast_packet, 32 32 int hdr_size); 33 - void batadv_bla_update_orig_address(struct bat_priv *bat_priv, 34 - struct hard_iface *primary_if, 35 - struct hard_iface *oldif); 36 - int batadv_bla_init(struct bat_priv *bat_priv); 37 - void batadv_bla_free(struct bat_priv *bat_priv); 33 + void batadv_bla_update_orig_address(struct batadv_priv *bat_priv, 34 + struct batadv_hard_iface *primary_if, 35 + struct batadv_hard_iface *oldif); 36 + int batadv_bla_init(struct batadv_priv *bat_priv); 37 + void batadv_bla_free(struct batadv_priv *bat_priv); 38 38 39 39 #define BATADV_BLA_CRC_INIT 0 40 40 #else /* ifdef CONFIG_BATMAN_ADV_BLA */ 41 41 42 - static inline int batadv_bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb, 43 - short vid) 42 + static inline int batadv_bla_rx(struct batadv_priv *bat_priv, 43 + struct sk_buff *skb, short vid) 44 44 { 45 45 return 0; 46 46 } 47 47 48 - static inline int batadv_bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb, 49 - short vid) 48 + static inline int batadv_bla_tx(struct batadv_priv *bat_priv, 49 + struct sk_buff *skb, short vid) 50 50 { 51 51 return 0; 52 52 } 53 53 54 54 static inline int batadv_bla_is_backbone_gw(struct sk_buff *skb, 55 - struct orig_node *orig_node, 55 + struct batadv_orig_node *orig_node, 56 56 int hdr_size) 57 57 { 58 58 return 0; ··· 64 64 return 0; 65 65 } 66 66 67 - static inline int batadv_bla_is_backbone_gw_orig(struct bat_priv *bat_priv, 67 + static inline int batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, 68 68 uint8_t *orig) 69 69 { 70 70 return 0; 71 71 } 72 72 73 73 static inline int 74 - batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv, 75 - struct bcast_packet *bcast_packet, 74 + batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, 75 + struct batadv_bcast_packet *bcast_packet, 76 76 int hdr_size) 77 77 { 78 78 return 0; 79 79 } 80 80 81 81 static inline void 82 - batadv_bla_update_orig_address(struct bat_priv *bat_priv, 83 - struct hard_iface *primary_if, 84 - struct hard_iface *oldif) 82 + batadv_bla_update_orig_address(struct batadv_priv *bat_priv, 83 + struct batadv_hard_iface *primary_if, 84 + struct batadv_hard_iface *oldif) 85 85 { 86 86 } 87 87 88 - static inline int batadv_bla_init(struct bat_priv *bat_priv) 88 + static inline int batadv_bla_init(struct batadv_priv *bat_priv) 89 89 { 90 90 return 1; 91 91 } 92 92 93 - static inline void batadv_bla_free(struct bat_priv *bat_priv) 93 + static inline void batadv_bla_free(struct batadv_priv *bat_priv) 94 94 { 95 95 } 96 96
+67 -60
net/batman-adv/gateway_client.c
··· 18 18 */ 19 19 20 20 #include "main.h" 21 - #include "bat_sysfs.h" 21 + #include "sysfs.h" 22 22 #include "gateway_client.h" 23 23 #include "gateway_common.h" 24 24 #include "hard-interface.h" ··· 36 36 #define BATADV_DHCP_OPTIONS_OFFSET 240 37 37 #define BATADV_DHCP_REQUEST 3 38 38 39 - static void batadv_gw_node_free_ref(struct gw_node *gw_node) 39 + static void batadv_gw_node_free_ref(struct batadv_gw_node *gw_node) 40 40 { 41 41 if (atomic_dec_and_test(&gw_node->refcount)) 42 42 kfree_rcu(gw_node, rcu); 43 43 } 44 44 45 - static struct gw_node *batadv_gw_get_selected_gw_node(struct bat_priv *bat_priv) 45 + static struct batadv_gw_node * 46 + batadv_gw_get_selected_gw_node(struct batadv_priv *bat_priv) 46 47 { 47 - struct gw_node *gw_node; 48 + struct batadv_gw_node *gw_node; 48 49 49 50 rcu_read_lock(); 50 51 gw_node = rcu_dereference(bat_priv->curr_gw); ··· 60 59 return gw_node; 61 60 } 62 61 63 - struct orig_node *batadv_gw_get_selected_orig(struct bat_priv *bat_priv) 62 + struct batadv_orig_node * 63 + batadv_gw_get_selected_orig(struct batadv_priv *bat_priv) 64 64 { 65 - struct gw_node *gw_node; 66 - struct orig_node *orig_node = NULL; 65 + struct batadv_gw_node *gw_node; 66 + struct batadv_orig_node *orig_node = NULL; 67 67 68 68 gw_node = batadv_gw_get_selected_gw_node(bat_priv); 69 69 if (!gw_node) ··· 86 84 return orig_node; 87 85 } 88 86 89 - static void batadv_gw_select(struct bat_priv *bat_priv, 90 - struct gw_node *new_gw_node) 87 + static void batadv_gw_select(struct batadv_priv *bat_priv, 88 + struct batadv_gw_node *new_gw_node) 91 89 { 92 - struct gw_node *curr_gw_node; 90 + struct batadv_gw_node *curr_gw_node; 93 91 94 92 spin_lock_bh(&bat_priv->gw_list_lock); 95 93 ··· 105 103 spin_unlock_bh(&bat_priv->gw_list_lock); 106 104 } 107 105 108 - void batadv_gw_deselect(struct bat_priv *bat_priv) 106 + void batadv_gw_deselect(struct batadv_priv *bat_priv) 109 107 { 110 108 atomic_set(&bat_priv->gw_reselect, 1); 111 109 } 112 110 113 - static struct gw_node *batadv_gw_get_best_gw_node(struct bat_priv *bat_priv) 111 + static struct batadv_gw_node * 112 + batadv_gw_get_best_gw_node(struct batadv_priv *bat_priv) 114 113 { 115 - struct neigh_node *router; 114 + struct batadv_neigh_node *router; 116 115 struct hlist_node *node; 117 - struct gw_node *gw_node, *curr_gw = NULL; 116 + struct batadv_gw_node *gw_node, *curr_gw = NULL; 118 117 uint32_t max_gw_factor = 0, tmp_gw_factor = 0; 119 118 uint8_t max_tq = 0; 120 119 int down, up; 121 - struct orig_node *orig_node; 120 + struct batadv_orig_node *orig_node; 122 121 123 122 rcu_read_lock(); 124 123 hlist_for_each_entry_rcu(gw_node, node, &bat_priv->gw_list, list) { ··· 186 183 return curr_gw; 187 184 } 188 185 189 - void batadv_gw_election(struct bat_priv *bat_priv) 186 + void batadv_gw_election(struct batadv_priv *bat_priv) 190 187 { 191 - struct gw_node *curr_gw = NULL, *next_gw = NULL; 192 - struct neigh_node *router = NULL; 188 + struct batadv_gw_node *curr_gw = NULL, *next_gw = NULL; 189 + struct batadv_neigh_node *router = NULL; 193 190 char gw_addr[18] = { '\0' }; 194 191 195 192 /* The batman daemon checks here if we already passed a full originator ··· 197 194 * hear about. This check is based on the daemon's uptime which we 198 195 * don't have. 199 196 */ 200 - if (atomic_read(&bat_priv->gw_mode) != GW_MODE_CLIENT) 197 + if (atomic_read(&bat_priv->gw_mode) != BATADV_GW_MODE_CLIENT) 201 198 goto out; 202 199 203 200 if (!batadv_atomic_dec_not_zero(&bat_priv->gw_reselect)) ··· 221 218 } 222 219 223 220 if ((curr_gw) && (!next_gw)) { 224 - batadv_dbg(DBG_BATMAN, bat_priv, 221 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 225 222 "Removing selected gateway - no gateway in range\n"); 226 - batadv_throw_uevent(bat_priv, UEV_GW, UEV_DEL, NULL); 223 + batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_DEL, 224 + NULL); 227 225 } else if ((!curr_gw) && (next_gw)) { 228 - batadv_dbg(DBG_BATMAN, bat_priv, 226 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 229 227 "Adding route to gateway %pM (gw_flags: %i, tq: %i)\n", 230 228 next_gw->orig_node->orig, 231 229 next_gw->orig_node->gw_flags, router->tq_avg); 232 - batadv_throw_uevent(bat_priv, UEV_GW, UEV_ADD, gw_addr); 230 + batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_ADD, 231 + gw_addr); 233 232 } else { 234 - batadv_dbg(DBG_BATMAN, bat_priv, 233 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 235 234 "Changing route to gateway %pM (gw_flags: %i, tq: %i)\n", 236 235 next_gw->orig_node->orig, 237 236 next_gw->orig_node->gw_flags, router->tq_avg); 238 - batadv_throw_uevent(bat_priv, UEV_GW, UEV_CHANGE, gw_addr); 237 + batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_CHANGE, 238 + gw_addr); 239 239 } 240 240 241 241 batadv_gw_select(bat_priv, next_gw); ··· 252 246 batadv_neigh_node_free_ref(router); 253 247 } 254 248 255 - void batadv_gw_check_election(struct bat_priv *bat_priv, 256 - struct orig_node *orig_node) 249 + void batadv_gw_check_election(struct batadv_priv *bat_priv, 250 + struct batadv_orig_node *orig_node) 257 251 { 258 - struct orig_node *curr_gw_orig; 259 - struct neigh_node *router_gw = NULL, *router_orig = NULL; 252 + struct batadv_orig_node *curr_gw_orig; 253 + struct batadv_neigh_node *router_gw = NULL, *router_orig = NULL; 260 254 uint8_t gw_tq_avg, orig_tq_avg; 261 255 262 256 curr_gw_orig = batadv_gw_get_selected_orig(bat_priv); ··· 289 283 (orig_tq_avg - gw_tq_avg < atomic_read(&bat_priv->gw_sel_class))) 290 284 goto out; 291 285 292 - batadv_dbg(DBG_BATMAN, bat_priv, 286 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 293 287 "Restarting gateway selection: better gateway found (tq curr: %i, tq new: %i)\n", 294 288 gw_tq_avg, orig_tq_avg); 295 289 ··· 306 300 return; 307 301 } 308 302 309 - static void batadv_gw_node_add(struct bat_priv *bat_priv, 310 - struct orig_node *orig_node, 303 + static void batadv_gw_node_add(struct batadv_priv *bat_priv, 304 + struct batadv_orig_node *orig_node, 311 305 uint8_t new_gwflags) 312 306 { 313 - struct gw_node *gw_node; 307 + struct batadv_gw_node *gw_node; 314 308 int down, up; 315 309 316 310 gw_node = kzalloc(sizeof(*gw_node), GFP_ATOMIC); ··· 326 320 spin_unlock_bh(&bat_priv->gw_list_lock); 327 321 328 322 batadv_gw_bandwidth_to_kbit(new_gwflags, &down, &up); 329 - batadv_dbg(DBG_BATMAN, bat_priv, 323 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 330 324 "Found new gateway %pM -> gw_class: %i - %i%s/%i%s\n", 331 325 orig_node->orig, new_gwflags, 332 326 (down > 2048 ? down / 1024 : down), ··· 335 329 (up > 2048 ? "MBit" : "KBit")); 336 330 } 337 331 338 - void batadv_gw_node_update(struct bat_priv *bat_priv, 339 - struct orig_node *orig_node, uint8_t new_gwflags) 332 + void batadv_gw_node_update(struct batadv_priv *bat_priv, 333 + struct batadv_orig_node *orig_node, 334 + uint8_t new_gwflags) 340 335 { 341 336 struct hlist_node *node; 342 - struct gw_node *gw_node, *curr_gw; 337 + struct batadv_gw_node *gw_node, *curr_gw; 343 338 344 339 /* Note: We don't need a NULL check here, since curr_gw never gets 345 340 * dereferenced. If curr_gw is NULL we also should not exit as we may ··· 354 347 if (gw_node->orig_node != orig_node) 355 348 continue; 356 349 357 - batadv_dbg(DBG_BATMAN, bat_priv, 350 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 358 351 "Gateway class of originator %pM changed from %i to %i\n", 359 352 orig_node->orig, gw_node->orig_node->gw_flags, 360 353 new_gwflags); ··· 363 356 364 357 if (new_gwflags == BATADV_NO_FLAGS) { 365 358 gw_node->deleted = jiffies; 366 - batadv_dbg(DBG_BATMAN, bat_priv, 359 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 367 360 "Gateway %pM removed from gateway list\n", 368 361 orig_node->orig); 369 362 ··· 389 382 batadv_gw_node_free_ref(curr_gw); 390 383 } 391 384 392 - void batadv_gw_node_delete(struct bat_priv *bat_priv, 393 - struct orig_node *orig_node) 385 + void batadv_gw_node_delete(struct batadv_priv *bat_priv, 386 + struct batadv_orig_node *orig_node) 394 387 { 395 388 batadv_gw_node_update(bat_priv, orig_node, 0); 396 389 } 397 390 398 - void batadv_gw_node_purge(struct bat_priv *bat_priv) 391 + void batadv_gw_node_purge(struct batadv_priv *bat_priv) 399 392 { 400 - struct gw_node *gw_node, *curr_gw; 393 + struct batadv_gw_node *gw_node, *curr_gw; 401 394 struct hlist_node *node, *node_tmp; 402 395 unsigned long timeout = msecs_to_jiffies(2 * BATADV_PURGE_TIMEOUT); 403 396 int do_deselect = 0; ··· 410 403 &bat_priv->gw_list, list) { 411 404 if (((!gw_node->deleted) || 412 405 (time_before(jiffies, gw_node->deleted + timeout))) && 413 - atomic_read(&bat_priv->mesh_state) == MESH_ACTIVE) 406 + atomic_read(&bat_priv->mesh_state) == BATADV_MESH_ACTIVE) 414 407 continue; 415 408 416 409 if (curr_gw == gw_node) ··· 431 424 } 432 425 433 426 /* fails if orig_node has no router */ 434 - static int batadv_write_buffer_text(struct bat_priv *bat_priv, 435 - struct seq_file *seq, 436 - const struct gw_node *gw_node) 427 + static int batadv_write_buffer_text(struct batadv_priv *bat_priv, 428 + struct seq_file *seq, 429 + const struct batadv_gw_node *gw_node) 437 430 { 438 - struct gw_node *curr_gw; 439 - struct neigh_node *router; 431 + struct batadv_gw_node *curr_gw; 432 + struct batadv_neigh_node *router; 440 433 int down, up, ret = -1; 441 434 442 435 batadv_gw_bandwidth_to_kbit(gw_node->orig_node->gw_flags, &down, &up); ··· 468 461 int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset) 469 462 { 470 463 struct net_device *net_dev = (struct net_device *)seq->private; 471 - struct bat_priv *bat_priv = netdev_priv(net_dev); 472 - struct hard_iface *primary_if; 473 - struct gw_node *gw_node; 464 + struct batadv_priv *bat_priv = netdev_priv(net_dev); 465 + struct batadv_hard_iface *primary_if; 466 + struct batadv_gw_node *gw_node; 474 467 struct hlist_node *node; 475 468 int gw_count = 0, ret = 0; 476 469 ··· 482 475 goto out; 483 476 } 484 477 485 - if (primary_if->if_status != IF_ACTIVE) { 478 + if (primary_if->if_status != BATADV_IF_ACTIVE) { 486 479 ret = seq_printf(seq, 487 480 "BATMAN mesh %s disabled - primary interface not active\n", 488 481 net_dev->name); ··· 643 636 return true; 644 637 } 645 638 646 - bool batadv_gw_out_of_range(struct bat_priv *bat_priv, 639 + bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, 647 640 struct sk_buff *skb, struct ethhdr *ethhdr) 648 641 { 649 - struct neigh_node *neigh_curr = NULL, *neigh_old = NULL; 650 - struct orig_node *orig_dst_node = NULL; 651 - struct gw_node *curr_gw = NULL; 642 + struct batadv_neigh_node *neigh_curr = NULL, *neigh_old = NULL; 643 + struct batadv_orig_node *orig_dst_node = NULL; 644 + struct batadv_gw_node *curr_gw = NULL; 652 645 bool ret, out_of_range = false; 653 646 unsigned int header_len = 0; 654 647 uint8_t curr_tq_avg; ··· 670 663 goto out; 671 664 672 665 switch (atomic_read(&bat_priv->gw_mode)) { 673 - case GW_MODE_SERVER: 666 + case BATADV_GW_MODE_SERVER: 674 667 /* If we are a GW then we are our best GW. We can artificially 675 668 * set the tq towards ourself as the maximum value 676 669 */ 677 670 curr_tq_avg = BATADV_TQ_MAX_VALUE; 678 671 break; 679 - case GW_MODE_CLIENT: 672 + case BATADV_GW_MODE_CLIENT: 680 673 curr_gw = batadv_gw_get_selected_gw_node(bat_priv); 681 674 if (!curr_gw) 682 675 goto out; ··· 696 689 697 690 curr_tq_avg = neigh_curr->tq_avg; 698 691 break; 699 - case GW_MODE_OFF: 692 + case BATADV_GW_MODE_OFF: 700 693 default: 701 694 goto out; 702 695 }
+13 -11
net/batman-adv/gateway_client.h
··· 20 20 #ifndef _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ 21 21 #define _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ 22 22 23 - void batadv_gw_deselect(struct bat_priv *bat_priv); 24 - void batadv_gw_election(struct bat_priv *bat_priv); 25 - struct orig_node *batadv_gw_get_selected_orig(struct bat_priv *bat_priv); 26 - void batadv_gw_check_election(struct bat_priv *bat_priv, 27 - struct orig_node *orig_node); 28 - void batadv_gw_node_update(struct bat_priv *bat_priv, 29 - struct orig_node *orig_node, uint8_t new_gwflags); 30 - void batadv_gw_node_delete(struct bat_priv *bat_priv, 31 - struct orig_node *orig_node); 32 - void batadv_gw_node_purge(struct bat_priv *bat_priv); 23 + void batadv_gw_deselect(struct batadv_priv *bat_priv); 24 + void batadv_gw_election(struct batadv_priv *bat_priv); 25 + struct batadv_orig_node * 26 + batadv_gw_get_selected_orig(struct batadv_priv *bat_priv); 27 + void batadv_gw_check_election(struct batadv_priv *bat_priv, 28 + struct batadv_orig_node *orig_node); 29 + void batadv_gw_node_update(struct batadv_priv *bat_priv, 30 + struct batadv_orig_node *orig_node, 31 + uint8_t new_gwflags); 32 + void batadv_gw_node_delete(struct batadv_priv *bat_priv, 33 + struct batadv_orig_node *orig_node); 34 + void batadv_gw_node_purge(struct batadv_priv *bat_priv); 33 35 int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset); 34 36 bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len); 35 - bool batadv_gw_out_of_range(struct bat_priv *bat_priv, 37 + bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, 36 38 struct sk_buff *skb, struct ethhdr *ethhdr); 37 39 38 40 #endif /* _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ */
+1 -1
net/batman-adv/gateway_common.c
··· 137 137 ssize_t batadv_gw_bandwidth_set(struct net_device *net_dev, char *buff, 138 138 size_t count) 139 139 { 140 - struct bat_priv *bat_priv = netdev_priv(net_dev); 140 + struct batadv_priv *bat_priv = netdev_priv(net_dev); 141 141 long gw_bandwidth_tmp = 0; 142 142 int up = 0, down = 0; 143 143 bool ret;
+4 -4
net/batman-adv/gateway_common.h
··· 20 20 #ifndef _NET_BATMAN_ADV_GATEWAY_COMMON_H_ 21 21 #define _NET_BATMAN_ADV_GATEWAY_COMMON_H_ 22 22 23 - enum gw_modes { 24 - GW_MODE_OFF, 25 - GW_MODE_CLIENT, 26 - GW_MODE_SERVER, 23 + enum batadv_gw_modes { 24 + BATADV_GW_MODE_OFF, 25 + BATADV_GW_MODE_CLIENT, 26 + BATADV_GW_MODE_SERVER, 27 27 }; 28 28 29 29 #define BATADV_GW_MODE_OFF_NAME "off"
+65 -60
net/batman-adv/hard-interface.c
··· 23 23 #include "send.h" 24 24 #include "translation-table.h" 25 25 #include "routing.h" 26 - #include "bat_sysfs.h" 26 + #include "sysfs.h" 27 27 #include "originator.h" 28 28 #include "hash.h" 29 29 #include "bridge_loop_avoidance.h" ··· 32 32 33 33 void batadv_hardif_free_rcu(struct rcu_head *rcu) 34 34 { 35 - struct hard_iface *hard_iface; 35 + struct batadv_hard_iface *hard_iface; 36 36 37 - hard_iface = container_of(rcu, struct hard_iface, rcu); 37 + hard_iface = container_of(rcu, struct batadv_hard_iface, rcu); 38 38 dev_put(hard_iface->net_dev); 39 39 kfree(hard_iface); 40 40 } 41 41 42 - struct hard_iface *batadv_hardif_get_by_netdev(const struct net_device *net_dev) 42 + struct batadv_hard_iface * 43 + batadv_hardif_get_by_netdev(const struct net_device *net_dev) 43 44 { 44 - struct hard_iface *hard_iface; 45 + struct batadv_hard_iface *hard_iface; 45 46 46 47 rcu_read_lock(); 47 48 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { ··· 76 75 return 1; 77 76 } 78 77 79 - static struct hard_iface * 78 + static struct batadv_hard_iface * 80 79 batadv_hardif_get_active(const struct net_device *soft_iface) 81 80 { 82 - struct hard_iface *hard_iface; 81 + struct batadv_hard_iface *hard_iface; 83 82 84 83 rcu_read_lock(); 85 84 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { 86 85 if (hard_iface->soft_iface != soft_iface) 87 86 continue; 88 87 89 - if (hard_iface->if_status == IF_ACTIVE && 88 + if (hard_iface->if_status == BATADV_IF_ACTIVE && 90 89 atomic_inc_not_zero(&hard_iface->refcount)) 91 90 goto out; 92 91 } ··· 98 97 return hard_iface; 99 98 } 100 99 101 - static void batadv_primary_if_update_addr(struct bat_priv *bat_priv, 102 - struct hard_iface *oldif) 100 + static void batadv_primary_if_update_addr(struct batadv_priv *bat_priv, 101 + struct batadv_hard_iface *oldif) 103 102 { 104 - struct vis_packet *vis_packet; 105 - struct hard_iface *primary_if; 103 + struct batadv_vis_packet *vis_packet; 104 + struct batadv_hard_iface *primary_if; 106 105 107 106 primary_if = batadv_primary_if_get_selected(bat_priv); 108 107 if (!primary_if) 109 108 goto out; 110 109 111 - vis_packet = (struct vis_packet *) 110 + vis_packet = (struct batadv_vis_packet *) 112 111 bat_priv->my_vis_info->skb_packet->data; 113 112 memcpy(vis_packet->vis_orig, primary_if->net_dev->dev_addr, ETH_ALEN); 114 113 memcpy(vis_packet->sender_orig, ··· 120 119 batadv_hardif_free_ref(primary_if); 121 120 } 122 121 123 - static void batadv_primary_if_select(struct bat_priv *bat_priv, 124 - struct hard_iface *new_hard_iface) 122 + static void batadv_primary_if_select(struct batadv_priv *bat_priv, 123 + struct batadv_hard_iface *new_hard_iface) 125 124 { 126 - struct hard_iface *curr_hard_iface; 125 + struct batadv_hard_iface *curr_hard_iface; 127 126 128 127 ASSERT_RTNL(); 129 128 ··· 144 143 batadv_hardif_free_ref(curr_hard_iface); 145 144 } 146 145 147 - static bool batadv_hardif_is_iface_up(const struct hard_iface *hard_iface) 146 + static bool 147 + batadv_hardif_is_iface_up(const struct batadv_hard_iface *hard_iface) 148 148 { 149 149 if (hard_iface->net_dev->flags & IFF_UP) 150 150 return true; ··· 155 153 156 154 static void batadv_check_known_mac_addr(const struct net_device *net_dev) 157 155 { 158 - const struct hard_iface *hard_iface; 156 + const struct batadv_hard_iface *hard_iface; 159 157 160 158 rcu_read_lock(); 161 159 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { 162 - if ((hard_iface->if_status != IF_ACTIVE) && 163 - (hard_iface->if_status != IF_TO_BE_ACTIVATED)) 160 + if ((hard_iface->if_status != BATADV_IF_ACTIVE) && 161 + (hard_iface->if_status != BATADV_IF_TO_BE_ACTIVATED)) 164 162 continue; 165 163 166 164 if (hard_iface->net_dev == net_dev) ··· 179 177 180 178 int batadv_hardif_min_mtu(struct net_device *soft_iface) 181 179 { 182 - const struct bat_priv *bat_priv = netdev_priv(soft_iface); 183 - const struct hard_iface *hard_iface; 180 + const struct batadv_priv *bat_priv = netdev_priv(soft_iface); 181 + const struct batadv_hard_iface *hard_iface; 184 182 /* allow big frames if all devices are capable to do so 185 183 * (have MTU > 1500 + BAT_HEADER_LEN) 186 184 */ ··· 191 189 192 190 rcu_read_lock(); 193 191 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { 194 - if ((hard_iface->if_status != IF_ACTIVE) && 195 - (hard_iface->if_status != IF_TO_BE_ACTIVATED)) 192 + if ((hard_iface->if_status != BATADV_IF_ACTIVE) && 193 + (hard_iface->if_status != BATADV_IF_TO_BE_ACTIVATED)) 196 194 continue; 197 195 198 196 if (hard_iface->soft_iface != soft_iface) ··· 217 215 soft_iface->mtu = min_mtu; 218 216 } 219 217 220 - static void batadv_hardif_activate_interface(struct hard_iface *hard_iface) 218 + static void 219 + batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface) 221 220 { 222 - struct bat_priv *bat_priv; 223 - struct hard_iface *primary_if = NULL; 221 + struct batadv_priv *bat_priv; 222 + struct batadv_hard_iface *primary_if = NULL; 224 223 225 - if (hard_iface->if_status != IF_INACTIVE) 224 + if (hard_iface->if_status != BATADV_IF_INACTIVE) 226 225 goto out; 227 226 228 227 bat_priv = netdev_priv(hard_iface->soft_iface); 229 228 230 229 bat_priv->bat_algo_ops->bat_iface_update_mac(hard_iface); 231 - hard_iface->if_status = IF_TO_BE_ACTIVATED; 230 + hard_iface->if_status = BATADV_IF_TO_BE_ACTIVATED; 232 231 233 232 /* the first active interface becomes our primary interface or 234 233 * the next active interface after the old primary interface was removed ··· 248 245 batadv_hardif_free_ref(primary_if); 249 246 } 250 247 251 - static void batadv_hardif_deactivate_interface(struct hard_iface *hard_iface) 248 + static void 249 + batadv_hardif_deactivate_interface(struct batadv_hard_iface *hard_iface) 252 250 { 253 - if ((hard_iface->if_status != IF_ACTIVE) && 254 - (hard_iface->if_status != IF_TO_BE_ACTIVATED)) 251 + if ((hard_iface->if_status != BATADV_IF_ACTIVE) && 252 + (hard_iface->if_status != BATADV_IF_TO_BE_ACTIVATED)) 255 253 return; 256 254 257 - hard_iface->if_status = IF_INACTIVE; 255 + hard_iface->if_status = BATADV_IF_INACTIVE; 258 256 259 257 batadv_info(hard_iface->soft_iface, "Interface deactivated: %s\n", 260 258 hard_iface->net_dev->name); ··· 263 259 batadv_update_min_mtu(hard_iface->soft_iface); 264 260 } 265 261 266 - int batadv_hardif_enable_interface(struct hard_iface *hard_iface, 262 + int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface, 267 263 const char *iface_name) 268 264 { 269 - struct bat_priv *bat_priv; 265 + struct batadv_priv *bat_priv; 270 266 struct net_device *soft_iface; 271 267 __be16 ethertype = __constant_htons(BATADV_ETH_P_BATMAN); 272 268 int ret; 273 269 274 - if (hard_iface->if_status != IF_NOT_IN_USE) 270 + if (hard_iface->if_status != BATADV_IF_NOT_IN_USE) 275 271 goto out; 276 272 277 273 if (!atomic_inc_not_zero(&hard_iface->refcount)) ··· 312 308 313 309 hard_iface->if_num = bat_priv->num_ifaces; 314 310 bat_priv->num_ifaces++; 315 - hard_iface->if_status = IF_INACTIVE; 311 + hard_iface->if_status = BATADV_IF_INACTIVE; 316 312 batadv_orig_hash_add_if(hard_iface, bat_priv->num_ifaces); 317 313 318 314 hard_iface->batman_adv_ptype.type = ethertype; ··· 324 320 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n", 325 321 hard_iface->net_dev->name); 326 322 327 - if (atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu < 328 - ETH_DATA_LEN + BATADV_HEADER_LEN) 323 + if (atomic_read(&bat_priv->fragmentation) && 324 + hard_iface->net_dev->mtu < ETH_DATA_LEN + BATADV_HEADER_LEN) 329 325 batadv_info(hard_iface->soft_iface, 330 326 "The MTU of interface %s is too small (%i) to handle the transport of batman-adv packets. Packets going over this interface will be fragmented on layer2 which could impact the performance. Setting the MTU to %zi would solve the problem.\n", 331 327 hard_iface->net_dev->name, hard_iface->net_dev->mtu, 332 328 ETH_DATA_LEN + BATADV_HEADER_LEN); 333 329 334 - if (!atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu < 335 - ETH_DATA_LEN + BATADV_HEADER_LEN) 330 + if (!atomic_read(&bat_priv->fragmentation) && 331 + hard_iface->net_dev->mtu < ETH_DATA_LEN + BATADV_HEADER_LEN) 336 332 batadv_info(hard_iface->soft_iface, 337 333 "The MTU of interface %s is too small (%i) to handle the transport of batman-adv packets. If you experience problems getting traffic through try increasing the MTU to %zi.\n", 338 334 hard_iface->net_dev->name, hard_iface->net_dev->mtu, ··· 358 354 return ret; 359 355 } 360 356 361 - void batadv_hardif_disable_interface(struct hard_iface *hard_iface) 357 + void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface) 362 358 { 363 - struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 364 - struct hard_iface *primary_if = NULL; 359 + struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 360 + struct batadv_hard_iface *primary_if = NULL; 365 361 366 - if (hard_iface->if_status == IF_ACTIVE) 362 + if (hard_iface->if_status == BATADV_IF_ACTIVE) 367 363 batadv_hardif_deactivate_interface(hard_iface); 368 364 369 - if (hard_iface->if_status != IF_INACTIVE) 365 + if (hard_iface->if_status != BATADV_IF_INACTIVE) 370 366 goto out; 371 367 372 368 batadv_info(hard_iface->soft_iface, "Removing interface: %s\n", ··· 378 374 379 375 primary_if = batadv_primary_if_get_selected(bat_priv); 380 376 if (hard_iface == primary_if) { 381 - struct hard_iface *new_if; 377 + struct batadv_hard_iface *new_if; 382 378 383 379 new_if = batadv_hardif_get_active(hard_iface->soft_iface); 384 380 batadv_primary_if_select(bat_priv, new_if); ··· 388 384 } 389 385 390 386 bat_priv->bat_algo_ops->bat_iface_disable(hard_iface); 391 - hard_iface->if_status = IF_NOT_IN_USE; 387 + hard_iface->if_status = BATADV_IF_NOT_IN_USE; 392 388 393 389 /* delete all references to this hard_iface */ 394 390 batadv_purge_orig_ref(bat_priv); ··· 407 403 batadv_hardif_free_ref(primary_if); 408 404 } 409 405 410 - static struct hard_iface * 406 + static struct batadv_hard_iface * 411 407 batadv_hardif_add_interface(struct net_device *net_dev) 412 408 { 413 - struct hard_iface *hard_iface; 409 + struct batadv_hard_iface *hard_iface; 414 410 int ret; 415 411 416 412 ASSERT_RTNL(); ··· 432 428 hard_iface->if_num = -1; 433 429 hard_iface->net_dev = net_dev; 434 430 hard_iface->soft_iface = NULL; 435 - hard_iface->if_status = IF_NOT_IN_USE; 431 + hard_iface->if_status = BATADV_IF_NOT_IN_USE; 436 432 INIT_LIST_HEAD(&hard_iface->list); 437 433 /* extra reference for return */ 438 434 atomic_set(&hard_iface->refcount, 2); ··· 456 452 return NULL; 457 453 } 458 454 459 - static void batadv_hardif_remove_interface(struct hard_iface *hard_iface) 455 + static void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface) 460 456 { 461 457 ASSERT_RTNL(); 462 458 463 459 /* first deactivate interface */ 464 - if (hard_iface->if_status != IF_NOT_IN_USE) 460 + if (hard_iface->if_status != BATADV_IF_NOT_IN_USE) 465 461 batadv_hardif_disable_interface(hard_iface); 466 462 467 - if (hard_iface->if_status != IF_NOT_IN_USE) 463 + if (hard_iface->if_status != BATADV_IF_NOT_IN_USE) 468 464 return; 469 465 470 - hard_iface->if_status = IF_TO_BE_REMOVED; 466 + hard_iface->if_status = BATADV_IF_TO_BE_REMOVED; 471 467 batadv_sysfs_del_hardif(&hard_iface->hardif_obj); 472 468 batadv_hardif_free_ref(hard_iface); 473 469 } 474 470 475 471 void batadv_hardif_remove_interfaces(void) 476 472 { 477 - struct hard_iface *hard_iface, *hard_iface_tmp; 473 + struct batadv_hard_iface *hard_iface, *hard_iface_tmp; 478 474 479 475 rtnl_lock(); 480 476 list_for_each_entry_safe(hard_iface, hard_iface_tmp, ··· 489 485 unsigned long event, void *ptr) 490 486 { 491 487 struct net_device *net_dev = ptr; 492 - struct hard_iface *hard_iface = batadv_hardif_get_by_netdev(net_dev); 493 - struct hard_iface *primary_if = NULL; 494 - struct bat_priv *bat_priv; 488 + struct batadv_hard_iface *hard_iface; 489 + struct batadv_hard_iface *primary_if = NULL; 490 + struct batadv_priv *bat_priv; 495 491 492 + hard_iface = batadv_hardif_get_by_netdev(net_dev); 496 493 if (!hard_iface && event == NETDEV_REGISTER) 497 494 hard_iface = batadv_hardif_add_interface(net_dev); 498 495 ··· 518 513 batadv_update_min_mtu(hard_iface->soft_iface); 519 514 break; 520 515 case NETDEV_CHANGEADDR: 521 - if (hard_iface->if_status == IF_NOT_IN_USE) 516 + if (hard_iface->if_status == BATADV_IF_NOT_IN_USE) 522 517 goto hardif_put; 523 518 524 519 batadv_check_known_mac_addr(hard_iface->net_dev);
+14 -14
net/batman-adv/hard-interface.h
··· 20 20 #ifndef _NET_BATMAN_ADV_HARD_INTERFACE_H_ 21 21 #define _NET_BATMAN_ADV_HARD_INTERFACE_H_ 22 22 23 - enum hard_if_state { 24 - IF_NOT_IN_USE, 25 - IF_TO_BE_REMOVED, 26 - IF_INACTIVE, 27 - IF_ACTIVE, 28 - IF_TO_BE_ACTIVATED, 29 - IF_I_WANT_YOU 23 + enum batadv_hard_if_state { 24 + BATADV_IF_NOT_IN_USE, 25 + BATADV_IF_TO_BE_REMOVED, 26 + BATADV_IF_INACTIVE, 27 + BATADV_IF_ACTIVE, 28 + BATADV_IF_TO_BE_ACTIVATED, 29 + BATADV_IF_I_WANT_YOU, 30 30 }; 31 31 32 32 extern struct notifier_block batadv_hard_if_notifier; 33 33 34 - struct hard_iface* 34 + struct batadv_hard_iface* 35 35 batadv_hardif_get_by_netdev(const struct net_device *net_dev); 36 - int batadv_hardif_enable_interface(struct hard_iface *hard_iface, 36 + int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface, 37 37 const char *iface_name); 38 - void batadv_hardif_disable_interface(struct hard_iface *hard_iface); 38 + void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface); 39 39 void batadv_hardif_remove_interfaces(void); 40 40 int batadv_hardif_min_mtu(struct net_device *soft_iface); 41 41 void batadv_update_min_mtu(struct net_device *soft_iface); ··· 43 43 bool batadv_is_wifi_iface(int ifindex); 44 44 45 45 static inline void 46 - batadv_hardif_free_ref(struct hard_iface *hard_iface) 46 + batadv_hardif_free_ref(struct batadv_hard_iface *hard_iface) 47 47 { 48 48 if (atomic_dec_and_test(&hard_iface->refcount)) 49 49 call_rcu(&hard_iface->rcu, batadv_hardif_free_rcu); 50 50 } 51 51 52 - static inline struct hard_iface * 53 - batadv_primary_if_get_selected(struct bat_priv *bat_priv) 52 + static inline struct batadv_hard_iface * 53 + batadv_primary_if_get_selected(struct batadv_priv *bat_priv) 54 54 { 55 - struct hard_iface *hard_iface; 55 + struct batadv_hard_iface *hard_iface; 56 56 57 57 rcu_read_lock(); 58 58 hard_iface = rcu_dereference(bat_priv->primary_if);
+6 -6
net/batman-adv/hash.c
··· 21 21 #include "hash.h" 22 22 23 23 /* clears the hash */ 24 - static void batadv_hash_init(struct hashtable_t *hash) 24 + static void batadv_hash_init(struct batadv_hashtable *hash) 25 25 { 26 26 uint32_t i; 27 27 28 - for (i = 0 ; i < hash->size; i++) { 28 + for (i = 0; i < hash->size; i++) { 29 29 INIT_HLIST_HEAD(&hash->table[i]); 30 30 spin_lock_init(&hash->list_locks[i]); 31 31 } 32 32 } 33 33 34 34 /* free only the hashtable and the hash itself. */ 35 - void batadv_hash_destroy(struct hashtable_t *hash) 35 + void batadv_hash_destroy(struct batadv_hashtable *hash) 36 36 { 37 37 kfree(hash->list_locks); 38 38 kfree(hash->table); ··· 40 40 } 41 41 42 42 /* allocates and clears the hash */ 43 - struct hashtable_t *batadv_hash_new(uint32_t size) 43 + struct batadv_hashtable *batadv_hash_new(uint32_t size) 44 44 { 45 - struct hashtable_t *hash; 45 + struct batadv_hashtable *hash; 46 46 47 47 hash = kmalloc(sizeof(*hash), GFP_ATOMIC); 48 48 if (!hash) ··· 68 68 return NULL; 69 69 } 70 70 71 - void batadv_hash_set_lock_class(struct hashtable_t *hash, 71 + void batadv_hash_set_lock_class(struct batadv_hashtable *hash, 72 72 struct lock_class_key *key) 73 73 { 74 74 uint32_t i;
+18 -15
net/batman-adv/hash.h
··· 25 25 /* callback to a compare function. should compare 2 element datas for their 26 26 * keys, return 0 if same and not 0 if not same 27 27 */ 28 - typedef int (*hashdata_compare_cb)(const struct hlist_node *, const void *); 28 + typedef int (*batadv_hashdata_compare_cb)(const struct hlist_node *, 29 + const void *); 29 30 30 31 /* the hashfunction, should return an index 31 32 * based on the key in the data of the first 32 33 * argument and the size the second 33 34 */ 34 - typedef uint32_t (*hashdata_choose_cb)(const void *, uint32_t); 35 - typedef void (*hashdata_free_cb)(struct hlist_node *, void *); 35 + typedef uint32_t (*batadv_hashdata_choose_cb)(const void *, uint32_t); 36 + typedef void (*batadv_hashdata_free_cb)(struct hlist_node *, void *); 36 37 37 - struct hashtable_t { 38 + struct batadv_hashtable { 38 39 struct hlist_head *table; /* the hashtable itself with the buckets */ 39 40 spinlock_t *list_locks; /* spinlock for each hash list entry */ 40 41 uint32_t size; /* size of hashtable */ 41 42 }; 42 43 43 44 /* allocates and clears the hash */ 44 - struct hashtable_t *batadv_hash_new(uint32_t size); 45 + struct batadv_hashtable *batadv_hash_new(uint32_t size); 45 46 46 47 /* set class key for all locks */ 47 - void batadv_hash_set_lock_class(struct hashtable_t *hash, 48 + void batadv_hash_set_lock_class(struct batadv_hashtable *hash, 48 49 struct lock_class_key *key); 49 50 50 51 /* free only the hashtable and the hash itself. */ 51 - void batadv_hash_destroy(struct hashtable_t *hash); 52 + void batadv_hash_destroy(struct batadv_hashtable *hash); 52 53 53 54 /* remove the hash structure. if hashdata_free_cb != NULL, this function will be 54 55 * called to remove the elements inside of the hash. if you don't remove the 55 56 * elements, memory might be leaked. 56 57 */ 57 - static inline void batadv_hash_delete(struct hashtable_t *hash, 58 - hashdata_free_cb free_cb, void *arg) 58 + static inline void batadv_hash_delete(struct batadv_hashtable *hash, 59 + batadv_hashdata_free_cb free_cb, 60 + void *arg) 59 61 { 60 62 struct hlist_head *head; 61 63 struct hlist_node *node, *node_tmp; ··· 91 89 * Returns 0 on success, 1 if the element already is in the hash 92 90 * and -1 on error. 93 91 */ 94 - static inline int batadv_hash_add(struct hashtable_t *hash, 95 - hashdata_compare_cb compare, 96 - hashdata_choose_cb choose, 92 + static inline int batadv_hash_add(struct batadv_hashtable *hash, 93 + batadv_hashdata_compare_cb compare, 94 + batadv_hashdata_choose_cb choose, 97 95 const void *data, 98 96 struct hlist_node *data_node) 99 97 { ··· 136 134 * structure you use with just the key filled, we just need the key for 137 135 * comparing. 138 136 */ 139 - static inline void *batadv_hash_remove(struct hashtable_t *hash, 140 - hashdata_compare_cb compare, 141 - hashdata_choose_cb choose, void *data) 137 + static inline void *batadv_hash_remove(struct batadv_hashtable *hash, 138 + batadv_hashdata_compare_cb compare, 139 + batadv_hashdata_choose_cb choose, 140 + void *data) 142 141 { 143 142 uint32_t index; 144 143 struct hlist_node *node;
+41 -40
net/batman-adv/icmp_socket.c
··· 26 26 #include "originator.h" 27 27 #include "hard-interface.h" 28 28 29 - static struct socket_client *batadv_socket_client_hash[256]; 29 + static struct batadv_socket_client *batadv_socket_client_hash[256]; 30 30 31 - static void batadv_socket_add_packet(struct socket_client *socket_client, 32 - struct icmp_packet_rr *icmp_packet, 31 + static void batadv_socket_add_packet(struct batadv_socket_client *socket_client, 32 + struct batadv_icmp_packet_rr *icmp_packet, 33 33 size_t icmp_len); 34 34 35 35 void batadv_socket_init(void) ··· 40 40 static int batadv_socket_open(struct inode *inode, struct file *file) 41 41 { 42 42 unsigned int i; 43 - struct socket_client *socket_client; 43 + struct batadv_socket_client *socket_client; 44 44 45 45 nonseekable_open(inode, file); 46 46 ··· 77 77 78 78 static int batadv_socket_release(struct inode *inode, struct file *file) 79 79 { 80 - struct socket_client *socket_client = file->private_data; 81 - struct socket_packet *socket_packet; 80 + struct batadv_socket_client *socket_client = file->private_data; 81 + struct batadv_socket_packet *socket_packet; 82 82 struct list_head *list_pos, *list_pos_tmp; 83 83 84 84 spin_lock_bh(&socket_client->lock); ··· 86 86 /* for all packets in the queue ... */ 87 87 list_for_each_safe(list_pos, list_pos_tmp, &socket_client->queue_list) { 88 88 socket_packet = list_entry(list_pos, 89 - struct socket_packet, list); 89 + struct batadv_socket_packet, list); 90 90 91 91 list_del(list_pos); 92 92 kfree(socket_packet); ··· 104 104 static ssize_t batadv_socket_read(struct file *file, char __user *buf, 105 105 size_t count, loff_t *ppos) 106 106 { 107 - struct socket_client *socket_client = file->private_data; 108 - struct socket_packet *socket_packet; 107 + struct batadv_socket_client *socket_client = file->private_data; 108 + struct batadv_socket_packet *socket_packet; 109 109 size_t packet_len; 110 110 int error; 111 111 112 112 if ((file->f_flags & O_NONBLOCK) && (socket_client->queue_len == 0)) 113 113 return -EAGAIN; 114 114 115 - if ((!buf) || (count < sizeof(struct icmp_packet))) 115 + if ((!buf) || (count < sizeof(struct batadv_icmp_packet))) 116 116 return -EINVAL; 117 117 118 118 if (!access_ok(VERIFY_WRITE, buf, count)) ··· 127 127 spin_lock_bh(&socket_client->lock); 128 128 129 129 socket_packet = list_first_entry(&socket_client->queue_list, 130 - struct socket_packet, list); 130 + struct batadv_socket_packet, list); 131 131 list_del(&socket_packet->list); 132 132 socket_client->queue_len--; 133 133 ··· 147 147 static ssize_t batadv_socket_write(struct file *file, const char __user *buff, 148 148 size_t len, loff_t *off) 149 149 { 150 - struct socket_client *socket_client = file->private_data; 151 - struct bat_priv *bat_priv = socket_client->bat_priv; 152 - struct hard_iface *primary_if = NULL; 150 + struct batadv_socket_client *socket_client = file->private_data; 151 + struct batadv_priv *bat_priv = socket_client->bat_priv; 152 + struct batadv_hard_iface *primary_if = NULL; 153 153 struct sk_buff *skb; 154 - struct icmp_packet_rr *icmp_packet; 154 + struct batadv_icmp_packet_rr *icmp_packet; 155 155 156 - struct orig_node *orig_node = NULL; 157 - struct neigh_node *neigh_node = NULL; 158 - size_t packet_len = sizeof(struct icmp_packet); 156 + struct batadv_orig_node *orig_node = NULL; 157 + struct batadv_neigh_node *neigh_node = NULL; 158 + size_t packet_len = sizeof(struct batadv_icmp_packet); 159 159 160 - if (len < sizeof(struct icmp_packet)) { 161 - batadv_dbg(DBG_BATMAN, bat_priv, 160 + if (len < sizeof(struct batadv_icmp_packet)) { 161 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 162 162 "Error - can't send packet from char device: invalid packet size\n"); 163 163 return -EINVAL; 164 164 } ··· 170 170 goto out; 171 171 } 172 172 173 - if (len >= sizeof(struct icmp_packet_rr)) 174 - packet_len = sizeof(struct icmp_packet_rr); 173 + if (len >= sizeof(struct batadv_icmp_packet_rr)) 174 + packet_len = sizeof(struct batadv_icmp_packet_rr); 175 175 176 176 skb = dev_alloc_skb(packet_len + ETH_HLEN); 177 177 if (!skb) { ··· 180 180 } 181 181 182 182 skb_reserve(skb, ETH_HLEN); 183 - icmp_packet = (struct icmp_packet_rr *)skb_put(skb, packet_len); 183 + icmp_packet = (struct batadv_icmp_packet_rr *)skb_put(skb, packet_len); 184 184 185 185 if (copy_from_user(icmp_packet, buff, packet_len)) { 186 186 len = -EFAULT; 187 187 goto free_skb; 188 188 } 189 189 190 - if (icmp_packet->header.packet_type != BAT_ICMP) { 191 - batadv_dbg(DBG_BATMAN, bat_priv, 190 + if (icmp_packet->header.packet_type != BATADV_ICMP) { 191 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 192 192 "Error - can't send packet from char device: got bogus packet type (expected: BAT_ICMP)\n"); 193 193 len = -EINVAL; 194 194 goto free_skb; 195 195 } 196 196 197 - if (icmp_packet->msg_type != ECHO_REQUEST) { 198 - batadv_dbg(DBG_BATMAN, bat_priv, 197 + if (icmp_packet->msg_type != BATADV_ECHO_REQUEST) { 198 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 199 199 "Error - can't send packet from char device: got bogus message type (expected: ECHO_REQUEST)\n"); 200 200 len = -EINVAL; 201 201 goto free_skb; ··· 204 204 icmp_packet->uid = socket_client->index; 205 205 206 206 if (icmp_packet->header.version != BATADV_COMPAT_VERSION) { 207 - icmp_packet->msg_type = PARAMETER_PROBLEM; 207 + icmp_packet->msg_type = BATADV_PARAMETER_PROBLEM; 208 208 icmp_packet->header.version = BATADV_COMPAT_VERSION; 209 209 batadv_socket_add_packet(socket_client, icmp_packet, 210 210 packet_len); 211 211 goto free_skb; 212 212 } 213 213 214 - if (atomic_read(&bat_priv->mesh_state) != MESH_ACTIVE) 214 + if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE) 215 215 goto dst_unreach; 216 216 217 217 orig_node = batadv_orig_hash_find(bat_priv, icmp_packet->dst); ··· 225 225 if (!neigh_node->if_incoming) 226 226 goto dst_unreach; 227 227 228 - if (neigh_node->if_incoming->if_status != IF_ACTIVE) 228 + if (neigh_node->if_incoming->if_status != BATADV_IF_ACTIVE) 229 229 goto dst_unreach; 230 230 231 231 memcpy(icmp_packet->orig, 232 232 primary_if->net_dev->dev_addr, ETH_ALEN); 233 233 234 - if (packet_len == sizeof(struct icmp_packet_rr)) 234 + if (packet_len == sizeof(struct batadv_icmp_packet_rr)) 235 235 memcpy(icmp_packet->rr, 236 236 neigh_node->if_incoming->net_dev->dev_addr, ETH_ALEN); 237 237 ··· 239 239 goto out; 240 240 241 241 dst_unreach: 242 - icmp_packet->msg_type = DESTINATION_UNREACHABLE; 242 + icmp_packet->msg_type = BATADV_DESTINATION_UNREACHABLE; 243 243 batadv_socket_add_packet(socket_client, icmp_packet, packet_len); 244 244 free_skb: 245 245 kfree_skb(skb); ··· 255 255 256 256 static unsigned int batadv_socket_poll(struct file *file, poll_table *wait) 257 257 { 258 - struct socket_client *socket_client = file->private_data; 258 + struct batadv_socket_client *socket_client = file->private_data; 259 259 260 260 poll_wait(file, &socket_client->queue_wait, wait); 261 261 ··· 275 275 .llseek = no_llseek, 276 276 }; 277 277 278 - int batadv_socket_setup(struct bat_priv *bat_priv) 278 + int batadv_socket_setup(struct batadv_priv *bat_priv) 279 279 { 280 280 struct dentry *d; 281 281 ··· 293 293 return -ENOMEM; 294 294 } 295 295 296 - static void batadv_socket_add_packet(struct socket_client *socket_client, 297 - struct icmp_packet_rr *icmp_packet, 296 + static void batadv_socket_add_packet(struct batadv_socket_client *socket_client, 297 + struct batadv_icmp_packet_rr *icmp_packet, 298 298 size_t icmp_len) 299 299 { 300 - struct socket_packet *socket_packet; 300 + struct batadv_socket_packet *socket_packet; 301 301 302 302 socket_packet = kmalloc(sizeof(*socket_packet), GFP_ATOMIC); 303 303 ··· 324 324 325 325 if (socket_client->queue_len > 100) { 326 326 socket_packet = list_first_entry(&socket_client->queue_list, 327 - struct socket_packet, list); 327 + struct batadv_socket_packet, 328 + list); 328 329 329 330 list_del(&socket_packet->list); 330 331 kfree(socket_packet); ··· 337 336 wake_up(&socket_client->queue_wait); 338 337 } 339 338 340 - void batadv_socket_receive_packet(struct icmp_packet_rr *icmp_packet, 339 + void batadv_socket_receive_packet(struct batadv_icmp_packet_rr *icmp_packet, 341 340 size_t icmp_len) 342 341 { 343 - struct socket_client *hash; 342 + struct batadv_socket_client *hash; 344 343 345 344 hash = batadv_socket_client_hash[icmp_packet->uid]; 346 345 if (hash)
+2 -2
net/batman-adv/icmp_socket.h
··· 23 23 #define BATADV_ICMP_SOCKET "socket" 24 24 25 25 void batadv_socket_init(void); 26 - int batadv_socket_setup(struct bat_priv *bat_priv); 27 - void batadv_socket_receive_packet(struct icmp_packet_rr *icmp_packet, 26 + int batadv_socket_setup(struct batadv_priv *bat_priv); 27 + void batadv_socket_receive_packet(struct batadv_icmp_packet_rr *icmp_packet, 28 28 size_t icmp_len); 29 29 30 30 #endif /* _NET_BATMAN_ADV_ICMP_SOCKET_H_ */
+42 -40
net/batman-adv/main.c
··· 18 18 */ 19 19 20 20 #include "main.h" 21 - #include "bat_sysfs.h" 22 - #include "bat_debugfs.h" 21 + #include "sysfs.h" 22 + #include "debugfs.h" 23 23 #include "routing.h" 24 24 #include "send.h" 25 25 #include "originator.h" ··· 39 39 */ 40 40 struct list_head batadv_hardif_list; 41 41 static int (*batadv_rx_handler[256])(struct sk_buff *, 42 - struct hard_iface *); 42 + struct batadv_hard_iface *); 43 43 char batadv_routing_algo[20] = "BATMAN_IV"; 44 44 static struct hlist_head batadv_algo_list; 45 45 ··· 92 92 93 93 int batadv_mesh_init(struct net_device *soft_iface) 94 94 { 95 - struct bat_priv *bat_priv = netdev_priv(soft_iface); 95 + struct batadv_priv *bat_priv = netdev_priv(soft_iface); 96 96 int ret; 97 97 98 98 spin_lock_init(&bat_priv->forw_bat_list_lock); ··· 132 132 goto err; 133 133 134 134 atomic_set(&bat_priv->gw_reselect, 0); 135 - atomic_set(&bat_priv->mesh_state, MESH_ACTIVE); 135 + atomic_set(&bat_priv->mesh_state, BATADV_MESH_ACTIVE); 136 136 137 137 return 0; 138 138 ··· 143 143 144 144 void batadv_mesh_free(struct net_device *soft_iface) 145 145 { 146 - struct bat_priv *bat_priv = netdev_priv(soft_iface); 146 + struct batadv_priv *bat_priv = netdev_priv(soft_iface); 147 147 148 - atomic_set(&bat_priv->mesh_state, MESH_DEACTIVATING); 148 + atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING); 149 149 150 150 batadv_purge_outstanding_packets(bat_priv, NULL); 151 151 ··· 160 160 161 161 free_percpu(bat_priv->bat_counters); 162 162 163 - atomic_set(&bat_priv->mesh_state, MESH_INACTIVE); 163 + atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE); 164 164 } 165 165 166 166 void batadv_inc_module_count(void) ··· 175 175 176 176 int batadv_is_my_mac(const uint8_t *addr) 177 177 { 178 - const struct hard_iface *hard_iface; 178 + const struct batadv_hard_iface *hard_iface; 179 179 180 180 rcu_read_lock(); 181 181 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { 182 - if (hard_iface->if_status != IF_ACTIVE) 182 + if (hard_iface->if_status != BATADV_IF_ACTIVE) 183 183 continue; 184 184 185 185 if (batadv_compare_eth(hard_iface->net_dev->dev_addr, addr)) { ··· 192 192 } 193 193 194 194 static int batadv_recv_unhandled_packet(struct sk_buff *skb, 195 - struct hard_iface *recv_if) 195 + struct batadv_hard_iface *recv_if) 196 196 { 197 197 return NET_RX_DROP; 198 198 } ··· 204 204 struct packet_type *ptype, 205 205 struct net_device *orig_dev) 206 206 { 207 - struct bat_priv *bat_priv; 208 - struct batman_ogm_packet *batman_ogm_packet; 209 - struct hard_iface *hard_iface; 207 + struct batadv_priv *bat_priv; 208 + struct batadv_ogm_packet *batadv_ogm_packet; 209 + struct batadv_hard_iface *hard_iface; 210 210 uint8_t idx; 211 211 int ret; 212 212 213 - hard_iface = container_of(ptype, struct hard_iface, batman_adv_ptype); 213 + hard_iface = container_of(ptype, struct batadv_hard_iface, 214 + batman_adv_ptype); 214 215 skb = skb_share_check(skb, GFP_ATOMIC); 215 216 216 217 /* skb was released by skb_share_check() */ ··· 231 230 232 231 bat_priv = netdev_priv(hard_iface->soft_iface); 233 232 234 - if (atomic_read(&bat_priv->mesh_state) != MESH_ACTIVE) 233 + if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE) 235 234 goto err_free; 236 235 237 236 /* discard frames on not active interfaces */ 238 - if (hard_iface->if_status != IF_ACTIVE) 237 + if (hard_iface->if_status != BATADV_IF_ACTIVE) 239 238 goto err_free; 240 239 241 - batman_ogm_packet = (struct batman_ogm_packet *)skb->data; 240 + batadv_ogm_packet = (struct batadv_ogm_packet *)skb->data; 242 241 243 - if (batman_ogm_packet->header.version != BATADV_COMPAT_VERSION) { 244 - batadv_dbg(DBG_BATMAN, bat_priv, 242 + if (batadv_ogm_packet->header.version != BATADV_COMPAT_VERSION) { 243 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 245 244 "Drop packet: incompatible batman version (%i)\n", 246 - batman_ogm_packet->header.version); 245 + batadv_ogm_packet->header.version); 247 246 goto err_free; 248 247 } 249 248 250 249 /* all receive handlers return whether they received or reused 251 250 * the supplied skb. if not, we have to free the skb. 252 251 */ 253 - idx = batman_ogm_packet->header.packet_type; 252 + idx = batadv_ogm_packet->header.packet_type; 254 253 ret = (*batadv_rx_handler[idx])(skb, hard_iface); 255 254 256 255 if (ret == NET_RX_DROP) ··· 276 275 batadv_rx_handler[i] = batadv_recv_unhandled_packet; 277 276 278 277 /* batman icmp packet */ 279 - batadv_rx_handler[BAT_ICMP] = batadv_recv_icmp_packet; 278 + batadv_rx_handler[BATADV_ICMP] = batadv_recv_icmp_packet; 280 279 /* unicast packet */ 281 - batadv_rx_handler[BAT_UNICAST] = batadv_recv_unicast_packet; 280 + batadv_rx_handler[BATADV_UNICAST] = batadv_recv_unicast_packet; 282 281 /* fragmented unicast packet */ 283 - batadv_rx_handler[BAT_UNICAST_FRAG] = batadv_recv_ucast_frag_packet; 282 + batadv_rx_handler[BATADV_UNICAST_FRAG] = batadv_recv_ucast_frag_packet; 284 283 /* broadcast packet */ 285 - batadv_rx_handler[BAT_BCAST] = batadv_recv_bcast_packet; 284 + batadv_rx_handler[BATADV_BCAST] = batadv_recv_bcast_packet; 286 285 /* vis packet */ 287 - batadv_rx_handler[BAT_VIS] = batadv_recv_vis_packet; 286 + batadv_rx_handler[BATADV_VIS] = batadv_recv_vis_packet; 288 287 /* Translation table query (request or response) */ 289 - batadv_rx_handler[BAT_TT_QUERY] = batadv_recv_tt_query; 288 + batadv_rx_handler[BATADV_TT_QUERY] = batadv_recv_tt_query; 290 289 /* Roaming advertisement */ 291 - batadv_rx_handler[BAT_ROAM_ADV] = batadv_recv_roam_adv; 290 + batadv_rx_handler[BATADV_ROAM_ADV] = batadv_recv_roam_adv; 292 291 } 293 292 294 - int batadv_recv_handler_register(uint8_t packet_type, 295 - int (*recv_handler)(struct sk_buff *, 296 - struct hard_iface *)) 293 + int 294 + batadv_recv_handler_register(uint8_t packet_type, 295 + int (*recv_handler)(struct sk_buff *, 296 + struct batadv_hard_iface *)) 297 297 { 298 298 if (batadv_rx_handler[packet_type] != &batadv_recv_unhandled_packet) 299 299 return -EBUSY; ··· 308 306 batadv_rx_handler[packet_type] = batadv_recv_unhandled_packet; 309 307 } 310 308 311 - static struct bat_algo_ops *batadv_algo_get(char *name) 309 + static struct batadv_algo_ops *batadv_algo_get(char *name) 312 310 { 313 - struct bat_algo_ops *bat_algo_ops = NULL, *bat_algo_ops_tmp; 311 + struct batadv_algo_ops *bat_algo_ops = NULL, *bat_algo_ops_tmp; 314 312 struct hlist_node *node; 315 313 316 314 hlist_for_each_entry(bat_algo_ops_tmp, node, &batadv_algo_list, list) { ··· 324 322 return bat_algo_ops; 325 323 } 326 324 327 - int batadv_algo_register(struct bat_algo_ops *bat_algo_ops) 325 + int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops) 328 326 { 329 - struct bat_algo_ops *bat_algo_ops_tmp; 327 + struct batadv_algo_ops *bat_algo_ops_tmp; 330 328 int ret; 331 329 332 330 bat_algo_ops_tmp = batadv_algo_get(bat_algo_ops->name); ··· 358 356 return ret; 359 357 } 360 358 361 - int batadv_algo_select(struct bat_priv *bat_priv, char *name) 359 + int batadv_algo_select(struct batadv_priv *bat_priv, char *name) 362 360 { 363 - struct bat_algo_ops *bat_algo_ops; 361 + struct batadv_algo_ops *bat_algo_ops; 364 362 int ret = -EINVAL; 365 363 366 364 bat_algo_ops = batadv_algo_get(name); ··· 376 374 377 375 int batadv_algo_seq_print_text(struct seq_file *seq, void *offset) 378 376 { 379 - struct bat_algo_ops *bat_algo_ops; 377 + struct batadv_algo_ops *bat_algo_ops; 380 378 struct hlist_node *node; 381 379 382 380 seq_printf(seq, "Available routing algorithms:\n"); ··· 390 388 391 389 static int batadv_param_set_ra(const char *val, const struct kernel_param *kp) 392 390 { 393 - struct bat_algo_ops *bat_algo_ops; 391 + struct batadv_algo_ops *bat_algo_ops; 394 392 char *algo_name = (char *)val; 395 393 size_t name_len = strlen(algo_name); 396 394
+32 -31
net/batman-adv/main.h
··· 95 95 #define BATADV_RESET_PROTECTION_MS 30000 96 96 #define BATADV_EXPECTED_SEQNO_RANGE 65536 97 97 98 - enum mesh_state { 99 - MESH_INACTIVE, 100 - MESH_ACTIVE, 101 - MESH_DEACTIVATING 98 + enum batadv_mesh_state { 99 + BATADV_MESH_INACTIVE, 100 + BATADV_MESH_ACTIVE, 101 + BATADV_MESH_DEACTIVATING, 102 102 }; 103 103 104 104 #define BATADV_BCAST_QUEUE_LEN 256 105 105 #define BATADV_BATMAN_QUEUE_LEN 256 106 106 107 - enum uev_action { 108 - UEV_ADD = 0, 109 - UEV_DEL, 110 - UEV_CHANGE 107 + enum batadv_uev_action { 108 + BATADV_UEV_ADD = 0, 109 + BATADV_UEV_DEL, 110 + BATADV_UEV_CHANGE, 111 111 }; 112 112 113 - enum uev_type { 114 - UEV_GW = 0 113 + enum batadv_uev_type { 114 + BATADV_UEV_GW = 0, 115 115 }; 116 116 117 117 #define BATADV_GW_THRESHOLD 50 ··· 124 124 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 125 125 126 126 /* all messages related to routing / flooding / broadcasting / etc */ 127 - enum dbg_level { 128 - DBG_BATMAN = 1 << 0, 129 - DBG_ROUTES = 1 << 1, /* route added / changed / deleted */ 130 - DBG_TT = 1 << 2, /* translation table operations */ 131 - DBG_BLA = 1 << 3, /* bridge loop avoidance */ 132 - DBG_ALL = 15 127 + enum batadv_dbg_level { 128 + BATADV_DBG_BATMAN = 1 << 0, 129 + BATADV_DBG_ROUTES = 1 << 1, /* route added / changed / deleted */ 130 + BATADV_DBG_TT = 1 << 2, /* translation table operations */ 131 + BATADV_DBG_BLA = 1 << 3, /* bridge loop avoidance */ 132 + BATADV_DBG_ALL = 15, 133 133 }; 134 134 135 135 /* Kernel headers */ ··· 164 164 int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev, 165 165 struct packet_type *ptype, 166 166 struct net_device *orig_dev); 167 - int batadv_recv_handler_register(uint8_t packet_type, 168 - int (*recv_handler)(struct sk_buff *, 169 - struct hard_iface *)); 167 + int 168 + batadv_recv_handler_register(uint8_t packet_type, 169 + int (*recv_handler)(struct sk_buff *, 170 + struct batadv_hard_iface *)); 170 171 void batadv_recv_handler_unregister(uint8_t packet_type); 171 - int batadv_algo_register(struct bat_algo_ops *bat_algo_ops); 172 - int batadv_algo_select(struct bat_priv *bat_priv, char *name); 172 + int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops); 173 + int batadv_algo_select(struct batadv_priv *bat_priv, char *name); 173 174 int batadv_algo_seq_print_text(struct seq_file *seq, void *offset); 174 175 175 176 #ifdef CONFIG_BATMAN_ADV_DEBUG 176 - int batadv_debug_log(struct bat_priv *bat_priv, const char *fmt, ...) 177 + int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...) 177 178 __printf(2, 3); 178 179 179 180 #define batadv_dbg(type, bat_priv, fmt, arg...) \ ··· 186 185 #else /* !CONFIG_BATMAN_ADV_DEBUG */ 187 186 __printf(3, 4) 188 187 static inline void batadv_dbg(int type __always_unused, 189 - struct bat_priv *bat_priv __always_unused, 188 + struct batadv_priv *bat_priv __always_unused, 190 189 const char *fmt __always_unused, ...) 191 190 { 192 191 } ··· 195 194 #define batadv_info(net_dev, fmt, arg...) \ 196 195 do { \ 197 196 struct net_device *_netdev = (net_dev); \ 198 - struct bat_priv *_batpriv = netdev_priv(_netdev); \ 199 - batadv_dbg(DBG_ALL, _batpriv, fmt, ## arg); \ 197 + struct batadv_priv *_batpriv = netdev_priv(_netdev); \ 198 + batadv_dbg(BATADV_DBG_ALL, _batpriv, fmt, ## arg); \ 200 199 pr_info("%s: " fmt, _netdev->name, ## arg); \ 201 200 } while (0) 202 201 #define batadv_err(net_dev, fmt, arg...) \ 203 202 do { \ 204 203 struct net_device *_netdev = (net_dev); \ 205 - struct bat_priv *_batpriv = netdev_priv(_netdev); \ 206 - batadv_dbg(DBG_ALL, _batpriv, fmt, ## arg); \ 204 + struct batadv_priv *_batpriv = netdev_priv(_netdev); \ 205 + batadv_dbg(BATADV_DBG_ALL, _batpriv, fmt, ## arg); \ 207 206 pr_err("%s: " fmt, _netdev->name, ## arg); \ 208 207 } while (0) 209 208 ··· 251 250 #define batadv_seq_after(x, y) batadv_seq_before(y, x) 252 251 253 252 /* Stop preemption on local cpu while incrementing the counter */ 254 - static inline void batadv_add_counter(struct bat_priv *bat_priv, size_t idx, 253 + static inline void batadv_add_counter(struct batadv_priv *bat_priv, size_t idx, 255 254 size_t count) 256 255 { 257 256 int cpu = get_cpu(); ··· 262 261 #define batadv_inc_counter(b, i) batadv_add_counter(b, i, 1) 263 262 264 263 /* Sum and return the cpu-local counters for index 'idx' */ 265 - static inline uint64_t batadv_sum_counter(struct bat_priv *bat_priv, size_t idx) 264 + static inline uint64_t batadv_sum_counter(struct batadv_priv *bat_priv, 265 + size_t idx) 266 266 { 267 - uint64_t *counters; 267 + uint64_t *counters, sum = 0; 268 268 int cpu; 269 - int sum = 0; 270 269 271 270 for_each_possible_cpu(cpu) { 272 271 counters = per_cpu_ptr(bat_priv->bat_counters, cpu);
+78 -71
net/batman-adv/originator.c
··· 30 30 31 31 static void batadv_purge_orig(struct work_struct *work); 32 32 33 - static void batadv_start_purge_timer(struct bat_priv *bat_priv) 33 + static void batadv_start_purge_timer(struct batadv_priv *bat_priv) 34 34 { 35 35 INIT_DELAYED_WORK(&bat_priv->orig_work, batadv_purge_orig); 36 36 queue_delayed_work(batadv_event_workqueue, ··· 40 40 /* returns 1 if they are the same originator */ 41 41 static int batadv_compare_orig(const struct hlist_node *node, const void *data2) 42 42 { 43 - const void *data1 = container_of(node, struct orig_node, hash_entry); 43 + const void *data1 = container_of(node, struct batadv_orig_node, 44 + hash_entry); 44 45 45 46 return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0); 46 47 } 47 48 48 - int batadv_originator_init(struct bat_priv *bat_priv) 49 + int batadv_originator_init(struct batadv_priv *bat_priv) 49 50 { 50 51 if (bat_priv->orig_hash) 51 52 return 0; ··· 63 62 return -ENOMEM; 64 63 } 65 64 66 - void batadv_neigh_node_free_ref(struct neigh_node *neigh_node) 65 + void batadv_neigh_node_free_ref(struct batadv_neigh_node *neigh_node) 67 66 { 68 67 if (atomic_dec_and_test(&neigh_node->refcount)) 69 68 kfree_rcu(neigh_node, rcu); 70 69 } 71 70 72 71 /* increases the refcounter of a found router */ 73 - struct neigh_node *batadv_orig_node_get_router(struct orig_node *orig_node) 72 + struct batadv_neigh_node * 73 + batadv_orig_node_get_router(struct batadv_orig_node *orig_node) 74 74 { 75 - struct neigh_node *router; 75 + struct batadv_neigh_node *router; 76 76 77 77 rcu_read_lock(); 78 78 router = rcu_dereference(orig_node->router); ··· 85 83 return router; 86 84 } 87 85 88 - struct neigh_node *batadv_neigh_node_new(struct hard_iface *hard_iface, 89 - const uint8_t *neigh_addr, 90 - uint32_t seqno) 86 + struct batadv_neigh_node * 87 + batadv_neigh_node_new(struct batadv_hard_iface *hard_iface, 88 + const uint8_t *neigh_addr, uint32_t seqno) 91 89 { 92 - struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 93 - struct neigh_node *neigh_node; 90 + struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 91 + struct batadv_neigh_node *neigh_node; 94 92 95 93 neigh_node = kzalloc(sizeof(*neigh_node), GFP_ATOMIC); 96 94 if (!neigh_node) ··· 104 102 /* extra reference for return */ 105 103 atomic_set(&neigh_node->refcount, 2); 106 104 107 - batadv_dbg(DBG_BATMAN, bat_priv, 105 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 108 106 "Creating new neighbor %pM, initial seqno %d\n", 109 107 neigh_addr, seqno); 110 108 ··· 115 113 static void batadv_orig_node_free_rcu(struct rcu_head *rcu) 116 114 { 117 115 struct hlist_node *node, *node_tmp; 118 - struct neigh_node *neigh_node, *tmp_neigh_node; 119 - struct orig_node *orig_node; 116 + struct batadv_neigh_node *neigh_node, *tmp_neigh_node; 117 + struct batadv_orig_node *orig_node; 120 118 121 - orig_node = container_of(rcu, struct orig_node, rcu); 119 + orig_node = container_of(rcu, struct batadv_orig_node, rcu); 122 120 123 121 spin_lock_bh(&orig_node->neigh_list_lock); 124 122 ··· 148 146 kfree(orig_node); 149 147 } 150 148 151 - void batadv_orig_node_free_ref(struct orig_node *orig_node) 149 + void batadv_orig_node_free_ref(struct batadv_orig_node *orig_node) 152 150 { 153 151 if (atomic_dec_and_test(&orig_node->refcount)) 154 152 call_rcu(&orig_node->rcu, batadv_orig_node_free_rcu); 155 153 } 156 154 157 - void batadv_originator_free(struct bat_priv *bat_priv) 155 + void batadv_originator_free(struct batadv_priv *bat_priv) 158 156 { 159 - struct hashtable_t *hash = bat_priv->orig_hash; 157 + struct batadv_hashtable *hash = bat_priv->orig_hash; 160 158 struct hlist_node *node, *node_tmp; 161 159 struct hlist_head *head; 162 160 spinlock_t *list_lock; /* spinlock to protect write access */ 163 - struct orig_node *orig_node; 161 + struct batadv_orig_node *orig_node; 164 162 uint32_t i; 165 163 166 164 if (!hash) ··· 190 188 /* this function finds or creates an originator entry for the given 191 189 * address if it does not exits 192 190 */ 193 - struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv, 194 - const uint8_t *addr) 191 + struct batadv_orig_node *batadv_get_orig_node(struct batadv_priv *bat_priv, 192 + const uint8_t *addr) 195 193 { 196 - struct orig_node *orig_node; 194 + struct batadv_orig_node *orig_node; 197 195 int size; 198 196 int hash_added; 199 197 unsigned long reset_time; ··· 202 200 if (orig_node) 203 201 return orig_node; 204 202 205 - batadv_dbg(DBG_BATMAN, bat_priv, "Creating new originator: %pM\n", 206 - addr); 203 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 204 + "Creating new originator: %pM\n", addr); 207 205 208 206 orig_node = kzalloc(sizeof(*orig_node), GFP_ATOMIC); 209 207 if (!orig_node) ··· 266 264 return NULL; 267 265 } 268 266 269 - static bool batadv_purge_orig_neighbors(struct bat_priv *bat_priv, 270 - struct orig_node *orig_node, 271 - struct neigh_node **best_neigh_node) 267 + static bool 268 + batadv_purge_orig_neighbors(struct batadv_priv *bat_priv, 269 + struct batadv_orig_node *orig_node, 270 + struct batadv_neigh_node **best_neigh_node) 272 271 { 273 272 struct hlist_node *node, *node_tmp; 274 - struct neigh_node *neigh_node; 273 + struct batadv_neigh_node *neigh_node; 275 274 bool neigh_purged = false; 276 275 unsigned long last_seen; 277 - struct hard_iface *if_incoming; 276 + struct batadv_hard_iface *if_incoming; 278 277 279 278 *best_neigh_node = NULL; 280 279 ··· 289 286 if_incoming = neigh_node->if_incoming; 290 287 291 288 if ((batadv_has_timed_out(last_seen, BATADV_PURGE_TIMEOUT)) || 292 - (if_incoming->if_status == IF_INACTIVE) || 293 - (if_incoming->if_status == IF_NOT_IN_USE) || 294 - (if_incoming->if_status == IF_TO_BE_REMOVED)) { 289 + (if_incoming->if_status == BATADV_IF_INACTIVE) || 290 + (if_incoming->if_status == BATADV_IF_NOT_IN_USE) || 291 + (if_incoming->if_status == BATADV_IF_TO_BE_REMOVED)) { 295 292 296 - if ((if_incoming->if_status == IF_INACTIVE) || 297 - (if_incoming->if_status == IF_NOT_IN_USE) || 298 - (if_incoming->if_status == IF_TO_BE_REMOVED)) 299 - batadv_dbg(DBG_BATMAN, bat_priv, 293 + if ((if_incoming->if_status == BATADV_IF_INACTIVE) || 294 + (if_incoming->if_status == BATADV_IF_NOT_IN_USE) || 295 + (if_incoming->if_status == BATADV_IF_TO_BE_REMOVED)) 296 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 300 297 "neighbor purge: originator %pM, neighbor: %pM, iface: %s\n", 301 298 orig_node->orig, neigh_node->addr, 302 299 if_incoming->net_dev->name); 303 300 else 304 - batadv_dbg(DBG_BATMAN, bat_priv, 301 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 305 302 "neighbor timeout: originator %pM, neighbor: %pM, last_seen: %u\n", 306 303 orig_node->orig, neigh_node->addr, 307 304 jiffies_to_msecs(last_seen)); ··· 322 319 return neigh_purged; 323 320 } 324 321 325 - static bool batadv_purge_orig_node(struct bat_priv *bat_priv, 326 - struct orig_node *orig_node) 322 + static bool batadv_purge_orig_node(struct batadv_priv *bat_priv, 323 + struct batadv_orig_node *orig_node) 327 324 { 328 - struct neigh_node *best_neigh_node; 325 + struct batadv_neigh_node *best_neigh_node; 329 326 330 327 if (batadv_has_timed_out(orig_node->last_seen, 331 328 2 * BATADV_PURGE_TIMEOUT)) { 332 - batadv_dbg(DBG_BATMAN, bat_priv, 329 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 333 330 "Originator timeout: originator %pM, last_seen %u\n", 334 331 orig_node->orig, 335 332 jiffies_to_msecs(orig_node->last_seen)); ··· 344 341 return false; 345 342 } 346 343 347 - static void _batadv_purge_orig(struct bat_priv *bat_priv) 344 + static void _batadv_purge_orig(struct batadv_priv *bat_priv) 348 345 { 349 - struct hashtable_t *hash = bat_priv->orig_hash; 346 + struct batadv_hashtable *hash = bat_priv->orig_hash; 350 347 struct hlist_node *node, *node_tmp; 351 348 struct hlist_head *head; 352 349 spinlock_t *list_lock; /* spinlock to protect write access */ 353 - struct orig_node *orig_node; 350 + struct batadv_orig_node *orig_node; 354 351 uint32_t i; 355 352 356 353 if (!hash) ··· 386 383 387 384 static void batadv_purge_orig(struct work_struct *work) 388 385 { 389 - struct delayed_work *delayed_work = 390 - container_of(work, struct delayed_work, work); 391 - struct bat_priv *bat_priv = 392 - container_of(delayed_work, struct bat_priv, orig_work); 386 + struct delayed_work *delayed_work; 387 + struct batadv_priv *bat_priv; 393 388 389 + delayed_work = container_of(work, struct delayed_work, work); 390 + bat_priv = container_of(delayed_work, struct batadv_priv, orig_work); 394 391 _batadv_purge_orig(bat_priv); 395 392 batadv_start_purge_timer(bat_priv); 396 393 } 397 394 398 - void batadv_purge_orig_ref(struct bat_priv *bat_priv) 395 + void batadv_purge_orig_ref(struct batadv_priv *bat_priv) 399 396 { 400 397 _batadv_purge_orig(bat_priv); 401 398 } ··· 403 400 int batadv_orig_seq_print_text(struct seq_file *seq, void *offset) 404 401 { 405 402 struct net_device *net_dev = (struct net_device *)seq->private; 406 - struct bat_priv *bat_priv = netdev_priv(net_dev); 407 - struct hashtable_t *hash = bat_priv->orig_hash; 403 + struct batadv_priv *bat_priv = netdev_priv(net_dev); 404 + struct batadv_hashtable *hash = bat_priv->orig_hash; 408 405 struct hlist_node *node, *node_tmp; 409 406 struct hlist_head *head; 410 - struct hard_iface *primary_if; 411 - struct orig_node *orig_node; 412 - struct neigh_node *neigh_node, *neigh_node_tmp; 407 + struct batadv_hard_iface *primary_if; 408 + struct batadv_orig_node *orig_node; 409 + struct batadv_neigh_node *neigh_node, *neigh_node_tmp; 413 410 int batman_count = 0; 414 411 int last_seen_secs; 415 412 int last_seen_msecs; 413 + unsigned long last_seen_jiffies; 416 414 uint32_t i; 417 415 int ret = 0; 418 416 ··· 426 422 goto out; 427 423 } 428 424 429 - if (primary_if->if_status != IF_ACTIVE) { 425 + if (primary_if->if_status != BATADV_IF_ACTIVE) { 430 426 ret = seq_printf(seq, 431 427 "BATMAN mesh %s disabled - primary interface not active\n", 432 428 net_dev->name); ··· 452 448 if (neigh_node->tq_avg == 0) 453 449 goto next; 454 450 455 - last_seen_secs = jiffies_to_msecs(jiffies - 456 - orig_node->last_seen) / 1000; 457 - last_seen_msecs = jiffies_to_msecs(jiffies - 458 - orig_node->last_seen) % 1000; 451 + last_seen_jiffies = jiffies - orig_node->last_seen; 452 + last_seen_msecs = jiffies_to_msecs(last_seen_jiffies); 453 + last_seen_secs = last_seen_msecs / 1000; 454 + last_seen_msecs = last_seen_msecs % 1000; 459 455 460 456 seq_printf(seq, "%pM %4i.%03is (%3i) %pM [%10s]:", 461 457 orig_node->orig, last_seen_secs, ··· 488 484 return ret; 489 485 } 490 486 491 - static int batadv_orig_node_add_if(struct orig_node *orig_node, int max_if_num) 487 + static int batadv_orig_node_add_if(struct batadv_orig_node *orig_node, 488 + int max_if_num) 492 489 { 493 490 void *data_ptr; 494 491 size_t data_size, old_size; ··· 516 511 return 0; 517 512 } 518 513 519 - int batadv_orig_hash_add_if(struct hard_iface *hard_iface, int max_if_num) 514 + int batadv_orig_hash_add_if(struct batadv_hard_iface *hard_iface, 515 + int max_if_num) 520 516 { 521 - struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 522 - struct hashtable_t *hash = bat_priv->orig_hash; 517 + struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 518 + struct batadv_hashtable *hash = bat_priv->orig_hash; 523 519 struct hlist_node *node; 524 520 struct hlist_head *head; 525 - struct orig_node *orig_node; 521 + struct batadv_orig_node *orig_node; 526 522 uint32_t i; 527 523 int ret; 528 524 ··· 552 546 return -ENOMEM; 553 547 } 554 548 555 - static int batadv_orig_node_del_if(struct orig_node *orig_node, 549 + static int batadv_orig_node_del_if(struct batadv_orig_node *orig_node, 556 550 int max_if_num, int del_if_num) 557 551 { 558 552 void *data_ptr = NULL; ··· 600 594 return 0; 601 595 } 602 596 603 - int batadv_orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num) 597 + int batadv_orig_hash_del_if(struct batadv_hard_iface *hard_iface, 598 + int max_if_num) 604 599 { 605 - struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 606 - struct hashtable_t *hash = bat_priv->orig_hash; 600 + struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 601 + struct batadv_hashtable *hash = bat_priv->orig_hash; 607 602 struct hlist_node *node; 608 603 struct hlist_head *head; 609 - struct hard_iface *hard_iface_tmp; 610 - struct orig_node *orig_node; 604 + struct batadv_hard_iface *hard_iface_tmp; 605 + struct batadv_orig_node *orig_node; 611 606 uint32_t i; 612 607 int ret; 613 608 ··· 634 627 /* renumber remaining batman interfaces _inside_ of orig_hash_lock */ 635 628 rcu_read_lock(); 636 629 list_for_each_entry_rcu(hard_iface_tmp, &batadv_hardif_list, list) { 637 - if (hard_iface_tmp->if_status == IF_NOT_IN_USE) 630 + if (hard_iface_tmp->if_status == BATADV_IF_NOT_IN_USE) 638 631 continue; 639 632 640 633 if (hard_iface == hard_iface_tmp)
+20 -17
net/batman-adv/originator.h
··· 22 22 23 23 #include "hash.h" 24 24 25 - int batadv_originator_init(struct bat_priv *bat_priv); 26 - void batadv_originator_free(struct bat_priv *bat_priv); 27 - void batadv_purge_orig_ref(struct bat_priv *bat_priv); 28 - void batadv_orig_node_free_ref(struct orig_node *orig_node); 29 - struct orig_node *batadv_get_orig_node(struct bat_priv *bat_priv, 30 - const uint8_t *addr); 31 - struct neigh_node *batadv_neigh_node_new(struct hard_iface *hard_iface, 32 - const uint8_t *neigh_addr, 33 - uint32_t seqno); 34 - void batadv_neigh_node_free_ref(struct neigh_node *neigh_node); 35 - struct neigh_node *batadv_orig_node_get_router(struct orig_node *orig_node); 25 + int batadv_originator_init(struct batadv_priv *bat_priv); 26 + void batadv_originator_free(struct batadv_priv *bat_priv); 27 + void batadv_purge_orig_ref(struct batadv_priv *bat_priv); 28 + void batadv_orig_node_free_ref(struct batadv_orig_node *orig_node); 29 + struct batadv_orig_node *batadv_get_orig_node(struct batadv_priv *bat_priv, 30 + const uint8_t *addr); 31 + struct batadv_neigh_node * 32 + batadv_neigh_node_new(struct batadv_hard_iface *hard_iface, 33 + const uint8_t *neigh_addr, uint32_t seqno); 34 + void batadv_neigh_node_free_ref(struct batadv_neigh_node *neigh_node); 35 + struct batadv_neigh_node * 36 + batadv_orig_node_get_router(struct batadv_orig_node *orig_node); 36 37 int batadv_orig_seq_print_text(struct seq_file *seq, void *offset); 37 - int batadv_orig_hash_add_if(struct hard_iface *hard_iface, int max_if_num); 38 - int batadv_orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num); 38 + int batadv_orig_hash_add_if(struct batadv_hard_iface *hard_iface, 39 + int max_if_num); 40 + int batadv_orig_hash_del_if(struct batadv_hard_iface *hard_iface, 41 + int max_if_num); 39 42 40 43 41 44 /* hashfunction to choose an entry in a hash table of given size ··· 63 60 return hash % size; 64 61 } 65 62 66 - static inline struct orig_node *batadv_orig_hash_find(struct bat_priv *bat_priv, 67 - const void *data) 63 + static inline struct batadv_orig_node * 64 + batadv_orig_hash_find(struct batadv_priv *bat_priv, const void *data) 68 65 { 69 - struct hashtable_t *hash = bat_priv->orig_hash; 66 + struct batadv_hashtable *hash = bat_priv->orig_hash; 70 67 struct hlist_head *head; 71 68 struct hlist_node *node; 72 - struct orig_node *orig_node, *orig_node_tmp = NULL; 69 + struct batadv_orig_node *orig_node, *orig_node_tmp = NULL; 73 70 int index; 74 71 75 72 if (!hash)
+66 -66
net/batman-adv/packet.h
··· 22 22 23 23 #define BATADV_ETH_P_BATMAN 0x4305 /* unofficial/not registered Ethertype */ 24 24 25 - enum bat_packettype { 26 - BAT_IV_OGM = 0x01, 27 - BAT_ICMP = 0x02, 28 - BAT_UNICAST = 0x03, 29 - BAT_BCAST = 0x04, 30 - BAT_VIS = 0x05, 31 - BAT_UNICAST_FRAG = 0x06, 32 - BAT_TT_QUERY = 0x07, 33 - BAT_ROAM_ADV = 0x08 25 + enum batadv_packettype { 26 + BATADV_IV_OGM = 0x01, 27 + BATADV_ICMP = 0x02, 28 + BATADV_UNICAST = 0x03, 29 + BATADV_BCAST = 0x04, 30 + BATADV_VIS = 0x05, 31 + BATADV_UNICAST_FRAG = 0x06, 32 + BATADV_TT_QUERY = 0x07, 33 + BATADV_ROAM_ADV = 0x08, 34 34 }; 35 35 36 36 /* this file is included by batctl which needs these defines */ 37 37 #define BATADV_COMPAT_VERSION 14 38 38 39 - enum batman_iv_flags { 40 - NOT_BEST_NEXT_HOP = 1 << 3, 41 - PRIMARIES_FIRST_HOP = 1 << 4, 42 - VIS_SERVER = 1 << 5, 43 - DIRECTLINK = 1 << 6 39 + enum batadv_iv_flags { 40 + BATADV_NOT_BEST_NEXT_HOP = 1 << 3, 41 + BATADV_PRIMARIES_FIRST_HOP = 1 << 4, 42 + BATADV_VIS_SERVER = 1 << 5, 43 + BATADV_DIRECTLINK = 1 << 6, 44 44 }; 45 45 46 46 /* ICMP message types */ 47 - enum icmp_packettype { 48 - ECHO_REPLY = 0, 49 - DESTINATION_UNREACHABLE = 3, 50 - ECHO_REQUEST = 8, 51 - TTL_EXCEEDED = 11, 52 - PARAMETER_PROBLEM = 12 47 + enum batadv_icmp_packettype { 48 + BATADV_ECHO_REPLY = 0, 49 + BATADV_DESTINATION_UNREACHABLE = 3, 50 + BATADV_ECHO_REQUEST = 8, 51 + BATADV_TTL_EXCEEDED = 11, 52 + BATADV_PARAMETER_PROBLEM = 12, 53 53 }; 54 54 55 55 /* vis defines */ 56 - enum vis_packettype { 57 - VIS_TYPE_SERVER_SYNC = 0, 58 - VIS_TYPE_CLIENT_UPDATE = 1 56 + enum batadv_vis_packettype { 57 + BATADV_VIS_TYPE_SERVER_SYNC = 0, 58 + BATADV_VIS_TYPE_CLIENT_UPDATE = 1, 59 59 }; 60 60 61 61 /* fragmentation defines */ 62 - enum unicast_frag_flags { 63 - UNI_FRAG_HEAD = 1 << 0, 64 - UNI_FRAG_LARGETAIL = 1 << 1 62 + enum batadv_unicast_frag_flags { 63 + BATADV_UNI_FRAG_HEAD = 1 << 0, 64 + BATADV_UNI_FRAG_LARGETAIL = 1 << 1, 65 65 }; 66 66 67 67 /* TT_QUERY subtypes */ 68 68 #define BATADV_TT_QUERY_TYPE_MASK 0x3 69 69 70 - enum tt_query_packettype { 71 - TT_REQUEST = 0, 72 - TT_RESPONSE = 1 70 + enum batadv_tt_query_packettype { 71 + BATADV_TT_REQUEST = 0, 72 + BATADV_TT_RESPONSE = 1, 73 73 }; 74 74 75 75 /* TT_QUERY flags */ 76 - enum tt_query_flags { 77 - TT_FULL_TABLE = 1 << 2 76 + enum batadv_tt_query_flags { 77 + BATADV_TT_FULL_TABLE = 1 << 2, 78 78 }; 79 79 80 - /* TT_CLIENT flags. 80 + /* BATADV_TT_CLIENT flags. 81 81 * Flags from 1 to 1 << 7 are sent on the wire, while flags from 1 << 8 to 82 82 * 1 << 15 are used for local computation only 83 83 */ 84 - enum tt_client_flags { 85 - TT_CLIENT_DEL = 1 << 0, 86 - TT_CLIENT_ROAM = 1 << 1, 87 - TT_CLIENT_WIFI = 1 << 2, 88 - TT_CLIENT_NOPURGE = 1 << 8, 89 - TT_CLIENT_NEW = 1 << 9, 90 - TT_CLIENT_PENDING = 1 << 10 84 + enum batadv_tt_client_flags { 85 + BATADV_TT_CLIENT_DEL = 1 << 0, 86 + BATADV_TT_CLIENT_ROAM = 1 << 1, 87 + BATADV_TT_CLIENT_WIFI = 1 << 2, 88 + BATADV_TT_CLIENT_NOPURGE = 1 << 8, 89 + BATADV_TT_CLIENT_NEW = 1 << 9, 90 + BATADV_TT_CLIENT_PENDING = 1 << 10, 91 91 }; 92 92 93 93 /* claim frame types for the bridge loop avoidance */ 94 - enum bla_claimframe { 95 - CLAIM_TYPE_ADD = 0x00, 96 - CLAIM_TYPE_DEL = 0x01, 97 - CLAIM_TYPE_ANNOUNCE = 0x02, 98 - CLAIM_TYPE_REQUEST = 0x03 94 + enum batadv_bla_claimframe { 95 + BATADV_CLAIM_TYPE_ADD = 0x00, 96 + BATADV_CLAIM_TYPE_DEL = 0x01, 97 + BATADV_CLAIM_TYPE_ANNOUNCE = 0x02, 98 + BATADV_CLAIM_TYPE_REQUEST = 0x03, 99 99 }; 100 100 101 101 /* the destination hardware field in the ARP frame is used to 102 102 * transport the claim type and the group id 103 103 */ 104 - struct bla_claim_dst { 104 + struct batadv_bla_claim_dst { 105 105 uint8_t magic[3]; /* FF:43:05 */ 106 106 uint8_t type; /* bla_claimframe */ 107 107 __be16 group; /* group id */ 108 108 } __packed; 109 109 110 - struct batman_header { 110 + struct batadv_header { 111 111 uint8_t packet_type; 112 112 uint8_t version; /* batman version field */ 113 113 uint8_t ttl; 114 114 } __packed; 115 115 116 - struct batman_ogm_packet { 117 - struct batman_header header; 116 + struct batadv_ogm_packet { 117 + struct batadv_header header; 118 118 uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */ 119 119 __be32 seqno; 120 120 uint8_t orig[ETH_ALEN]; ··· 126 126 __be16 tt_crc; 127 127 } __packed; 128 128 129 - #define BATADV_OGM_HLEN sizeof(struct batman_ogm_packet) 129 + #define BATADV_OGM_HLEN sizeof(struct batadv_ogm_packet) 130 130 131 - struct icmp_packet { 132 - struct batman_header header; 131 + struct batadv_icmp_packet { 132 + struct batadv_header header; 133 133 uint8_t msg_type; /* see ICMP message types above */ 134 134 uint8_t dst[ETH_ALEN]; 135 135 uint8_t orig[ETH_ALEN]; ··· 143 143 /* icmp_packet_rr must start with all fields from imcp_packet 144 144 * as this is assumed by code that handles ICMP packets 145 145 */ 146 - struct icmp_packet_rr { 147 - struct batman_header header; 146 + struct batadv_icmp_packet_rr { 147 + struct batadv_header header; 148 148 uint8_t msg_type; /* see ICMP message types above */ 149 149 uint8_t dst[ETH_ALEN]; 150 150 uint8_t orig[ETH_ALEN]; ··· 154 154 uint8_t rr[BATADV_RR_LEN][ETH_ALEN]; 155 155 } __packed; 156 156 157 - struct unicast_packet { 158 - struct batman_header header; 157 + struct batadv_unicast_packet { 158 + struct batadv_header header; 159 159 uint8_t ttvn; /* destination translation table version number */ 160 160 uint8_t dest[ETH_ALEN]; 161 161 } __packed; 162 162 163 - struct unicast_frag_packet { 164 - struct batman_header header; 163 + struct batadv_unicast_frag_packet { 164 + struct batadv_header header; 165 165 uint8_t ttvn; /* destination translation table version number */ 166 166 uint8_t dest[ETH_ALEN]; 167 167 uint8_t flags; ··· 170 170 __be16 seqno; 171 171 } __packed; 172 172 173 - struct bcast_packet { 174 - struct batman_header header; 173 + struct batadv_bcast_packet { 174 + struct batadv_header header; 175 175 uint8_t reserved; 176 176 __be32 seqno; 177 177 uint8_t orig[ETH_ALEN]; 178 178 } __packed; 179 179 180 - struct vis_packet { 181 - struct batman_header header; 180 + struct batadv_vis_packet { 181 + struct batadv_header header; 182 182 uint8_t vis_type; /* which type of vis-participant sent this? */ 183 183 __be32 seqno; /* sequence number */ 184 184 uint8_t entries; /* number of entries behind this struct */ ··· 188 188 uint8_t sender_orig[ETH_ALEN]; /* who sent or forwarded this packet */ 189 189 } __packed; 190 190 191 - struct tt_query_packet { 192 - struct batman_header header; 191 + struct batadv_tt_query_packet { 192 + struct batadv_header header; 193 193 /* the flag field is a combination of: 194 194 * - TT_REQUEST or TT_RESPONSE 195 195 * - TT_FULL_TABLE ··· 212 212 __be16 tt_data; 213 213 } __packed; 214 214 215 - struct roam_adv_packet { 216 - struct batman_header header; 215 + struct batadv_roam_adv_packet { 216 + struct batadv_header header; 217 217 uint8_t reserved; 218 218 uint8_t dst[ETH_ALEN]; 219 219 uint8_t src[ETH_ALEN]; 220 220 uint8_t client[ETH_ALEN]; 221 221 } __packed; 222 222 223 - struct tt_change { 223 + struct batadv_tt_change { 224 224 uint8_t flags; 225 225 uint8_t addr[ETH_ALEN]; 226 226 } __packed;
+158 -142
net/batman-adv/routing.c
··· 30 30 #include "bridge_loop_avoidance.h" 31 31 32 32 static int batadv_route_unicast_packet(struct sk_buff *skb, 33 - struct hard_iface *recv_if); 33 + struct batadv_hard_iface *recv_if); 34 34 35 - void batadv_slide_own_bcast_window(struct hard_iface *hard_iface) 35 + void batadv_slide_own_bcast_window(struct batadv_hard_iface *hard_iface) 36 36 { 37 - struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 38 - struct hashtable_t *hash = bat_priv->orig_hash; 37 + struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 38 + struct batadv_hashtable *hash = bat_priv->orig_hash; 39 39 struct hlist_node *node; 40 40 struct hlist_head *head; 41 - struct orig_node *orig_node; 41 + struct batadv_orig_node *orig_node; 42 42 unsigned long *word; 43 43 uint32_t i; 44 44 size_t word_index; ··· 62 62 } 63 63 } 64 64 65 - static void _batadv_update_route(struct bat_priv *bat_priv, 66 - struct orig_node *orig_node, 67 - struct neigh_node *neigh_node) 65 + static void _batadv_update_route(struct batadv_priv *bat_priv, 66 + struct batadv_orig_node *orig_node, 67 + struct batadv_neigh_node *neigh_node) 68 68 { 69 - struct neigh_node *curr_router; 69 + struct batadv_neigh_node *curr_router; 70 70 71 71 curr_router = batadv_orig_node_get_router(orig_node); 72 72 73 73 /* route deleted */ 74 74 if ((curr_router) && (!neigh_node)) { 75 - batadv_dbg(DBG_ROUTES, bat_priv, "Deleting route towards: %pM\n", 76 - orig_node->orig); 75 + batadv_dbg(BATADV_DBG_ROUTES, bat_priv, 76 + "Deleting route towards: %pM\n", orig_node->orig); 77 77 batadv_tt_global_del_orig(bat_priv, orig_node, 78 78 "Deleted route towards originator"); 79 79 80 80 /* route added */ 81 81 } else if ((!curr_router) && (neigh_node)) { 82 82 83 - batadv_dbg(DBG_ROUTES, bat_priv, 83 + batadv_dbg(BATADV_DBG_ROUTES, bat_priv, 84 84 "Adding route towards: %pM (via %pM)\n", 85 85 orig_node->orig, neigh_node->addr); 86 86 /* route changed */ 87 87 } else if (neigh_node && curr_router) { 88 - batadv_dbg(DBG_ROUTES, bat_priv, 88 + batadv_dbg(BATADV_DBG_ROUTES, bat_priv, 89 89 "Changing route towards: %pM (now via %pM - was via %pM)\n", 90 90 orig_node->orig, neigh_node->addr, 91 91 curr_router->addr); ··· 107 107 batadv_neigh_node_free_ref(curr_router); 108 108 } 109 109 110 - void batadv_update_route(struct bat_priv *bat_priv, struct orig_node *orig_node, 111 - struct neigh_node *neigh_node) 110 + void batadv_update_route(struct batadv_priv *bat_priv, 111 + struct batadv_orig_node *orig_node, 112 + struct batadv_neigh_node *neigh_node) 112 113 { 113 - struct neigh_node *router = NULL; 114 + struct batadv_neigh_node *router = NULL; 114 115 115 116 if (!orig_node) 116 117 goto out; ··· 127 126 } 128 127 129 128 /* caller must hold the neigh_list_lock */ 130 - void batadv_bonding_candidate_del(struct orig_node *orig_node, 131 - struct neigh_node *neigh_node) 129 + void batadv_bonding_candidate_del(struct batadv_orig_node *orig_node, 130 + struct batadv_neigh_node *neigh_node) 132 131 { 133 132 /* this neighbor is not part of our candidate list */ 134 133 if (list_empty(&neigh_node->bonding_list)) ··· 143 142 return; 144 143 } 145 144 146 - void batadv_bonding_candidate_add(struct orig_node *orig_node, 147 - struct neigh_node *neigh_node) 145 + void batadv_bonding_candidate_add(struct batadv_orig_node *orig_node, 146 + struct batadv_neigh_node *neigh_node) 148 147 { 149 148 struct hlist_node *node; 150 - struct neigh_node *tmp_neigh_node, *router = NULL; 149 + struct batadv_neigh_node *tmp_neigh_node, *router = NULL; 151 150 uint8_t interference_candidate = 0; 152 151 153 152 spin_lock_bh(&orig_node->neigh_list_lock); ··· 216 215 217 216 /* copy primary address for bonding */ 218 217 void 219 - batadv_bonding_save_primary(const struct orig_node *orig_node, 220 - struct orig_node *orig_neigh_node, 221 - const struct batman_ogm_packet *batman_ogm_packet) 218 + batadv_bonding_save_primary(const struct batadv_orig_node *orig_node, 219 + struct batadv_orig_node *orig_neigh_node, 220 + const struct batadv_ogm_packet *batman_ogm_packet) 222 221 { 223 - if (!(batman_ogm_packet->flags & PRIMARIES_FIRST_HOP)) 222 + if (!(batman_ogm_packet->flags & BATADV_PRIMARIES_FIRST_HOP)) 224 223 return; 225 224 226 225 memcpy(orig_neigh_node->primary_addr, orig_node->orig, ETH_ALEN); ··· 231 230 * 0 if the packet is to be accepted 232 231 * 1 if the packet is to be ignored. 233 232 */ 234 - int batadv_window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff, 233 + int batadv_window_protected(struct batadv_priv *bat_priv, int32_t seq_num_diff, 235 234 unsigned long *last_reset) 236 235 { 237 236 if (seq_num_diff <= -BATADV_TQ_LOCAL_WINDOW_SIZE || ··· 241 240 return 1; 242 241 243 242 *last_reset = jiffies; 244 - batadv_dbg(DBG_BATMAN, bat_priv, 243 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 245 244 "old packet received, start protection\n"); 246 245 } 247 246 ··· 249 248 } 250 249 251 250 bool batadv_check_management_packet(struct sk_buff *skb, 252 - struct hard_iface *hard_iface, 251 + struct batadv_hard_iface *hard_iface, 253 252 int header_len) 254 253 { 255 254 struct ethhdr *ethhdr; ··· 279 278 return true; 280 279 } 281 280 282 - static int batadv_recv_my_icmp_packet(struct bat_priv *bat_priv, 281 + static int batadv_recv_my_icmp_packet(struct batadv_priv *bat_priv, 283 282 struct sk_buff *skb, size_t icmp_len) 284 283 { 285 - struct hard_iface *primary_if = NULL; 286 - struct orig_node *orig_node = NULL; 287 - struct neigh_node *router = NULL; 288 - struct icmp_packet_rr *icmp_packet; 284 + struct batadv_hard_iface *primary_if = NULL; 285 + struct batadv_orig_node *orig_node = NULL; 286 + struct batadv_neigh_node *router = NULL; 287 + struct batadv_icmp_packet_rr *icmp_packet; 289 288 int ret = NET_RX_DROP; 290 289 291 - icmp_packet = (struct icmp_packet_rr *)skb->data; 290 + icmp_packet = (struct batadv_icmp_packet_rr *)skb->data; 292 291 293 292 /* add data to device queue */ 294 - if (icmp_packet->msg_type != ECHO_REQUEST) { 293 + if (icmp_packet->msg_type != BATADV_ECHO_REQUEST) { 295 294 batadv_socket_receive_packet(icmp_packet, icmp_len); 296 295 goto out; 297 296 } ··· 314 313 if (skb_cow(skb, ETH_HLEN) < 0) 315 314 goto out; 316 315 317 - icmp_packet = (struct icmp_packet_rr *)skb->data; 316 + icmp_packet = (struct batadv_icmp_packet_rr *)skb->data; 318 317 319 318 memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN); 320 319 memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN); 321 - icmp_packet->msg_type = ECHO_REPLY; 320 + icmp_packet->msg_type = BATADV_ECHO_REPLY; 322 321 icmp_packet->header.ttl = BATADV_TTL; 323 322 324 323 batadv_send_skb_packet(skb, router->if_incoming, router->addr); ··· 334 333 return ret; 335 334 } 336 335 337 - static int batadv_recv_icmp_ttl_exceeded(struct bat_priv *bat_priv, 336 + static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv, 338 337 struct sk_buff *skb) 339 338 { 340 - struct hard_iface *primary_if = NULL; 341 - struct orig_node *orig_node = NULL; 342 - struct neigh_node *router = NULL; 343 - struct icmp_packet *icmp_packet; 339 + struct batadv_hard_iface *primary_if = NULL; 340 + struct batadv_orig_node *orig_node = NULL; 341 + struct batadv_neigh_node *router = NULL; 342 + struct batadv_icmp_packet *icmp_packet; 344 343 int ret = NET_RX_DROP; 345 344 346 - icmp_packet = (struct icmp_packet *)skb->data; 345 + icmp_packet = (struct batadv_icmp_packet *)skb->data; 347 346 348 347 /* send TTL exceeded if packet is an echo request (traceroute) */ 349 - if (icmp_packet->msg_type != ECHO_REQUEST) { 348 + if (icmp_packet->msg_type != BATADV_ECHO_REQUEST) { 350 349 pr_debug("Warning - can't forward icmp packet from %pM to %pM: ttl exceeded\n", 351 350 icmp_packet->orig, icmp_packet->dst); 352 351 goto out; ··· 369 368 if (skb_cow(skb, ETH_HLEN) < 0) 370 369 goto out; 371 370 372 - icmp_packet = (struct icmp_packet *)skb->data; 371 + icmp_packet = (struct batadv_icmp_packet *)skb->data; 373 372 374 373 memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN); 375 374 memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN); 376 - icmp_packet->msg_type = TTL_EXCEEDED; 375 + icmp_packet->msg_type = BATADV_TTL_EXCEEDED; 377 376 icmp_packet->header.ttl = BATADV_TTL; 378 377 379 378 batadv_send_skb_packet(skb, router->if_incoming, router->addr); ··· 390 389 } 391 390 392 391 393 - int batadv_recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if) 392 + int batadv_recv_icmp_packet(struct sk_buff *skb, 393 + struct batadv_hard_iface *recv_if) 394 394 { 395 - struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); 396 - struct icmp_packet_rr *icmp_packet; 395 + struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface); 396 + struct batadv_icmp_packet_rr *icmp_packet; 397 397 struct ethhdr *ethhdr; 398 - struct orig_node *orig_node = NULL; 399 - struct neigh_node *router = NULL; 400 - int hdr_size = sizeof(struct icmp_packet); 398 + struct batadv_orig_node *orig_node = NULL; 399 + struct batadv_neigh_node *router = NULL; 400 + int hdr_size = sizeof(struct batadv_icmp_packet); 401 401 int ret = NET_RX_DROP; 402 402 403 403 /* we truncate all incoming icmp packets if they don't match our size */ 404 - if (skb->len >= sizeof(struct icmp_packet_rr)) 405 - hdr_size = sizeof(struct icmp_packet_rr); 404 + if (skb->len >= sizeof(struct batadv_icmp_packet_rr)) 405 + hdr_size = sizeof(struct batadv_icmp_packet_rr); 406 406 407 407 /* drop packet if it has not necessary minimum size */ 408 408 if (unlikely(!pskb_may_pull(skb, hdr_size))) ··· 423 421 if (!batadv_is_my_mac(ethhdr->h_dest)) 424 422 goto out; 425 423 426 - icmp_packet = (struct icmp_packet_rr *)skb->data; 424 + icmp_packet = (struct batadv_icmp_packet_rr *)skb->data; 427 425 428 426 /* add record route information if not full */ 429 - if ((hdr_size == sizeof(struct icmp_packet_rr)) && 427 + if ((hdr_size == sizeof(struct batadv_icmp_packet_rr)) && 430 428 (icmp_packet->rr_cur < BATADV_RR_LEN)) { 431 429 memcpy(&(icmp_packet->rr[icmp_packet->rr_cur]), 432 430 ethhdr->h_dest, ETH_ALEN); ··· 454 452 if (skb_cow(skb, ETH_HLEN) < 0) 455 453 goto out; 456 454 457 - icmp_packet = (struct icmp_packet_rr *)skb->data; 455 + icmp_packet = (struct batadv_icmp_packet_rr *)skb->data; 458 456 459 457 /* decrement ttl */ 460 458 icmp_packet->header.ttl--; ··· 477 475 * This method rotates the bonding list and increases the 478 476 * returned router's refcount. 479 477 */ 480 - static struct neigh_node * 481 - batadv_find_bond_router(struct orig_node *primary_orig, 482 - const struct hard_iface *recv_if) 478 + static struct batadv_neigh_node * 479 + batadv_find_bond_router(struct batadv_orig_node *primary_orig, 480 + const struct batadv_hard_iface *recv_if) 483 481 { 484 - struct neigh_node *tmp_neigh_node; 485 - struct neigh_node *router = NULL, *first_candidate = NULL; 482 + struct batadv_neigh_node *tmp_neigh_node; 483 + struct batadv_neigh_node *router = NULL, *first_candidate = NULL; 486 484 487 485 rcu_read_lock(); 488 486 list_for_each_entry_rcu(tmp_neigh_node, &primary_orig->bond_list, ··· 532 530 * 533 531 * Increases the returned router's refcount 534 532 */ 535 - static struct neigh_node * 536 - batadv_find_ifalter_router(struct orig_node *primary_orig, 537 - const struct hard_iface *recv_if) 533 + static struct batadv_neigh_node * 534 + batadv_find_ifalter_router(struct batadv_orig_node *primary_orig, 535 + const struct batadv_hard_iface *recv_if) 538 536 { 539 - struct neigh_node *tmp_neigh_node; 540 - struct neigh_node *router = NULL, *first_candidate = NULL; 537 + struct batadv_neigh_node *tmp_neigh_node; 538 + struct batadv_neigh_node *router = NULL, *first_candidate = NULL; 541 539 542 540 rcu_read_lock(); 543 541 list_for_each_entry_rcu(tmp_neigh_node, &primary_orig->bond_list, ··· 579 577 return router; 580 578 } 581 579 582 - int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if) 580 + int batadv_recv_tt_query(struct sk_buff *skb, struct batadv_hard_iface *recv_if) 583 581 { 584 - struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); 585 - struct tt_query_packet *tt_query; 582 + struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface); 583 + struct batadv_tt_query_packet *tt_query; 586 584 uint16_t tt_size; 587 585 struct ethhdr *ethhdr; 588 586 char tt_flag; 587 + size_t packet_size; 589 588 590 589 /* drop packet if it has not necessary minimum size */ 591 - if (unlikely(!pskb_may_pull(skb, sizeof(struct tt_query_packet)))) 590 + if (unlikely(!pskb_may_pull(skb, 591 + sizeof(struct batadv_tt_query_packet)))) 592 592 goto out; 593 593 594 594 /* I could need to modify it */ 595 - if (skb_cow(skb, sizeof(struct tt_query_packet)) < 0) 595 + if (skb_cow(skb, sizeof(struct batadv_tt_query_packet)) < 0) 596 596 goto out; 597 597 598 598 ethhdr = (struct ethhdr *)skb_mac_header(skb); ··· 607 603 if (is_broadcast_ether_addr(ethhdr->h_source)) 608 604 goto out; 609 605 610 - tt_query = (struct tt_query_packet *)skb->data; 606 + tt_query = (struct batadv_tt_query_packet *)skb->data; 611 607 612 608 switch (tt_query->flags & BATADV_TT_QUERY_TYPE_MASK) { 613 - case TT_REQUEST: 614 - batadv_inc_counter(bat_priv, BAT_CNT_TT_REQUEST_RX); 609 + case BATADV_TT_REQUEST: 610 + batadv_inc_counter(bat_priv, BATADV_CNT_TT_REQUEST_RX); 615 611 616 612 /* If we cannot provide an answer the tt_request is 617 613 * forwarded 618 614 */ 619 615 if (!batadv_send_tt_response(bat_priv, tt_query)) { 620 - tt_flag = tt_query->flags & TT_FULL_TABLE ? 'F' : '.'; 621 - batadv_dbg(DBG_TT, bat_priv, 616 + if (tt_query->flags & BATADV_TT_FULL_TABLE) 617 + tt_flag = 'F'; 618 + else 619 + tt_flag = '.'; 620 + 621 + batadv_dbg(BATADV_DBG_TT, bat_priv, 622 622 "Routing TT_REQUEST to %pM [%c]\n", 623 623 tt_query->dst, 624 624 tt_flag); 625 625 return batadv_route_unicast_packet(skb, recv_if); 626 626 } 627 627 break; 628 - case TT_RESPONSE: 629 - batadv_inc_counter(bat_priv, BAT_CNT_TT_RESPONSE_RX); 628 + case BATADV_TT_RESPONSE: 629 + batadv_inc_counter(bat_priv, BATADV_CNT_TT_RESPONSE_RX); 630 630 631 631 if (batadv_is_my_mac(tt_query->dst)) { 632 632 /* packet needs to be linearized to access the TT ··· 639 631 if (skb_linearize(skb) < 0) 640 632 goto out; 641 633 /* skb_linearize() possibly changed skb->data */ 642 - tt_query = (struct tt_query_packet *)skb->data; 634 + tt_query = (struct batadv_tt_query_packet *)skb->data; 643 635 644 636 tt_size = batadv_tt_len(ntohs(tt_query->tt_data)); 645 637 646 638 /* Ensure we have all the claimed data */ 647 - if (unlikely(skb_headlen(skb) < 648 - sizeof(struct tt_query_packet) + tt_size)) 639 + packet_size = sizeof(struct batadv_tt_query_packet); 640 + packet_size += tt_size; 641 + if (unlikely(skb_headlen(skb) < packet_size)) 649 642 goto out; 650 643 651 644 batadv_handle_tt_response(bat_priv, tt_query); 652 645 } else { 653 - tt_flag = tt_query->flags & TT_FULL_TABLE ? 'F' : '.'; 654 - batadv_dbg(DBG_TT, bat_priv, 646 + if (tt_query->flags & BATADV_TT_FULL_TABLE) 647 + tt_flag = 'F'; 648 + else 649 + tt_flag = '.'; 650 + batadv_dbg(BATADV_DBG_TT, bat_priv, 655 651 "Routing TT_RESPONSE to %pM [%c]\n", 656 652 tt_query->dst, 657 653 tt_flag); ··· 669 657 return NET_RX_DROP; 670 658 } 671 659 672 - int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if) 660 + int batadv_recv_roam_adv(struct sk_buff *skb, struct batadv_hard_iface *recv_if) 673 661 { 674 - struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); 675 - struct roam_adv_packet *roam_adv_packet; 676 - struct orig_node *orig_node; 662 + struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface); 663 + struct batadv_roam_adv_packet *roam_adv_packet; 664 + struct batadv_orig_node *orig_node; 677 665 struct ethhdr *ethhdr; 678 666 679 667 /* drop packet if it has not necessary minimum size */ 680 - if (unlikely(!pskb_may_pull(skb, sizeof(struct roam_adv_packet)))) 668 + if (unlikely(!pskb_may_pull(skb, 669 + sizeof(struct batadv_roam_adv_packet)))) 681 670 goto out; 682 671 683 672 ethhdr = (struct ethhdr *)skb_mac_header(skb); ··· 691 678 if (is_broadcast_ether_addr(ethhdr->h_source)) 692 679 goto out; 693 680 694 - batadv_inc_counter(bat_priv, BAT_CNT_TT_ROAM_ADV_RX); 681 + batadv_inc_counter(bat_priv, BATADV_CNT_TT_ROAM_ADV_RX); 695 682 696 - roam_adv_packet = (struct roam_adv_packet *)skb->data; 683 + roam_adv_packet = (struct batadv_roam_adv_packet *)skb->data; 697 684 698 685 if (!batadv_is_my_mac(roam_adv_packet->dst)) 699 686 return batadv_route_unicast_packet(skb, recv_if); ··· 709 696 if (!orig_node) 710 697 goto out; 711 698 712 - batadv_dbg(DBG_TT, bat_priv, 699 + batadv_dbg(BATADV_DBG_TT, bat_priv, 713 700 "Received ROAMING_ADV from %pM (client %pM)\n", 714 701 roam_adv_packet->src, roam_adv_packet->client); 715 702 716 703 batadv_tt_global_add(bat_priv, orig_node, roam_adv_packet->client, 717 - TT_CLIENT_ROAM, 704 + BATADV_TT_CLIENT_ROAM, 718 705 atomic_read(&orig_node->last_ttvn) + 1); 719 706 720 707 /* Roaming phase starts: I have new information but the ttvn has not ··· 733 720 * bonding if possible. increases the found neighbors 734 721 * refcount. 735 722 */ 736 - struct neigh_node *batadv_find_router(struct bat_priv *bat_priv, 737 - struct orig_node *orig_node, 738 - const struct hard_iface *recv_if) 723 + struct batadv_neigh_node * 724 + batadv_find_router(struct batadv_priv *bat_priv, 725 + struct batadv_orig_node *orig_node, 726 + const struct batadv_hard_iface *recv_if) 739 727 { 740 - struct orig_node *primary_orig_node; 741 - struct orig_node *router_orig; 742 - struct neigh_node *router; 728 + struct batadv_orig_node *primary_orig_node; 729 + struct batadv_orig_node *router_orig; 730 + struct batadv_neigh_node *router; 743 731 static uint8_t zero_mac[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; 744 732 int bonding_enabled; 745 733 uint8_t *primary_addr; ··· 806 792 router = batadv_find_ifalter_router(primary_orig_node, recv_if); 807 793 808 794 return_router: 809 - if (router && router->if_incoming->if_status != IF_ACTIVE) 795 + if (router && router->if_incoming->if_status != BATADV_IF_ACTIVE) 810 796 goto err_unlock; 811 797 812 798 rcu_read_unlock(); ··· 845 831 } 846 832 847 833 static int batadv_route_unicast_packet(struct sk_buff *skb, 848 - struct hard_iface *recv_if) 834 + struct batadv_hard_iface *recv_if) 849 835 { 850 - struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); 851 - struct orig_node *orig_node = NULL; 852 - struct neigh_node *neigh_node = NULL; 853 - struct unicast_packet *unicast_packet; 836 + struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface); 837 + struct batadv_orig_node *orig_node = NULL; 838 + struct batadv_neigh_node *neigh_node = NULL; 839 + struct batadv_unicast_packet *unicast_packet; 854 840 struct ethhdr *ethhdr = (struct ethhdr *)skb_mac_header(skb); 855 841 int ret = NET_RX_DROP; 856 842 struct sk_buff *new_skb; 857 843 858 - unicast_packet = (struct unicast_packet *)skb->data; 844 + unicast_packet = (struct batadv_unicast_packet *)skb->data; 859 845 860 846 /* TTL exceeded */ 861 847 if (unicast_packet->header.ttl < 2) { ··· 880 866 if (skb_cow(skb, ETH_HLEN) < 0) 881 867 goto out; 882 868 883 - unicast_packet = (struct unicast_packet *)skb->data; 869 + unicast_packet = (struct batadv_unicast_packet *)skb->data; 884 870 885 - if (unicast_packet->header.packet_type == BAT_UNICAST && 871 + if (unicast_packet->header.packet_type == BATADV_UNICAST && 886 872 atomic_read(&bat_priv->fragmentation) && 887 873 skb->len > neigh_node->if_incoming->net_dev->mtu) { 888 874 ret = batadv_frag_send_skb(skb, bat_priv, ··· 891 877 goto out; 892 878 } 893 879 894 - if (unicast_packet->header.packet_type == BAT_UNICAST_FRAG && 880 + if (unicast_packet->header.packet_type == BATADV_UNICAST_FRAG && 895 881 batadv_frag_can_reassemble(skb, 896 882 neigh_node->if_incoming->net_dev->mtu)) { 897 883 ··· 907 893 } 908 894 909 895 skb = new_skb; 910 - unicast_packet = (struct unicast_packet *)skb->data; 896 + unicast_packet = (struct batadv_unicast_packet *)skb->data; 911 897 } 912 898 913 899 /* decrement ttl */ 914 900 unicast_packet->header.ttl--; 915 901 916 902 /* Update stats counter */ 917 - batadv_inc_counter(bat_priv, BAT_CNT_FORWARD); 918 - batadv_add_counter(bat_priv, BAT_CNT_FORWARD_BYTES, 903 + batadv_inc_counter(bat_priv, BATADV_CNT_FORWARD); 904 + batadv_add_counter(bat_priv, BATADV_CNT_FORWARD_BYTES, 919 905 skb->len + ETH_HLEN); 920 906 921 907 /* route it */ ··· 930 916 return ret; 931 917 } 932 918 933 - static int batadv_check_unicast_ttvn(struct bat_priv *bat_priv, 919 + static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, 934 920 struct sk_buff *skb) { 935 921 uint8_t curr_ttvn; 936 - struct orig_node *orig_node; 922 + struct batadv_orig_node *orig_node; 937 923 struct ethhdr *ethhdr; 938 - struct hard_iface *primary_if; 939 - struct unicast_packet *unicast_packet; 924 + struct batadv_hard_iface *primary_if; 925 + struct batadv_unicast_packet *unicast_packet; 940 926 bool tt_poss_change; 941 927 int is_old_ttvn; 942 928 943 929 /* I could need to modify it */ 944 - if (skb_cow(skb, sizeof(struct unicast_packet)) < 0) 930 + if (skb_cow(skb, sizeof(struct batadv_unicast_packet)) < 0) 945 931 return 0; 946 932 947 - unicast_packet = (struct unicast_packet *)skb->data; 933 + unicast_packet = (struct batadv_unicast_packet *)skb->data; 948 934 949 935 if (batadv_is_my_mac(unicast_packet->dest)) { 950 936 tt_poss_change = bat_priv->tt_poss_change; ··· 965 951 is_old_ttvn = batadv_seq_before(unicast_packet->ttvn, curr_ttvn); 966 952 if (is_old_ttvn || tt_poss_change) { 967 953 /* check if there is enough data before accessing it */ 968 - if (pskb_may_pull(skb, sizeof(struct unicast_packet) + 954 + if (pskb_may_pull(skb, sizeof(struct batadv_unicast_packet) + 969 955 ETH_HLEN) < 0) 970 956 return 0; 971 957 972 - ethhdr = (struct ethhdr *)(skb->data + 973 - sizeof(struct unicast_packet)); 958 + ethhdr = (struct ethhdr *)(skb->data + sizeof(*unicast_packet)); 974 959 975 960 /* we don't have an updated route for this client, so we should 976 961 * not try to reroute the packet!! ··· 998 985 batadv_orig_node_free_ref(orig_node); 999 986 } 1000 987 1001 - batadv_dbg(DBG_ROUTES, bat_priv, 988 + batadv_dbg(BATADV_DBG_ROUTES, bat_priv, 1002 989 "TTVN mismatch (old_ttvn %u new_ttvn %u)! Rerouting unicast packet (for %pM) to %pM\n", 1003 990 unicast_packet->ttvn, curr_ttvn, ethhdr->h_dest, 1004 991 unicast_packet->dest); ··· 1008 995 return 1; 1009 996 } 1010 997 1011 - int batadv_recv_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if) 998 + int batadv_recv_unicast_packet(struct sk_buff *skb, 999 + struct batadv_hard_iface *recv_if) 1012 1000 { 1013 - struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); 1014 - struct unicast_packet *unicast_packet; 1001 + struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface); 1002 + struct batadv_unicast_packet *unicast_packet; 1015 1003 int hdr_size = sizeof(*unicast_packet); 1016 1004 1017 1005 if (batadv_check_unicast_packet(skb, hdr_size) < 0) ··· 1021 1007 if (!batadv_check_unicast_ttvn(bat_priv, skb)) 1022 1008 return NET_RX_DROP; 1023 1009 1024 - unicast_packet = (struct unicast_packet *)skb->data; 1010 + unicast_packet = (struct batadv_unicast_packet *)skb->data; 1025 1011 1026 1012 /* packet for me */ 1027 1013 if (batadv_is_my_mac(unicast_packet->dest)) { ··· 1034 1020 } 1035 1021 1036 1022 int batadv_recv_ucast_frag_packet(struct sk_buff *skb, 1037 - struct hard_iface *recv_if) 1023 + struct batadv_hard_iface *recv_if) 1038 1024 { 1039 - struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); 1040 - struct unicast_frag_packet *unicast_packet; 1025 + struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface); 1026 + struct batadv_unicast_frag_packet *unicast_packet; 1041 1027 int hdr_size = sizeof(*unicast_packet); 1042 1028 struct sk_buff *new_skb = NULL; 1043 1029 int ret; ··· 1048 1034 if (!batadv_check_unicast_ttvn(bat_priv, skb)) 1049 1035 return NET_RX_DROP; 1050 1036 1051 - unicast_packet = (struct unicast_frag_packet *)skb->data; 1037 + unicast_packet = (struct batadv_unicast_frag_packet *)skb->data; 1052 1038 1053 1039 /* packet for me */ 1054 1040 if (batadv_is_my_mac(unicast_packet->dest)) { ··· 1063 1049 return NET_RX_SUCCESS; 1064 1050 1065 1051 batadv_interface_rx(recv_if->soft_iface, new_skb, recv_if, 1066 - sizeof(struct unicast_packet)); 1052 + sizeof(struct batadv_unicast_packet)); 1067 1053 return NET_RX_SUCCESS; 1068 1054 } 1069 1055 ··· 1071 1057 } 1072 1058 1073 1059 1074 - int batadv_recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if) 1060 + int batadv_recv_bcast_packet(struct sk_buff *skb, 1061 + struct batadv_hard_iface *recv_if) 1075 1062 { 1076 - struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); 1077 - struct orig_node *orig_node = NULL; 1078 - struct bcast_packet *bcast_packet; 1063 + struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface); 1064 + struct batadv_orig_node *orig_node = NULL; 1065 + struct batadv_bcast_packet *bcast_packet; 1079 1066 struct ethhdr *ethhdr; 1080 1067 int hdr_size = sizeof(*bcast_packet); 1081 1068 int ret = NET_RX_DROP; ··· 1100 1085 if (batadv_is_my_mac(ethhdr->h_source)) 1101 1086 goto out; 1102 1087 1103 - bcast_packet = (struct bcast_packet *)skb->data; 1088 + bcast_packet = (struct batadv_bcast_packet *)skb->data; 1104 1089 1105 1090 /* ignore broadcasts originated by myself */ 1106 1091 if (batadv_is_my_mac(bcast_packet->orig)) ··· 1162 1147 return ret; 1163 1148 } 1164 1149 1165 - int batadv_recv_vis_packet(struct sk_buff *skb, struct hard_iface *recv_if) 1150 + int batadv_recv_vis_packet(struct sk_buff *skb, 1151 + struct batadv_hard_iface *recv_if) 1166 1152 { 1167 - struct vis_packet *vis_packet; 1153 + struct batadv_vis_packet *vis_packet; 1168 1154 struct ethhdr *ethhdr; 1169 - struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); 1155 + struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface); 1170 1156 int hdr_size = sizeof(*vis_packet); 1171 1157 1172 1158 /* keep skb linear */ ··· 1177 1161 if (unlikely(!pskb_may_pull(skb, hdr_size))) 1178 1162 return NET_RX_DROP; 1179 1163 1180 - vis_packet = (struct vis_packet *)skb->data; 1164 + vis_packet = (struct batadv_vis_packet *)skb->data; 1181 1165 ethhdr = (struct ethhdr *)skb_mac_header(skb); 1182 1166 1183 1167 /* not for me */ ··· 1192 1176 return NET_RX_DROP; 1193 1177 1194 1178 switch (vis_packet->vis_type) { 1195 - case VIS_TYPE_SERVER_SYNC: 1179 + case BATADV_VIS_TYPE_SERVER_SYNC: 1196 1180 batadv_receive_server_sync_packet(bat_priv, vis_packet, 1197 1181 skb_headlen(skb)); 1198 1182 break; 1199 1183 1200 - case VIS_TYPE_CLIENT_UPDATE: 1184 + case BATADV_VIS_TYPE_CLIENT_UPDATE: 1201 1185 batadv_receive_client_update_packet(bat_priv, vis_packet, 1202 1186 skb_headlen(skb)); 1203 1187 break;
+30 -22
net/batman-adv/routing.h
··· 20 20 #ifndef _NET_BATMAN_ADV_ROUTING_H_ 21 21 #define _NET_BATMAN_ADV_ROUTING_H_ 22 22 23 - void batadv_slide_own_bcast_window(struct hard_iface *hard_iface); 23 + void batadv_slide_own_bcast_window(struct batadv_hard_iface *hard_iface); 24 24 bool batadv_check_management_packet(struct sk_buff *skb, 25 - struct hard_iface *hard_iface, 25 + struct batadv_hard_iface *hard_iface, 26 26 int header_len); 27 - void batadv_update_route(struct bat_priv *bat_priv, struct orig_node *orig_node, 28 - struct neigh_node *neigh_node); 29 - int batadv_recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if); 30 - int batadv_recv_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if); 27 + void batadv_update_route(struct batadv_priv *bat_priv, 28 + struct batadv_orig_node *orig_node, 29 + struct batadv_neigh_node *neigh_node); 30 + int batadv_recv_icmp_packet(struct sk_buff *skb, 31 + struct batadv_hard_iface *recv_if); 32 + int batadv_recv_unicast_packet(struct sk_buff *skb, 33 + struct batadv_hard_iface *recv_if); 31 34 int batadv_recv_ucast_frag_packet(struct sk_buff *skb, 32 - struct hard_iface *recv_if); 33 - int batadv_recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if); 34 - int batadv_recv_vis_packet(struct sk_buff *skb, struct hard_iface *recv_if); 35 - int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if); 36 - int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if); 37 - struct neigh_node *batadv_find_router(struct bat_priv *bat_priv, 38 - struct orig_node *orig_node, 39 - const struct hard_iface *recv_if); 40 - void batadv_bonding_candidate_del(struct orig_node *orig_node, 41 - struct neigh_node *neigh_node); 42 - void batadv_bonding_candidate_add(struct orig_node *orig_node, 43 - struct neigh_node *neigh_node); 44 - void batadv_bonding_save_primary(const struct orig_node *orig_node, 45 - struct orig_node *orig_neigh_node, 46 - const struct batman_ogm_packet 35 + struct batadv_hard_iface *recv_if); 36 + int batadv_recv_bcast_packet(struct sk_buff *skb, 37 + struct batadv_hard_iface *recv_if); 38 + int batadv_recv_vis_packet(struct sk_buff *skb, 39 + struct batadv_hard_iface *recv_if); 40 + int batadv_recv_tt_query(struct sk_buff *skb, 41 + struct batadv_hard_iface *recv_if); 42 + int batadv_recv_roam_adv(struct sk_buff *skb, 43 + struct batadv_hard_iface *recv_if); 44 + struct batadv_neigh_node * 45 + batadv_find_router(struct batadv_priv *bat_priv, 46 + struct batadv_orig_node *orig_node, 47 + const struct batadv_hard_iface *recv_if); 48 + void batadv_bonding_candidate_del(struct batadv_orig_node *orig_node, 49 + struct batadv_neigh_node *neigh_node); 50 + void batadv_bonding_candidate_add(struct batadv_orig_node *orig_node, 51 + struct batadv_neigh_node *neigh_node); 52 + void batadv_bonding_save_primary(const struct batadv_orig_node *orig_node, 53 + struct batadv_orig_node *orig_neigh_node, 54 + const struct batadv_ogm_packet 47 55 *batman_ogm_packet); 48 - int batadv_window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff, 56 + int batadv_window_protected(struct batadv_priv *bat_priv, int32_t seq_num_diff, 49 57 unsigned long *last_reset); 50 58 51 59 #endif /* _NET_BATMAN_ADV_ROUTING_H_ */
+42 -33
net/batman-adv/send.c
··· 32 32 /* send out an already prepared packet to the given address via the 33 33 * specified batman interface 34 34 */ 35 - int batadv_send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface, 35 + int batadv_send_skb_packet(struct sk_buff *skb, 36 + struct batadv_hard_iface *hard_iface, 36 37 const uint8_t *dst_addr) 37 38 { 38 39 struct ethhdr *ethhdr; 39 40 40 - if (hard_iface->if_status != IF_ACTIVE) 41 + if (hard_iface->if_status != BATADV_IF_ACTIVE) 41 42 goto send_skb_err; 42 43 43 44 if (unlikely(!hard_iface->net_dev)) ··· 77 76 return NET_XMIT_DROP; 78 77 } 79 78 80 - void batadv_schedule_bat_ogm(struct hard_iface *hard_iface) 79 + void batadv_schedule_bat_ogm(struct batadv_hard_iface *hard_iface) 81 80 { 82 - struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 81 + struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 83 82 84 - if ((hard_iface->if_status == IF_NOT_IN_USE) || 85 - (hard_iface->if_status == IF_TO_BE_REMOVED)) 83 + if ((hard_iface->if_status == BATADV_IF_NOT_IN_USE) || 84 + (hard_iface->if_status == BATADV_IF_TO_BE_REMOVED)) 86 85 return; 87 86 88 87 /* the interface gets activated here to avoid race conditions between ··· 91 90 * outdated packets (especially uninitialized mac addresses) in the 92 91 * packet queue 93 92 */ 94 - if (hard_iface->if_status == IF_TO_BE_ACTIVATED) 95 - hard_iface->if_status = IF_ACTIVE; 93 + if (hard_iface->if_status == BATADV_IF_TO_BE_ACTIVATED) 94 + hard_iface->if_status = BATADV_IF_ACTIVE; 96 95 97 96 bat_priv->bat_algo_ops->bat_ogm_schedule(hard_iface); 98 97 } 99 98 100 - static void batadv_forw_packet_free(struct forw_packet *forw_packet) 99 + static void batadv_forw_packet_free(struct batadv_forw_packet *forw_packet) 101 100 { 102 101 if (forw_packet->skb) 103 102 kfree_skb(forw_packet->skb); ··· 106 105 kfree(forw_packet); 107 106 } 108 107 109 - static void _batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv, 110 - struct forw_packet *forw_packet, 111 - unsigned long send_time) 108 + static void 109 + _batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv, 110 + struct batadv_forw_packet *forw_packet, 111 + unsigned long send_time) 112 112 { 113 113 INIT_HLIST_NODE(&forw_packet->list); 114 114 ··· 134 132 * The skb is not consumed, so the caller should make sure that the 135 133 * skb is freed. 136 134 */ 137 - int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv, 135 + int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv, 138 136 const struct sk_buff *skb, 139 137 unsigned long delay) 140 138 { 141 - struct hard_iface *primary_if = NULL; 142 - struct forw_packet *forw_packet; 143 - struct bcast_packet *bcast_packet; 139 + struct batadv_hard_iface *primary_if = NULL; 140 + struct batadv_forw_packet *forw_packet; 141 + struct batadv_bcast_packet *bcast_packet; 144 142 struct sk_buff *newskb; 145 143 146 144 if (!batadv_atomic_dec_not_zero(&bat_priv->bcast_queue_left)) { 147 - batadv_dbg(DBG_BATMAN, bat_priv, "bcast packet queue full\n"); 145 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 146 + "bcast packet queue full\n"); 148 147 goto out; 149 148 } 150 149 ··· 163 160 goto packet_free; 164 161 165 162 /* as we have a copy now, it is safe to decrease the TTL */ 166 - bcast_packet = (struct bcast_packet *)newskb->data; 163 + bcast_packet = (struct batadv_bcast_packet *)newskb->data; 167 164 bcast_packet->header.ttl--; 168 165 169 166 skb_reset_mac_header(newskb); ··· 189 186 190 187 static void batadv_send_outstanding_bcast_packet(struct work_struct *work) 191 188 { 192 - struct hard_iface *hard_iface; 189 + struct batadv_hard_iface *hard_iface; 193 190 struct delayed_work *delayed_work = 194 191 container_of(work, struct delayed_work, work); 195 - struct forw_packet *forw_packet = 196 - container_of(delayed_work, struct forw_packet, delayed_work); 192 + struct batadv_forw_packet *forw_packet; 197 193 struct sk_buff *skb1; 198 - struct net_device *soft_iface = forw_packet->if_incoming->soft_iface; 199 - struct bat_priv *bat_priv = netdev_priv(soft_iface); 194 + struct net_device *soft_iface; 195 + struct batadv_priv *bat_priv; 196 + 197 + forw_packet = container_of(delayed_work, struct batadv_forw_packet, 198 + delayed_work); 199 + soft_iface = forw_packet->if_incoming->soft_iface; 200 + bat_priv = netdev_priv(soft_iface); 200 201 201 202 spin_lock_bh(&bat_priv->forw_bcast_list_lock); 202 203 hlist_del(&forw_packet->list); 203 204 spin_unlock_bh(&bat_priv->forw_bcast_list_lock); 204 205 205 - if (atomic_read(&bat_priv->mesh_state) == MESH_DEACTIVATING) 206 + if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_DEACTIVATING) 206 207 goto out; 207 208 208 209 /* rebroadcast packet */ ··· 241 234 { 242 235 struct delayed_work *delayed_work = 243 236 container_of(work, struct delayed_work, work); 244 - struct forw_packet *forw_packet = 245 - container_of(delayed_work, struct forw_packet, delayed_work); 246 - struct bat_priv *bat_priv; 237 + struct batadv_forw_packet *forw_packet; 238 + struct batadv_priv *bat_priv; 247 239 240 + forw_packet = container_of(delayed_work, struct batadv_forw_packet, 241 + delayed_work); 248 242 bat_priv = netdev_priv(forw_packet->if_incoming->soft_iface); 249 243 spin_lock_bh(&bat_priv->forw_bat_list_lock); 250 244 hlist_del(&forw_packet->list); 251 245 spin_unlock_bh(&bat_priv->forw_bat_list_lock); 252 246 253 - if (atomic_read(&bat_priv->mesh_state) == MESH_DEACTIVATING) 247 + if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_DEACTIVATING) 254 248 goto out; 255 249 256 250 bat_priv->bat_algo_ops->bat_ogm_emit(forw_packet); ··· 271 263 batadv_forw_packet_free(forw_packet); 272 264 } 273 265 274 - void batadv_purge_outstanding_packets(struct bat_priv *bat_priv, 275 - const struct hard_iface *hard_iface) 266 + void 267 + batadv_purge_outstanding_packets(struct batadv_priv *bat_priv, 268 + const struct batadv_hard_iface *hard_iface) 276 269 { 277 - struct forw_packet *forw_packet; 270 + struct batadv_forw_packet *forw_packet; 278 271 struct hlist_node *tmp_node, *safe_tmp_node; 279 272 bool pending; 280 273 281 274 if (hard_iface) 282 - batadv_dbg(DBG_BATMAN, bat_priv, 275 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 283 276 "purge_outstanding_packets(): %s\n", 284 277 hard_iface->net_dev->name); 285 278 else 286 - batadv_dbg(DBG_BATMAN, bat_priv, 279 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 287 280 "purge_outstanding_packets()\n"); 288 281 289 282 /* free bcast list */
+7 -5
net/batman-adv/send.h
··· 20 20 #ifndef _NET_BATMAN_ADV_SEND_H_ 21 21 #define _NET_BATMAN_ADV_SEND_H_ 22 22 23 - int batadv_send_skb_packet(struct sk_buff *skb, struct hard_iface *hard_iface, 23 + int batadv_send_skb_packet(struct sk_buff *skb, 24 + struct batadv_hard_iface *hard_iface, 24 25 const uint8_t *dst_addr); 25 - void batadv_schedule_bat_ogm(struct hard_iface *hard_iface); 26 - int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv, 26 + void batadv_schedule_bat_ogm(struct batadv_hard_iface *hard_iface); 27 + int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv, 27 28 const struct sk_buff *skb, 28 29 unsigned long delay); 29 30 void batadv_send_outstanding_bat_ogm_packet(struct work_struct *work); 30 - void batadv_purge_outstanding_packets(struct bat_priv *bat_priv, 31 - const struct hard_iface *hard_iface); 31 + void 32 + batadv_purge_outstanding_packets(struct batadv_priv *bat_priv, 33 + const struct batadv_hard_iface *hard_iface); 32 34 33 35 #endif /* _NET_BATMAN_ADV_SEND_H_ */
+28 -27
net/batman-adv/soft-interface.c
··· 22 22 #include "hard-interface.h" 23 23 #include "routing.h" 24 24 #include "send.h" 25 - #include "bat_debugfs.h" 25 + #include "debugfs.h" 26 26 #include "translation-table.h" 27 27 #include "hash.h" 28 28 #include "gateway_common.h" 29 29 #include "gateway_client.h" 30 - #include "bat_sysfs.h" 30 + #include "sysfs.h" 31 31 #include "originator.h" 32 32 #include <linux/slab.h> 33 33 #include <linux/ethtool.h> ··· 92 92 93 93 static struct net_device_stats *batadv_interface_stats(struct net_device *dev) 94 94 { 95 - struct bat_priv *bat_priv = netdev_priv(dev); 95 + struct batadv_priv *bat_priv = netdev_priv(dev); 96 96 return &bat_priv->stats; 97 97 } 98 98 99 99 static int batadv_interface_set_mac_addr(struct net_device *dev, void *p) 100 100 { 101 - struct bat_priv *bat_priv = netdev_priv(dev); 101 + struct batadv_priv *bat_priv = netdev_priv(dev); 102 102 struct sockaddr *addr = p; 103 103 104 104 if (!is_valid_ether_addr(addr->sa_data)) 105 105 return -EADDRNOTAVAIL; 106 106 107 107 /* only modify transtable if it has been initialized before */ 108 - if (atomic_read(&bat_priv->mesh_state) == MESH_ACTIVE) { 108 + if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_ACTIVE) { 109 109 batadv_tt_local_remove(bat_priv, dev->dev_addr, 110 110 "mac address changed", false); 111 111 batadv_tt_local_add(dev, addr->sa_data, BATADV_NULL_IFINDEX); ··· 131 131 struct net_device *soft_iface) 132 132 { 133 133 struct ethhdr *ethhdr = (struct ethhdr *)skb->data; 134 - struct bat_priv *bat_priv = netdev_priv(soft_iface); 135 - struct hard_iface *primary_if = NULL; 136 - struct bcast_packet *bcast_packet; 134 + struct batadv_priv *bat_priv = netdev_priv(soft_iface); 135 + struct batadv_hard_iface *primary_if = NULL; 136 + struct batadv_bcast_packet *bcast_packet; 137 137 struct vlan_ethhdr *vhdr; 138 138 __be16 ethertype = __constant_htons(BATADV_ETH_P_BATMAN); 139 139 static const uint8_t stp_addr[ETH_ALEN] = {0x01, 0x80, 0xC2, 0x00, 0x00, ··· 143 143 short vid __maybe_unused = -1; 144 144 bool do_bcast = false; 145 145 146 - if (atomic_read(&bat_priv->mesh_state) != MESH_ACTIVE) 146 + if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE) 147 147 goto dropped; 148 148 149 149 soft_iface->trans_start = jiffies; ··· 177 177 do_bcast = true; 178 178 179 179 switch (atomic_read(&bat_priv->gw_mode)) { 180 - case GW_MODE_SERVER: 180 + case BATADV_GW_MODE_SERVER: 181 181 /* gateway servers should not send dhcp 182 182 * requests into the mesh 183 183 */ ··· 185 185 if (ret) 186 186 goto dropped; 187 187 break; 188 - case GW_MODE_CLIENT: 188 + case BATADV_GW_MODE_CLIENT: 189 189 /* gateway clients should send dhcp requests 190 190 * via unicast to their gateway 191 191 */ ··· 193 193 if (ret) 194 194 do_bcast = false; 195 195 break; 196 - case GW_MODE_OFF: 196 + case BATADV_GW_MODE_OFF: 197 197 default: 198 198 break; 199 199 } ··· 208 208 if (batadv_skb_head_push(skb, sizeof(*bcast_packet)) < 0) 209 209 goto dropped; 210 210 211 - bcast_packet = (struct bcast_packet *)skb->data; 211 + bcast_packet = (struct batadv_bcast_packet *)skb->data; 212 212 bcast_packet->header.version = BATADV_COMPAT_VERSION; 213 213 bcast_packet->header.ttl = BATADV_TTL; 214 214 215 215 /* batman packet type: broadcast */ 216 - bcast_packet->header.packet_type = BAT_BCAST; 216 + bcast_packet->header.packet_type = BATADV_BCAST; 217 + bcast_packet->reserved = 0; 217 218 218 219 /* hw address of first interface is the orig mac because only 219 220 * this mac is known throughout the mesh ··· 235 234 236 235 /* unicast packet */ 237 236 } else { 238 - if (atomic_read(&bat_priv->gw_mode) != GW_MODE_OFF) { 237 + if (atomic_read(&bat_priv->gw_mode) != BATADV_GW_MODE_OFF) { 239 238 ret = batadv_gw_out_of_range(bat_priv, skb, ethhdr); 240 239 if (ret) 241 240 goto dropped; ··· 261 260 } 262 261 263 262 void batadv_interface_rx(struct net_device *soft_iface, 264 - struct sk_buff *skb, struct hard_iface *recv_if, 263 + struct sk_buff *skb, struct batadv_hard_iface *recv_if, 265 264 int hdr_size) 266 265 { 267 - struct bat_priv *bat_priv = netdev_priv(soft_iface); 266 + struct batadv_priv *bat_priv = netdev_priv(soft_iface); 268 267 struct ethhdr *ethhdr; 269 268 struct vlan_ethhdr *vhdr; 270 269 short vid __maybe_unused = -1; ··· 339 338 340 339 static void batadv_interface_setup(struct net_device *dev) 341 340 { 342 - struct bat_priv *priv = netdev_priv(dev); 341 + struct batadv_priv *priv = netdev_priv(dev); 343 342 344 343 ether_setup(dev); 345 344 ··· 365 364 struct net_device *batadv_softif_create(const char *name) 366 365 { 367 366 struct net_device *soft_iface; 368 - struct bat_priv *bat_priv; 367 + struct batadv_priv *bat_priv; 369 368 int ret; 369 + size_t cnt_len = sizeof(uint64_t) * BATADV_CNT_NUM; 370 370 371 371 soft_iface = alloc_netdev(sizeof(*bat_priv), name, 372 372 batadv_interface_setup); ··· 388 386 atomic_set(&bat_priv->bonding, 0); 389 387 atomic_set(&bat_priv->bridge_loop_avoidance, 0); 390 388 atomic_set(&bat_priv->ap_isolation, 0); 391 - atomic_set(&bat_priv->vis_mode, VIS_TYPE_CLIENT_UPDATE); 392 - atomic_set(&bat_priv->gw_mode, GW_MODE_OFF); 389 + atomic_set(&bat_priv->vis_mode, BATADV_VIS_TYPE_CLIENT_UPDATE); 390 + atomic_set(&bat_priv->gw_mode, BATADV_GW_MODE_OFF); 393 391 atomic_set(&bat_priv->gw_sel_class, 20); 394 392 atomic_set(&bat_priv->gw_bandwidth, 41); 395 393 atomic_set(&bat_priv->orig_interval, 1000); ··· 399 397 atomic_set(&bat_priv->bcast_queue_left, BATADV_BCAST_QUEUE_LEN); 400 398 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN); 401 399 402 - atomic_set(&bat_priv->mesh_state, MESH_INACTIVE); 400 + atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE); 403 401 atomic_set(&bat_priv->bcast_seqno, 1); 404 402 atomic_set(&bat_priv->ttvn, 0); 405 403 atomic_set(&bat_priv->tt_local_changes, 0); ··· 413 411 bat_priv->primary_if = NULL; 414 412 bat_priv->num_ifaces = 0; 415 413 416 - bat_priv->bat_counters = __alloc_percpu(sizeof(uint64_t) * BAT_CNT_NUM, 417 - __alignof__(uint64_t)); 414 + bat_priv->bat_counters = __alloc_percpu(cnt_len, __alignof__(uint64_t)); 418 415 if (!bat_priv->bat_counters) 419 416 goto unreg_soft_iface; 420 417 ··· 540 539 struct ethtool_stats *stats, 541 540 uint64_t *data) 542 541 { 543 - struct bat_priv *bat_priv = netdev_priv(dev); 542 + struct batadv_priv *bat_priv = netdev_priv(dev); 544 543 int i; 545 544 546 - for (i = 0; i < BAT_CNT_NUM; i++) 545 + for (i = 0; i < BATADV_CNT_NUM; i++) 547 546 data[i] = batadv_sum_counter(bat_priv, i); 548 547 } 549 548 550 549 static int batadv_get_sset_count(struct net_device *dev, int stringset) 551 550 { 552 551 if (stringset == ETH_SS_STATS) 553 - return BAT_CNT_NUM; 552 + return BATADV_CNT_NUM; 554 553 555 554 return -EOPNOTSUPP; 556 555 }
+1 -1
net/batman-adv/soft-interface.h
··· 22 22 23 23 int batadv_skb_head_push(struct sk_buff *skb, unsigned int len); 24 24 void batadv_interface_rx(struct net_device *soft_iface, struct sk_buff *skb, 25 - struct hard_iface *recv_if, int hdr_size); 25 + struct batadv_hard_iface *recv_if, int hdr_size); 26 26 struct net_device *batadv_softif_create(const char *name); 27 27 void batadv_softif_destroy(struct net_device *soft_iface); 28 28 int batadv_softif_is_valid(const struct net_device *net_dev);
+421 -387
net/batman-adv/translation-table.c
··· 29 29 30 30 #include <linux/crc16.h> 31 31 32 - static void batadv_send_roam_adv(struct bat_priv *bat_priv, uint8_t *client, 33 - struct orig_node *orig_node); 32 + static void batadv_send_roam_adv(struct batadv_priv *bat_priv, uint8_t *client, 33 + struct batadv_orig_node *orig_node); 34 34 static void batadv_tt_purge(struct work_struct *work); 35 35 static void 36 - batadv_tt_global_del_orig_list(struct tt_global_entry *tt_global_entry); 36 + batadv_tt_global_del_orig_list(struct batadv_tt_global_entry *tt_global_entry); 37 37 38 38 /* returns 1 if they are the same mac addr */ 39 39 static int batadv_compare_tt(const struct hlist_node *node, const void *data2) 40 40 { 41 - const void *data1 = container_of(node, struct tt_common_entry, 41 + const void *data1 = container_of(node, struct batadv_tt_common_entry, 42 42 hash_entry); 43 43 44 44 return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0); 45 45 } 46 46 47 - static void batadv_tt_start_timer(struct bat_priv *bat_priv) 47 + static void batadv_tt_start_timer(struct batadv_priv *bat_priv) 48 48 { 49 49 INIT_DELAYED_WORK(&bat_priv->tt_work, batadv_tt_purge); 50 50 queue_delayed_work(batadv_event_workqueue, &bat_priv->tt_work, 51 51 msecs_to_jiffies(5000)); 52 52 } 53 53 54 - static struct tt_common_entry *batadv_tt_hash_find(struct hashtable_t *hash, 55 - const void *data) 54 + static struct batadv_tt_common_entry * 55 + batadv_tt_hash_find(struct batadv_hashtable *hash, const void *data) 56 56 { 57 57 struct hlist_head *head; 58 58 struct hlist_node *node; 59 - struct tt_common_entry *tt_common_entry, *tt_common_entry_tmp = NULL; 59 + struct batadv_tt_common_entry *tt_common_entry; 60 + struct batadv_tt_common_entry *tt_common_entry_tmp = NULL; 60 61 uint32_t index; 61 62 62 63 if (!hash) ··· 82 81 return tt_common_entry_tmp; 83 82 } 84 83 85 - static struct tt_local_entry * 86 - batadv_tt_local_hash_find(struct bat_priv *bat_priv, const void *data) 84 + static struct batadv_tt_local_entry * 85 + batadv_tt_local_hash_find(struct batadv_priv *bat_priv, const void *data) 87 86 { 88 - struct tt_common_entry *tt_common_entry; 89 - struct tt_local_entry *tt_local_entry = NULL; 87 + struct batadv_tt_common_entry *tt_common_entry; 88 + struct batadv_tt_local_entry *tt_local_entry = NULL; 90 89 91 90 tt_common_entry = batadv_tt_hash_find(bat_priv->tt_local_hash, data); 92 91 if (tt_common_entry) 93 92 tt_local_entry = container_of(tt_common_entry, 94 - struct tt_local_entry, common); 93 + struct batadv_tt_local_entry, 94 + common); 95 95 return tt_local_entry; 96 96 } 97 97 98 - static struct tt_global_entry * 99 - batadv_tt_global_hash_find(struct bat_priv *bat_priv, const void *data) 98 + static struct batadv_tt_global_entry * 99 + batadv_tt_global_hash_find(struct batadv_priv *bat_priv, const void *data) 100 100 { 101 - struct tt_common_entry *tt_common_entry; 102 - struct tt_global_entry *tt_global_entry = NULL; 101 + struct batadv_tt_common_entry *tt_common_entry; 102 + struct batadv_tt_global_entry *tt_global_entry = NULL; 103 103 104 104 tt_common_entry = batadv_tt_hash_find(bat_priv->tt_global_hash, data); 105 105 if (tt_common_entry) 106 106 tt_global_entry = container_of(tt_common_entry, 107 - struct tt_global_entry, common); 107 + struct batadv_tt_global_entry, 108 + common); 108 109 return tt_global_entry; 109 110 110 111 } 111 112 112 113 static void 113 - batadv_tt_local_entry_free_ref(struct tt_local_entry *tt_local_entry) 114 + batadv_tt_local_entry_free_ref(struct batadv_tt_local_entry *tt_local_entry) 114 115 { 115 116 if (atomic_dec_and_test(&tt_local_entry->common.refcount)) 116 117 kfree_rcu(tt_local_entry, common.rcu); ··· 120 117 121 118 static void batadv_tt_global_entry_free_rcu(struct rcu_head *rcu) 122 119 { 123 - struct tt_common_entry *tt_common_entry; 124 - struct tt_global_entry *tt_global_entry; 120 + struct batadv_tt_common_entry *tt_common_entry; 121 + struct batadv_tt_global_entry *tt_global_entry; 125 122 126 - tt_common_entry = container_of(rcu, struct tt_common_entry, rcu); 127 - tt_global_entry = container_of(tt_common_entry, struct tt_global_entry, 128 - common); 123 + tt_common_entry = container_of(rcu, struct batadv_tt_common_entry, rcu); 124 + tt_global_entry = container_of(tt_common_entry, 125 + struct batadv_tt_global_entry, common); 129 126 130 127 kfree(tt_global_entry); 131 128 } 132 129 133 130 static void 134 - batadv_tt_global_entry_free_ref(struct tt_global_entry *tt_global_entry) 131 + batadv_tt_global_entry_free_ref(struct batadv_tt_global_entry *tt_global_entry) 135 132 { 136 133 if (atomic_dec_and_test(&tt_global_entry->common.refcount)) { 137 134 batadv_tt_global_del_orig_list(tt_global_entry); ··· 142 139 143 140 static void batadv_tt_orig_list_entry_free_rcu(struct rcu_head *rcu) 144 141 { 145 - struct tt_orig_list_entry *orig_entry; 142 + struct batadv_tt_orig_list_entry *orig_entry; 146 143 147 - orig_entry = container_of(rcu, struct tt_orig_list_entry, rcu); 144 + orig_entry = container_of(rcu, struct batadv_tt_orig_list_entry, rcu); 148 145 batadv_orig_node_free_ref(orig_entry->orig_node); 149 146 kfree(orig_entry); 150 147 } 151 148 152 149 static void 153 - batadv_tt_orig_list_entry_free_ref(struct tt_orig_list_entry *orig_entry) 150 + batadv_tt_orig_list_entry_free_ref(struct batadv_tt_orig_list_entry *orig_entry) 154 151 { 155 152 /* to avoid race conditions, immediately decrease the tt counter */ 156 153 atomic_dec(&orig_entry->orig_node->tt_size); 157 154 call_rcu(&orig_entry->rcu, batadv_tt_orig_list_entry_free_rcu); 158 155 } 159 156 160 - static void batadv_tt_local_event(struct bat_priv *bat_priv, 157 + static void batadv_tt_local_event(struct batadv_priv *bat_priv, 161 158 const uint8_t *addr, uint8_t flags) 162 159 { 163 - struct tt_change_node *tt_change_node, *entry, *safe; 160 + struct batadv_tt_change_node *tt_change_node, *entry, *safe; 164 161 bool event_removed = false; 165 162 bool del_op_requested, del_op_entry; 166 163 ··· 172 169 tt_change_node->change.flags = flags; 173 170 memcpy(tt_change_node->change.addr, addr, ETH_ALEN); 174 171 175 - del_op_requested = flags & TT_CLIENT_DEL; 172 + del_op_requested = flags & BATADV_TT_CLIENT_DEL; 176 173 177 174 /* check for ADD+DEL or DEL+ADD events */ 178 175 spin_lock_bh(&bat_priv->tt_changes_list_lock); ··· 188 185 * now possible due to automatically recognition of "temporary" 189 186 * clients 190 187 */ 191 - del_op_entry = entry->change.flags & TT_CLIENT_DEL; 188 + del_op_entry = entry->change.flags & BATADV_TT_CLIENT_DEL; 192 189 if (!del_op_requested && del_op_entry) 193 190 goto del; 194 191 if (del_op_requested && !del_op_entry) ··· 215 212 216 213 int batadv_tt_len(int changes_num) 217 214 { 218 - return changes_num * sizeof(struct tt_change); 215 + return changes_num * sizeof(struct batadv_tt_change); 219 216 } 220 217 221 - static int batadv_tt_local_init(struct bat_priv *bat_priv) 218 + static int batadv_tt_local_init(struct batadv_priv *bat_priv) 222 219 { 223 220 if (bat_priv->tt_local_hash) 224 221 return 0; ··· 234 231 void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, 235 232 int ifindex) 236 233 { 237 - struct bat_priv *bat_priv = netdev_priv(soft_iface); 238 - struct tt_local_entry *tt_local_entry = NULL; 239 - struct tt_global_entry *tt_global_entry = NULL; 234 + struct batadv_priv *bat_priv = netdev_priv(soft_iface); 235 + struct batadv_tt_local_entry *tt_local_entry = NULL; 236 + struct batadv_tt_global_entry *tt_global_entry = NULL; 240 237 struct hlist_head *head; 241 238 struct hlist_node *node; 242 - struct tt_orig_list_entry *orig_entry; 239 + struct batadv_tt_orig_list_entry *orig_entry; 243 240 int hash_added; 244 241 245 242 tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr); 246 243 247 244 if (tt_local_entry) { 248 245 tt_local_entry->last_seen = jiffies; 249 - /* possibly unset the TT_CLIENT_PENDING flag */ 250 - tt_local_entry->common.flags &= ~TT_CLIENT_PENDING; 246 + /* possibly unset the BATADV_TT_CLIENT_PENDING flag */ 247 + tt_local_entry->common.flags &= ~BATADV_TT_CLIENT_PENDING; 251 248 goto out; 252 249 } 253 250 ··· 255 252 if (!tt_local_entry) 256 253 goto out; 257 254 258 - batadv_dbg(DBG_TT, bat_priv, 255 + batadv_dbg(BATADV_DBG_TT, bat_priv, 259 256 "Creating new local tt entry: %pM (ttvn: %d)\n", addr, 260 257 (uint8_t)atomic_read(&bat_priv->ttvn)); 261 258 262 259 memcpy(tt_local_entry->common.addr, addr, ETH_ALEN); 263 260 tt_local_entry->common.flags = BATADV_NO_FLAGS; 264 261 if (batadv_is_wifi_iface(ifindex)) 265 - tt_local_entry->common.flags |= TT_CLIENT_WIFI; 262 + tt_local_entry->common.flags |= BATADV_TT_CLIENT_WIFI; 266 263 atomic_set(&tt_local_entry->common.refcount, 2); 267 264 tt_local_entry->last_seen = jiffies; 268 265 269 266 /* the batman interface mac address should never be purged */ 270 267 if (batadv_compare_eth(addr, soft_iface->dev_addr)) 271 - tt_local_entry->common.flags |= TT_CLIENT_NOPURGE; 268 + tt_local_entry->common.flags |= BATADV_TT_CLIENT_NOPURGE; 272 269 273 270 /* The local entry has to be marked as NEW to avoid to send it in 274 271 * a full table response going out before the next ttvn increment 275 272 * (consistency check) 276 273 */ 277 - tt_local_entry->common.flags |= TT_CLIENT_NEW; 274 + tt_local_entry->common.flags |= BATADV_TT_CLIENT_NEW; 278 275 279 276 hash_added = batadv_hash_add(bat_priv->tt_local_hash, batadv_compare_tt, 280 277 batadv_choose_orig, ··· 308 305 /* The global entry has to be marked as ROAMING and 309 306 * has to be kept for consistency purpose 310 307 */ 311 - tt_global_entry->common.flags |= TT_CLIENT_ROAM; 308 + tt_global_entry->common.flags |= BATADV_TT_CLIENT_ROAM; 312 309 tt_global_entry->roam_at = jiffies; 313 310 } 314 311 out: ··· 336 333 } 337 334 } 338 335 339 - static void batadv_tt_prepare_packet_buff(struct bat_priv *bat_priv, 336 + static void batadv_tt_prepare_packet_buff(struct batadv_priv *bat_priv, 340 337 unsigned char **packet_buff, 341 338 int *packet_buff_len, 342 339 int min_packet_len) 343 340 { 344 - struct hard_iface *primary_if; 341 + struct batadv_hard_iface *primary_if; 345 342 int req_len; 346 343 347 344 primary_if = batadv_primary_if_get_selected(bat_priv); ··· 362 359 batadv_hardif_free_ref(primary_if); 363 360 } 364 361 365 - static int batadv_tt_changes_fill_buff(struct bat_priv *bat_priv, 362 + static int batadv_tt_changes_fill_buff(struct batadv_priv *bat_priv, 366 363 unsigned char **packet_buff, 367 364 int *packet_buff_len, 368 365 int min_packet_len) 369 366 { 370 - struct tt_change_node *entry, *safe; 367 + struct batadv_tt_change_node *entry, *safe; 371 368 int count = 0, tot_changes = 0, new_len; 372 369 unsigned char *tt_buff; 373 370 ··· 387 384 list) { 388 385 if (count < tot_changes) { 389 386 memcpy(tt_buff + batadv_tt_len(count), 390 - &entry->change, sizeof(struct tt_change)); 387 + &entry->change, sizeof(struct batadv_tt_change)); 391 388 count++; 392 389 } 393 390 list_del(&entry->list); ··· 419 416 int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset) 420 417 { 421 418 struct net_device *net_dev = (struct net_device *)seq->private; 422 - struct bat_priv *bat_priv = netdev_priv(net_dev); 423 - struct hashtable_t *hash = bat_priv->tt_local_hash; 424 - struct tt_common_entry *tt_common_entry; 425 - struct hard_iface *primary_if; 419 + struct batadv_priv *bat_priv = netdev_priv(net_dev); 420 + struct batadv_hashtable *hash = bat_priv->tt_local_hash; 421 + struct batadv_tt_common_entry *tt_common_entry; 422 + struct batadv_hard_iface *primary_if; 426 423 struct hlist_node *node; 427 424 struct hlist_head *head; 428 425 uint32_t i; ··· 436 433 goto out; 437 434 } 438 435 439 - if (primary_if->if_status != IF_ACTIVE) { 436 + if (primary_if->if_status != BATADV_IF_ACTIVE) { 440 437 ret = seq_printf(seq, 441 438 "BATMAN mesh %s disabled - primary interface not active\n", 442 439 net_dev->name); ··· 456 453 seq_printf(seq, " * %pM [%c%c%c%c%c]\n", 457 454 tt_common_entry->addr, 458 455 (tt_common_entry->flags & 459 - TT_CLIENT_ROAM ? 'R' : '.'), 456 + BATADV_TT_CLIENT_ROAM ? 'R' : '.'), 460 457 (tt_common_entry->flags & 461 - TT_CLIENT_NOPURGE ? 'P' : '.'), 458 + BATADV_TT_CLIENT_NOPURGE ? 'P' : '.'), 462 459 (tt_common_entry->flags & 463 - TT_CLIENT_NEW ? 'N' : '.'), 460 + BATADV_TT_CLIENT_NEW ? 'N' : '.'), 464 461 (tt_common_entry->flags & 465 - TT_CLIENT_PENDING ? 'X' : '.'), 462 + BATADV_TT_CLIENT_PENDING ? 'X' : '.'), 466 463 (tt_common_entry->flags & 467 - TT_CLIENT_WIFI ? 'W' : '.')); 464 + BATADV_TT_CLIENT_WIFI ? 'W' : '.')); 468 465 } 469 466 rcu_read_unlock(); 470 467 } ··· 474 471 return ret; 475 472 } 476 473 477 - static void batadv_tt_local_set_pending(struct bat_priv *bat_priv, 478 - struct tt_local_entry *tt_local_entry, 479 - uint16_t flags, const char *message) 474 + static void 475 + batadv_tt_local_set_pending(struct batadv_priv *bat_priv, 476 + struct batadv_tt_local_entry *tt_local_entry, 477 + uint16_t flags, const char *message) 480 478 { 481 479 batadv_tt_local_event(bat_priv, tt_local_entry->common.addr, 482 480 tt_local_entry->common.flags | flags); ··· 486 482 * to be kept in the table in order to send it in a full table 487 483 * response issued before the net ttvn increment (consistency check) 488 484 */ 489 - tt_local_entry->common.flags |= TT_CLIENT_PENDING; 485 + tt_local_entry->common.flags |= BATADV_TT_CLIENT_PENDING; 490 486 491 - batadv_dbg(DBG_TT, bat_priv, 487 + batadv_dbg(BATADV_DBG_TT, bat_priv, 492 488 "Local tt entry (%pM) pending to be removed: %s\n", 493 489 tt_local_entry->common.addr, message); 494 490 } 495 491 496 - void batadv_tt_local_remove(struct bat_priv *bat_priv, const uint8_t *addr, 492 + void batadv_tt_local_remove(struct batadv_priv *bat_priv, const uint8_t *addr, 497 493 const char *message, bool roaming) 498 494 { 499 - struct tt_local_entry *tt_local_entry = NULL; 495 + struct batadv_tt_local_entry *tt_local_entry = NULL; 500 496 uint16_t flags; 501 497 502 498 tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr); 503 499 if (!tt_local_entry) 504 500 goto out; 505 501 506 - flags = TT_CLIENT_DEL; 502 + flags = BATADV_TT_CLIENT_DEL; 507 503 if (roaming) 508 - flags |= TT_CLIENT_ROAM; 504 + flags |= BATADV_TT_CLIENT_ROAM; 509 505 510 506 batadv_tt_local_set_pending(bat_priv, tt_local_entry, flags, message); 511 507 out: ··· 513 509 batadv_tt_local_entry_free_ref(tt_local_entry); 514 510 } 515 511 516 - static void batadv_tt_local_purge(struct bat_priv *bat_priv) 512 + static void batadv_tt_local_purge_list(struct batadv_priv *bat_priv, 513 + struct hlist_head *head) 517 514 { 518 - struct hashtable_t *hash = bat_priv->tt_local_hash; 519 - struct tt_local_entry *tt_local_entry; 520 - struct tt_common_entry *tt_common_entry; 515 + struct batadv_tt_local_entry *tt_local_entry; 516 + struct batadv_tt_common_entry *tt_common_entry; 521 517 struct hlist_node *node, *node_tmp; 518 + 519 + hlist_for_each_entry_safe(tt_common_entry, node, node_tmp, head, 520 + hash_entry) { 521 + tt_local_entry = container_of(tt_common_entry, 522 + struct batadv_tt_local_entry, 523 + common); 524 + if (tt_local_entry->common.flags & BATADV_TT_CLIENT_NOPURGE) 525 + continue; 526 + 527 + /* entry already marked for deletion */ 528 + if (tt_local_entry->common.flags & BATADV_TT_CLIENT_PENDING) 529 + continue; 530 + 531 + if (!batadv_has_timed_out(tt_local_entry->last_seen, 532 + BATADV_TT_LOCAL_TIMEOUT)) 533 + continue; 534 + 535 + batadv_tt_local_set_pending(bat_priv, tt_local_entry, 536 + BATADV_TT_CLIENT_DEL, "timed out"); 537 + } 538 + } 539 + 540 + static void batadv_tt_local_purge(struct batadv_priv *bat_priv) 541 + { 542 + struct batadv_hashtable *hash = bat_priv->tt_local_hash; 522 543 struct hlist_head *head; 523 544 spinlock_t *list_lock; /* protects write access to the hash lists */ 524 545 uint32_t i; ··· 553 524 list_lock = &hash->list_locks[i]; 554 525 555 526 spin_lock_bh(list_lock); 556 - hlist_for_each_entry_safe(tt_common_entry, node, node_tmp, 557 - head, hash_entry) { 558 - tt_local_entry = container_of(tt_common_entry, 559 - struct tt_local_entry, 560 - common); 561 - if (tt_local_entry->common.flags & TT_CLIENT_NOPURGE) 562 - continue; 563 - 564 - /* entry already marked for deletion */ 565 - if (tt_local_entry->common.flags & TT_CLIENT_PENDING) 566 - continue; 567 - 568 - if (!batadv_has_timed_out(tt_local_entry->last_seen, 569 - BATADV_TT_LOCAL_TIMEOUT)) 570 - continue; 571 - 572 - batadv_tt_local_set_pending(bat_priv, tt_local_entry, 573 - TT_CLIENT_DEL, "timed out"); 574 - } 527 + batadv_tt_local_purge_list(bat_priv, head); 575 528 spin_unlock_bh(list_lock); 576 529 } 577 530 578 531 } 579 532 580 - static void batadv_tt_local_table_free(struct bat_priv *bat_priv) 533 + static void batadv_tt_local_table_free(struct batadv_priv *bat_priv) 581 534 { 582 - struct hashtable_t *hash; 535 + struct batadv_hashtable *hash; 583 536 spinlock_t *list_lock; /* protects write access to the hash lists */ 584 - struct tt_common_entry *tt_common_entry; 585 - struct tt_local_entry *tt_local_entry; 537 + struct batadv_tt_common_entry *tt_common_entry; 538 + struct batadv_tt_local_entry *tt_local; 586 539 struct hlist_node *node, *node_tmp; 587 540 struct hlist_head *head; 588 541 uint32_t i; ··· 582 571 hlist_for_each_entry_safe(tt_common_entry, node, node_tmp, 583 572 head, hash_entry) { 584 573 hlist_del_rcu(node); 585 - tt_local_entry = container_of(tt_common_entry, 586 - struct tt_local_entry, 587 - common); 588 - batadv_tt_local_entry_free_ref(tt_local_entry); 574 + tt_local = container_of(tt_common_entry, 575 + struct batadv_tt_local_entry, 576 + common); 577 + batadv_tt_local_entry_free_ref(tt_local); 589 578 } 590 579 spin_unlock_bh(list_lock); 591 580 } ··· 595 584 bat_priv->tt_local_hash = NULL; 596 585 } 597 586 598 - static int batadv_tt_global_init(struct bat_priv *bat_priv) 587 + static int batadv_tt_global_init(struct batadv_priv *bat_priv) 599 588 { 600 589 if (bat_priv->tt_global_hash) 601 590 return 0; ··· 608 597 return 0; 609 598 } 610 599 611 - static void batadv_tt_changes_list_free(struct bat_priv *bat_priv) 600 + static void batadv_tt_changes_list_free(struct batadv_priv *bat_priv) 612 601 { 613 - struct tt_change_node *entry, *safe; 602 + struct batadv_tt_change_node *entry, *safe; 614 603 615 604 spin_lock_bh(&bat_priv->tt_changes_list_lock); 616 605 ··· 627 616 /* find out if an orig_node is already in the list of a tt_global_entry. 628 617 * returns 1 if found, 0 otherwise 629 618 */ 630 - static bool batadv_tt_global_entry_has_orig(const struct tt_global_entry *entry, 631 - const struct orig_node *orig_node) 619 + static bool 620 + batadv_tt_global_entry_has_orig(const struct batadv_tt_global_entry *entry, 621 + const struct batadv_orig_node *orig_node) 632 622 { 633 - struct tt_orig_list_entry *tmp_orig_entry; 623 + struct batadv_tt_orig_list_entry *tmp_orig_entry; 634 624 const struct hlist_head *head; 635 625 struct hlist_node *node; 636 626 bool found = false; ··· 649 637 } 650 638 651 639 static void 652 - batadv_tt_global_add_orig_entry(struct tt_global_entry *tt_global_entry, 653 - struct orig_node *orig_node, int ttvn) 640 + batadv_tt_global_add_orig_entry(struct batadv_tt_global_entry *tt_global_entry, 641 + struct batadv_orig_node *orig_node, int ttvn) 654 642 { 655 - struct tt_orig_list_entry *orig_entry; 643 + struct batadv_tt_orig_list_entry *orig_entry; 656 644 657 645 orig_entry = kzalloc(sizeof(*orig_entry), GFP_ATOMIC); 658 646 if (!orig_entry) ··· 671 659 } 672 660 673 661 /* caller must hold orig_node refcount */ 674 - int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, 662 + int batadv_tt_global_add(struct batadv_priv *bat_priv, 663 + struct batadv_orig_node *orig_node, 675 664 const unsigned char *tt_addr, uint8_t flags, 676 665 uint8_t ttvn) 677 666 { 678 - struct tt_global_entry *tt_global_entry = NULL; 667 + struct batadv_tt_global_entry *tt_global_entry = NULL; 679 668 int ret = 0; 680 669 int hash_added; 681 - struct tt_common_entry *common; 670 + struct batadv_tt_common_entry *common; 682 671 683 672 tt_global_entry = batadv_tt_global_hash_find(bat_priv, tt_addr); 684 673 ··· 714 701 } else { 715 702 /* there is already a global entry, use this one. */ 716 703 717 - /* If there is the TT_CLIENT_ROAM flag set, there is only one 718 - * originator left in the list and we previously received a 704 + /* If there is the BATADV_TT_CLIENT_ROAM flag set, there is only 705 + * one originator left in the list and we previously received a 719 706 * delete + roaming change for this originator. 720 707 * 721 708 * We should first delete the old originator before adding the 722 709 * new one. 723 710 */ 724 - if (tt_global_entry->common.flags & TT_CLIENT_ROAM) { 711 + if (tt_global_entry->common.flags & BATADV_TT_CLIENT_ROAM) { 725 712 batadv_tt_global_del_orig_list(tt_global_entry); 726 - tt_global_entry->common.flags &= ~TT_CLIENT_ROAM; 713 + tt_global_entry->common.flags &= ~BATADV_TT_CLIENT_ROAM; 727 714 tt_global_entry->roam_at = 0; 728 715 } 729 716 ··· 733 720 orig_node, ttvn); 734 721 } 735 722 736 - batadv_dbg(DBG_TT, bat_priv, 723 + batadv_dbg(BATADV_DBG_TT, bat_priv, 737 724 "Creating new global tt entry: %pM (via %pM)\n", 738 725 tt_global_entry->common.addr, orig_node->orig); 739 726 740 727 out_remove: 741 728 /* remove address from local hash if present */ 742 729 batadv_tt_local_remove(bat_priv, tt_global_entry->common.addr, 743 - "global tt received", flags & TT_CLIENT_ROAM); 730 + "global tt received", 731 + flags & BATADV_TT_CLIENT_ROAM); 744 732 ret = 1; 745 733 out: 746 734 if (tt_global_entry) ··· 753 739 * it is assumed that the caller holds rcu_read_lock(); 754 740 */ 755 741 static void 756 - batadv_tt_global_print_entry(struct tt_global_entry *tt_global_entry, 742 + batadv_tt_global_print_entry(struct batadv_tt_global_entry *tt_global_entry, 757 743 struct seq_file *seq) 758 744 { 759 745 struct hlist_head *head; 760 746 struct hlist_node *node; 761 - struct tt_orig_list_entry *orig_entry; 762 - struct tt_common_entry *tt_common_entry; 747 + struct batadv_tt_orig_list_entry *orig_entry; 748 + struct batadv_tt_common_entry *tt_common_entry; 763 749 uint16_t flags; 764 750 uint8_t last_ttvn; 765 751 ··· 773 759 seq_printf(seq, " * %pM (%3u) via %pM (%3u) [%c%c]\n", 774 760 tt_global_entry->common.addr, orig_entry->ttvn, 775 761 orig_entry->orig_node->orig, last_ttvn, 776 - (flags & TT_CLIENT_ROAM ? 'R' : '.'), 777 - (flags & TT_CLIENT_WIFI ? 'W' : '.')); 762 + (flags & BATADV_TT_CLIENT_ROAM ? 'R' : '.'), 763 + (flags & BATADV_TT_CLIENT_WIFI ? 'W' : '.')); 778 764 } 779 765 } 780 766 781 767 int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset) 782 768 { 783 769 struct net_device *net_dev = (struct net_device *)seq->private; 784 - struct bat_priv *bat_priv = netdev_priv(net_dev); 785 - struct hashtable_t *hash = bat_priv->tt_global_hash; 786 - struct tt_common_entry *tt_common_entry; 787 - struct tt_global_entry *tt_global_entry; 788 - struct hard_iface *primary_if; 770 + struct batadv_priv *bat_priv = netdev_priv(net_dev); 771 + struct batadv_hashtable *hash = bat_priv->tt_global_hash; 772 + struct batadv_tt_common_entry *tt_common_entry; 773 + struct batadv_tt_global_entry *tt_global; 774 + struct batadv_hard_iface *primary_if; 789 775 struct hlist_node *node; 790 776 struct hlist_head *head; 791 777 uint32_t i; ··· 799 785 goto out; 800 786 } 801 787 802 - if (primary_if->if_status != IF_ACTIVE) { 788 + if (primary_if->if_status != BATADV_IF_ACTIVE) { 803 789 ret = seq_printf(seq, 804 790 "BATMAN mesh %s disabled - primary interface not active\n", 805 791 net_dev->name); ··· 818 804 rcu_read_lock(); 819 805 hlist_for_each_entry_rcu(tt_common_entry, node, 820 806 head, hash_entry) { 821 - tt_global_entry = container_of(tt_common_entry, 822 - struct tt_global_entry, 823 - common); 824 - batadv_tt_global_print_entry(tt_global_entry, seq); 807 + tt_global = container_of(tt_common_entry, 808 + struct batadv_tt_global_entry, 809 + common); 810 + batadv_tt_global_print_entry(tt_global, seq); 825 811 } 826 812 rcu_read_unlock(); 827 813 } ··· 833 819 834 820 /* deletes the orig list of a tt_global_entry */ 835 821 static void 836 - batadv_tt_global_del_orig_list(struct tt_global_entry *tt_global_entry) 822 + batadv_tt_global_del_orig_list(struct batadv_tt_global_entry *tt_global_entry) 837 823 { 838 824 struct hlist_head *head; 839 825 struct hlist_node *node, *safe; 840 - struct tt_orig_list_entry *orig_entry; 826 + struct batadv_tt_orig_list_entry *orig_entry; 841 827 842 828 spin_lock_bh(&tt_global_entry->list_lock); 843 829 head = &tt_global_entry->orig_list; ··· 850 836 } 851 837 852 838 static void 853 - batadv_tt_global_del_orig_entry(struct bat_priv *bat_priv, 854 - struct tt_global_entry *tt_global_entry, 855 - struct orig_node *orig_node, 839 + batadv_tt_global_del_orig_entry(struct batadv_priv *bat_priv, 840 + struct batadv_tt_global_entry *tt_global_entry, 841 + struct batadv_orig_node *orig_node, 856 842 const char *message) 857 843 { 858 844 struct hlist_head *head; 859 845 struct hlist_node *node, *safe; 860 - struct tt_orig_list_entry *orig_entry; 846 + struct batadv_tt_orig_list_entry *orig_entry; 861 847 862 848 spin_lock_bh(&tt_global_entry->list_lock); 863 849 head = &tt_global_entry->orig_list; 864 850 hlist_for_each_entry_safe(orig_entry, node, safe, head, list) { 865 851 if (orig_entry->orig_node == orig_node) { 866 - batadv_dbg(DBG_TT, bat_priv, 852 + batadv_dbg(BATADV_DBG_TT, bat_priv, 867 853 "Deleting %pM from global tt entry %pM: %s\n", 868 854 orig_node->orig, 869 855 tt_global_entry->common.addr, message); ··· 874 860 spin_unlock_bh(&tt_global_entry->list_lock); 875 861 } 876 862 877 - static void batadv_tt_global_del_struct(struct bat_priv *bat_priv, 878 - struct tt_global_entry *tt_global_entry, 879 - const char *message) 863 + static void 864 + batadv_tt_global_del_struct(struct batadv_priv *bat_priv, 865 + struct batadv_tt_global_entry *tt_global_entry, 866 + const char *message) 880 867 { 881 - batadv_dbg(DBG_TT, bat_priv, "Deleting global tt entry %pM: %s\n", 868 + batadv_dbg(BATADV_DBG_TT, bat_priv, 869 + "Deleting global tt entry %pM: %s\n", 882 870 tt_global_entry->common.addr, message); 883 871 884 872 batadv_hash_remove(bat_priv->tt_global_hash, batadv_compare_tt, ··· 890 874 } 891 875 892 876 /* If the client is to be deleted, we check if it is the last origantor entry 893 - * within tt_global entry. If yes, we set the TT_CLIENT_ROAM flag and the timer, 894 - * otherwise we simply remove the originator scheduled for deletion. 877 + * within tt_global entry. If yes, we set the BATADV_TT_CLIENT_ROAM flag and the 878 + * timer, otherwise we simply remove the originator scheduled for deletion. 895 879 */ 896 880 static void 897 - batadv_tt_global_del_roaming(struct bat_priv *bat_priv, 898 - struct tt_global_entry *tt_global_entry, 899 - struct orig_node *orig_node, const char *message) 881 + batadv_tt_global_del_roaming(struct batadv_priv *bat_priv, 882 + struct batadv_tt_global_entry *tt_global_entry, 883 + struct batadv_orig_node *orig_node, 884 + const char *message) 900 885 { 901 886 bool last_entry = true; 902 887 struct hlist_head *head; 903 888 struct hlist_node *node; 904 - struct tt_orig_list_entry *orig_entry; 889 + struct batadv_tt_orig_list_entry *orig_entry; 905 890 906 891 /* no local entry exists, case 1: 907 892 * Check if this is the last one or if other entries exist. ··· 920 903 921 904 if (last_entry) { 922 905 /* its the last one, mark for roaming. */ 923 - tt_global_entry->common.flags |= TT_CLIENT_ROAM; 906 + tt_global_entry->common.flags |= BATADV_TT_CLIENT_ROAM; 924 907 tt_global_entry->roam_at = jiffies; 925 908 } else 926 909 /* there is another entry, we can simply delete this ··· 932 915 933 916 934 917 935 - static void batadv_tt_global_del(struct bat_priv *bat_priv, 936 - struct orig_node *orig_node, 918 + static void batadv_tt_global_del(struct batadv_priv *bat_priv, 919 + struct batadv_orig_node *orig_node, 937 920 const unsigned char *addr, 938 921 const char *message, bool roaming) 939 922 { 940 - struct tt_global_entry *tt_global_entry = NULL; 941 - struct tt_local_entry *local_entry = NULL; 923 + struct batadv_tt_global_entry *tt_global_entry = NULL; 924 + struct batadv_tt_local_entry *local_entry = NULL; 942 925 943 926 tt_global_entry = batadv_tt_global_hash_find(bat_priv, addr); 944 927 if (!tt_global_entry) ··· 959 942 * event, there are two possibilities: 960 943 * 1) the client roamed from node A to node B => if there 961 944 * is only one originator left for this client, we mark 962 - * it with TT_CLIENT_ROAM, we start a timer and we 945 + * it with BATADV_TT_CLIENT_ROAM, we start a timer and we 963 946 * wait for node B to claim it. In case of timeout 964 947 * the entry is purged. 965 948 * ··· 987 970 batadv_tt_local_entry_free_ref(local_entry); 988 971 } 989 972 990 - void batadv_tt_global_del_orig(struct bat_priv *bat_priv, 991 - struct orig_node *orig_node, const char *message) 973 + void batadv_tt_global_del_orig(struct batadv_priv *bat_priv, 974 + struct batadv_orig_node *orig_node, 975 + const char *message) 992 976 { 993 - struct tt_global_entry *global_entry; 994 - struct tt_common_entry *tt_common_entry; 977 + struct batadv_tt_global_entry *tt_global; 978 + struct batadv_tt_common_entry *tt_common_entry; 995 979 uint32_t i; 996 - struct hashtable_t *hash = bat_priv->tt_global_hash; 980 + struct batadv_hashtable *hash = bat_priv->tt_global_hash; 997 981 struct hlist_node *node, *safe; 998 982 struct hlist_head *head; 999 983 spinlock_t *list_lock; /* protects write access to the hash lists */ ··· 1009 991 spin_lock_bh(list_lock); 1010 992 hlist_for_each_entry_safe(tt_common_entry, node, safe, 1011 993 head, hash_entry) { 1012 - global_entry = container_of(tt_common_entry, 1013 - struct tt_global_entry, 1014 - common); 994 + tt_global = container_of(tt_common_entry, 995 + struct batadv_tt_global_entry, 996 + common); 1015 997 1016 - batadv_tt_global_del_orig_entry(bat_priv, global_entry, 998 + batadv_tt_global_del_orig_entry(bat_priv, tt_global, 1017 999 orig_node, message); 1018 1000 1019 - if (hlist_empty(&global_entry->orig_list)) { 1020 - batadv_dbg(DBG_TT, bat_priv, 1001 + if (hlist_empty(&tt_global->orig_list)) { 1002 + batadv_dbg(BATADV_DBG_TT, bat_priv, 1021 1003 "Deleting global tt entry %pM: %s\n", 1022 - global_entry->common.addr, message); 1004 + tt_global->common.addr, message); 1023 1005 hlist_del_rcu(node); 1024 - batadv_tt_global_entry_free_ref(global_entry); 1006 + batadv_tt_global_entry_free_ref(tt_global); 1025 1007 } 1026 1008 } 1027 1009 spin_unlock_bh(list_lock); ··· 1029 1011 orig_node->tt_initialised = false; 1030 1012 } 1031 1013 1032 - static void batadv_tt_global_roam_purge_list(struct bat_priv *bat_priv, 1014 + static void batadv_tt_global_roam_purge_list(struct batadv_priv *bat_priv, 1033 1015 struct hlist_head *head) 1034 1016 { 1035 - struct tt_common_entry *tt_common_entry; 1036 - struct tt_global_entry *tt_global_entry; 1017 + struct batadv_tt_common_entry *tt_common_entry; 1018 + struct batadv_tt_global_entry *tt_global_entry; 1037 1019 struct hlist_node *node, *node_tmp; 1038 1020 1039 1021 hlist_for_each_entry_safe(tt_common_entry, node, node_tmp, head, 1040 1022 hash_entry) { 1041 1023 tt_global_entry = container_of(tt_common_entry, 1042 - struct tt_global_entry, common); 1043 - if (!(tt_global_entry->common.flags & TT_CLIENT_ROAM)) 1024 + struct batadv_tt_global_entry, 1025 + common); 1026 + if (!(tt_global_entry->common.flags & BATADV_TT_CLIENT_ROAM)) 1044 1027 continue; 1045 1028 if (!batadv_has_timed_out(tt_global_entry->roam_at, 1046 1029 BATADV_TT_CLIENT_ROAM_TIMEOUT)) 1047 1030 continue; 1048 1031 1049 - batadv_dbg(DBG_TT, bat_priv, 1032 + batadv_dbg(BATADV_DBG_TT, bat_priv, 1050 1033 "Deleting global tt entry (%pM): Roaming timeout\n", 1051 1034 tt_global_entry->common.addr); 1052 1035 ··· 1056 1037 } 1057 1038 } 1058 1039 1059 - static void batadv_tt_global_roam_purge(struct bat_priv *bat_priv) 1040 + static void batadv_tt_global_roam_purge(struct batadv_priv *bat_priv) 1060 1041 { 1061 - struct hashtable_t *hash = bat_priv->tt_global_hash; 1042 + struct batadv_hashtable *hash = bat_priv->tt_global_hash; 1062 1043 struct hlist_head *head; 1063 1044 spinlock_t *list_lock; /* protects write access to the hash lists */ 1064 1045 uint32_t i; ··· 1074 1055 1075 1056 } 1076 1057 1077 - static void batadv_tt_global_table_free(struct bat_priv *bat_priv) 1058 + static void batadv_tt_global_table_free(struct batadv_priv *bat_priv) 1078 1059 { 1079 - struct hashtable_t *hash; 1060 + struct batadv_hashtable *hash; 1080 1061 spinlock_t *list_lock; /* protects write access to the hash lists */ 1081 - struct tt_common_entry *tt_common_entry; 1082 - struct tt_global_entry *tt_global_entry; 1062 + struct batadv_tt_common_entry *tt_common_entry; 1063 + struct batadv_tt_global_entry *tt_global; 1083 1064 struct hlist_node *node, *node_tmp; 1084 1065 struct hlist_head *head; 1085 1066 uint32_t i; ··· 1097 1078 hlist_for_each_entry_safe(tt_common_entry, node, node_tmp, 1098 1079 head, hash_entry) { 1099 1080 hlist_del_rcu(node); 1100 - tt_global_entry = container_of(tt_common_entry, 1101 - struct tt_global_entry, 1102 - common); 1103 - batadv_tt_global_entry_free_ref(tt_global_entry); 1081 + tt_global = container_of(tt_common_entry, 1082 + struct batadv_tt_global_entry, 1083 + common); 1084 + batadv_tt_global_entry_free_ref(tt_global); 1104 1085 } 1105 1086 spin_unlock_bh(list_lock); 1106 1087 } ··· 1110 1091 bat_priv->tt_global_hash = NULL; 1111 1092 } 1112 1093 1113 - static bool _batadv_is_ap_isolated(struct tt_local_entry *tt_local_entry, 1114 - struct tt_global_entry *tt_global_entry) 1094 + static bool 1095 + _batadv_is_ap_isolated(struct batadv_tt_local_entry *tt_local_entry, 1096 + struct batadv_tt_global_entry *tt_global_entry) 1115 1097 { 1116 1098 bool ret = false; 1117 1099 1118 - if (tt_local_entry->common.flags & TT_CLIENT_WIFI && 1119 - tt_global_entry->common.flags & TT_CLIENT_WIFI) 1100 + if (tt_local_entry->common.flags & BATADV_TT_CLIENT_WIFI && 1101 + tt_global_entry->common.flags & BATADV_TT_CLIENT_WIFI) 1120 1102 ret = true; 1121 1103 1122 1104 return ret; 1123 1105 } 1124 1106 1125 - struct orig_node *batadv_transtable_search(struct bat_priv *bat_priv, 1126 - const uint8_t *src, 1127 - const uint8_t *addr) 1107 + struct batadv_orig_node *batadv_transtable_search(struct batadv_priv *bat_priv, 1108 + const uint8_t *src, 1109 + const uint8_t *addr) 1128 1110 { 1129 - struct tt_local_entry *tt_local_entry = NULL; 1130 - struct tt_global_entry *tt_global_entry = NULL; 1131 - struct orig_node *orig_node = NULL; 1132 - struct neigh_node *router = NULL; 1111 + struct batadv_tt_local_entry *tt_local_entry = NULL; 1112 + struct batadv_tt_global_entry *tt_global_entry = NULL; 1113 + struct batadv_orig_node *orig_node = NULL; 1114 + struct batadv_neigh_node *router = NULL; 1133 1115 struct hlist_head *head; 1134 1116 struct hlist_node *node; 1135 - struct tt_orig_list_entry *orig_entry; 1117 + struct batadv_tt_orig_list_entry *orig_entry; 1136 1118 int best_tq; 1137 1119 1138 1120 if (src && atomic_read(&bat_priv->ap_isolation)) { ··· 1182 1162 } 1183 1163 1184 1164 /* Calculates the checksum of the local table of a given orig_node */ 1185 - static uint16_t batadv_tt_global_crc(struct bat_priv *bat_priv, 1186 - struct orig_node *orig_node) 1165 + static uint16_t batadv_tt_global_crc(struct batadv_priv *bat_priv, 1166 + struct batadv_orig_node *orig_node) 1187 1167 { 1188 1168 uint16_t total = 0, total_one; 1189 - struct hashtable_t *hash = bat_priv->tt_global_hash; 1190 - struct tt_common_entry *tt_common_entry; 1191 - struct tt_global_entry *tt_global_entry; 1169 + struct batadv_hashtable *hash = bat_priv->tt_global_hash; 1170 + struct batadv_tt_common_entry *tt_common; 1171 + struct batadv_tt_global_entry *tt_global; 1192 1172 struct hlist_node *node; 1193 1173 struct hlist_head *head; 1194 1174 uint32_t i; ··· 1198 1178 head = &hash->table[i]; 1199 1179 1200 1180 rcu_read_lock(); 1201 - hlist_for_each_entry_rcu(tt_common_entry, node, 1202 - head, hash_entry) { 1203 - tt_global_entry = container_of(tt_common_entry, 1204 - struct tt_global_entry, 1205 - common); 1181 + hlist_for_each_entry_rcu(tt_common, node, head, hash_entry) { 1182 + tt_global = container_of(tt_common, 1183 + struct batadv_tt_global_entry, 1184 + common); 1206 1185 /* Roaming clients are in the global table for 1207 1186 * consistency only. They don't have to be 1208 1187 * taken into account while computing the 1209 1188 * global crc 1210 1189 */ 1211 - if (tt_global_entry->common.flags & TT_CLIENT_ROAM) 1190 + if (tt_common->flags & BATADV_TT_CLIENT_ROAM) 1212 1191 continue; 1213 1192 1214 1193 /* find out if this global entry is announced by this 1215 1194 * originator 1216 1195 */ 1217 - if (!batadv_tt_global_entry_has_orig(tt_global_entry, 1196 + if (!batadv_tt_global_entry_has_orig(tt_global, 1218 1197 orig_node)) 1219 1198 continue; 1220 1199 1221 1200 total_one = 0; 1222 1201 for (j = 0; j < ETH_ALEN; j++) 1223 1202 total_one = crc16_byte(total_one, 1224 - tt_global_entry->common.addr[j]); 1203 + tt_common->addr[j]); 1225 1204 total ^= total_one; 1226 1205 } 1227 1206 rcu_read_unlock(); ··· 1230 1211 } 1231 1212 1232 1213 /* Calculates the checksum of the local table */ 1233 - static uint16_t batadv_tt_local_crc(struct bat_priv *bat_priv) 1214 + static uint16_t batadv_tt_local_crc(struct batadv_priv *bat_priv) 1234 1215 { 1235 1216 uint16_t total = 0, total_one; 1236 - struct hashtable_t *hash = bat_priv->tt_local_hash; 1237 - struct tt_common_entry *tt_common_entry; 1217 + struct batadv_hashtable *hash = bat_priv->tt_local_hash; 1218 + struct batadv_tt_common_entry *tt_common; 1238 1219 struct hlist_node *node; 1239 1220 struct hlist_head *head; 1240 1221 uint32_t i; ··· 1244 1225 head = &hash->table[i]; 1245 1226 1246 1227 rcu_read_lock(); 1247 - hlist_for_each_entry_rcu(tt_common_entry, node, 1248 - head, hash_entry) { 1228 + hlist_for_each_entry_rcu(tt_common, node, head, hash_entry) { 1249 1229 /* not yet committed clients have not to be taken into 1250 1230 * account while computing the CRC 1251 1231 */ 1252 - if (tt_common_entry->flags & TT_CLIENT_NEW) 1232 + if (tt_common->flags & BATADV_TT_CLIENT_NEW) 1253 1233 continue; 1254 1234 total_one = 0; 1255 1235 for (j = 0; j < ETH_ALEN; j++) 1256 1236 total_one = crc16_byte(total_one, 1257 - tt_common_entry->addr[j]); 1237 + tt_common->addr[j]); 1258 1238 total ^= total_one; 1259 1239 } 1260 1240 rcu_read_unlock(); ··· 1262 1244 return total; 1263 1245 } 1264 1246 1265 - static void batadv_tt_req_list_free(struct bat_priv *bat_priv) 1247 + static void batadv_tt_req_list_free(struct batadv_priv *bat_priv) 1266 1248 { 1267 - struct tt_req_node *node, *safe; 1249 + struct batadv_tt_req_node *node, *safe; 1268 1250 1269 1251 spin_lock_bh(&bat_priv->tt_req_list_lock); 1270 1252 ··· 1276 1258 spin_unlock_bh(&bat_priv->tt_req_list_lock); 1277 1259 } 1278 1260 1279 - static void batadv_tt_save_orig_buffer(struct bat_priv *bat_priv, 1280 - struct orig_node *orig_node, 1261 + static void batadv_tt_save_orig_buffer(struct batadv_priv *bat_priv, 1262 + struct batadv_orig_node *orig_node, 1281 1263 const unsigned char *tt_buff, 1282 1264 uint8_t tt_num_changes) 1283 1265 { ··· 1299 1281 spin_unlock_bh(&orig_node->tt_buff_lock); 1300 1282 } 1301 1283 1302 - static void batadv_tt_req_purge(struct bat_priv *bat_priv) 1284 + static void batadv_tt_req_purge(struct batadv_priv *bat_priv) 1303 1285 { 1304 - struct tt_req_node *node, *safe; 1286 + struct batadv_tt_req_node *node, *safe; 1305 1287 1306 1288 spin_lock_bh(&bat_priv->tt_req_list_lock); 1307 1289 list_for_each_entry_safe(node, safe, &bat_priv->tt_req_list, list) { ··· 1317 1299 /* returns the pointer to the new tt_req_node struct if no request 1318 1300 * has already been issued for this orig_node, NULL otherwise 1319 1301 */ 1320 - static struct tt_req_node *batadv_new_tt_req_node(struct bat_priv *bat_priv, 1321 - struct orig_node *orig_node) 1302 + static struct batadv_tt_req_node * 1303 + batadv_new_tt_req_node(struct batadv_priv *bat_priv, 1304 + struct batadv_orig_node *orig_node) 1322 1305 { 1323 - struct tt_req_node *tt_req_node_tmp, *tt_req_node = NULL; 1306 + struct batadv_tt_req_node *tt_req_node_tmp, *tt_req_node = NULL; 1324 1307 1325 1308 spin_lock_bh(&bat_priv->tt_req_list_lock); 1326 1309 list_for_each_entry(tt_req_node_tmp, &bat_priv->tt_req_list, list) { ··· 1348 1329 static int batadv_tt_local_valid_entry(const void *entry_ptr, 1349 1330 const void *data_ptr) 1350 1331 { 1351 - const struct tt_common_entry *tt_common_entry = entry_ptr; 1332 + const struct batadv_tt_common_entry *tt_common_entry = entry_ptr; 1352 1333 1353 - if (tt_common_entry->flags & TT_CLIENT_NEW) 1334 + if (tt_common_entry->flags & BATADV_TT_CLIENT_NEW) 1354 1335 return 0; 1355 1336 return 1; 1356 1337 } ··· 1358 1339 static int batadv_tt_global_valid(const void *entry_ptr, 1359 1340 const void *data_ptr) 1360 1341 { 1361 - const struct tt_common_entry *tt_common_entry = entry_ptr; 1362 - const struct tt_global_entry *tt_global_entry; 1363 - const struct orig_node *orig_node = data_ptr; 1342 + const struct batadv_tt_common_entry *tt_common_entry = entry_ptr; 1343 + const struct batadv_tt_global_entry *tt_global_entry; 1344 + const struct batadv_orig_node *orig_node = data_ptr; 1364 1345 1365 - if (tt_common_entry->flags & TT_CLIENT_ROAM) 1346 + if (tt_common_entry->flags & BATADV_TT_CLIENT_ROAM) 1366 1347 return 0; 1367 1348 1368 - tt_global_entry = container_of(tt_common_entry, struct tt_global_entry, 1349 + tt_global_entry = container_of(tt_common_entry, 1350 + struct batadv_tt_global_entry, 1369 1351 common); 1370 1352 1371 1353 return batadv_tt_global_entry_has_orig(tt_global_entry, orig_node); ··· 1374 1354 1375 1355 static struct sk_buff * 1376 1356 batadv_tt_response_fill_table(uint16_t tt_len, uint8_t ttvn, 1377 - struct hashtable_t *hash, 1378 - struct hard_iface *primary_if, 1357 + struct batadv_hashtable *hash, 1358 + struct batadv_hard_iface *primary_if, 1379 1359 int (*valid_cb)(const void *, const void *), 1380 1360 void *cb_data) 1381 1361 { 1382 - struct tt_common_entry *tt_common_entry; 1383 - struct tt_query_packet *tt_response; 1384 - struct tt_change *tt_change; 1362 + struct batadv_tt_common_entry *tt_common_entry; 1363 + struct batadv_tt_query_packet *tt_response; 1364 + struct batadv_tt_change *tt_change; 1385 1365 struct hlist_node *node; 1386 1366 struct hlist_head *head; 1387 1367 struct sk_buff *skb = NULL; 1388 1368 uint16_t tt_tot, tt_count; 1389 - ssize_t tt_query_size = sizeof(struct tt_query_packet); 1369 + ssize_t tt_query_size = sizeof(struct batadv_tt_query_packet); 1390 1370 uint32_t i; 1371 + size_t len; 1391 1372 1392 1373 if (tt_query_size + tt_len > primary_if->soft_iface->mtu) { 1393 1374 tt_len = primary_if->soft_iface->mtu - tt_query_size; 1394 - tt_len -= tt_len % sizeof(struct tt_change); 1375 + tt_len -= tt_len % sizeof(struct batadv_tt_change); 1395 1376 } 1396 - tt_tot = tt_len / sizeof(struct tt_change); 1377 + tt_tot = tt_len / sizeof(struct batadv_tt_change); 1397 1378 1398 - skb = dev_alloc_skb(tt_query_size + tt_len + ETH_HLEN); 1379 + len = tt_query_size + tt_len; 1380 + skb = dev_alloc_skb(len + ETH_HLEN); 1399 1381 if (!skb) 1400 1382 goto out; 1401 1383 1402 1384 skb_reserve(skb, ETH_HLEN); 1403 - tt_response = (struct tt_query_packet *)skb_put(skb, 1404 - tt_query_size + tt_len); 1385 + tt_response = (struct batadv_tt_query_packet *)skb_put(skb, len); 1405 1386 tt_response->ttvn = ttvn; 1406 1387 1407 - tt_change = (struct tt_change *)(skb->data + tt_query_size); 1388 + tt_change = (struct batadv_tt_change *)(skb->data + tt_query_size); 1408 1389 tt_count = 0; 1409 1390 1410 1391 rcu_read_lock(); ··· 1439 1418 return skb; 1440 1419 } 1441 1420 1442 - static int batadv_send_tt_request(struct bat_priv *bat_priv, 1443 - struct orig_node *dst_orig_node, 1421 + static int batadv_send_tt_request(struct batadv_priv *bat_priv, 1422 + struct batadv_orig_node *dst_orig_node, 1444 1423 uint8_t ttvn, uint16_t tt_crc, 1445 1424 bool full_table) 1446 1425 { 1447 1426 struct sk_buff *skb = NULL; 1448 - struct tt_query_packet *tt_request; 1449 - struct neigh_node *neigh_node = NULL; 1450 - struct hard_iface *primary_if; 1451 - struct tt_req_node *tt_req_node = NULL; 1427 + struct batadv_tt_query_packet *tt_request; 1428 + struct batadv_neigh_node *neigh_node = NULL; 1429 + struct batadv_hard_iface *primary_if; 1430 + struct batadv_tt_req_node *tt_req_node = NULL; 1452 1431 int ret = 1; 1432 + size_t tt_req_len; 1453 1433 1454 1434 primary_if = batadv_primary_if_get_selected(bat_priv); 1455 1435 if (!primary_if) ··· 1463 1441 if (!tt_req_node) 1464 1442 goto out; 1465 1443 1466 - skb = dev_alloc_skb(sizeof(struct tt_query_packet) + ETH_HLEN); 1444 + skb = dev_alloc_skb(sizeof(*tt_request) + ETH_HLEN); 1467 1445 if (!skb) 1468 1446 goto out; 1469 1447 1470 1448 skb_reserve(skb, ETH_HLEN); 1471 1449 1472 - tt_request = (struct tt_query_packet *)skb_put(skb, 1473 - sizeof(struct tt_query_packet)); 1450 + tt_req_len = sizeof(*tt_request); 1451 + tt_request = (struct batadv_tt_query_packet *)skb_put(skb, tt_req_len); 1474 1452 1475 - tt_request->header.packet_type = BAT_TT_QUERY; 1453 + tt_request->header.packet_type = BATADV_TT_QUERY; 1476 1454 tt_request->header.version = BATADV_COMPAT_VERSION; 1477 1455 memcpy(tt_request->src, primary_if->net_dev->dev_addr, ETH_ALEN); 1478 1456 memcpy(tt_request->dst, dst_orig_node->orig, ETH_ALEN); 1479 1457 tt_request->header.ttl = BATADV_TTL; 1480 1458 tt_request->ttvn = ttvn; 1481 1459 tt_request->tt_data = htons(tt_crc); 1482 - tt_request->flags = TT_REQUEST; 1460 + tt_request->flags = BATADV_TT_REQUEST; 1483 1461 1484 1462 if (full_table) 1485 - tt_request->flags |= TT_FULL_TABLE; 1463 + tt_request->flags |= BATADV_TT_FULL_TABLE; 1486 1464 1487 1465 neigh_node = batadv_orig_node_get_router(dst_orig_node); 1488 1466 if (!neigh_node) 1489 1467 goto out; 1490 1468 1491 - batadv_dbg(DBG_TT, bat_priv, 1469 + batadv_dbg(BATADV_DBG_TT, bat_priv, 1492 1470 "Sending TT_REQUEST to %pM via %pM [%c]\n", 1493 1471 dst_orig_node->orig, neigh_node->addr, 1494 1472 (full_table ? 'F' : '.')); 1495 1473 1496 - batadv_inc_counter(bat_priv, BAT_CNT_TT_REQUEST_TX); 1474 + batadv_inc_counter(bat_priv, BATADV_CNT_TT_REQUEST_TX); 1497 1475 1498 1476 batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); 1499 1477 ret = 0; ··· 1514 1492 return ret; 1515 1493 } 1516 1494 1517 - static bool batadv_send_other_tt_response(struct bat_priv *bat_priv, 1518 - struct tt_query_packet *tt_request) 1495 + static bool 1496 + batadv_send_other_tt_response(struct batadv_priv *bat_priv, 1497 + struct batadv_tt_query_packet *tt_request) 1519 1498 { 1520 - struct orig_node *req_dst_orig_node = NULL, *res_dst_orig_node = NULL; 1521 - struct neigh_node *neigh_node = NULL; 1522 - struct hard_iface *primary_if = NULL; 1499 + struct batadv_orig_node *req_dst_orig_node = NULL; 1500 + struct batadv_orig_node *res_dst_orig_node = NULL; 1501 + struct batadv_neigh_node *neigh_node = NULL; 1502 + struct batadv_hard_iface *primary_if = NULL; 1523 1503 uint8_t orig_ttvn, req_ttvn, ttvn; 1524 1504 int ret = false; 1525 1505 unsigned char *tt_buff; 1526 1506 bool full_table; 1527 1507 uint16_t tt_len, tt_tot; 1528 1508 struct sk_buff *skb = NULL; 1529 - struct tt_query_packet *tt_response; 1509 + struct batadv_tt_query_packet *tt_response; 1510 + size_t len; 1530 1511 1531 - batadv_dbg(DBG_TT, bat_priv, 1512 + batadv_dbg(BATADV_DBG_TT, bat_priv, 1532 1513 "Received TT_REQUEST from %pM for ttvn: %u (%pM) [%c]\n", 1533 1514 tt_request->src, tt_request->ttvn, tt_request->dst, 1534 - (tt_request->flags & TT_FULL_TABLE ? 'F' : '.')); 1515 + (tt_request->flags & BATADV_TT_FULL_TABLE ? 'F' : '.')); 1535 1516 1536 1517 /* Let's get the orig node of the REAL destination */ 1537 1518 req_dst_orig_node = batadv_orig_hash_find(bat_priv, tt_request->dst); ··· 1562 1537 goto out; 1563 1538 1564 1539 /* If the full table has been explicitly requested */ 1565 - if (tt_request->flags & TT_FULL_TABLE || 1540 + if (tt_request->flags & BATADV_TT_FULL_TABLE || 1566 1541 !req_dst_orig_node->tt_buff) 1567 1542 full_table = true; 1568 1543 else ··· 1574 1549 if (!full_table) { 1575 1550 spin_lock_bh(&req_dst_orig_node->tt_buff_lock); 1576 1551 tt_len = req_dst_orig_node->tt_buff_len; 1577 - tt_tot = tt_len / sizeof(struct tt_change); 1552 + tt_tot = tt_len / sizeof(struct batadv_tt_change); 1578 1553 1579 - skb = dev_alloc_skb(sizeof(struct tt_query_packet) + 1580 - tt_len + ETH_HLEN); 1554 + len = sizeof(*tt_response) + tt_len; 1555 + skb = dev_alloc_skb(len + ETH_HLEN); 1581 1556 if (!skb) 1582 1557 goto unlock; 1583 1558 1584 1559 skb_reserve(skb, ETH_HLEN); 1585 - tt_response = (struct tt_query_packet *)skb_put(skb, 1586 - sizeof(struct tt_query_packet) + tt_len); 1560 + tt_response = (struct batadv_tt_query_packet *)skb_put(skb, 1561 + len); 1587 1562 tt_response->ttvn = req_ttvn; 1588 1563 tt_response->tt_data = htons(tt_tot); 1589 1564 1590 - tt_buff = skb->data + sizeof(struct tt_query_packet); 1565 + tt_buff = skb->data + sizeof(*tt_response); 1591 1566 /* Copy the last orig_node's OGM buffer */ 1592 1567 memcpy(tt_buff, req_dst_orig_node->tt_buff, 1593 1568 req_dst_orig_node->tt_buff_len); 1594 1569 1595 1570 spin_unlock_bh(&req_dst_orig_node->tt_buff_lock); 1596 1571 } else { 1597 - tt_len = (uint16_t)atomic_read(&req_dst_orig_node->tt_size) * 1598 - sizeof(struct tt_change); 1572 + tt_len = (uint16_t)atomic_read(&req_dst_orig_node->tt_size); 1573 + tt_len *= sizeof(struct batadv_tt_change); 1599 1574 ttvn = (uint8_t)atomic_read(&req_dst_orig_node->last_ttvn); 1600 1575 1601 1576 skb = batadv_tt_response_fill_table(tt_len, ttvn, ··· 1606 1581 if (!skb) 1607 1582 goto out; 1608 1583 1609 - tt_response = (struct tt_query_packet *)skb->data; 1584 + tt_response = (struct batadv_tt_query_packet *)skb->data; 1610 1585 } 1611 1586 1612 - tt_response->header.packet_type = BAT_TT_QUERY; 1587 + tt_response->header.packet_type = BATADV_TT_QUERY; 1613 1588 tt_response->header.version = BATADV_COMPAT_VERSION; 1614 1589 tt_response->header.ttl = BATADV_TTL; 1615 1590 memcpy(tt_response->src, req_dst_orig_node->orig, ETH_ALEN); 1616 1591 memcpy(tt_response->dst, tt_request->src, ETH_ALEN); 1617 - tt_response->flags = TT_RESPONSE; 1592 + tt_response->flags = BATADV_TT_RESPONSE; 1618 1593 1619 1594 if (full_table) 1620 - tt_response->flags |= TT_FULL_TABLE; 1595 + tt_response->flags |= BATADV_TT_FULL_TABLE; 1621 1596 1622 - batadv_dbg(DBG_TT, bat_priv, 1597 + batadv_dbg(BATADV_DBG_TT, bat_priv, 1623 1598 "Sending TT_RESPONSE %pM via %pM for %pM (ttvn: %u)\n", 1624 1599 res_dst_orig_node->orig, neigh_node->addr, 1625 1600 req_dst_orig_node->orig, req_ttvn); 1626 1601 1627 - batadv_inc_counter(bat_priv, BAT_CNT_TT_RESPONSE_TX); 1602 + batadv_inc_counter(bat_priv, BATADV_CNT_TT_RESPONSE_TX); 1628 1603 1629 1604 batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); 1630 1605 ret = true; ··· 1647 1622 return ret; 1648 1623 1649 1624 } 1650 - static bool batadv_send_my_tt_response(struct bat_priv *bat_priv, 1651 - struct tt_query_packet *tt_request) 1625 + 1626 + static bool 1627 + batadv_send_my_tt_response(struct batadv_priv *bat_priv, 1628 + struct batadv_tt_query_packet *tt_request) 1652 1629 { 1653 - struct orig_node *orig_node = NULL; 1654 - struct neigh_node *neigh_node = NULL; 1655 - struct hard_iface *primary_if = NULL; 1630 + struct batadv_orig_node *orig_node = NULL; 1631 + struct batadv_neigh_node *neigh_node = NULL; 1632 + struct batadv_hard_iface *primary_if = NULL; 1656 1633 uint8_t my_ttvn, req_ttvn, ttvn; 1657 1634 int ret = false; 1658 1635 unsigned char *tt_buff; 1659 1636 bool full_table; 1660 1637 uint16_t tt_len, tt_tot; 1661 1638 struct sk_buff *skb = NULL; 1662 - struct tt_query_packet *tt_response; 1639 + struct batadv_tt_query_packet *tt_response; 1640 + size_t len; 1663 1641 1664 - batadv_dbg(DBG_TT, bat_priv, 1642 + batadv_dbg(BATADV_DBG_TT, bat_priv, 1665 1643 "Received TT_REQUEST from %pM for ttvn: %u (me) [%c]\n", 1666 1644 tt_request->src, tt_request->ttvn, 1667 - (tt_request->flags & TT_FULL_TABLE ? 'F' : '.')); 1645 + (tt_request->flags & BATADV_TT_FULL_TABLE ? 'F' : '.')); 1668 1646 1669 1647 1670 1648 my_ttvn = (uint8_t)atomic_read(&bat_priv->ttvn); ··· 1688 1660 /* If the full table has been explicitly requested or the gap 1689 1661 * is too big send the whole local translation table 1690 1662 */ 1691 - if (tt_request->flags & TT_FULL_TABLE || my_ttvn != req_ttvn || 1663 + if (tt_request->flags & BATADV_TT_FULL_TABLE || my_ttvn != req_ttvn || 1692 1664 !bat_priv->tt_buff) 1693 1665 full_table = true; 1694 1666 else ··· 1700 1672 if (!full_table) { 1701 1673 spin_lock_bh(&bat_priv->tt_buff_lock); 1702 1674 tt_len = bat_priv->tt_buff_len; 1703 - tt_tot = tt_len / sizeof(struct tt_change); 1675 + tt_tot = tt_len / sizeof(struct batadv_tt_change); 1704 1676 1705 - skb = dev_alloc_skb(sizeof(struct tt_query_packet) + 1706 - tt_len + ETH_HLEN); 1677 + len = sizeof(*tt_response) + tt_len; 1678 + skb = dev_alloc_skb(len + ETH_HLEN); 1707 1679 if (!skb) 1708 1680 goto unlock; 1709 1681 1710 1682 skb_reserve(skb, ETH_HLEN); 1711 - tt_response = (struct tt_query_packet *)skb_put(skb, 1712 - sizeof(struct tt_query_packet) + tt_len); 1683 + tt_response = (struct batadv_tt_query_packet *)skb_put(skb, 1684 + len); 1713 1685 tt_response->ttvn = req_ttvn; 1714 1686 tt_response->tt_data = htons(tt_tot); 1715 1687 1716 - tt_buff = skb->data + sizeof(struct tt_query_packet); 1688 + tt_buff = skb->data + sizeof(*tt_response); 1717 1689 memcpy(tt_buff, bat_priv->tt_buff, 1718 1690 bat_priv->tt_buff_len); 1719 1691 spin_unlock_bh(&bat_priv->tt_buff_lock); 1720 1692 } else { 1721 - tt_len = (uint16_t)atomic_read(&bat_priv->num_local_tt) * 1722 - sizeof(struct tt_change); 1693 + tt_len = (uint16_t)atomic_read(&bat_priv->num_local_tt); 1694 + tt_len *= sizeof(struct batadv_tt_change); 1723 1695 ttvn = (uint8_t)atomic_read(&bat_priv->ttvn); 1724 1696 1725 1697 skb = batadv_tt_response_fill_table(tt_len, ttvn, ··· 1730 1702 if (!skb) 1731 1703 goto out; 1732 1704 1733 - tt_response = (struct tt_query_packet *)skb->data; 1705 + tt_response = (struct batadv_tt_query_packet *)skb->data; 1734 1706 } 1735 1707 1736 - tt_response->header.packet_type = BAT_TT_QUERY; 1708 + tt_response->header.packet_type = BATADV_TT_QUERY; 1737 1709 tt_response->header.version = BATADV_COMPAT_VERSION; 1738 1710 tt_response->header.ttl = BATADV_TTL; 1739 1711 memcpy(tt_response->src, primary_if->net_dev->dev_addr, ETH_ALEN); 1740 1712 memcpy(tt_response->dst, tt_request->src, ETH_ALEN); 1741 - tt_response->flags = TT_RESPONSE; 1713 + tt_response->flags = BATADV_TT_RESPONSE; 1742 1714 1743 1715 if (full_table) 1744 - tt_response->flags |= TT_FULL_TABLE; 1716 + tt_response->flags |= BATADV_TT_FULL_TABLE; 1745 1717 1746 - batadv_dbg(DBG_TT, bat_priv, 1718 + batadv_dbg(BATADV_DBG_TT, bat_priv, 1747 1719 "Sending TT_RESPONSE to %pM via %pM [%c]\n", 1748 1720 orig_node->orig, neigh_node->addr, 1749 - (tt_response->flags & TT_FULL_TABLE ? 'F' : '.')); 1721 + (tt_response->flags & BATADV_TT_FULL_TABLE ? 'F' : '.')); 1750 1722 1751 - batadv_inc_counter(bat_priv, BAT_CNT_TT_RESPONSE_TX); 1723 + batadv_inc_counter(bat_priv, BATADV_CNT_TT_RESPONSE_TX); 1752 1724 1753 1725 batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); 1754 1726 ret = true; ··· 1769 1741 return true; 1770 1742 } 1771 1743 1772 - bool batadv_send_tt_response(struct bat_priv *bat_priv, 1773 - struct tt_query_packet *tt_request) 1744 + bool batadv_send_tt_response(struct batadv_priv *bat_priv, 1745 + struct batadv_tt_query_packet *tt_request) 1774 1746 { 1775 1747 if (batadv_is_my_mac(tt_request->dst)) { 1776 1748 /* don't answer backbone gws! */ ··· 1783 1755 } 1784 1756 } 1785 1757 1786 - static void _batadv_tt_update_changes(struct bat_priv *bat_priv, 1787 - struct orig_node *orig_node, 1788 - struct tt_change *tt_change, 1758 + static void _batadv_tt_update_changes(struct batadv_priv *bat_priv, 1759 + struct batadv_orig_node *orig_node, 1760 + struct batadv_tt_change *tt_change, 1789 1761 uint16_t tt_num_changes, uint8_t ttvn) 1790 1762 { 1791 1763 int i; 1792 1764 int roams; 1793 1765 1794 1766 for (i = 0; i < tt_num_changes; i++) { 1795 - if ((tt_change + i)->flags & TT_CLIENT_DEL) { 1796 - roams = (tt_change + i)->flags & TT_CLIENT_ROAM; 1767 + if ((tt_change + i)->flags & BATADV_TT_CLIENT_DEL) { 1768 + roams = (tt_change + i)->flags & BATADV_TT_CLIENT_ROAM; 1797 1769 batadv_tt_global_del(bat_priv, orig_node, 1798 1770 (tt_change + i)->addr, 1799 1771 "tt removed by changes", ··· 1814 1786 orig_node->tt_initialised = true; 1815 1787 } 1816 1788 1817 - static void batadv_tt_fill_gtable(struct bat_priv *bat_priv, 1818 - struct tt_query_packet *tt_response) 1789 + static void batadv_tt_fill_gtable(struct batadv_priv *bat_priv, 1790 + struct batadv_tt_query_packet *tt_response) 1819 1791 { 1820 - struct orig_node *orig_node = NULL; 1792 + struct batadv_orig_node *orig_node = NULL; 1821 1793 1822 1794 orig_node = batadv_orig_hash_find(bat_priv, tt_response->src); 1823 1795 if (!orig_node) ··· 1827 1799 batadv_tt_global_del_orig(bat_priv, orig_node, "Received full table"); 1828 1800 1829 1801 _batadv_tt_update_changes(bat_priv, orig_node, 1830 - (struct tt_change *)(tt_response + 1), 1802 + (struct batadv_tt_change *)(tt_response + 1), 1831 1803 ntohs(tt_response->tt_data), 1832 1804 tt_response->ttvn); 1833 1805 ··· 1844 1816 batadv_orig_node_free_ref(orig_node); 1845 1817 } 1846 1818 1847 - static void batadv_tt_update_changes(struct bat_priv *bat_priv, 1848 - struct orig_node *orig_node, 1819 + static void batadv_tt_update_changes(struct batadv_priv *bat_priv, 1820 + struct batadv_orig_node *orig_node, 1849 1821 uint16_t tt_num_changes, uint8_t ttvn, 1850 - struct tt_change *tt_change) 1822 + struct batadv_tt_change *tt_change) 1851 1823 { 1852 1824 _batadv_tt_update_changes(bat_priv, orig_node, tt_change, 1853 1825 tt_num_changes, ttvn); ··· 1857 1829 atomic_set(&orig_node->last_ttvn, ttvn); 1858 1830 } 1859 1831 1860 - bool batadv_is_my_client(struct bat_priv *bat_priv, const uint8_t *addr) 1832 + bool batadv_is_my_client(struct batadv_priv *bat_priv, const uint8_t *addr) 1861 1833 { 1862 - struct tt_local_entry *tt_local_entry = NULL; 1834 + struct batadv_tt_local_entry *tt_local_entry = NULL; 1863 1835 bool ret = false; 1864 1836 1865 1837 tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr); ··· 1868 1840 /* Check if the client has been logically deleted (but is kept for 1869 1841 * consistency purpose) 1870 1842 */ 1871 - if (tt_local_entry->common.flags & TT_CLIENT_PENDING) 1843 + if (tt_local_entry->common.flags & BATADV_TT_CLIENT_PENDING) 1872 1844 goto out; 1873 1845 ret = true; 1874 1846 out: ··· 1877 1849 return ret; 1878 1850 } 1879 1851 1880 - void batadv_handle_tt_response(struct bat_priv *bat_priv, 1881 - struct tt_query_packet *tt_response) 1852 + void batadv_handle_tt_response(struct batadv_priv *bat_priv, 1853 + struct batadv_tt_query_packet *tt_response) 1882 1854 { 1883 - struct tt_req_node *node, *safe; 1884 - struct orig_node *orig_node = NULL; 1855 + struct batadv_tt_req_node *node, *safe; 1856 + struct batadv_orig_node *orig_node = NULL; 1857 + struct batadv_tt_change *tt_change; 1885 1858 1886 - batadv_dbg(DBG_TT, bat_priv, 1859 + batadv_dbg(BATADV_DBG_TT, bat_priv, 1887 1860 "Received TT_RESPONSE from %pM for ttvn %d t_size: %d [%c]\n", 1888 1861 tt_response->src, tt_response->ttvn, 1889 1862 ntohs(tt_response->tt_data), 1890 - (tt_response->flags & TT_FULL_TABLE ? 'F' : '.')); 1863 + (tt_response->flags & BATADV_TT_FULL_TABLE ? 'F' : '.')); 1891 1864 1892 1865 /* we should have never asked a backbone gw */ 1893 1866 if (batadv_bla_is_backbone_gw_orig(bat_priv, tt_response->src)) ··· 1898 1869 if (!orig_node) 1899 1870 goto out; 1900 1871 1901 - if (tt_response->flags & TT_FULL_TABLE) 1872 + if (tt_response->flags & BATADV_TT_FULL_TABLE) { 1902 1873 batadv_tt_fill_gtable(bat_priv, tt_response); 1903 - else 1874 + } else { 1875 + tt_change = (struct batadv_tt_change *)(tt_response + 1); 1904 1876 batadv_tt_update_changes(bat_priv, orig_node, 1905 1877 ntohs(tt_response->tt_data), 1906 - tt_response->ttvn, 1907 - (struct tt_change *)(tt_response + 1)); 1878 + tt_response->ttvn, tt_change); 1879 + } 1908 1880 1909 1881 /* Delete the tt_req_node from pending tt_requests list */ 1910 1882 spin_lock_bh(&bat_priv->tt_req_list_lock); ··· 1928 1898 batadv_orig_node_free_ref(orig_node); 1929 1899 } 1930 1900 1931 - int batadv_tt_init(struct bat_priv *bat_priv) 1901 + int batadv_tt_init(struct batadv_priv *bat_priv) 1932 1902 { 1933 1903 int ret; 1934 1904 ··· 1945 1915 return 1; 1946 1916 } 1947 1917 1948 - static void batadv_tt_roam_list_free(struct bat_priv *bat_priv) 1918 + static void batadv_tt_roam_list_free(struct batadv_priv *bat_priv) 1949 1919 { 1950 - struct tt_roam_node *node, *safe; 1920 + struct batadv_tt_roam_node *node, *safe; 1951 1921 1952 1922 spin_lock_bh(&bat_priv->tt_roam_list_lock); 1953 1923 ··· 1959 1929 spin_unlock_bh(&bat_priv->tt_roam_list_lock); 1960 1930 } 1961 1931 1962 - static void batadv_tt_roam_purge(struct bat_priv *bat_priv) 1932 + static void batadv_tt_roam_purge(struct batadv_priv *bat_priv) 1963 1933 { 1964 - struct tt_roam_node *node, *safe; 1934 + struct batadv_tt_roam_node *node, *safe; 1965 1935 1966 1936 spin_lock_bh(&bat_priv->tt_roam_list_lock); 1967 1937 list_for_each_entry_safe(node, safe, &bat_priv->tt_roam_list, list) { ··· 1981 1951 * 1982 1952 * returns true if the ROAMING_ADV can be sent, false otherwise 1983 1953 */ 1984 - static bool batadv_tt_check_roam_count(struct bat_priv *bat_priv, 1954 + static bool batadv_tt_check_roam_count(struct batadv_priv *bat_priv, 1985 1955 uint8_t *client) 1986 1956 { 1987 - struct tt_roam_node *tt_roam_node; 1957 + struct batadv_tt_roam_node *tt_roam_node; 1988 1958 bool ret = false; 1989 1959 1990 1960 spin_lock_bh(&bat_priv->tt_roam_list_lock); ··· 2025 1995 return ret; 2026 1996 } 2027 1997 2028 - static void batadv_send_roam_adv(struct bat_priv *bat_priv, uint8_t *client, 2029 - struct orig_node *orig_node) 1998 + static void batadv_send_roam_adv(struct batadv_priv *bat_priv, uint8_t *client, 1999 + struct batadv_orig_node *orig_node) 2030 2000 { 2031 - struct neigh_node *neigh_node = NULL; 2001 + struct batadv_neigh_node *neigh_node = NULL; 2032 2002 struct sk_buff *skb = NULL; 2033 - struct roam_adv_packet *roam_adv_packet; 2003 + struct batadv_roam_adv_packet *roam_adv_packet; 2034 2004 int ret = 1; 2035 - struct hard_iface *primary_if; 2005 + struct batadv_hard_iface *primary_if; 2006 + size_t len = sizeof(*roam_adv_packet); 2036 2007 2037 2008 /* before going on we have to check whether the client has 2038 2009 * already roamed to us too many times ··· 2041 2010 if (!batadv_tt_check_roam_count(bat_priv, client)) 2042 2011 goto out; 2043 2012 2044 - skb = dev_alloc_skb(sizeof(struct roam_adv_packet) + ETH_HLEN); 2013 + skb = dev_alloc_skb(sizeof(*roam_adv_packet) + ETH_HLEN); 2045 2014 if (!skb) 2046 2015 goto out; 2047 2016 2048 2017 skb_reserve(skb, ETH_HLEN); 2049 2018 2050 - roam_adv_packet = (struct roam_adv_packet *)skb_put(skb, 2051 - sizeof(struct roam_adv_packet)); 2019 + roam_adv_packet = (struct batadv_roam_adv_packet *)skb_put(skb, len); 2052 2020 2053 - roam_adv_packet->header.packet_type = BAT_ROAM_ADV; 2021 + roam_adv_packet->header.packet_type = BATADV_ROAM_ADV; 2054 2022 roam_adv_packet->header.version = BATADV_COMPAT_VERSION; 2055 2023 roam_adv_packet->header.ttl = BATADV_TTL; 2024 + roam_adv_packet->reserved = 0; 2056 2025 primary_if = batadv_primary_if_get_selected(bat_priv); 2057 2026 if (!primary_if) 2058 2027 goto out; ··· 2065 2034 if (!neigh_node) 2066 2035 goto out; 2067 2036 2068 - batadv_dbg(DBG_TT, bat_priv, 2037 + batadv_dbg(BATADV_DBG_TT, bat_priv, 2069 2038 "Sending ROAMING_ADV to %pM (client %pM) via %pM\n", 2070 2039 orig_node->orig, client, neigh_node->addr); 2071 2040 2072 - batadv_inc_counter(bat_priv, BAT_CNT_TT_ROAM_ADV_TX); 2041 + batadv_inc_counter(bat_priv, BATADV_CNT_TT_ROAM_ADV_TX); 2073 2042 2074 2043 batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); 2075 2044 ret = 0; ··· 2084 2053 2085 2054 static void batadv_tt_purge(struct work_struct *work) 2086 2055 { 2087 - struct delayed_work *delayed_work = 2088 - container_of(work, struct delayed_work, work); 2089 - struct bat_priv *bat_priv = 2090 - container_of(delayed_work, struct bat_priv, tt_work); 2056 + struct delayed_work *delayed_work; 2057 + struct batadv_priv *bat_priv; 2058 + 2059 + delayed_work = container_of(work, struct delayed_work, work); 2060 + bat_priv = container_of(delayed_work, struct batadv_priv, tt_work); 2091 2061 2092 2062 batadv_tt_local_purge(bat_priv); 2093 2063 batadv_tt_global_roam_purge(bat_priv); ··· 2098 2066 batadv_tt_start_timer(bat_priv); 2099 2067 } 2100 2068 2101 - void batadv_tt_free(struct bat_priv *bat_priv) 2069 + void batadv_tt_free(struct batadv_priv *bat_priv) 2102 2070 { 2103 2071 cancel_delayed_work_sync(&bat_priv->tt_work); 2104 2072 ··· 2114 2082 /* This function will enable or disable the specified flags for all the entries 2115 2083 * in the given hash table and returns the number of modified entries 2116 2084 */ 2117 - static uint16_t batadv_tt_set_flags(struct hashtable_t *hash, uint16_t flags, 2118 - bool enable) 2085 + static uint16_t batadv_tt_set_flags(struct batadv_hashtable *hash, 2086 + uint16_t flags, bool enable) 2119 2087 { 2120 2088 uint32_t i; 2121 2089 uint16_t changed_num = 0; 2122 2090 struct hlist_head *head; 2123 2091 struct hlist_node *node; 2124 - struct tt_common_entry *tt_common_entry; 2092 + struct batadv_tt_common_entry *tt_common_entry; 2125 2093 2126 2094 if (!hash) 2127 2095 goto out; ··· 2149 2117 return changed_num; 2150 2118 } 2151 2119 2152 - /* Purge out all the tt local entries marked with TT_CLIENT_PENDING */ 2153 - static void batadv_tt_local_purge_pending_clients(struct bat_priv *bat_priv) 2120 + /* Purge out all the tt local entries marked with BATADV_TT_CLIENT_PENDING */ 2121 + static void batadv_tt_local_purge_pending_clients(struct batadv_priv *bat_priv) 2154 2122 { 2155 - struct hashtable_t *hash = bat_priv->tt_local_hash; 2156 - struct tt_common_entry *tt_common_entry; 2157 - struct tt_local_entry *tt_local_entry; 2123 + struct batadv_hashtable *hash = bat_priv->tt_local_hash; 2124 + struct batadv_tt_common_entry *tt_common; 2125 + struct batadv_tt_local_entry *tt_local; 2158 2126 struct hlist_node *node, *node_tmp; 2159 2127 struct hlist_head *head; 2160 2128 spinlock_t *list_lock; /* protects write access to the hash lists */ ··· 2168 2136 list_lock = &hash->list_locks[i]; 2169 2137 2170 2138 spin_lock_bh(list_lock); 2171 - hlist_for_each_entry_safe(tt_common_entry, node, node_tmp, 2172 - head, hash_entry) { 2173 - if (!(tt_common_entry->flags & TT_CLIENT_PENDING)) 2139 + hlist_for_each_entry_safe(tt_common, node, node_tmp, head, 2140 + hash_entry) { 2141 + if (!(tt_common->flags & BATADV_TT_CLIENT_PENDING)) 2174 2142 continue; 2175 2143 2176 - batadv_dbg(DBG_TT, bat_priv, 2144 + batadv_dbg(BATADV_DBG_TT, bat_priv, 2177 2145 "Deleting local tt entry (%pM): pending\n", 2178 - tt_common_entry->addr); 2146 + tt_common->addr); 2179 2147 2180 2148 atomic_dec(&bat_priv->num_local_tt); 2181 2149 hlist_del_rcu(node); 2182 - tt_local_entry = container_of(tt_common_entry, 2183 - struct tt_local_entry, 2184 - common); 2185 - batadv_tt_local_entry_free_ref(tt_local_entry); 2150 + tt_local = container_of(tt_common, 2151 + struct batadv_tt_local_entry, 2152 + common); 2153 + batadv_tt_local_entry_free_ref(tt_local); 2186 2154 } 2187 2155 spin_unlock_bh(list_lock); 2188 2156 } 2189 2157 2190 2158 } 2191 2159 2192 - static int batadv_tt_commit_changes(struct bat_priv *bat_priv, 2160 + static int batadv_tt_commit_changes(struct batadv_priv *bat_priv, 2193 2161 unsigned char **packet_buff, 2194 2162 int *packet_buff_len, int packet_min_len) 2195 2163 { ··· 2199 2167 return -ENOENT; 2200 2168 2201 2169 changed_num = batadv_tt_set_flags(bat_priv->tt_local_hash, 2202 - TT_CLIENT_NEW, false); 2170 + BATADV_TT_CLIENT_NEW, false); 2203 2171 2204 2172 /* all reset entries have to be counted as local entries */ 2205 2173 atomic_add(changed_num, &bat_priv->num_local_tt); ··· 2208 2176 2209 2177 /* Increment the TTVN only once per OGM interval */ 2210 2178 atomic_inc(&bat_priv->ttvn); 2211 - batadv_dbg(DBG_TT, bat_priv, 2179 + batadv_dbg(BATADV_DBG_TT, bat_priv, 2212 2180 "Local changes committed, updating to ttvn %u\n", 2213 2181 (uint8_t)atomic_read(&bat_priv->ttvn)); 2214 2182 bat_priv->tt_poss_change = false; ··· 2221 2189 } 2222 2190 2223 2191 /* when calling this function (hard_iface == primary_if) has to be true */ 2224 - int batadv_tt_append_diff(struct bat_priv *bat_priv, 2192 + int batadv_tt_append_diff(struct batadv_priv *bat_priv, 2225 2193 unsigned char **packet_buff, int *packet_buff_len, 2226 2194 int packet_min_len) 2227 2195 { ··· 2243 2211 return tt_num_changes; 2244 2212 } 2245 2213 2246 - bool batadv_is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src, 2214 + bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, uint8_t *src, 2247 2215 uint8_t *dst) 2248 2216 { 2249 - struct tt_local_entry *tt_local_entry = NULL; 2250 - struct tt_global_entry *tt_global_entry = NULL; 2217 + struct batadv_tt_local_entry *tt_local_entry = NULL; 2218 + struct batadv_tt_global_entry *tt_global_entry = NULL; 2251 2219 bool ret = false; 2252 2220 2253 2221 if (!atomic_read(&bat_priv->ap_isolation)) ··· 2274 2242 return ret; 2275 2243 } 2276 2244 2277 - void batadv_tt_update_orig(struct bat_priv *bat_priv, 2278 - struct orig_node *orig_node, 2245 + void batadv_tt_update_orig(struct batadv_priv *bat_priv, 2246 + struct batadv_orig_node *orig_node, 2279 2247 const unsigned char *tt_buff, uint8_t tt_num_changes, 2280 2248 uint8_t ttvn, uint16_t tt_crc) 2281 2249 { 2282 2250 uint8_t orig_ttvn = (uint8_t)atomic_read(&orig_node->last_ttvn); 2283 2251 bool full_table = true; 2252 + struct batadv_tt_change *tt_change; 2284 2253 2285 2254 /* don't care about a backbone gateways updates. */ 2286 2255 if (batadv_bla_is_backbone_gw_orig(bat_priv, orig_node->orig)) ··· 2302 2269 goto request_table; 2303 2270 } 2304 2271 2272 + tt_change = (struct batadv_tt_change *)tt_buff; 2305 2273 batadv_tt_update_changes(bat_priv, orig_node, tt_num_changes, 2306 - ttvn, (struct tt_change *)tt_buff); 2274 + ttvn, tt_change); 2307 2275 2308 2276 /* Even if we received the precomputed crc with the OGM, we 2309 2277 * prefer to recompute it to spot any possible inconsistency ··· 2335 2301 if (!orig_node->tt_initialised || ttvn != orig_ttvn || 2336 2302 orig_node->tt_crc != tt_crc) { 2337 2303 request_table: 2338 - batadv_dbg(DBG_TT, bat_priv, 2304 + batadv_dbg(BATADV_DBG_TT, bat_priv, 2339 2305 "TT inconsistency for %pM. Need to retrieve the correct information (ttvn: %u last_ttvn: %u crc: %u last_crc: %u num_changes: %u)\n", 2340 2306 orig_node->orig, ttvn, orig_ttvn, tt_crc, 2341 2307 orig_node->tt_crc, tt_num_changes); ··· 2350 2316 * originator to another one. This entry is kept is still kept for consistency 2351 2317 * purposes 2352 2318 */ 2353 - bool batadv_tt_global_client_is_roaming(struct bat_priv *bat_priv, 2319 + bool batadv_tt_global_client_is_roaming(struct batadv_priv *bat_priv, 2354 2320 uint8_t *addr) 2355 2321 { 2356 - struct tt_global_entry *tt_global_entry; 2322 + struct batadv_tt_global_entry *tt_global_entry; 2357 2323 bool ret = false; 2358 2324 2359 2325 tt_global_entry = batadv_tt_global_hash_find(bat_priv, addr); 2360 2326 if (!tt_global_entry) 2361 2327 goto out; 2362 2328 2363 - ret = tt_global_entry->common.flags & TT_CLIENT_ROAM; 2329 + ret = tt_global_entry->common.flags & BATADV_TT_CLIENT_ROAM; 2364 2330 batadv_tt_global_entry_free_ref(tt_global_entry); 2365 2331 out: 2366 2332 return ret;
+22 -21
net/batman-adv/translation-table.h
··· 21 21 #define _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ 22 22 23 23 int batadv_tt_len(int changes_num); 24 - int batadv_tt_init(struct bat_priv *bat_priv); 24 + int batadv_tt_init(struct batadv_priv *bat_priv); 25 25 void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, 26 26 int ifindex); 27 - void batadv_tt_local_remove(struct bat_priv *bat_priv, 27 + void batadv_tt_local_remove(struct batadv_priv *bat_priv, 28 28 const uint8_t *addr, const char *message, 29 29 bool roaming); 30 30 int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset); 31 - void batadv_tt_global_add_orig(struct bat_priv *bat_priv, 32 - struct orig_node *orig_node, 31 + void batadv_tt_global_add_orig(struct batadv_priv *bat_priv, 32 + struct batadv_orig_node *orig_node, 33 33 const unsigned char *tt_buff, int tt_buff_len); 34 - int batadv_tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, 34 + int batadv_tt_global_add(struct batadv_priv *bat_priv, 35 + struct batadv_orig_node *orig_node, 35 36 const unsigned char *addr, uint8_t flags, 36 37 uint8_t ttvn); 37 38 int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset); 38 - void batadv_tt_global_del_orig(struct bat_priv *bat_priv, 39 - struct orig_node *orig_node, 39 + void batadv_tt_global_del_orig(struct batadv_priv *bat_priv, 40 + struct batadv_orig_node *orig_node, 40 41 const char *message); 41 - struct orig_node *batadv_transtable_search(struct bat_priv *bat_priv, 42 - const uint8_t *src, 43 - const uint8_t *addr); 44 - void batadv_tt_free(struct bat_priv *bat_priv); 45 - bool batadv_send_tt_response(struct bat_priv *bat_priv, 46 - struct tt_query_packet *tt_request); 47 - bool batadv_is_my_client(struct bat_priv *bat_priv, const uint8_t *addr); 48 - void batadv_handle_tt_response(struct bat_priv *bat_priv, 49 - struct tt_query_packet *tt_response); 50 - bool batadv_is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src, 42 + struct batadv_orig_node *batadv_transtable_search(struct batadv_priv *bat_priv, 43 + const uint8_t *src, 44 + const uint8_t *addr); 45 + void batadv_tt_free(struct batadv_priv *bat_priv); 46 + bool batadv_send_tt_response(struct batadv_priv *bat_priv, 47 + struct batadv_tt_query_packet *tt_request); 48 + bool batadv_is_my_client(struct batadv_priv *bat_priv, const uint8_t *addr); 49 + void batadv_handle_tt_response(struct batadv_priv *bat_priv, 50 + struct batadv_tt_query_packet *tt_response); 51 + bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, uint8_t *src, 51 52 uint8_t *dst); 52 - void batadv_tt_update_orig(struct bat_priv *bat_priv, 53 - struct orig_node *orig_node, 53 + void batadv_tt_update_orig(struct batadv_priv *bat_priv, 54 + struct batadv_orig_node *orig_node, 54 55 const unsigned char *tt_buff, uint8_t tt_num_changes, 55 56 uint8_t ttvn, uint16_t tt_crc); 56 - int batadv_tt_append_diff(struct bat_priv *bat_priv, 57 + int batadv_tt_append_diff(struct batadv_priv *bat_priv, 57 58 unsigned char **packet_buff, int *packet_buff_len, 58 59 int packet_min_len); 59 - bool batadv_tt_global_client_is_roaming(struct bat_priv *bat_priv, 60 + bool batadv_tt_global_client_is_roaming(struct batadv_priv *bat_priv, 60 61 uint8_t *addr); 61 62 62 63
+77 -77
net/batman-adv/types.h
··· 25 25 #include <linux/kernel.h> 26 26 27 27 #define BATADV_HEADER_LEN \ 28 - (ETH_HLEN + max(sizeof(struct unicast_packet), \ 29 - sizeof(struct bcast_packet))) 28 + (ETH_HLEN + max(sizeof(struct batadv_unicast_packet), \ 29 + sizeof(struct batadv_bcast_packet))) 30 30 31 - struct hard_iface { 31 + struct batadv_hard_iface { 32 32 struct list_head list; 33 33 int16_t if_num; 34 34 char if_status; ··· 44 44 struct rcu_head rcu; 45 45 }; 46 46 47 - /* orig_node - structure for orig_list maintaining nodes of mesh 47 + /* batadv_orig_node - structure for orig_list maintaining nodes of mesh 48 48 * @primary_addr: hosts primary interface address 49 49 * @last_seen: when last packet from this node was received 50 50 * @bcast_seqno_reset: time when the broadcast seqno window was reset ··· 58 58 * @candidates: how many candidates are available 59 59 * @selected: next bonding candidate 60 60 */ 61 - struct orig_node { 61 + struct batadv_orig_node { 62 62 uint8_t orig[ETH_ALEN]; 63 63 uint8_t primary_addr[ETH_ALEN]; 64 - struct neigh_node __rcu *router; /* rcu protected pointer */ 64 + struct batadv_neigh_node __rcu *router; /* rcu protected pointer */ 65 65 unsigned long *bcast_own; 66 66 uint8_t *bcast_own_sum; 67 67 unsigned long last_seen; ··· 93 93 atomic_t refcount; 94 94 struct rcu_head rcu; 95 95 struct hlist_node hash_entry; 96 - struct bat_priv *bat_priv; 96 + struct batadv_priv *bat_priv; 97 97 unsigned long last_frag_packet; 98 98 /* ogm_cnt_lock protects: bcast_own, bcast_own_sum, 99 99 * neigh_node->real_bits, neigh_node->real_packet_count ··· 106 106 struct list_head bond_list; 107 107 }; 108 108 109 - struct gw_node { 109 + struct batadv_gw_node { 110 110 struct hlist_node list; 111 - struct orig_node *orig_node; 111 + struct batadv_orig_node *orig_node; 112 112 unsigned long deleted; 113 113 atomic_t refcount; 114 114 struct rcu_head rcu; 115 115 }; 116 116 117 - /* neigh_node 117 + /* batadv_neigh_node 118 118 * @last_seen: when last packet via this neighbor was received 119 119 */ 120 - struct neigh_node { 120 + struct batadv_neigh_node { 121 121 struct hlist_node list; 122 122 uint8_t addr[ETH_ALEN]; 123 123 uint8_t real_packet_count; ··· 130 130 DECLARE_BITMAP(real_bits, BATADV_TQ_LOCAL_WINDOW_SIZE); 131 131 atomic_t refcount; 132 132 struct rcu_head rcu; 133 - struct orig_node *orig_node; 134 - struct hard_iface *if_incoming; 133 + struct batadv_orig_node *orig_node; 134 + struct batadv_hard_iface *if_incoming; 135 135 spinlock_t lq_update_lock; /* protects: tq_recv, tq_index */ 136 136 }; 137 137 138 138 #ifdef CONFIG_BATMAN_ADV_BLA 139 - struct bcast_duplist_entry { 139 + struct batadv_bcast_duplist_entry { 140 140 uint8_t orig[ETH_ALEN]; 141 141 uint16_t crc; 142 142 unsigned long entrytime; 143 143 }; 144 144 #endif 145 145 146 - enum bat_counters { 147 - BAT_CNT_FORWARD, 148 - BAT_CNT_FORWARD_BYTES, 149 - BAT_CNT_MGMT_TX, 150 - BAT_CNT_MGMT_TX_BYTES, 151 - BAT_CNT_MGMT_RX, 152 - BAT_CNT_MGMT_RX_BYTES, 153 - BAT_CNT_TT_REQUEST_TX, 154 - BAT_CNT_TT_REQUEST_RX, 155 - BAT_CNT_TT_RESPONSE_TX, 156 - BAT_CNT_TT_RESPONSE_RX, 157 - BAT_CNT_TT_ROAM_ADV_TX, 158 - BAT_CNT_TT_ROAM_ADV_RX, 159 - BAT_CNT_NUM, 146 + enum batadv_counters { 147 + BATADV_CNT_FORWARD, 148 + BATADV_CNT_FORWARD_BYTES, 149 + BATADV_CNT_MGMT_TX, 150 + BATADV_CNT_MGMT_TX_BYTES, 151 + BATADV_CNT_MGMT_RX, 152 + BATADV_CNT_MGMT_RX_BYTES, 153 + BATADV_CNT_TT_REQUEST_TX, 154 + BATADV_CNT_TT_REQUEST_RX, 155 + BATADV_CNT_TT_RESPONSE_TX, 156 + BATADV_CNT_TT_RESPONSE_RX, 157 + BATADV_CNT_TT_ROAM_ADV_TX, 158 + BATADV_CNT_TT_ROAM_ADV_RX, 159 + BATADV_CNT_NUM, 160 160 }; 161 161 162 - struct bat_priv { 162 + struct batadv_priv { 163 163 atomic_t mesh_state; 164 164 struct net_device_stats stats; 165 165 uint64_t __percpu *bat_counters; /* Per cpu counters */ ··· 190 190 */ 191 191 bool tt_poss_change; 192 192 char num_ifaces; 193 - struct debug_log *debug_log; 193 + struct batadv_debug_log *debug_log; 194 194 struct kobject *mesh_obj; 195 195 struct dentry *debug_dir; 196 196 struct hlist_head forw_bat_list; ··· 198 198 struct hlist_head gw_list; 199 199 struct list_head tt_changes_list; /* tracks changes in a OGM int */ 200 200 struct list_head vis_send_list; 201 - struct hashtable_t *orig_hash; 202 - struct hashtable_t *tt_local_hash; 203 - struct hashtable_t *tt_global_hash; 201 + struct batadv_hashtable *orig_hash; 202 + struct batadv_hashtable *tt_local_hash; 203 + struct batadv_hashtable *tt_global_hash; 204 204 #ifdef CONFIG_BATMAN_ADV_BLA 205 - struct hashtable_t *claim_hash; 206 - struct hashtable_t *backbone_hash; 205 + struct batadv_hashtable *claim_hash; 206 + struct batadv_hashtable *backbone_hash; 207 207 #endif 208 208 struct list_head tt_req_list; /* list of pending tt_requests */ 209 209 struct list_head tt_roam_list; 210 - struct hashtable_t *vis_hash; 210 + struct batadv_hashtable *vis_hash; 211 211 #ifdef CONFIG_BATMAN_ADV_BLA 212 - struct bcast_duplist_entry bcast_duplist[BATADV_DUPLIST_SIZE]; 212 + struct batadv_bcast_duplist_entry bcast_duplist[BATADV_DUPLIST_SIZE]; 213 213 int bcast_duplist_curr; 214 - struct bla_claim_dst claim_dest; 214 + struct batadv_bla_claim_dst claim_dest; 215 215 #endif 216 216 spinlock_t forw_bat_list_lock; /* protects forw_bat_list */ 217 217 spinlock_t forw_bcast_list_lock; /* protects */ ··· 231 231 struct delayed_work orig_work; 232 232 struct delayed_work vis_work; 233 233 struct delayed_work bla_work; 234 - struct gw_node __rcu *curr_gw; /* rcu protected pointer */ 234 + struct batadv_gw_node __rcu *curr_gw; /* rcu protected pointer */ 235 235 atomic_t gw_reselect; 236 - struct hard_iface __rcu *primary_if; /* rcu protected pointer */ 237 - struct vis_info *my_vis_info; 238 - struct bat_algo_ops *bat_algo_ops; 236 + struct batadv_hard_iface __rcu *primary_if; /* rcu protected pointer */ 237 + struct batadv_vis_info *my_vis_info; 238 + struct batadv_algo_ops *bat_algo_ops; 239 239 }; 240 240 241 - struct socket_client { 241 + struct batadv_socket_client { 242 242 struct list_head queue_list; 243 243 unsigned int queue_len; 244 244 unsigned char index; 245 245 spinlock_t lock; /* protects queue_list, queue_len, index */ 246 246 wait_queue_head_t queue_wait; 247 - struct bat_priv *bat_priv; 247 + struct batadv_priv *bat_priv; 248 248 }; 249 249 250 - struct socket_packet { 250 + struct batadv_socket_packet { 251 251 struct list_head list; 252 252 size_t icmp_len; 253 - struct icmp_packet_rr icmp_packet; 253 + struct batadv_icmp_packet_rr icmp_packet; 254 254 }; 255 255 256 - struct tt_common_entry { 256 + struct batadv_tt_common_entry { 257 257 uint8_t addr[ETH_ALEN]; 258 258 struct hlist_node hash_entry; 259 259 uint16_t flags; ··· 261 261 struct rcu_head rcu; 262 262 }; 263 263 264 - struct tt_local_entry { 265 - struct tt_common_entry common; 264 + struct batadv_tt_local_entry { 265 + struct batadv_tt_common_entry common; 266 266 unsigned long last_seen; 267 267 }; 268 268 269 - struct tt_global_entry { 270 - struct tt_common_entry common; 269 + struct batadv_tt_global_entry { 270 + struct batadv_tt_common_entry common; 271 271 struct hlist_head orig_list; 272 272 spinlock_t list_lock; /* protects the list */ 273 273 unsigned long roam_at; /* time at which TT_GLOBAL_ROAM was set */ 274 274 }; 275 275 276 - struct tt_orig_list_entry { 277 - struct orig_node *orig_node; 276 + struct batadv_tt_orig_list_entry { 277 + struct batadv_orig_node *orig_node; 278 278 uint8_t ttvn; 279 279 struct rcu_head rcu; 280 280 struct hlist_node list; 281 281 }; 282 282 283 283 #ifdef CONFIG_BATMAN_ADV_BLA 284 - struct backbone_gw { 284 + struct batadv_backbone_gw { 285 285 uint8_t orig[ETH_ALEN]; 286 286 short vid; /* used VLAN ID */ 287 287 struct hlist_node hash_entry; 288 - struct bat_priv *bat_priv; 288 + struct batadv_priv *bat_priv; 289 289 unsigned long lasttime; /* last time we heard of this backbone gw */ 290 290 atomic_t request_sent; 291 291 atomic_t refcount; ··· 293 293 uint16_t crc; /* crc checksum over all claims */ 294 294 }; 295 295 296 - struct claim { 296 + struct batadv_claim { 297 297 uint8_t addr[ETH_ALEN]; 298 298 short vid; 299 - struct backbone_gw *backbone_gw; 299 + struct batadv_backbone_gw *backbone_gw; 300 300 unsigned long lasttime; /* last time we heard of claim (locals only) */ 301 301 struct rcu_head rcu; 302 302 atomic_t refcount; ··· 304 304 }; 305 305 #endif 306 306 307 - struct tt_change_node { 307 + struct batadv_tt_change_node { 308 308 struct list_head list; 309 - struct tt_change change; 309 + struct batadv_tt_change change; 310 310 }; 311 311 312 - struct tt_req_node { 312 + struct batadv_tt_req_node { 313 313 uint8_t addr[ETH_ALEN]; 314 314 unsigned long issued_at; 315 315 struct list_head list; 316 316 }; 317 317 318 - struct tt_roam_node { 318 + struct batadv_tt_roam_node { 319 319 uint8_t addr[ETH_ALEN]; 320 320 atomic_t counter; 321 321 unsigned long first_time; ··· 325 325 /* forw_packet - structure for forw_list maintaining packets to be 326 326 * send/forwarded 327 327 */ 328 - struct forw_packet { 328 + struct batadv_forw_packet { 329 329 struct hlist_node list; 330 330 unsigned long send_time; 331 331 uint8_t own; ··· 334 334 uint32_t direct_link_flags; 335 335 uint8_t num_packets; 336 336 struct delayed_work delayed_work; 337 - struct hard_iface *if_incoming; 337 + struct batadv_hard_iface *if_incoming; 338 338 }; 339 339 340 340 /* While scanning for vis-entries of a particular vis-originator 341 341 * this list collects its interfaces to create a subgraph/cluster 342 342 * out of them later 343 343 */ 344 - struct if_list_entry { 344 + struct batadv_if_list_entry { 345 345 uint8_t addr[ETH_ALEN]; 346 346 bool primary; 347 347 struct hlist_node list; 348 348 }; 349 349 350 - struct debug_log { 350 + struct batadv_debug_log { 351 351 char log_buff[BATADV_LOG_BUF_LEN]; 352 352 unsigned long log_start; 353 353 unsigned long log_end; ··· 355 355 wait_queue_head_t queue_wait; 356 356 }; 357 357 358 - struct frag_packet_list_entry { 358 + struct batadv_frag_packet_list_entry { 359 359 struct list_head list; 360 360 uint16_t seqno; 361 361 struct sk_buff *skb; 362 362 }; 363 363 364 - struct vis_info { 364 + struct batadv_vis_info { 365 365 unsigned long first_seen; 366 366 /* list of server-neighbors we received a vis-packet 367 367 * from. we should not reply to them. ··· 370 370 struct list_head send_list; 371 371 struct kref refcount; 372 372 struct hlist_node hash_entry; 373 - struct bat_priv *bat_priv; 373 + struct batadv_priv *bat_priv; 374 374 /* this packet might be part of the vis send queue. */ 375 375 struct sk_buff *skb_packet; 376 376 /* vis_info may follow here */ 377 377 } __packed; 378 378 379 - struct vis_info_entry { 379 + struct batadv_vis_info_entry { 380 380 uint8_t src[ETH_ALEN]; 381 381 uint8_t dest[ETH_ALEN]; 382 382 uint8_t quality; /* quality = 0 client */ 383 383 } __packed; 384 384 385 - struct recvlist_node { 385 + struct batadv_recvlist_node { 386 386 struct list_head list; 387 387 uint8_t mac[ETH_ALEN]; 388 388 }; 389 389 390 - struct bat_algo_ops { 390 + struct batadv_algo_ops { 391 391 struct hlist_node list; 392 392 char *name; 393 393 /* init routing info when hard-interface is enabled */ 394 - int (*bat_iface_enable)(struct hard_iface *hard_iface); 394 + int (*bat_iface_enable)(struct batadv_hard_iface *hard_iface); 395 395 /* de-init routing info when hard-interface is disabled */ 396 - void (*bat_iface_disable)(struct hard_iface *hard_iface); 396 + void (*bat_iface_disable)(struct batadv_hard_iface *hard_iface); 397 397 /* (re-)init mac addresses of the protocol information 398 398 * belonging to this hard-interface 399 399 */ 400 - void (*bat_iface_update_mac)(struct hard_iface *hard_iface); 400 + void (*bat_iface_update_mac)(struct batadv_hard_iface *hard_iface); 401 401 /* called when primary interface is selected / changed */ 402 - void (*bat_primary_iface_set)(struct hard_iface *hard_iface); 402 + void (*bat_primary_iface_set)(struct batadv_hard_iface *hard_iface); 403 403 /* prepare a new outgoing OGM for the send queue */ 404 - void (*bat_ogm_schedule)(struct hard_iface *hard_iface); 404 + void (*bat_ogm_schedule)(struct batadv_hard_iface *hard_iface); 405 405 /* send scheduled OGM */ 406 - void (*bat_ogm_emit)(struct forw_packet *forw_packet); 406 + void (*bat_ogm_emit)(struct batadv_forw_packet *forw_packet); 407 407 }; 408 408 409 409 #endif /* _NET_BATMAN_ADV_TYPES_H_ */
+51 -44
net/batman-adv/unicast.c
··· 31 31 32 32 static struct sk_buff * 33 33 batadv_frag_merge_packet(struct list_head *head, 34 - struct frag_packet_list_entry *tfp, 34 + struct batadv_frag_packet_list_entry *tfp, 35 35 struct sk_buff *skb) 36 36 { 37 - struct unicast_frag_packet *up = 38 - (struct unicast_frag_packet *)skb->data; 37 + struct batadv_unicast_frag_packet *up; 39 38 struct sk_buff *tmp_skb; 40 - struct unicast_packet *unicast_packet; 39 + struct batadv_unicast_packet *unicast_packet; 41 40 int hdr_len = sizeof(*unicast_packet); 42 41 int uni_diff = sizeof(*up) - hdr_len; 43 42 43 + up = (struct batadv_unicast_frag_packet *)skb->data; 44 44 /* set skb to the first part and tmp_skb to the second part */ 45 - if (up->flags & UNI_FRAG_HEAD) { 45 + if (up->flags & BATADV_UNI_FRAG_HEAD) { 46 46 tmp_skb = tfp->skb; 47 47 } else { 48 48 tmp_skb = skb; ··· 65 65 kfree_skb(tmp_skb); 66 66 67 67 memmove(skb->data + uni_diff, skb->data, hdr_len); 68 - unicast_packet = (struct unicast_packet *)skb_pull(skb, uni_diff); 69 - unicast_packet->header.packet_type = BAT_UNICAST; 68 + unicast_packet = (struct batadv_unicast_packet *)skb_pull(skb, 69 + uni_diff); 70 + unicast_packet->header.packet_type = BATADV_UNICAST; 70 71 71 72 return skb; 72 73 ··· 80 79 static void batadv_frag_create_entry(struct list_head *head, 81 80 struct sk_buff *skb) 82 81 { 83 - struct frag_packet_list_entry *tfp; 84 - struct unicast_frag_packet *up = 85 - (struct unicast_frag_packet *)skb->data; 82 + struct batadv_frag_packet_list_entry *tfp; 83 + struct batadv_unicast_frag_packet *up; 84 + 85 + up = (struct batadv_unicast_frag_packet *)skb->data; 86 86 87 87 /* free and oldest packets stand at the end */ 88 88 tfp = list_entry((head)->prev, typeof(*tfp), list); ··· 98 96 static int batadv_frag_create_buffer(struct list_head *head) 99 97 { 100 98 int i; 101 - struct frag_packet_list_entry *tfp; 99 + struct batadv_frag_packet_list_entry *tfp; 102 100 103 101 for (i = 0; i < BATADV_FRAG_BUFFER_SIZE; i++) { 104 102 tfp = kmalloc(sizeof(*tfp), GFP_ATOMIC); ··· 115 113 return 0; 116 114 } 117 115 118 - static struct frag_packet_list_entry * 116 + static struct batadv_frag_packet_list_entry * 119 117 batadv_frag_search_packet(struct list_head *head, 120 - const struct unicast_frag_packet *up) 118 + const struct batadv_unicast_frag_packet *up) 121 119 { 122 - struct frag_packet_list_entry *tfp; 123 - struct unicast_frag_packet *tmp_up = NULL; 120 + struct batadv_frag_packet_list_entry *tfp; 121 + struct batadv_unicast_frag_packet *tmp_up = NULL; 124 122 uint16_t search_seqno; 125 123 126 - if (up->flags & UNI_FRAG_HEAD) 124 + if (up->flags & BATADV_UNI_FRAG_HEAD) 127 125 search_seqno = ntohs(up->seqno)+1; 128 126 else 129 127 search_seqno = ntohs(up->seqno)-1; ··· 136 134 if (tfp->seqno == ntohs(up->seqno)) 137 135 goto mov_tail; 138 136 139 - tmp_up = (struct unicast_frag_packet *)tfp->skb->data; 137 + tmp_up = (struct batadv_unicast_frag_packet *)tfp->skb->data; 140 138 141 139 if (tfp->seqno == search_seqno) { 142 140 143 - if ((tmp_up->flags & UNI_FRAG_HEAD) != 144 - (up->flags & UNI_FRAG_HEAD)) 141 + if ((tmp_up->flags & BATADV_UNI_FRAG_HEAD) != 142 + (up->flags & BATADV_UNI_FRAG_HEAD)) 145 143 return tfp; 146 144 else 147 145 goto mov_tail; ··· 156 154 157 155 void batadv_frag_list_free(struct list_head *head) 158 156 { 159 - struct frag_packet_list_entry *pf, *tmp_pf; 157 + struct batadv_frag_packet_list_entry *pf, *tmp_pf; 160 158 161 159 if (!list_empty(head)) { 162 160 ··· 175 173 * or the skb could be reassembled (skb_new will point to the new packet and 176 174 * skb was freed) 177 175 */ 178 - int batadv_frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv, 176 + int batadv_frag_reassemble_skb(struct sk_buff *skb, 177 + struct batadv_priv *bat_priv, 179 178 struct sk_buff **new_skb) 180 179 { 181 - struct orig_node *orig_node; 182 - struct frag_packet_list_entry *tmp_frag_entry; 180 + struct batadv_orig_node *orig_node; 181 + struct batadv_frag_packet_list_entry *tmp_frag_entry; 183 182 int ret = NET_RX_DROP; 184 - struct unicast_frag_packet *unicast_packet = 185 - (struct unicast_frag_packet *)skb->data; 183 + struct batadv_unicast_frag_packet *unicast_packet; 186 184 185 + unicast_packet = (struct batadv_unicast_frag_packet *)skb->data; 187 186 *new_skb = NULL; 188 187 189 188 orig_node = batadv_orig_hash_find(bat_priv, unicast_packet->orig); ··· 220 217 return ret; 221 218 } 222 219 223 - int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv, 224 - struct hard_iface *hard_iface, const uint8_t dstaddr[]) 220 + int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv, 221 + struct batadv_hard_iface *hard_iface, 222 + const uint8_t dstaddr[]) 225 223 { 226 - struct unicast_packet tmp_uc, *unicast_packet; 227 - struct hard_iface *primary_if; 224 + struct batadv_unicast_packet tmp_uc, *unicast_packet; 225 + struct batadv_hard_iface *primary_if; 228 226 struct sk_buff *frag_skb; 229 - struct unicast_frag_packet *frag1, *frag2; 227 + struct batadv_unicast_frag_packet *frag1, *frag2; 230 228 int uc_hdr_len = sizeof(*unicast_packet); 231 229 int ucf_hdr_len = sizeof(*frag1); 232 230 int data_len = skb->len - uc_hdr_len; ··· 243 239 goto dropped; 244 240 skb_reserve(frag_skb, ucf_hdr_len); 245 241 246 - unicast_packet = (struct unicast_packet *)skb->data; 242 + unicast_packet = (struct batadv_unicast_packet *)skb->data; 247 243 memcpy(&tmp_uc, unicast_packet, uc_hdr_len); 248 244 skb_split(skb, frag_skb, data_len / 2 + uc_hdr_len); 249 245 ··· 251 247 batadv_skb_head_push(frag_skb, ucf_hdr_len) < 0) 252 248 goto drop_frag; 253 249 254 - frag1 = (struct unicast_frag_packet *)skb->data; 255 - frag2 = (struct unicast_frag_packet *)frag_skb->data; 250 + frag1 = (struct batadv_unicast_frag_packet *)skb->data; 251 + frag2 = (struct batadv_unicast_frag_packet *)frag_skb->data; 256 252 257 253 memcpy(frag1, &tmp_uc, sizeof(tmp_uc)); 258 254 259 255 frag1->header.ttl--; 260 256 frag1->header.version = BATADV_COMPAT_VERSION; 261 - frag1->header.packet_type = BAT_UNICAST_FRAG; 257 + frag1->header.packet_type = BATADV_UNICAST_FRAG; 262 258 263 259 memcpy(frag1->orig, primary_if->net_dev->dev_addr, ETH_ALEN); 264 260 memcpy(frag2, frag1, sizeof(*frag2)); 265 261 266 262 if (data_len & 1) 267 - large_tail = UNI_FRAG_LARGETAIL; 263 + large_tail = BATADV_UNI_FRAG_LARGETAIL; 268 264 269 - frag1->flags = UNI_FRAG_HEAD | large_tail; 265 + frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail; 270 266 frag2->flags = large_tail; 271 267 272 268 seqno = atomic_add_return(2, &hard_iface->frag_seqno); ··· 288 284 return ret; 289 285 } 290 286 291 - int batadv_unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv) 287 + int batadv_unicast_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv) 292 288 { 293 289 struct ethhdr *ethhdr = (struct ethhdr *)skb->data; 294 - struct unicast_packet *unicast_packet; 295 - struct orig_node *orig_node; 296 - struct neigh_node *neigh_node; 290 + struct batadv_unicast_packet *unicast_packet; 291 + struct batadv_orig_node *orig_node; 292 + struct batadv_neigh_node *neigh_node; 297 293 int data_len = skb->len; 298 294 int ret = 1; 295 + unsigned int dev_mtu; 299 296 300 297 /* get routing information */ 301 298 if (is_multicast_ether_addr(ethhdr->h_dest)) { ··· 310 305 */ 311 306 orig_node = batadv_transtable_search(bat_priv, ethhdr->h_source, 312 307 ethhdr->h_dest); 308 + 313 309 find_router: 314 310 /* find_router(): 315 311 * - if orig_node is NULL it returns NULL 316 312 * - increases neigh_nodes refcount if found. 317 313 */ 318 314 neigh_node = batadv_find_router(bat_priv, orig_node, NULL); 315 + 319 316 if (!neigh_node) 320 317 goto out; 321 318 322 319 if (batadv_skb_head_push(skb, sizeof(*unicast_packet)) < 0) 323 320 goto out; 324 321 325 - unicast_packet = (struct unicast_packet *)skb->data; 322 + unicast_packet = (struct batadv_unicast_packet *)skb->data; 326 323 327 324 unicast_packet->header.version = BATADV_COMPAT_VERSION; 328 325 /* batman packet type: unicast */ 329 - unicast_packet->header.packet_type = BAT_UNICAST; 326 + unicast_packet->header.packet_type = BATADV_UNICAST; 330 327 /* set unicast ttl */ 331 328 unicast_packet->header.ttl = BATADV_TTL; 332 329 /* copy the destination for faster routing */ ··· 345 338 if (batadv_tt_global_client_is_roaming(bat_priv, ethhdr->h_dest)) 346 339 unicast_packet->ttvn = unicast_packet->ttvn - 1; 347 340 341 + dev_mtu = neigh_node->if_incoming->net_dev->mtu; 348 342 if (atomic_read(&bat_priv->fragmentation) && 349 - data_len + sizeof(*unicast_packet) > 350 - neigh_node->if_incoming->net_dev->mtu) { 343 + data_len + sizeof(*unicast_packet) > dev_mtu) { 351 344 /* send frag skb decreases ttl */ 352 345 unicast_packet->header.ttl++; 353 346 ret = batadv_frag_send_skb(skb, bat_priv,
+10 -9
net/batman-adv/unicast.h
··· 25 25 #define BATADV_FRAG_TIMEOUT 10000 /* purge frag list entries after time in ms */ 26 26 #define BATADV_FRAG_BUFFER_SIZE 6 /* number of list elements in buffer */ 27 27 28 - int batadv_frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv, 28 + int batadv_frag_reassemble_skb(struct sk_buff *skb, 29 + struct batadv_priv *bat_priv, 29 30 struct sk_buff **new_skb); 30 31 void batadv_frag_list_free(struct list_head *head); 31 - int batadv_unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv); 32 - int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv, 33 - struct hard_iface *hard_iface, 32 + int batadv_unicast_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv); 33 + int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv, 34 + struct batadv_hard_iface *hard_iface, 34 35 const uint8_t dstaddr[]); 35 36 36 37 static inline int batadv_frag_can_reassemble(const struct sk_buff *skb, int mtu) 37 38 { 38 - const struct unicast_frag_packet *unicast_packet; 39 + const struct batadv_unicast_frag_packet *unicast_packet; 39 40 int uneven_correction = 0; 40 41 unsigned int merged_size; 41 42 42 - unicast_packet = (struct unicast_frag_packet *)skb->data; 43 + unicast_packet = (struct batadv_unicast_frag_packet *)skb->data; 43 44 44 - if (unicast_packet->flags & UNI_FRAG_LARGETAIL) { 45 - if (unicast_packet->flags & UNI_FRAG_HEAD) 45 + if (unicast_packet->flags & BATADV_UNI_FRAG_LARGETAIL) { 46 + if (unicast_packet->flags & BATADV_UNI_FRAG_HEAD) 46 47 uneven_correction = 1; 47 48 else 48 49 uneven_correction = -1; 49 50 } 50 51 51 52 merged_size = (skb->len - sizeof(*unicast_packet)) * 2; 52 - merged_size += sizeof(struct unicast_packet) + uneven_correction; 53 + merged_size += sizeof(struct batadv_unicast_packet) + uneven_correction; 53 54 54 55 return merged_size <= mtu; 55 56 }
+149 -135
net/batman-adv/vis.c
··· 28 28 29 29 #define BATADV_MAX_VIS_PACKET_SIZE 1000 30 30 31 - static void batadv_start_vis_timer(struct bat_priv *bat_priv); 31 + static void batadv_start_vis_timer(struct batadv_priv *bat_priv); 32 32 33 33 /* free the info */ 34 34 static void batadv_free_info(struct kref *ref) 35 35 { 36 - struct vis_info *info = container_of(ref, struct vis_info, refcount); 37 - struct bat_priv *bat_priv = info->bat_priv; 38 - struct recvlist_node *entry, *tmp; 36 + struct batadv_vis_info *info; 37 + struct batadv_priv *bat_priv; 38 + struct batadv_recvlist_node *entry, *tmp; 39 + 40 + info = container_of(ref, struct batadv_vis_info, refcount); 41 + bat_priv = info->bat_priv; 39 42 40 43 list_del_init(&info->send_list); 41 44 spin_lock_bh(&bat_priv->vis_list_lock); ··· 55 52 /* Compare two vis packets, used by the hashing algorithm */ 56 53 static int batadv_vis_info_cmp(const struct hlist_node *node, const void *data2) 57 54 { 58 - const struct vis_info *d1, *d2; 59 - const struct vis_packet *p1, *p2; 55 + const struct batadv_vis_info *d1, *d2; 56 + const struct batadv_vis_packet *p1, *p2; 60 57 61 - d1 = container_of(node, struct vis_info, hash_entry); 58 + d1 = container_of(node, struct batadv_vis_info, hash_entry); 62 59 d2 = data2; 63 - p1 = (struct vis_packet *)d1->skb_packet->data; 64 - p2 = (struct vis_packet *)d2->skb_packet->data; 60 + p1 = (struct batadv_vis_packet *)d1->skb_packet->data; 61 + p2 = (struct batadv_vis_packet *)d2->skb_packet->data; 65 62 return batadv_compare_eth(p1->vis_orig, p2->vis_orig); 66 63 } 67 64 ··· 70 67 */ 71 68 static uint32_t batadv_vis_info_choose(const void *data, uint32_t size) 72 69 { 73 - const struct vis_info *vis_info = data; 74 - const struct vis_packet *packet; 70 + const struct batadv_vis_info *vis_info = data; 71 + const struct batadv_vis_packet *packet; 75 72 const unsigned char *key; 76 73 uint32_t hash = 0; 77 74 size_t i; 78 75 79 - packet = (struct vis_packet *)vis_info->skb_packet->data; 76 + packet = (struct batadv_vis_packet *)vis_info->skb_packet->data; 80 77 key = packet->vis_orig; 81 78 for (i = 0; i < ETH_ALEN; i++) { 82 79 hash += key[i]; ··· 91 88 return hash % size; 92 89 } 93 90 94 - static struct vis_info *batadv_vis_hash_find(struct bat_priv *bat_priv, 95 - const void *data) 91 + static struct batadv_vis_info * 92 + batadv_vis_hash_find(struct batadv_priv *bat_priv, const void *data) 96 93 { 97 - struct hashtable_t *hash = bat_priv->vis_hash; 94 + struct batadv_hashtable *hash = bat_priv->vis_hash; 98 95 struct hlist_head *head; 99 96 struct hlist_node *node; 100 - struct vis_info *vis_info, *vis_info_tmp = NULL; 97 + struct batadv_vis_info *vis_info, *vis_info_tmp = NULL; 101 98 uint32_t index; 102 99 103 100 if (!hash) ··· 126 123 struct hlist_head *if_list, 127 124 bool primary) 128 125 { 129 - struct if_list_entry *entry; 126 + struct batadv_if_list_entry *entry; 130 127 struct hlist_node *pos; 131 128 132 129 hlist_for_each_entry(entry, pos, if_list, list) { ··· 146 143 static void batadv_vis_data_read_prim_sec(struct seq_file *seq, 147 144 const struct hlist_head *if_list) 148 145 { 149 - struct if_list_entry *entry; 146 + struct batadv_if_list_entry *entry; 150 147 struct hlist_node *pos; 151 148 152 149 hlist_for_each_entry(entry, pos, if_list, list) { ··· 158 155 } 159 156 160 157 /* read an entry */ 161 - static ssize_t batadv_vis_data_read_entry(struct seq_file *seq, 162 - const struct vis_info_entry *entry, 163 - const uint8_t *src, bool primary) 158 + static ssize_t 159 + batadv_vis_data_read_entry(struct seq_file *seq, 160 + const struct batadv_vis_info_entry *entry, 161 + const uint8_t *src, bool primary) 164 162 { 165 163 if (primary && entry->quality == 0) 166 164 return seq_printf(seq, "TT %pM, ", entry->dest); ··· 172 168 return 0; 173 169 } 174 170 175 - static void batadv_vis_data_insert_interfaces(struct hlist_head *list, 176 - struct vis_packet *packet, 177 - struct vis_info_entry *entries) 171 + static void 172 + batadv_vis_data_insert_interfaces(struct hlist_head *list, 173 + struct batadv_vis_packet *packet, 174 + struct batadv_vis_info_entry *entries) 178 175 { 179 176 int i; 180 177 ··· 192 187 193 188 static void batadv_vis_data_read_entries(struct seq_file *seq, 194 189 struct hlist_head *list, 195 - struct vis_packet *packet, 196 - struct vis_info_entry *entries) 190 + struct batadv_vis_packet *packet, 191 + struct batadv_vis_info_entry *entries) 197 192 { 198 193 int i; 199 - struct if_list_entry *entry; 194 + struct batadv_if_list_entry *entry; 200 195 struct hlist_node *pos; 201 196 202 197 hlist_for_each_entry(entry, pos, list, list) { ··· 218 213 const struct hlist_head *head) 219 214 { 220 215 struct hlist_node *node; 221 - struct vis_info *info; 222 - struct vis_packet *packet; 216 + struct batadv_vis_info *info; 217 + struct batadv_vis_packet *packet; 223 218 uint8_t *entries_pos; 224 - struct vis_info_entry *entries; 225 - struct if_list_entry *entry; 219 + struct batadv_vis_info_entry *entries; 220 + struct batadv_if_list_entry *entry; 226 221 struct hlist_node *pos, *n; 227 222 228 223 HLIST_HEAD(vis_if_list); 229 224 230 225 hlist_for_each_entry_rcu(info, node, head, hash_entry) { 231 - packet = (struct vis_packet *)info->skb_packet->data; 226 + packet = (struct batadv_vis_packet *)info->skb_packet->data; 232 227 entries_pos = (uint8_t *)packet + sizeof(*packet); 233 - entries = (struct vis_info_entry *)entries_pos; 228 + entries = (struct batadv_vis_info_entry *)entries_pos; 234 229 235 230 batadv_vis_data_insert_interface(packet->vis_orig, &vis_if_list, 236 231 true); ··· 248 243 249 244 int batadv_vis_seq_print_text(struct seq_file *seq, void *offset) 250 245 { 251 - struct hard_iface *primary_if; 246 + struct batadv_hard_iface *primary_if; 252 247 struct hlist_head *head; 253 248 struct net_device *net_dev = (struct net_device *)seq->private; 254 - struct bat_priv *bat_priv = netdev_priv(net_dev); 255 - struct hashtable_t *hash = bat_priv->vis_hash; 249 + struct batadv_priv *bat_priv = netdev_priv(net_dev); 250 + struct batadv_hashtable *hash = bat_priv->vis_hash; 256 251 uint32_t i; 257 252 int ret = 0; 258 253 int vis_server = atomic_read(&bat_priv->vis_mode); ··· 261 256 if (!primary_if) 262 257 goto out; 263 258 264 - if (vis_server == VIS_TYPE_CLIENT_UPDATE) 259 + if (vis_server == BATADV_VIS_TYPE_CLIENT_UPDATE) 265 260 goto out; 266 261 267 262 spin_lock_bh(&bat_priv->vis_hash_lock); ··· 280 275 /* add the info packet to the send list, if it was not 281 276 * already linked in. 282 277 */ 283 - static void batadv_send_list_add(struct bat_priv *bat_priv, 284 - struct vis_info *info) 278 + static void batadv_send_list_add(struct batadv_priv *bat_priv, 279 + struct batadv_vis_info *info) 285 280 { 286 281 if (list_empty(&info->send_list)) { 287 282 kref_get(&info->refcount); ··· 292 287 /* delete the info packet from the send list, if it was 293 288 * linked in. 294 289 */ 295 - static void batadv_send_list_del(struct vis_info *info) 290 + static void batadv_send_list_del(struct batadv_vis_info *info) 296 291 { 297 292 if (!list_empty(&info->send_list)) { 298 293 list_del_init(&info->send_list); ··· 301 296 } 302 297 303 298 /* tries to add one entry to the receive list. */ 304 - static void batadv_recv_list_add(struct bat_priv *bat_priv, 299 + static void batadv_recv_list_add(struct batadv_priv *bat_priv, 305 300 struct list_head *recv_list, const char *mac) 306 301 { 307 - struct recvlist_node *entry; 302 + struct batadv_recvlist_node *entry; 308 303 309 304 entry = kmalloc(sizeof(*entry), GFP_ATOMIC); 310 305 if (!entry) ··· 317 312 } 318 313 319 314 /* returns 1 if this mac is in the recv_list */ 320 - static int batadv_recv_list_is_in(struct bat_priv *bat_priv, 315 + static int batadv_recv_list_is_in(struct batadv_priv *bat_priv, 321 316 const struct list_head *recv_list, 322 317 const char *mac) 323 318 { 324 - const struct recvlist_node *entry; 319 + const struct batadv_recvlist_node *entry; 325 320 326 321 spin_lock_bh(&bat_priv->vis_list_lock); 327 322 list_for_each_entry(entry, recv_list, list) { ··· 338 333 * broken.. ). vis hash must be locked outside. is_new is set when the packet 339 334 * is newer than old entries in the hash. 340 335 */ 341 - static struct vis_info *batadv_add_packet(struct bat_priv *bat_priv, 342 - struct vis_packet *vis_packet, 343 - int vis_info_len, int *is_new, 344 - int make_broadcast) 336 + static struct batadv_vis_info * 337 + batadv_add_packet(struct batadv_priv *bat_priv, 338 + struct batadv_vis_packet *vis_packet, int vis_info_len, 339 + int *is_new, int make_broadcast) 345 340 { 346 - struct vis_info *info, *old_info; 347 - struct vis_packet *search_packet, *old_packet; 348 - struct vis_info search_elem; 349 - struct vis_packet *packet; 341 + struct batadv_vis_info *info, *old_info; 342 + struct batadv_vis_packet *search_packet, *old_packet; 343 + struct batadv_vis_info search_elem; 344 + struct batadv_vis_packet *packet; 345 + struct sk_buff *tmp_skb; 350 346 int hash_added; 347 + size_t len; 348 + size_t max_entries; 351 349 352 350 *is_new = 0; 353 351 /* sanity check */ ··· 361 353 search_elem.skb_packet = dev_alloc_skb(sizeof(*search_packet)); 362 354 if (!search_elem.skb_packet) 363 355 return NULL; 364 - search_packet = (struct vis_packet *)skb_put(search_elem.skb_packet, 365 - sizeof(*search_packet)); 356 + len = sizeof(*search_packet); 357 + tmp_skb = search_elem.skb_packet; 358 + search_packet = (struct batadv_vis_packet *)skb_put(tmp_skb, len); 366 359 367 360 memcpy(search_packet->vis_orig, vis_packet->vis_orig, ETH_ALEN); 368 361 old_info = batadv_vis_hash_find(bat_priv, &search_elem); 369 362 kfree_skb(search_elem.skb_packet); 370 363 371 364 if (old_info) { 372 - old_packet = (struct vis_packet *)old_info->skb_packet->data; 365 + tmp_skb = old_info->skb_packet; 366 + old_packet = (struct batadv_vis_packet *)tmp_skb->data; 373 367 if (!batadv_seq_after(ntohl(vis_packet->seqno), 374 368 ntohl(old_packet->seqno))) { 375 369 if (old_packet->seqno == vis_packet->seqno) { ··· 395 385 if (!info) 396 386 return NULL; 397 387 398 - info->skb_packet = dev_alloc_skb(sizeof(*packet) + vis_info_len + 399 - ETH_HLEN); 388 + len = sizeof(*packet) + vis_info_len; 389 + info->skb_packet = dev_alloc_skb(len + ETH_HLEN); 400 390 if (!info->skb_packet) { 401 391 kfree(info); 402 392 return NULL; 403 393 } 404 394 skb_reserve(info->skb_packet, ETH_HLEN); 405 - packet = (struct vis_packet *)skb_put(info->skb_packet, sizeof(*packet) 406 - + vis_info_len); 395 + packet = (struct batadv_vis_packet *)skb_put(info->skb_packet, len); 407 396 408 397 kref_init(&info->refcount); 409 398 INIT_LIST_HEAD(&info->send_list); 410 399 INIT_LIST_HEAD(&info->recv_list); 411 400 info->first_seen = jiffies; 412 401 info->bat_priv = bat_priv; 413 - memcpy(packet, vis_packet, sizeof(*packet) + vis_info_len); 402 + memcpy(packet, vis_packet, len); 414 403 415 404 /* initialize and add new packet. */ 416 405 *is_new = 1; ··· 419 410 memcpy(packet->target_orig, batadv_broadcast_addr, ETH_ALEN); 420 411 421 412 /* repair if entries is longer than packet. */ 422 - if (packet->entries * sizeof(struct vis_info_entry) > vis_info_len) 423 - packet->entries = vis_info_len / sizeof(struct vis_info_entry); 413 + max_entries = vis_info_len / sizeof(struct batadv_vis_info_entry); 414 + if (packet->entries > max_entries) 415 + packet->entries = max_entries; 424 416 425 417 batadv_recv_list_add(bat_priv, &info->recv_list, packet->sender_orig); 426 418 ··· 439 429 } 440 430 441 431 /* handle the server sync packet, forward if needed. */ 442 - void batadv_receive_server_sync_packet(struct bat_priv *bat_priv, 443 - struct vis_packet *vis_packet, 432 + void batadv_receive_server_sync_packet(struct batadv_priv *bat_priv, 433 + struct batadv_vis_packet *vis_packet, 444 434 int vis_info_len) 445 435 { 446 - struct vis_info *info; 436 + struct batadv_vis_info *info; 447 437 int is_new, make_broadcast; 448 438 int vis_server = atomic_read(&bat_priv->vis_mode); 449 439 450 - make_broadcast = (vis_server == VIS_TYPE_SERVER_SYNC); 440 + make_broadcast = (vis_server == BATADV_VIS_TYPE_SERVER_SYNC); 451 441 452 442 spin_lock_bh(&bat_priv->vis_hash_lock); 453 443 info = batadv_add_packet(bat_priv, vis_packet, vis_info_len, ··· 458 448 /* only if we are server ourselves and packet is newer than the one in 459 449 * hash. 460 450 */ 461 - if (vis_server == VIS_TYPE_SERVER_SYNC && is_new) 451 + if (vis_server == BATADV_VIS_TYPE_SERVER_SYNC && is_new) 462 452 batadv_send_list_add(bat_priv, info); 463 453 end: 464 454 spin_unlock_bh(&bat_priv->vis_hash_lock); 465 455 } 466 456 467 457 /* handle an incoming client update packet and schedule forward if needed. */ 468 - void batadv_receive_client_update_packet(struct bat_priv *bat_priv, 469 - struct vis_packet *vis_packet, 458 + void batadv_receive_client_update_packet(struct batadv_priv *bat_priv, 459 + struct batadv_vis_packet *vis_packet, 470 460 int vis_info_len) 471 461 { 472 - struct vis_info *info; 473 - struct vis_packet *packet; 462 + struct batadv_vis_info *info; 463 + struct batadv_vis_packet *packet; 474 464 int is_new; 475 465 int vis_server = atomic_read(&bat_priv->vis_mode); 476 466 int are_target = 0; ··· 480 470 return; 481 471 482 472 /* Are we the target for this VIS packet? */ 483 - if (vis_server == VIS_TYPE_SERVER_SYNC && 473 + if (vis_server == BATADV_VIS_TYPE_SERVER_SYNC && 484 474 batadv_is_my_mac(vis_packet->target_orig)) 485 475 are_target = 1; 486 476 ··· 492 482 goto end; 493 483 /* note that outdated packets will be dropped at this point. */ 494 484 495 - packet = (struct vis_packet *)info->skb_packet->data; 485 + packet = (struct batadv_vis_packet *)info->skb_packet->data; 496 486 497 487 /* send only if we're the target server or ... */ 498 488 if (are_target && is_new) { 499 - packet->vis_type = VIS_TYPE_SERVER_SYNC; /* upgrade! */ 489 + packet->vis_type = BATADV_VIS_TYPE_SERVER_SYNC; /* upgrade! */ 500 490 batadv_send_list_add(bat_priv, info); 501 491 502 492 /* ... we're not the recipient (and thus need to forward). */ ··· 513 503 * 514 504 * Must be called with the originator hash locked 515 505 */ 516 - static int batadv_find_best_vis_server(struct bat_priv *bat_priv, 517 - struct vis_info *info) 506 + static int batadv_find_best_vis_server(struct batadv_priv *bat_priv, 507 + struct batadv_vis_info *info) 518 508 { 519 - struct hashtable_t *hash = bat_priv->orig_hash; 520 - struct neigh_node *router; 509 + struct batadv_hashtable *hash = bat_priv->orig_hash; 510 + struct batadv_neigh_node *router; 521 511 struct hlist_node *node; 522 512 struct hlist_head *head; 523 - struct orig_node *orig_node; 524 - struct vis_packet *packet; 513 + struct batadv_orig_node *orig_node; 514 + struct batadv_vis_packet *packet; 525 515 int best_tq = -1; 526 516 uint32_t i; 527 517 528 - packet = (struct vis_packet *)info->skb_packet->data; 518 + packet = (struct batadv_vis_packet *)info->skb_packet->data; 529 519 530 520 for (i = 0; i < hash->size; i++) { 531 521 head = &hash->table[i]; ··· 536 526 if (!router) 537 527 continue; 538 528 539 - if ((orig_node->flags & VIS_SERVER) && 529 + if ((orig_node->flags & BATADV_VIS_SERVER) && 540 530 (router->tq_avg > best_tq)) { 541 531 best_tq = router->tq_avg; 542 532 memcpy(packet->target_orig, orig_node->orig, ··· 551 541 } 552 542 553 543 /* Return true if the vis packet is full. */ 554 - static bool batadv_vis_packet_full(const struct vis_info *info) 544 + static bool batadv_vis_packet_full(const struct batadv_vis_info *info) 555 545 { 556 - const struct vis_packet *packet; 557 - size_t num_items; 546 + const struct batadv_vis_packet *packet; 547 + size_t num; 558 548 559 - packet = (struct vis_packet *)info->skb_packet->data; 560 - num_items = BATADV_MAX_VIS_PACKET_SIZE / sizeof(struct vis_info_entry); 549 + packet = (struct batadv_vis_packet *)info->skb_packet->data; 550 + num = BATADV_MAX_VIS_PACKET_SIZE / sizeof(struct batadv_vis_info_entry); 561 551 562 - if (num_items < packet->entries + 1) 552 + if (num < packet->entries + 1) 563 553 return true; 564 554 return false; 565 555 } ··· 567 557 /* generates a packet of own vis data, 568 558 * returns 0 on success, -1 if no packet could be generated 569 559 */ 570 - static int batadv_generate_vis_packet(struct bat_priv *bat_priv) 560 + static int batadv_generate_vis_packet(struct batadv_priv *bat_priv) 571 561 { 572 - struct hashtable_t *hash = bat_priv->orig_hash; 562 + struct batadv_hashtable *hash = bat_priv->orig_hash; 573 563 struct hlist_node *node; 574 564 struct hlist_head *head; 575 - struct orig_node *orig_node; 576 - struct neigh_node *router; 577 - struct vis_info *info = bat_priv->my_vis_info; 578 - struct vis_packet *packet = (struct vis_packet *)info->skb_packet->data; 579 - struct vis_info_entry *entry; 580 - struct tt_common_entry *tt_common_entry; 565 + struct batadv_orig_node *orig_node; 566 + struct batadv_neigh_node *router; 567 + struct batadv_vis_info *info = bat_priv->my_vis_info; 568 + struct batadv_vis_packet *packet; 569 + struct batadv_vis_info_entry *entry; 570 + struct batadv_tt_common_entry *tt_common_entry; 581 571 int best_tq = -1; 582 572 uint32_t i; 583 573 584 574 info->first_seen = jiffies; 575 + packet = (struct batadv_vis_packet *)info->skb_packet->data; 585 576 packet->vis_type = atomic_read(&bat_priv->vis_mode); 586 577 587 578 memcpy(packet->target_orig, batadv_broadcast_addr, ETH_ALEN); 588 579 packet->header.ttl = BATADV_TTL; 589 580 packet->seqno = htonl(ntohl(packet->seqno) + 1); 590 581 packet->entries = 0; 582 + packet->reserved = 0; 591 583 skb_trim(info->skb_packet, sizeof(*packet)); 592 584 593 - if (packet->vis_type == VIS_TYPE_CLIENT_UPDATE) { 585 + if (packet->vis_type == BATADV_VIS_TYPE_CLIENT_UPDATE) { 594 586 best_tq = batadv_find_best_vis_server(bat_priv, info); 595 587 596 588 if (best_tq < 0) ··· 611 599 if (!batadv_compare_eth(router->addr, orig_node->orig)) 612 600 goto next; 613 601 614 - if (router->if_incoming->if_status != IF_ACTIVE) 602 + if (router->if_incoming->if_status != BATADV_IF_ACTIVE) 615 603 goto next; 616 604 617 605 if (router->tq_avg < 1) 618 606 goto next; 619 607 620 608 /* fill one entry into buffer. */ 621 - entry = (struct vis_info_entry *) 609 + entry = (struct batadv_vis_info_entry *) 622 610 skb_put(info->skb_packet, sizeof(*entry)); 623 611 memcpy(entry->src, 624 612 router->if_incoming->net_dev->dev_addr, ··· 644 632 rcu_read_lock(); 645 633 hlist_for_each_entry_rcu(tt_common_entry, node, head, 646 634 hash_entry) { 647 - entry = (struct vis_info_entry *) 635 + entry = (struct batadv_vis_info_entry *) 648 636 skb_put(info->skb_packet, 649 637 sizeof(*entry)); 650 638 memset(entry->src, 0, ETH_ALEN); ··· 668 656 /* free old vis packets. Must be called with this vis_hash_lock 669 657 * held 670 658 */ 671 - static void batadv_purge_vis_packets(struct bat_priv *bat_priv) 659 + static void batadv_purge_vis_packets(struct batadv_priv *bat_priv) 672 660 { 673 661 uint32_t i; 674 - struct hashtable_t *hash = bat_priv->vis_hash; 662 + struct batadv_hashtable *hash = bat_priv->vis_hash; 675 663 struct hlist_node *node, *node_tmp; 676 664 struct hlist_head *head; 677 - struct vis_info *info; 665 + struct batadv_vis_info *info; 678 666 679 667 for (i = 0; i < hash->size; i++) { 680 668 head = &hash->table[i]; ··· 695 683 } 696 684 } 697 685 698 - static void batadv_broadcast_vis_packet(struct bat_priv *bat_priv, 699 - struct vis_info *info) 686 + static void batadv_broadcast_vis_packet(struct batadv_priv *bat_priv, 687 + struct batadv_vis_info *info) 700 688 { 701 - struct neigh_node *router; 702 - struct hashtable_t *hash = bat_priv->orig_hash; 689 + struct batadv_neigh_node *router; 690 + struct batadv_hashtable *hash = bat_priv->orig_hash; 703 691 struct hlist_node *node; 704 692 struct hlist_head *head; 705 - struct orig_node *orig_node; 706 - struct vis_packet *packet; 693 + struct batadv_orig_node *orig_node; 694 + struct batadv_vis_packet *packet; 707 695 struct sk_buff *skb; 708 - struct hard_iface *hard_iface; 696 + struct batadv_hard_iface *hard_iface; 709 697 uint8_t dstaddr[ETH_ALEN]; 710 698 uint32_t i; 711 699 712 700 713 - packet = (struct vis_packet *)info->skb_packet->data; 701 + packet = (struct batadv_vis_packet *)info->skb_packet->data; 714 702 715 703 /* send to all routers in range. */ 716 704 for (i = 0; i < hash->size; i++) { ··· 719 707 rcu_read_lock(); 720 708 hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { 721 709 /* if it's a vis server and reachable, send it. */ 722 - if (!(orig_node->flags & VIS_SERVER)) 710 + if (!(orig_node->flags & BATADV_VIS_SERVER)) 723 711 continue; 724 712 725 713 router = batadv_orig_node_get_router(orig_node); ··· 751 739 } 752 740 } 753 741 754 - static void batadv_unicast_vis_packet(struct bat_priv *bat_priv, 755 - struct vis_info *info) 742 + static void batadv_unicast_vis_packet(struct batadv_priv *bat_priv, 743 + struct batadv_vis_info *info) 756 744 { 757 - struct orig_node *orig_node; 758 - struct neigh_node *router = NULL; 745 + struct batadv_orig_node *orig_node; 746 + struct batadv_neigh_node *router = NULL; 759 747 struct sk_buff *skb; 760 - struct vis_packet *packet; 748 + struct batadv_vis_packet *packet; 761 749 762 - packet = (struct vis_packet *)info->skb_packet->data; 750 + packet = (struct batadv_vis_packet *)info->skb_packet->data; 763 751 764 752 orig_node = batadv_orig_hash_find(bat_priv, packet->target_orig); 765 753 if (!orig_node) ··· 781 769 } 782 770 783 771 /* only send one vis packet. called from batadv_send_vis_packets() */ 784 - static void batadv_send_vis_packet(struct bat_priv *bat_priv, 785 - struct vis_info *info) 772 + static void batadv_send_vis_packet(struct batadv_priv *bat_priv, 773 + struct batadv_vis_info *info) 786 774 { 787 - struct hard_iface *primary_if; 788 - struct vis_packet *packet; 775 + struct batadv_hard_iface *primary_if; 776 + struct batadv_vis_packet *packet; 789 777 790 778 primary_if = batadv_primary_if_get_selected(bat_priv); 791 779 if (!primary_if) 792 780 goto out; 793 781 794 - packet = (struct vis_packet *)info->skb_packet->data; 782 + packet = (struct batadv_vis_packet *)info->skb_packet->data; 795 783 if (packet->header.ttl < 2) { 796 784 pr_debug("Error - can't send vis packet: ttl exceeded\n"); 797 785 goto out; ··· 816 804 { 817 805 struct delayed_work *delayed_work = 818 806 container_of(work, struct delayed_work, work); 819 - struct bat_priv *bat_priv = 820 - container_of(delayed_work, struct bat_priv, vis_work); 821 - struct vis_info *info; 807 + struct batadv_priv *bat_priv; 808 + struct batadv_vis_info *info; 822 809 810 + bat_priv = container_of(delayed_work, struct batadv_priv, vis_work); 823 811 spin_lock_bh(&bat_priv->vis_hash_lock); 824 812 batadv_purge_vis_packets(bat_priv); 825 813 ··· 848 836 /* init the vis server. this may only be called when if_list is already 849 837 * initialized (e.g. bat0 is initialized, interfaces have been added) 850 838 */ 851 - int batadv_vis_init(struct bat_priv *bat_priv) 839 + int batadv_vis_init(struct batadv_priv *bat_priv) 852 840 { 853 - struct vis_packet *packet; 841 + struct batadv_vis_packet *packet; 854 842 int hash_added; 855 843 unsigned int len; 856 844 unsigned long first_seen; 845 + struct sk_buff *tmp_skb; 857 846 858 847 if (bat_priv->vis_hash) 859 848 return 0; ··· 877 864 goto free_info; 878 865 879 866 skb_reserve(bat_priv->my_vis_info->skb_packet, ETH_HLEN); 880 - packet = (struct vis_packet *)skb_put(bat_priv->my_vis_info->skb_packet, 881 - sizeof(*packet)); 867 + tmp_skb = bat_priv->my_vis_info->skb_packet; 868 + packet = (struct batadv_vis_packet *)skb_put(tmp_skb, sizeof(*packet)); 882 869 883 870 /* prefill the vis info */ 884 871 first_seen = jiffies - msecs_to_jiffies(BATADV_VIS_INTERVAL); ··· 888 875 kref_init(&bat_priv->my_vis_info->refcount); 889 876 bat_priv->my_vis_info->bat_priv = bat_priv; 890 877 packet->header.version = BATADV_COMPAT_VERSION; 891 - packet->header.packet_type = BAT_VIS; 878 + packet->header.packet_type = BATADV_VIS; 892 879 packet->header.ttl = BATADV_TTL; 893 880 packet->seqno = 0; 881 + packet->reserved = 0; 894 882 packet->entries = 0; 895 883 896 884 INIT_LIST_HEAD(&bat_priv->vis_send_list); ··· 923 909 /* Decrease the reference count on a hash item info */ 924 910 static void batadv_free_info_ref(struct hlist_node *node, void *arg) 925 911 { 926 - struct vis_info *info; 912 + struct batadv_vis_info *info; 927 913 928 - info = container_of(node, struct vis_info, hash_entry); 914 + info = container_of(node, struct batadv_vis_info, hash_entry); 929 915 batadv_send_list_del(info); 930 916 kref_put(&info->refcount, batadv_free_info); 931 917 } 932 918 933 919 /* shutdown vis-server */ 934 - void batadv_vis_quit(struct bat_priv *bat_priv) 920 + void batadv_vis_quit(struct batadv_priv *bat_priv) 935 921 { 936 922 if (!bat_priv->vis_hash) 937 923 return; ··· 947 933 } 948 934 949 935 /* schedule packets for (re)transmission */ 950 - static void batadv_start_vis_timer(struct bat_priv *bat_priv) 936 + static void batadv_start_vis_timer(struct batadv_priv *bat_priv) 951 937 { 952 938 INIT_DELAYED_WORK(&bat_priv->vis_work, batadv_send_vis_packets); 953 939 queue_delayed_work(batadv_event_workqueue, &bat_priv->vis_work,
+6 -6
net/batman-adv/vis.h
··· 24 24 #define BATADV_VIS_TIMEOUT 200000 25 25 26 26 int batadv_vis_seq_print_text(struct seq_file *seq, void *offset); 27 - void batadv_receive_server_sync_packet(struct bat_priv *bat_priv, 28 - struct vis_packet *vis_packet, 27 + void batadv_receive_server_sync_packet(struct batadv_priv *bat_priv, 28 + struct batadv_vis_packet *vis_packet, 29 29 int vis_info_len); 30 - void batadv_receive_client_update_packet(struct bat_priv *bat_priv, 31 - struct vis_packet *vis_packet, 30 + void batadv_receive_client_update_packet(struct batadv_priv *bat_priv, 31 + struct batadv_vis_packet *vis_packet, 32 32 int vis_info_len); 33 - int batadv_vis_init(struct bat_priv *bat_priv); 34 - void batadv_vis_quit(struct bat_priv *bat_priv); 33 + int batadv_vis_init(struct batadv_priv *bat_priv); 34 + void batadv_vis_quit(struct batadv_priv *bat_priv); 35 35 36 36 #endif /* _NET_BATMAN_ADV_VIS_H_ */