Merge branch 'for-linus-4.2' of git://git.kernel.org/pub/scm/linux/kernel/git/mason...
[firefly-linux-kernel-4.4.55.git] / net / batman-adv / bat_iv_ogm.c
index 190a64299090ed0c7d0f2384714851287819611c..753383c2215c2c01539acc3458d43992b53afccd 100644 (file)
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "bat_algo.h"
 #include "main.h"
-#include "translation-table.h"
+
+#include <linux/atomic.h>
+#include <linux/bitmap.h>
+#include <linux/bitops.h>
+#include <linux/bug.h>
+#include <linux/byteorder/generic.h>
+#include <linux/cache.h>
+#include <linux/errno.h>
+#include <linux/etherdevice.h>
+#include <linux/fs.h>
+#include <linux/if_ether.h>
+#include <linux/init.h>
+#include <linux/jiffies.h>
+#include <linux/list.h>
+#include <linux/netdevice.h>
+#include <linux/pkt_sched.h>
+#include <linux/printk.h>
+#include <linux/random.h>
+#include <linux/rculist.h>
+#include <linux/rcupdate.h>
+#include <linux/seq_file.h>
+#include <linux/skbuff.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+#include <linux/stddef.h>
+#include <linux/string.h>
+#include <linux/types.h>
+#include <linux/workqueue.h>
+
+#include "bitarray.h"
+#include "hard-interface.h"
+#include "hash.h"
+#include "network-coding.h"
 #include "originator.h"
+#include "packet.h"
 #include "routing.h"
-#include "gateway_common.h"
-#include "gateway_client.h"
-#include "hard-interface.h"
 #include "send.h"
-#include "bat_algo.h"
-#include "network-coding.h"
+#include "translation-table.h"
 
 /**
  * enum batadv_dup_status - duplicate status
- * @BATADV_NO_DUP: the packet is a duplicate
+ * @BATADV_NO_DUP: the packet is no duplicate
  * @BATADV_ORIG_DUP: OGM is a duplicate in the originator (but not for the
  *  neighbor)
  * @BATADV_NEIGH_DUP: OGM is a duplicate for the neighbor
@@ -55,7 +85,7 @@ static void batadv_ring_buffer_set(uint8_t lq_recv[], uint8_t *lq_index,
 }
 
 /**
- * batadv_ring_buffer_set - compute the average of all non-zero values stored
+ * batadv_ring_buffer_avg - compute the average of all non-zero values stored
  * in the given ring buffer
  * @lq_recv: pointer to the ring buffer
  *
@@ -64,7 +94,9 @@ static void batadv_ring_buffer_set(uint8_t lq_recv[], uint8_t *lq_index,
 static uint8_t batadv_ring_buffer_avg(const uint8_t lq_recv[])
 {
        const uint8_t *ptr;
-       uint16_t count = 0, i = 0, sum = 0;
+       uint16_t count = 0;
+       uint16_t i = 0;
+       uint16_t sum = 0;
 
        ptr = lq_recv;
 
@@ -447,7 +479,7 @@ static void batadv_iv_ogm_send_to_if(struct batadv_forw_packet *forw_packet,
                           batadv_ogm_packet->orig,
                           ntohl(batadv_ogm_packet->seqno),
                           batadv_ogm_packet->tq, batadv_ogm_packet->ttl,
-                          (batadv_ogm_packet->flags & BATADV_DIRECTLINK ?
+                          ((batadv_ogm_packet->flags & BATADV_DIRECTLINK) ?
                            "on" : "off"),
                           hard_iface->net_dev->name,
                           hard_iface->net_dev->dev_addr);
@@ -750,13 +782,13 @@ static void batadv_iv_ogm_queue_add(struct batadv_priv *bat_priv,
        unsigned long max_aggregation_jiffies;
 
        batadv_ogm_packet = (struct batadv_ogm_packet *)packet_buff;
-       direct_link = batadv_ogm_packet->flags & BATADV_DIRECTLINK ? 1 : 0;
+       direct_link = !!(batadv_ogm_packet->flags & BATADV_DIRECTLINK);
        max_aggregation_jiffies = msecs_to_jiffies(BATADV_MAX_AGGREGATION_MS);
 
        /* find position for the packet in the forward queue */
        spin_lock_bh(&bat_priv->forw_bat_list_lock);
        /* own packets are not to be aggregated */
-       if ((atomic_read(&bat_priv->aggregated_ogms)) && (!own_packet)) {
+       if (atomic_read(&bat_priv->aggregated_ogms) && !own_packet) {
                hlist_for_each_entry(forw_packet_pos,
                                     &bat_priv->forw_bat_list, list) {
                        if (batadv_iv_ogm_can_aggregate(batadv_ogm_packet,
@@ -1032,9 +1064,10 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
                batadv_orig_node_free_ref(orig_tmp);
                if (!neigh_node)
                        goto unlock;
-       } else
+       } else {
                batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
                           "Updating existing last-hop neighbor of originator\n");
+       }
 
        rcu_read_unlock();
        neigh_ifinfo = batadv_neigh_ifinfo_new(neigh_node, if_outgoing);
@@ -1354,8 +1387,7 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
 out:
        spin_unlock_bh(&orig_node->bat_iv.ogm_cnt_lock);
        batadv_orig_node_free_ref(orig_node);
-       if (orig_ifinfo)
-               batadv_orig_ifinfo_free_ref(orig_ifinfo);
+       batadv_orig_ifinfo_free_ref(orig_ifinfo);
        return ret;
 }