*
  * Fills the tvlv buff with the tt entries from the specified hash. If valid_cb
  * is not provided then this becomes a no-op.
+ *
+ * Return: Remaining unused length in tvlv_buff.
  */
-static void batadv_tt_tvlv_generate(struct batadv_priv *bat_priv,
-                                   struct batadv_hashtable *hash,
-                                   void *tvlv_buff, u16 tt_len,
-                                   bool (*valid_cb)(const void *,
-                                                    const void *,
-                                                    u8 *flags),
-                                   void *cb_data)
+static u16 batadv_tt_tvlv_generate(struct batadv_priv *bat_priv,
+                                  struct batadv_hashtable *hash,
+                                  void *tvlv_buff, u16 tt_len,
+                                  bool (*valid_cb)(const void *,
+                                                   const void *,
+                                                   u8 *flags),
+                                  void *cb_data)
 {
        struct batadv_tt_common_entry *tt_common_entry;
        struct batadv_tvlv_tt_change *tt_change;
        tt_change = tvlv_buff;
 
        if (!valid_cb)
-               return;
+               return tt_len;
 
        rcu_read_lock();
        for (i = 0; i < hash->size; i++) {
                }
        }
        rcu_read_unlock();
+
+       return batadv_tt_len(tt_tot - tt_num_entries);
 }
 
 /**
                        goto out;
 
                /* fill the rest of the tvlv with the real TT entries */
-               batadv_tt_tvlv_generate(bat_priv, bat_priv->tt.global_hash,
-                                       tt_change, tt_len,
-                                       batadv_tt_global_valid,
-                                       req_dst_orig_node);
+               tvlv_len -= batadv_tt_tvlv_generate(bat_priv,
+                                                   bat_priv->tt.global_hash,
+                                                   tt_change, tt_len,
+                                                   batadv_tt_global_valid,
+                                                   req_dst_orig_node);
        }
 
        /* Don't send the response, if larger than fragmented packet. */
                        goto out;
 
                /* fill the rest of the tvlv with the real TT entries */
-               batadv_tt_tvlv_generate(bat_priv, bat_priv->tt.local_hash,
-                                       tt_change, tt_len,
-                                       batadv_tt_local_valid, NULL);
+               tvlv_len -= batadv_tt_tvlv_generate(bat_priv,
+                                                   bat_priv->tt.local_hash,
+                                                   tt_change, tt_len,
+                                                   batadv_tt_local_valid,
+                                                   NULL);
        }
 
        tvlv_tt_data->flags = BATADV_TT_RESPONSE;