Staging: batman-adv: layer2 unicast packet fragmentation
[firefly-linux-kernel-4.4.55.git] / drivers / staging / batman-adv / originator.c
index de5a8c1a810462da1d2f7e8779afd582eb779784..b51a13ef8565b8ab936655ce8f7fdacdb92a5510 100644 (file)
@@ -27,6 +27,7 @@
 #include "translation-table.h"
 #include "routing.h"
 #include "hard-interface.h"
+#include "unicast.h"
 
 static DECLARE_DELAYED_WORK(purge_orig_wq, purge_orig);
 
@@ -95,6 +96,7 @@ static void free_orig_node(void *data)
                kfree(neigh_node);
        }
 
+       frag_list_free(&orig_node->frag_list);
        hna_global_del_orig(orig_node, "originator timed out");
 
        kfree(orig_node->bcast_own);
@@ -157,6 +159,10 @@ struct orig_node *get_orig_node(uint8_t *addr)
 
        size = bat_priv->num_ifaces * sizeof(uint8_t);
        orig_node->bcast_own_sum = kzalloc(size, GFP_ATOMIC);
+
+       INIT_LIST_HEAD(&orig_node->frag_list);
+       orig_node->last_frag_packet = 0;
+
        if (!orig_node->bcast_own_sum)
                goto free_bcast_own;
 
@@ -271,6 +277,10 @@ void purge_orig(struct work_struct *work)
                        hash_remove_bucket(orig_hash, &hashit);
                        free_orig_node(orig_node);
                }
+
+               if (time_after(jiffies, (orig_node->last_frag_packet +
+                       msecs_to_jiffies(FRAG_TIMEOUT))))
+                       frag_list_free(&orig_node->frag_list);
        }
 
        spin_unlock_irqrestore(&orig_hash_lock, flags);