1 /* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors:
3 * Marek Lindner, Simon Wunderlich
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU General Public
7 * License as published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 #include "translation-table.h"
22 #include "originator.h"
24 #include "gateway_common.h"
25 #include "gateway_client.h"
26 #include "hard-interface.h"
29 #include "network-coding.h"
33 * batadv_dup_status - duplicate status
34 * @BATADV_NO_DUP: the packet is a duplicate
35 * @BATADV_ORIG_DUP: OGM is a duplicate in the originator (but not for the
37 * @BATADV_NEIGH_DUP: OGM is a duplicate for the neighbor
38 * @BATADV_PROTECTED: originator is currently protected (after reboot)
40 enum batadv_dup_status {
48 * batadv_ring_buffer_set - update the ring buffer with the given value
49 * @lq_recv: pointer to the ring buffer
50 * @lq_index: index to store the value at
51 * @value: value to store in the ring buffer
53 static void batadv_ring_buffer_set(uint8_t lq_recv[], uint8_t *lq_index,
56 lq_recv[*lq_index] = value;
57 *lq_index = (*lq_index + 1) % BATADV_TQ_GLOBAL_WINDOW_SIZE;
61 * batadv_ring_buffer_set - compute the average of all non-zero values stored
62 * in the given ring buffer
63 * @lq_recv: pointer to the ring buffer
65 * Returns computed average value.
67 static uint8_t batadv_ring_buffer_avg(const uint8_t lq_recv[])
70 uint16_t count = 0, i = 0, sum = 0;
74 while (i < BATADV_TQ_GLOBAL_WINDOW_SIZE) {
87 return (uint8_t)(sum / count);
90 static struct batadv_neigh_node *
91 batadv_iv_ogm_neigh_new(struct batadv_hard_iface *hard_iface,
92 const uint8_t *neigh_addr,
93 struct batadv_orig_node *orig_node,
94 struct batadv_orig_node *orig_neigh)
96 struct batadv_neigh_node *neigh_node;
98 neigh_node = batadv_neigh_node_new(hard_iface, neigh_addr);
102 INIT_LIST_HEAD(&neigh_node->bonding_list);
104 neigh_node->orig_node = orig_neigh;
105 neigh_node->if_incoming = hard_iface;
107 spin_lock_bh(&orig_node->neigh_list_lock);
108 hlist_add_head_rcu(&neigh_node->list, &orig_node->neigh_list);
109 spin_unlock_bh(&orig_node->neigh_list_lock);
115 static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
117 struct batadv_ogm_packet *batadv_ogm_packet;
118 unsigned char *ogm_buff;
119 uint32_t random_seqno;
122 /* randomize initial seqno to avoid collision */
123 get_random_bytes(&random_seqno, sizeof(random_seqno));
124 atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
126 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
127 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
131 hard_iface->bat_iv.ogm_buff = ogm_buff;
133 batadv_ogm_packet = (struct batadv_ogm_packet *)ogm_buff;
134 batadv_ogm_packet->header.packet_type = BATADV_IV_OGM;
135 batadv_ogm_packet->header.version = BATADV_COMPAT_VERSION;
136 batadv_ogm_packet->header.ttl = 2;
137 batadv_ogm_packet->flags = BATADV_NO_FLAGS;
138 batadv_ogm_packet->reserved = 0;
139 batadv_ogm_packet->tq = BATADV_TQ_MAX_VALUE;
147 static void batadv_iv_ogm_iface_disable(struct batadv_hard_iface *hard_iface)
149 kfree(hard_iface->bat_iv.ogm_buff);
150 hard_iface->bat_iv.ogm_buff = NULL;
153 static void batadv_iv_ogm_iface_update_mac(struct batadv_hard_iface *hard_iface)
155 struct batadv_ogm_packet *batadv_ogm_packet;
156 unsigned char *ogm_buff = hard_iface->bat_iv.ogm_buff;
158 batadv_ogm_packet = (struct batadv_ogm_packet *)ogm_buff;
159 memcpy(batadv_ogm_packet->orig,
160 hard_iface->net_dev->dev_addr, ETH_ALEN);
161 memcpy(batadv_ogm_packet->prev_sender,
162 hard_iface->net_dev->dev_addr, ETH_ALEN);
166 batadv_iv_ogm_primary_iface_set(struct batadv_hard_iface *hard_iface)
168 struct batadv_ogm_packet *batadv_ogm_packet;
169 unsigned char *ogm_buff = hard_iface->bat_iv.ogm_buff;
171 batadv_ogm_packet = (struct batadv_ogm_packet *)ogm_buff;
172 batadv_ogm_packet->flags = BATADV_PRIMARIES_FIRST_HOP;
173 batadv_ogm_packet->header.ttl = BATADV_TTL;
176 /* when do we schedule our own ogm to be sent */
178 batadv_iv_ogm_emit_send_time(const struct batadv_priv *bat_priv)
182 msecs = atomic_read(&bat_priv->orig_interval) - BATADV_JITTER;
183 msecs += prandom_u32() % (2 * BATADV_JITTER);
185 return jiffies + msecs_to_jiffies(msecs);
188 /* when do we schedule a ogm packet to be sent */
189 static unsigned long batadv_iv_ogm_fwd_send_time(void)
191 return jiffies + msecs_to_jiffies(prandom_u32() % (BATADV_JITTER / 2));
194 /* apply hop penalty for a normal link */
195 static uint8_t batadv_hop_penalty(uint8_t tq,
196 const struct batadv_priv *bat_priv)
198 int hop_penalty = atomic_read(&bat_priv->hop_penalty);
201 new_tq = tq * (BATADV_TQ_MAX_VALUE - hop_penalty);
202 new_tq /= BATADV_TQ_MAX_VALUE;
207 /* is there another aggregated packet here? */
208 static int batadv_iv_ogm_aggr_packet(int buff_pos, int packet_len,
211 int next_buff_pos = 0;
213 next_buff_pos += buff_pos + BATADV_OGM_HLEN;
214 next_buff_pos += ntohs(tvlv_len);
216 return (next_buff_pos <= packet_len) &&
217 (next_buff_pos <= BATADV_MAX_AGGREGATION_BYTES);
220 /* send a batman ogm to a given interface */
221 static void batadv_iv_ogm_send_to_if(struct batadv_forw_packet *forw_packet,
222 struct batadv_hard_iface *hard_iface)
224 struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
228 struct batadv_ogm_packet *batadv_ogm_packet;
232 if (hard_iface->if_status != BATADV_IF_ACTIVE)
237 packet_pos = forw_packet->skb->data;
238 batadv_ogm_packet = (struct batadv_ogm_packet *)packet_pos;
240 /* adjust all flags and log packets */
241 while (batadv_iv_ogm_aggr_packet(buff_pos, forw_packet->packet_len,
242 batadv_ogm_packet->tvlv_len)) {
243 /* we might have aggregated direct link packets with an
244 * ordinary base packet
246 if (forw_packet->direct_link_flags & BIT(packet_num) &&
247 forw_packet->if_incoming == hard_iface)
248 batadv_ogm_packet->flags |= BATADV_DIRECTLINK;
250 batadv_ogm_packet->flags &= ~BATADV_DIRECTLINK;
252 if (packet_num > 0 || !forw_packet->own)
253 fwd_str = "Forwarding";
255 fwd_str = "Sending own";
257 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
258 "%s %spacket (originator %pM, seqno %u, TQ %d, TTL %d, IDF %s) on interface %s [%pM]\n",
259 fwd_str, (packet_num > 0 ? "aggregated " : ""),
260 batadv_ogm_packet->orig,
261 ntohl(batadv_ogm_packet->seqno),
262 batadv_ogm_packet->tq, batadv_ogm_packet->header.ttl,
263 (batadv_ogm_packet->flags & BATADV_DIRECTLINK ?
265 hard_iface->net_dev->name,
266 hard_iface->net_dev->dev_addr);
268 buff_pos += BATADV_OGM_HLEN;
269 buff_pos += ntohs(batadv_ogm_packet->tvlv_len);
271 packet_pos = forw_packet->skb->data + buff_pos;
272 batadv_ogm_packet = (struct batadv_ogm_packet *)packet_pos;
275 /* create clone because function is called more than once */
276 skb = skb_clone(forw_packet->skb, GFP_ATOMIC);
278 batadv_inc_counter(bat_priv, BATADV_CNT_MGMT_TX);
279 batadv_add_counter(bat_priv, BATADV_CNT_MGMT_TX_BYTES,
280 skb->len + ETH_HLEN);
281 batadv_send_skb_packet(skb, hard_iface, batadv_broadcast_addr);
285 /* send a batman ogm packet */
286 static void batadv_iv_ogm_emit(struct batadv_forw_packet *forw_packet)
288 struct batadv_hard_iface *hard_iface;
289 struct net_device *soft_iface;
290 struct batadv_priv *bat_priv;
291 struct batadv_hard_iface *primary_if = NULL;
292 struct batadv_ogm_packet *batadv_ogm_packet;
293 unsigned char directlink;
296 packet_pos = forw_packet->skb->data;
297 batadv_ogm_packet = (struct batadv_ogm_packet *)packet_pos;
298 directlink = (batadv_ogm_packet->flags & BATADV_DIRECTLINK ? 1 : 0);
300 if (!forw_packet->if_incoming) {
301 pr_err("Error - can't forward packet: incoming iface not specified\n");
305 soft_iface = forw_packet->if_incoming->soft_iface;
306 bat_priv = netdev_priv(soft_iface);
308 if (forw_packet->if_incoming->if_status != BATADV_IF_ACTIVE)
311 primary_if = batadv_primary_if_get_selected(bat_priv);
315 /* multihomed peer assumed
316 * non-primary OGMs are only broadcasted on their interface
318 if ((directlink && (batadv_ogm_packet->header.ttl == 1)) ||
319 (forw_packet->own && (forw_packet->if_incoming != primary_if))) {
320 /* FIXME: what about aggregated packets ? */
321 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
322 "%s packet (originator %pM, seqno %u, TTL %d) on interface %s [%pM]\n",
323 (forw_packet->own ? "Sending own" : "Forwarding"),
324 batadv_ogm_packet->orig,
325 ntohl(batadv_ogm_packet->seqno),
326 batadv_ogm_packet->header.ttl,
327 forw_packet->if_incoming->net_dev->name,
328 forw_packet->if_incoming->net_dev->dev_addr);
330 /* skb is only used once and than forw_packet is free'd */
331 batadv_send_skb_packet(forw_packet->skb,
332 forw_packet->if_incoming,
333 batadv_broadcast_addr);
334 forw_packet->skb = NULL;
339 /* broadcast on every interface */
341 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
342 if (hard_iface->soft_iface != soft_iface)
345 batadv_iv_ogm_send_to_if(forw_packet, hard_iface);
351 batadv_hardif_free_ref(primary_if);
354 /* return true if new_packet can be aggregated with forw_packet */
356 batadv_iv_ogm_can_aggregate(const struct batadv_ogm_packet *new_bat_ogm_packet,
357 struct batadv_priv *bat_priv,
358 int packet_len, unsigned long send_time,
360 const struct batadv_hard_iface *if_incoming,
361 const struct batadv_forw_packet *forw_packet)
363 struct batadv_ogm_packet *batadv_ogm_packet;
364 int aggregated_bytes = forw_packet->packet_len + packet_len;
365 struct batadv_hard_iface *primary_if = NULL;
367 unsigned long aggregation_end_time;
369 batadv_ogm_packet = (struct batadv_ogm_packet *)forw_packet->skb->data;
370 aggregation_end_time = send_time;
371 aggregation_end_time += msecs_to_jiffies(BATADV_MAX_AGGREGATION_MS);
373 /* we can aggregate the current packet to this aggregated packet
376 * - the send time is within our MAX_AGGREGATION_MS time
377 * - the resulting packet wont be bigger than
378 * MAX_AGGREGATION_BYTES
380 if (time_before(send_time, forw_packet->send_time) &&
381 time_after_eq(aggregation_end_time, forw_packet->send_time) &&
382 (aggregated_bytes <= BATADV_MAX_AGGREGATION_BYTES)) {
383 /* check aggregation compatibility
384 * -> direct link packets are broadcasted on
385 * their interface only
386 * -> aggregate packet if the current packet is
387 * a "global" packet as well as the base
390 primary_if = batadv_primary_if_get_selected(bat_priv);
394 /* packets without direct link flag and high TTL
395 * are flooded through the net
398 (!(batadv_ogm_packet->flags & BATADV_DIRECTLINK)) &&
399 (batadv_ogm_packet->header.ttl != 1) &&
401 /* own packets originating non-primary
402 * interfaces leave only that interface
404 ((!forw_packet->own) ||
405 (forw_packet->if_incoming == primary_if))) {
410 /* if the incoming packet is sent via this one
411 * interface only - we still can aggregate
414 (new_bat_ogm_packet->header.ttl == 1) &&
415 (forw_packet->if_incoming == if_incoming) &&
417 /* packets from direct neighbors or
418 * own secondary interface packets
419 * (= secondary interface packets in general)
421 (batadv_ogm_packet->flags & BATADV_DIRECTLINK ||
423 forw_packet->if_incoming != primary_if))) {
431 batadv_hardif_free_ref(primary_if);
435 /* create a new aggregated packet and add this packet to it */
436 static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff,
437 int packet_len, unsigned long send_time,
439 struct batadv_hard_iface *if_incoming,
442 struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
443 struct batadv_forw_packet *forw_packet_aggr;
444 unsigned char *skb_buff;
445 unsigned int skb_size;
447 if (!atomic_inc_not_zero(&if_incoming->refcount))
450 /* own packet should always be scheduled */
452 if (!batadv_atomic_dec_not_zero(&bat_priv->batman_queue_left)) {
453 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
454 "batman packet queue full\n");
459 forw_packet_aggr = kmalloc(sizeof(*forw_packet_aggr), GFP_ATOMIC);
460 if (!forw_packet_aggr) {
462 atomic_inc(&bat_priv->batman_queue_left);
466 if ((atomic_read(&bat_priv->aggregated_ogms)) &&
467 (packet_len < BATADV_MAX_AGGREGATION_BYTES))
468 skb_size = BATADV_MAX_AGGREGATION_BYTES;
470 skb_size = packet_len;
472 skb_size += ETH_HLEN;
474 forw_packet_aggr->skb = netdev_alloc_skb_ip_align(NULL, skb_size);
475 if (!forw_packet_aggr->skb) {
477 atomic_inc(&bat_priv->batman_queue_left);
478 kfree(forw_packet_aggr);
481 forw_packet_aggr->skb->priority = TC_PRIO_CONTROL;
482 skb_reserve(forw_packet_aggr->skb, ETH_HLEN);
484 skb_buff = skb_put(forw_packet_aggr->skb, packet_len);
485 forw_packet_aggr->packet_len = packet_len;
486 memcpy(skb_buff, packet_buff, packet_len);
488 forw_packet_aggr->own = own_packet;
489 forw_packet_aggr->if_incoming = if_incoming;
490 forw_packet_aggr->num_packets = 0;
491 forw_packet_aggr->direct_link_flags = BATADV_NO_FLAGS;
492 forw_packet_aggr->send_time = send_time;
494 /* save packet direct link flag status */
496 forw_packet_aggr->direct_link_flags |= 1;
498 /* add new packet to packet list */
499 spin_lock_bh(&bat_priv->forw_bat_list_lock);
500 hlist_add_head(&forw_packet_aggr->list, &bat_priv->forw_bat_list);
501 spin_unlock_bh(&bat_priv->forw_bat_list_lock);
503 /* start timer for this packet */
504 INIT_DELAYED_WORK(&forw_packet_aggr->delayed_work,
505 batadv_send_outstanding_bat_ogm_packet);
506 queue_delayed_work(batadv_event_workqueue,
507 &forw_packet_aggr->delayed_work,
508 send_time - jiffies);
512 batadv_hardif_free_ref(if_incoming);
515 /* aggregate a new packet into the existing ogm packet */
516 static void batadv_iv_ogm_aggregate(struct batadv_forw_packet *forw_packet_aggr,
517 const unsigned char *packet_buff,
518 int packet_len, bool direct_link)
520 unsigned char *skb_buff;
521 unsigned long new_direct_link_flag;
523 skb_buff = skb_put(forw_packet_aggr->skb, packet_len);
524 memcpy(skb_buff, packet_buff, packet_len);
525 forw_packet_aggr->packet_len += packet_len;
526 forw_packet_aggr->num_packets++;
528 /* save packet direct link flag status */
530 new_direct_link_flag = BIT(forw_packet_aggr->num_packets);
531 forw_packet_aggr->direct_link_flags |= new_direct_link_flag;
535 static void batadv_iv_ogm_queue_add(struct batadv_priv *bat_priv,
536 unsigned char *packet_buff,
538 struct batadv_hard_iface *if_incoming,
539 int own_packet, unsigned long send_time)
541 /* _aggr -> pointer to the packet we want to aggregate with
542 * _pos -> pointer to the position in the queue
544 struct batadv_forw_packet *forw_packet_aggr = NULL;
545 struct batadv_forw_packet *forw_packet_pos = NULL;
546 struct batadv_ogm_packet *batadv_ogm_packet;
548 unsigned long max_aggregation_jiffies;
550 batadv_ogm_packet = (struct batadv_ogm_packet *)packet_buff;
551 direct_link = batadv_ogm_packet->flags & BATADV_DIRECTLINK ? 1 : 0;
552 max_aggregation_jiffies = msecs_to_jiffies(BATADV_MAX_AGGREGATION_MS);
554 /* find position for the packet in the forward queue */
555 spin_lock_bh(&bat_priv->forw_bat_list_lock);
556 /* own packets are not to be aggregated */
557 if ((atomic_read(&bat_priv->aggregated_ogms)) && (!own_packet)) {
558 hlist_for_each_entry(forw_packet_pos,
559 &bat_priv->forw_bat_list, list) {
560 if (batadv_iv_ogm_can_aggregate(batadv_ogm_packet,
561 bat_priv, packet_len,
562 send_time, direct_link,
565 forw_packet_aggr = forw_packet_pos;
571 /* nothing to aggregate with - either aggregation disabled or no
572 * suitable aggregation packet found
574 if (!forw_packet_aggr) {
575 /* the following section can run without the lock */
576 spin_unlock_bh(&bat_priv->forw_bat_list_lock);
578 /* if we could not aggregate this packet with one of the others
579 * we hold it back for a while, so that it might be aggregated
582 if (!own_packet && atomic_read(&bat_priv->aggregated_ogms))
583 send_time += max_aggregation_jiffies;
585 batadv_iv_ogm_aggregate_new(packet_buff, packet_len,
586 send_time, direct_link,
587 if_incoming, own_packet);
589 batadv_iv_ogm_aggregate(forw_packet_aggr, packet_buff,
590 packet_len, direct_link);
591 spin_unlock_bh(&bat_priv->forw_bat_list_lock);
595 static void batadv_iv_ogm_forward(struct batadv_orig_node *orig_node,
596 const struct ethhdr *ethhdr,
597 struct batadv_ogm_packet *batadv_ogm_packet,
598 bool is_single_hop_neigh,
599 bool is_from_best_next_hop,
600 struct batadv_hard_iface *if_incoming)
602 struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
605 if (batadv_ogm_packet->header.ttl <= 1) {
606 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "ttl exceeded\n");
610 if (!is_from_best_next_hop) {
611 /* Mark the forwarded packet when it is not coming from our
612 * best next hop. We still need to forward the packet for our
613 * neighbor link quality detection to work in case the packet
614 * originated from a single hop neighbor. Otherwise we can
615 * simply drop the ogm.
617 if (is_single_hop_neigh)
618 batadv_ogm_packet->flags |= BATADV_NOT_BEST_NEXT_HOP;
623 tvlv_len = ntohs(batadv_ogm_packet->tvlv_len);
625 batadv_ogm_packet->header.ttl--;
626 memcpy(batadv_ogm_packet->prev_sender, ethhdr->h_source, ETH_ALEN);
628 /* apply hop penalty */
629 batadv_ogm_packet->tq = batadv_hop_penalty(batadv_ogm_packet->tq,
632 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
633 "Forwarding packet: tq: %i, ttl: %i\n",
634 batadv_ogm_packet->tq, batadv_ogm_packet->header.ttl);
636 /* switch of primaries first hop flag when forwarding */
637 batadv_ogm_packet->flags &= ~BATADV_PRIMARIES_FIRST_HOP;
638 if (is_single_hop_neigh)
639 batadv_ogm_packet->flags |= BATADV_DIRECTLINK;
641 batadv_ogm_packet->flags &= ~BATADV_DIRECTLINK;
643 batadv_iv_ogm_queue_add(bat_priv, (unsigned char *)batadv_ogm_packet,
644 BATADV_OGM_HLEN + tvlv_len,
645 if_incoming, 0, batadv_iv_ogm_fwd_send_time());
649 * batadv_iv_ogm_slide_own_bcast_window - bitshift own OGM broadcast windows for
650 * the given interface
651 * @hard_iface: the interface for which the windows have to be shifted
654 batadv_iv_ogm_slide_own_bcast_window(struct batadv_hard_iface *hard_iface)
656 struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
657 struct batadv_hashtable *hash = bat_priv->orig_hash;
658 struct hlist_head *head;
659 struct batadv_orig_node *orig_node;
665 for (i = 0; i < hash->size; i++) {
666 head = &hash->table[i];
669 hlist_for_each_entry_rcu(orig_node, head, hash_entry) {
670 spin_lock_bh(&orig_node->ogm_cnt_lock);
671 word_index = hard_iface->if_num * BATADV_NUM_WORDS;
672 word = &(orig_node->bcast_own[word_index]);
674 batadv_bit_get_packet(bat_priv, word, 1, 0);
675 w = &orig_node->bcast_own_sum[hard_iface->if_num];
676 *w = bitmap_weight(word, BATADV_TQ_LOCAL_WINDOW_SIZE);
677 spin_unlock_bh(&orig_node->ogm_cnt_lock);
683 static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
685 struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
686 unsigned char **ogm_buff = &hard_iface->bat_iv.ogm_buff;
687 struct batadv_ogm_packet *batadv_ogm_packet;
688 struct batadv_hard_iface *primary_if;
689 int *ogm_buff_len = &hard_iface->bat_iv.ogm_buff_len;
691 uint16_t tvlv_len = 0;
693 primary_if = batadv_primary_if_get_selected(bat_priv);
695 if (hard_iface == primary_if) {
696 /* tt changes have to be committed before the tvlv data is
697 * appended as it may alter the tt tvlv container
699 batadv_tt_local_commit_changes(bat_priv);
700 tvlv_len = batadv_tvlv_container_ogm_append(bat_priv, ogm_buff,
705 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
706 batadv_ogm_packet->tvlv_len = htons(tvlv_len);
708 /* change sequence number to network order */
709 seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
710 batadv_ogm_packet->seqno = htonl(seqno);
711 atomic_inc(&hard_iface->bat_iv.ogm_seqno);
713 batadv_iv_ogm_slide_own_bcast_window(hard_iface);
714 batadv_iv_ogm_queue_add(bat_priv, hard_iface->bat_iv.ogm_buff,
715 hard_iface->bat_iv.ogm_buff_len, hard_iface, 1,
716 batadv_iv_ogm_emit_send_time(bat_priv));
719 batadv_hardif_free_ref(primary_if);
723 batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
724 struct batadv_orig_node *orig_node,
725 const struct ethhdr *ethhdr,
726 const struct batadv_ogm_packet *batadv_ogm_packet,
727 struct batadv_hard_iface *if_incoming,
728 const unsigned char *tt_buff,
729 enum batadv_dup_status dup_status)
731 struct batadv_neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL;
732 struct batadv_neigh_node *router = NULL;
733 struct batadv_orig_node *orig_node_tmp;
735 uint8_t sum_orig, sum_neigh;
739 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
740 "update_originator(): Searching and updating originator entry of received packet\n");
743 hlist_for_each_entry_rcu(tmp_neigh_node,
744 &orig_node->neigh_list, list) {
745 neigh_addr = tmp_neigh_node->addr;
746 if (batadv_compare_eth(neigh_addr, ethhdr->h_source) &&
747 tmp_neigh_node->if_incoming == if_incoming &&
748 atomic_inc_not_zero(&tmp_neigh_node->refcount)) {
749 if (WARN(neigh_node, "too many matching neigh_nodes"))
750 batadv_neigh_node_free_ref(neigh_node);
751 neigh_node = tmp_neigh_node;
755 if (dup_status != BATADV_NO_DUP)
758 spin_lock_bh(&tmp_neigh_node->lq_update_lock);
759 batadv_ring_buffer_set(tmp_neigh_node->tq_recv,
760 &tmp_neigh_node->tq_index, 0);
761 tq_avg = batadv_ring_buffer_avg(tmp_neigh_node->tq_recv);
762 tmp_neigh_node->tq_avg = tq_avg;
763 spin_unlock_bh(&tmp_neigh_node->lq_update_lock);
767 struct batadv_orig_node *orig_tmp;
769 orig_tmp = batadv_get_orig_node(bat_priv, ethhdr->h_source);
773 neigh_node = batadv_iv_ogm_neigh_new(if_incoming,
775 orig_node, orig_tmp);
777 batadv_orig_node_free_ref(orig_tmp);
781 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
782 "Updating existing last-hop neighbor of originator\n");
786 neigh_node->last_seen = jiffies;
788 spin_lock_bh(&neigh_node->lq_update_lock);
789 batadv_ring_buffer_set(neigh_node->tq_recv,
790 &neigh_node->tq_index,
791 batadv_ogm_packet->tq);
792 neigh_node->tq_avg = batadv_ring_buffer_avg(neigh_node->tq_recv);
793 spin_unlock_bh(&neigh_node->lq_update_lock);
795 if (dup_status == BATADV_NO_DUP) {
796 orig_node->last_ttl = batadv_ogm_packet->header.ttl;
797 neigh_node->last_ttl = batadv_ogm_packet->header.ttl;
800 batadv_bonding_candidate_add(orig_node, neigh_node);
802 /* if this neighbor already is our next hop there is nothing
805 router = batadv_orig_node_get_router(orig_node);
806 if (router == neigh_node)
809 /* if this neighbor does not offer a better TQ we won't consider it */
810 if (router && (router->tq_avg > neigh_node->tq_avg))
813 /* if the TQ is the same and the link not more symmetric we
814 * won't consider it either
816 if (router && (neigh_node->tq_avg == router->tq_avg)) {
817 orig_node_tmp = router->orig_node;
818 spin_lock_bh(&orig_node_tmp->ogm_cnt_lock);
819 if_num = router->if_incoming->if_num;
820 sum_orig = orig_node_tmp->bcast_own_sum[if_num];
821 spin_unlock_bh(&orig_node_tmp->ogm_cnt_lock);
823 orig_node_tmp = neigh_node->orig_node;
824 spin_lock_bh(&orig_node_tmp->ogm_cnt_lock);
825 if_num = neigh_node->if_incoming->if_num;
826 sum_neigh = orig_node_tmp->bcast_own_sum[if_num];
827 spin_unlock_bh(&orig_node_tmp->ogm_cnt_lock);
829 if (sum_orig >= sum_neigh)
833 batadv_update_route(bat_priv, orig_node, neigh_node);
840 batadv_neigh_node_free_ref(neigh_node);
842 batadv_neigh_node_free_ref(router);
845 static int batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node,
846 struct batadv_orig_node *orig_neigh_node,
847 struct batadv_ogm_packet *batadv_ogm_packet,
848 struct batadv_hard_iface *if_incoming)
850 struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
851 struct batadv_neigh_node *neigh_node = NULL, *tmp_neigh_node;
853 uint8_t orig_eq_count, neigh_rq_count, neigh_rq_inv, tq_own;
854 unsigned int neigh_rq_inv_cube, neigh_rq_max_cube;
855 int tq_asym_penalty, inv_asym_penalty, ret = 0;
856 unsigned int combined_tq;
858 /* find corresponding one hop neighbor */
860 hlist_for_each_entry_rcu(tmp_neigh_node,
861 &orig_neigh_node->neigh_list, list) {
862 if (!batadv_compare_eth(tmp_neigh_node->addr,
863 orig_neigh_node->orig))
866 if (tmp_neigh_node->if_incoming != if_incoming)
869 if (!atomic_inc_not_zero(&tmp_neigh_node->refcount))
872 neigh_node = tmp_neigh_node;
878 neigh_node = batadv_iv_ogm_neigh_new(if_incoming,
879 orig_neigh_node->orig,
886 /* if orig_node is direct neighbor update neigh_node last_seen */
887 if (orig_node == orig_neigh_node)
888 neigh_node->last_seen = jiffies;
890 orig_node->last_seen = jiffies;
892 /* find packet count of corresponding one hop neighbor */
893 spin_lock_bh(&orig_node->ogm_cnt_lock);
894 orig_eq_count = orig_neigh_node->bcast_own_sum[if_incoming->if_num];
895 neigh_rq_count = neigh_node->real_packet_count;
896 spin_unlock_bh(&orig_node->ogm_cnt_lock);
898 /* pay attention to not get a value bigger than 100 % */
899 if (orig_eq_count > neigh_rq_count)
900 total_count = neigh_rq_count;
902 total_count = orig_eq_count;
904 /* if we have too few packets (too less data) we set tq_own to zero
905 * if we receive too few packets it is not considered bidirectional
907 if (total_count < BATADV_TQ_LOCAL_BIDRECT_SEND_MINIMUM ||
908 neigh_rq_count < BATADV_TQ_LOCAL_BIDRECT_RECV_MINIMUM)
911 /* neigh_node->real_packet_count is never zero as we
912 * only purge old information when getting new
915 tq_own = (BATADV_TQ_MAX_VALUE * total_count) / neigh_rq_count;
917 /* 1 - ((1-x) ** 3), normalized to TQ_MAX_VALUE this does
918 * affect the nearly-symmetric links only a little, but
919 * punishes asymmetric links more. This will give a value
920 * between 0 and TQ_MAX_VALUE
922 neigh_rq_inv = BATADV_TQ_LOCAL_WINDOW_SIZE - neigh_rq_count;
923 neigh_rq_inv_cube = neigh_rq_inv * neigh_rq_inv * neigh_rq_inv;
924 neigh_rq_max_cube = BATADV_TQ_LOCAL_WINDOW_SIZE *
925 BATADV_TQ_LOCAL_WINDOW_SIZE *
926 BATADV_TQ_LOCAL_WINDOW_SIZE;
927 inv_asym_penalty = BATADV_TQ_MAX_VALUE * neigh_rq_inv_cube;
928 inv_asym_penalty /= neigh_rq_max_cube;
929 tq_asym_penalty = BATADV_TQ_MAX_VALUE - inv_asym_penalty;
931 combined_tq = batadv_ogm_packet->tq * tq_own * tq_asym_penalty;
932 combined_tq /= BATADV_TQ_MAX_VALUE * BATADV_TQ_MAX_VALUE;
933 batadv_ogm_packet->tq = combined_tq;
935 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
936 "bidirectional: orig = %-15pM neigh = %-15pM => own_bcast = %2i, real recv = %2i, local tq: %3i, asym_penalty: %3i, total tq: %3i\n",
937 orig_node->orig, orig_neigh_node->orig, total_count,
938 neigh_rq_count, tq_own,
939 tq_asym_penalty, batadv_ogm_packet->tq);
941 /* if link has the minimum required transmission quality
942 * consider it bidirectional
944 if (batadv_ogm_packet->tq >= BATADV_TQ_TOTAL_BIDRECT_LIMIT)
949 batadv_neigh_node_free_ref(neigh_node);
954 * batadv_iv_ogm_update_seqnos - process a batman packet for all interfaces,
955 * adjust the sequence number and find out whether it is a duplicate
956 * @ethhdr: ethernet header of the packet
957 * @batadv_ogm_packet: OGM packet to be considered
958 * @if_incoming: interface on which the OGM packet was received
960 * Returns duplicate status as enum batadv_dup_status
962 static enum batadv_dup_status
963 batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
964 const struct batadv_ogm_packet *batadv_ogm_packet,
965 const struct batadv_hard_iface *if_incoming)
967 struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
968 struct batadv_orig_node *orig_node;
969 struct batadv_neigh_node *tmp_neigh_node;
974 enum batadv_dup_status ret = BATADV_NO_DUP;
975 uint32_t seqno = ntohl(batadv_ogm_packet->seqno);
977 uint8_t packet_count;
979 orig_node = batadv_get_orig_node(bat_priv, batadv_ogm_packet->orig);
981 return BATADV_NO_DUP;
983 spin_lock_bh(&orig_node->ogm_cnt_lock);
984 seq_diff = seqno - orig_node->last_real_seqno;
986 /* signalize caller that the packet is to be dropped. */
987 if (!hlist_empty(&orig_node->neigh_list) &&
988 batadv_window_protected(bat_priv, seq_diff,
989 &orig_node->batman_seqno_reset)) {
990 ret = BATADV_PROTECTED;
995 hlist_for_each_entry_rcu(tmp_neigh_node,
996 &orig_node->neigh_list, list) {
997 neigh_addr = tmp_neigh_node->addr;
998 is_dup = batadv_test_bit(tmp_neigh_node->real_bits,
999 orig_node->last_real_seqno,
1002 if (batadv_compare_eth(neigh_addr, ethhdr->h_source) &&
1003 tmp_neigh_node->if_incoming == if_incoming) {
1006 ret = BATADV_NEIGH_DUP;
1009 if (is_dup && (ret != BATADV_NEIGH_DUP))
1010 ret = BATADV_ORIG_DUP;
1013 /* if the window moved, set the update flag. */
1014 need_update |= batadv_bit_get_packet(bat_priv,
1015 tmp_neigh_node->real_bits,
1016 seq_diff, set_mark);
1018 packet_count = bitmap_weight(tmp_neigh_node->real_bits,
1019 BATADV_TQ_LOCAL_WINDOW_SIZE);
1020 tmp_neigh_node->real_packet_count = packet_count;
1025 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
1026 "updating last_seqno: old %u, new %u\n",
1027 orig_node->last_real_seqno, seqno);
1028 orig_node->last_real_seqno = seqno;
1032 spin_unlock_bh(&orig_node->ogm_cnt_lock);
1033 batadv_orig_node_free_ref(orig_node);
1037 static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
1038 struct batadv_ogm_packet *batadv_ogm_packet,
1039 const unsigned char *tt_buff,
1040 struct batadv_hard_iface *if_incoming)
1042 struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
1043 struct batadv_hard_iface *hard_iface;
1044 struct batadv_orig_node *orig_neigh_node, *orig_node;
1045 struct batadv_neigh_node *router = NULL, *router_router = NULL;
1046 struct batadv_neigh_node *orig_neigh_router = NULL;
1047 int has_directlink_flag;
1048 int is_my_addr = 0, is_my_orig = 0, is_my_oldorig = 0;
1050 bool is_single_hop_neigh = false;
1051 bool is_from_best_next_hop = false;
1052 int sameseq, similar_ttl;
1053 enum batadv_dup_status dup_status;
1054 uint32_t if_incoming_seqno;
1055 uint8_t *prev_sender;
1057 /* Silently drop when the batman packet is actually not a
1060 * This might happen if a packet is padded (e.g. Ethernet has a
1061 * minimum frame length of 64 byte) and the aggregation interprets
1062 * it as an additional length.
1064 * TODO: A more sane solution would be to have a bit in the
1065 * batadv_ogm_packet to detect whether the packet is the last
1066 * packet in an aggregation. Here we expect that the padding
1067 * is always zero (or not 0x01)
1069 if (batadv_ogm_packet->header.packet_type != BATADV_IV_OGM)
1072 /* could be changed by schedule_own_packet() */
1073 if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
1075 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
1076 has_directlink_flag = 1;
1078 has_directlink_flag = 0;
1080 if (batadv_compare_eth(ethhdr->h_source, batadv_ogm_packet->orig))
1081 is_single_hop_neigh = true;
1083 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
1084 "Received BATMAN packet via NB: %pM, IF: %s [%pM] (from OG: %pM, via prev OG: %pM, seqno %u, tq %d, TTL %d, V %d, IDF %d)\n",
1085 ethhdr->h_source, if_incoming->net_dev->name,
1086 if_incoming->net_dev->dev_addr, batadv_ogm_packet->orig,
1087 batadv_ogm_packet->prev_sender,
1088 ntohl(batadv_ogm_packet->seqno), batadv_ogm_packet->tq,
1089 batadv_ogm_packet->header.ttl,
1090 batadv_ogm_packet->header.version, has_directlink_flag);
1093 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
1094 if (hard_iface->if_status != BATADV_IF_ACTIVE)
1097 if (hard_iface->soft_iface != if_incoming->soft_iface)
1100 if (batadv_compare_eth(ethhdr->h_source,
1101 hard_iface->net_dev->dev_addr))
1104 if (batadv_compare_eth(batadv_ogm_packet->orig,
1105 hard_iface->net_dev->dev_addr))
1108 if (batadv_compare_eth(batadv_ogm_packet->prev_sender,
1109 hard_iface->net_dev->dev_addr))
1115 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
1116 "Drop packet: received my own broadcast (sender: %pM)\n",
1122 unsigned long *word;
1128 orig_neigh_node = batadv_get_orig_node(bat_priv,
1130 if (!orig_neigh_node)
1133 /* neighbor has to indicate direct link and it has to
1134 * come via the corresponding interface
1135 * save packet seqno for bidirectional check
1137 if (has_directlink_flag &&
1138 batadv_compare_eth(if_incoming->net_dev->dev_addr,
1139 batadv_ogm_packet->orig)) {
1140 if_num = if_incoming->if_num;
1141 offset = if_num * BATADV_NUM_WORDS;
1143 spin_lock_bh(&orig_neigh_node->ogm_cnt_lock);
1144 word = &(orig_neigh_node->bcast_own[offset]);
1145 bit_pos = if_incoming_seqno - 2;
1146 bit_pos -= ntohl(batadv_ogm_packet->seqno);
1147 batadv_set_bit(word, bit_pos);
1148 weight = &orig_neigh_node->bcast_own_sum[if_num];
1149 *weight = bitmap_weight(word,
1150 BATADV_TQ_LOCAL_WINDOW_SIZE);
1151 spin_unlock_bh(&orig_neigh_node->ogm_cnt_lock);
1154 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
1155 "Drop packet: originator packet from myself (via neighbor)\n");
1156 batadv_orig_node_free_ref(orig_neigh_node);
1160 if (is_my_oldorig) {
1161 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
1162 "Drop packet: ignoring all rebroadcast echos (sender: %pM)\n",
1167 if (batadv_ogm_packet->flags & BATADV_NOT_BEST_NEXT_HOP) {
1168 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
1169 "Drop packet: ignoring all packets not forwarded from the best next hop (sender: %pM)\n",
1174 orig_node = batadv_get_orig_node(bat_priv, batadv_ogm_packet->orig);
1178 dup_status = batadv_iv_ogm_update_seqnos(ethhdr, batadv_ogm_packet,
1181 if (dup_status == BATADV_PROTECTED) {
1182 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
1183 "Drop packet: packet within seqno protection time (sender: %pM)\n",
1188 if (batadv_ogm_packet->tq == 0) {
1189 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
1190 "Drop packet: originator packet with tq equal 0\n");
1194 router = batadv_orig_node_get_router(orig_node);
1196 router_router = batadv_orig_node_get_router(router->orig_node);
1198 if ((router && router->tq_avg != 0) &&
1199 (batadv_compare_eth(router->addr, ethhdr->h_source)))
1200 is_from_best_next_hop = true;
1202 prev_sender = batadv_ogm_packet->prev_sender;
1203 /* avoid temporary routing loops */
1204 if (router && router_router &&
1205 (batadv_compare_eth(router->addr, prev_sender)) &&
1206 !(batadv_compare_eth(batadv_ogm_packet->orig, prev_sender)) &&
1207 (batadv_compare_eth(router->addr, router_router->addr))) {
1208 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
1209 "Drop packet: ignoring all rebroadcast packets that may make me loop (sender: %pM)\n",
1214 batadv_tvlv_ogm_receive(bat_priv, batadv_ogm_packet, orig_node);
1216 /* if sender is a direct neighbor the sender mac equals
1219 if (is_single_hop_neigh)
1220 orig_neigh_node = orig_node;
1222 orig_neigh_node = batadv_get_orig_node(bat_priv,
1225 if (!orig_neigh_node)
1228 /* Update nc_nodes of the originator */
1229 batadv_nc_update_nc_node(bat_priv, orig_node, orig_neigh_node,
1230 batadv_ogm_packet, is_single_hop_neigh);
1232 orig_neigh_router = batadv_orig_node_get_router(orig_neigh_node);
1234 /* drop packet if sender is not a direct neighbor and if we
1235 * don't route towards it
1237 if (!is_single_hop_neigh && (!orig_neigh_router)) {
1238 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
1239 "Drop packet: OGM via unknown neighbor!\n");
1243 is_bidirect = batadv_iv_ogm_calc_tq(orig_node, orig_neigh_node,
1244 batadv_ogm_packet, if_incoming);
1246 batadv_bonding_save_primary(orig_node, orig_neigh_node,
1249 /* update ranking if it is not a duplicate or has the same
1250 * seqno and similar ttl as the non-duplicate
1252 sameseq = orig_node->last_real_seqno == ntohl(batadv_ogm_packet->seqno);
1253 similar_ttl = orig_node->last_ttl - 3 <= batadv_ogm_packet->header.ttl;
1254 if (is_bidirect && ((dup_status == BATADV_NO_DUP) ||
1255 (sameseq && similar_ttl)))
1256 batadv_iv_ogm_orig_update(bat_priv, orig_node, ethhdr,
1257 batadv_ogm_packet, if_incoming,
1258 tt_buff, dup_status);
1260 /* is single hop (direct) neighbor */
1261 if (is_single_hop_neigh) {
1262 /* mark direct link on incoming interface */
1263 batadv_iv_ogm_forward(orig_node, ethhdr, batadv_ogm_packet,
1264 is_single_hop_neigh,
1265 is_from_best_next_hop, if_incoming);
1267 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
1268 "Forwarding packet: rebroadcast neighbor packet with direct link flag\n");
1272 /* multihop originator */
1274 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
1275 "Drop packet: not received via bidirectional link\n");
1279 if (dup_status == BATADV_NEIGH_DUP) {
1280 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
1281 "Drop packet: duplicate packet received\n");
1285 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
1286 "Forwarding packet: rebroadcast originator packet\n");
1287 batadv_iv_ogm_forward(orig_node, ethhdr, batadv_ogm_packet,
1288 is_single_hop_neigh, is_from_best_next_hop,
1292 if ((orig_neigh_node) && (!is_single_hop_neigh))
1293 batadv_orig_node_free_ref(orig_neigh_node);
1296 batadv_neigh_node_free_ref(router);
1298 batadv_neigh_node_free_ref(router_router);
1299 if (orig_neigh_router)
1300 batadv_neigh_node_free_ref(orig_neigh_router);
1302 batadv_orig_node_free_ref(orig_node);
1305 static int batadv_iv_ogm_receive(struct sk_buff *skb,
1306 struct batadv_hard_iface *if_incoming)
1308 struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
1309 struct batadv_ogm_packet *batadv_ogm_packet;
1310 struct ethhdr *ethhdr;
1311 int buff_pos = 0, packet_len;
1312 unsigned char *tvlv_buff, *packet_buff;
1313 uint8_t *packet_pos;
1316 ret = batadv_check_management_packet(skb, if_incoming, BATADV_OGM_HLEN);
1320 /* did we receive a B.A.T.M.A.N. IV OGM packet on an interface
1321 * that does not have B.A.T.M.A.N. IV enabled ?
1323 if (bat_priv->bat_algo_ops->bat_ogm_emit != batadv_iv_ogm_emit)
1326 batadv_inc_counter(bat_priv, BATADV_CNT_MGMT_RX);
1327 batadv_add_counter(bat_priv, BATADV_CNT_MGMT_RX_BYTES,
1328 skb->len + ETH_HLEN);
1330 packet_len = skb_headlen(skb);
1331 ethhdr = eth_hdr(skb);
1332 packet_buff = skb->data;
1333 batadv_ogm_packet = (struct batadv_ogm_packet *)packet_buff;
1335 /* unpack the aggregated packets and process them one by one */
1336 while (batadv_iv_ogm_aggr_packet(buff_pos, packet_len,
1337 batadv_ogm_packet->tvlv_len)) {
1338 tvlv_buff = packet_buff + buff_pos + BATADV_OGM_HLEN;
1340 batadv_iv_ogm_process(ethhdr, batadv_ogm_packet,
1341 tvlv_buff, if_incoming);
1343 buff_pos += BATADV_OGM_HLEN;
1344 buff_pos += ntohs(batadv_ogm_packet->tvlv_len);
1346 packet_pos = packet_buff + buff_pos;
1347 batadv_ogm_packet = (struct batadv_ogm_packet *)packet_pos;
1351 return NET_RX_SUCCESS;
1354 static struct batadv_algo_ops batadv_batman_iv __read_mostly = {
1355 .name = "BATMAN_IV",
1356 .bat_iface_enable = batadv_iv_ogm_iface_enable,
1357 .bat_iface_disable = batadv_iv_ogm_iface_disable,
1358 .bat_iface_update_mac = batadv_iv_ogm_iface_update_mac,
1359 .bat_primary_iface_set = batadv_iv_ogm_primary_iface_set,
1360 .bat_ogm_schedule = batadv_iv_ogm_schedule,
1361 .bat_ogm_emit = batadv_iv_ogm_emit,
1364 int __init batadv_iv_init(void)
1368 /* batman originator packet */
1369 ret = batadv_recv_handler_register(BATADV_IV_OGM,
1370 batadv_iv_ogm_receive);
1374 ret = batadv_algo_register(&batadv_batman_iv);
1376 goto handler_unregister;
1381 batadv_recv_handler_unregister(BATADV_IV_OGM);