Compare commits

..

9 Commits

Author SHA1 Message Date
Luca Marturana
d42d0e2dd1 Merge branch 'dev' into agent-master 2017-04-14 14:57:56 +02:00
Luca Marturana
135b4d9975 Merge branch 'dev' into agent-master 2017-03-30 14:46:44 +02:00
Luca Marturana
a25166b7ac Merge branch 'dev' into agent-master 2017-03-20 15:45:29 +01:00
Luca Marturana
800a3f1ea1 Merge branch 'dev' into agent-master 2017-02-21 11:47:36 +01:00
Luca Marturana
31464de885 Merge branch 'dev' into agent-master 2017-02-07 11:06:22 +01:00
Luca Marturana
9b308d2793 Merge branch 'dev' into agent-master 2017-02-02 12:35:47 +01:00
Luca Marturana
a99f09da96 Merge branch 'dev' into agent-master 2017-01-31 11:47:33 +01:00
Luca Marturana
1e0ddba11a Merge branch 'dev' into agent-master 2017-01-25 18:08:35 +01:00
Luca Marturana
b6d1101cb6 Merge branch 'agent-master' into dev 2017-01-17 10:55:07 +01:00
4 changed files with 15 additions and 67 deletions

View File

@@ -2,26 +2,6 @@
This file documents all notable changes to Falco. The release numbering uses [semantic versioning](http://semver.org).
## v0.6.1
Released 2016-05-15
### Major Changes
None
### Minor Changes
* Small changes to token bucket used to throttle falco events [[#234](https://github.com/draios/falco/pull/234)]] [[#235](https://github.com/draios/falco/pull/235)]] [[#236](https://github.com/draios/falco/pull/236)]] [[#238](https://github.com/draios/falco/pull/238)]]
### Bug Fixes
* Update the falco driver to work with kernel 4.11 [[#829](https://github.com/draios/sysdig/pull/829)]
### Rule Changes
* Don't allow apache2 to spawn shells in containers [[#231](https://github.com/draios/falco/issues/231)] [[#232](https://github.com/draios/falco/pull/232)]
## v0.6.0
Released 2016-03-29

View File

@@ -2,7 +2,7 @@
#### Latest release
**v0.6.1**
**v0.6.0**
Read the [change log](https://github.com/draios/falco/blob/dev/CHANGELOG.md)
Dev Branch: [![Build Status](https://travis-ci.org/draios/falco.svg?branch=dev)](https://travis-ci.org/draios/falco)<br />

View File

@@ -31,30 +31,20 @@ token_bucket::~token_bucket()
{
}
void token_bucket::init(double rate, double max_tokens, uint64_t now)
void token_bucket::init(uint32_t rate, uint32_t max_tokens)
{
m_rate = rate;
m_max_tokens = max_tokens;
m_tokens = max_tokens;
if(now == 0)
{
now = sinsp_utils::get_current_time_ns();
}
m_last_seen = now;
m_last_seen = sinsp_utils::get_current_time_ns();
}
bool token_bucket::claim()
{
// Determine the number of tokens gained. Delta between
// last_seen and now, divided by the rate.
uint64_t now = sinsp_utils::get_current_time_ns();
return claim(1, now);
}
bool token_bucket::claim(double tokens, uint64_t now)
{
double tokens_gained = m_rate * ((now - m_last_seen) / (1000000000.0));
uint64_t tokens_gained = (now - m_last_seen) / (m_rate * 1000000000);
m_last_seen = now;
m_tokens += tokens_gained;
@@ -68,24 +58,14 @@ bool token_bucket::claim(double tokens, uint64_t now)
}
//
// If m_tokens is < tokens, can't claim.
// If tokens is < 1, can't claim.
//
if(m_tokens < tokens)
if(m_tokens < 1)
{
return false;
}
m_tokens -= tokens;
m_tokens--;
return true;
}
double token_bucket::get_tokens()
{
return m_tokens;
}
uint64_t token_bucket::get_last_seen()
{
return m_last_seen;
}

View File

@@ -31,42 +31,30 @@ public:
//
// Initialize the token bucket and start accumulating tokens
//
void init(double rate, double max_tokens, uint64_t now = 0);
void init(uint32_t rate, uint32_t max_tokens);
//
// Try to claim tokens tokens from the token bucket, using a
// timestamp of now. Returns true if the tokens could be
// claimed. Also updates internal metrics.
// Returns true if a token can be claimed. Also updates
// internal metrics.
//
bool claim(double tokens, uint64_t now);
// Simpler version of claim that claims a single token and
// uses the current time for now
bool claim();
// Return the current number of tokens available
double get_tokens();
// Return the last time someone tried to claim a token.
uint64_t get_last_seen();
private:
//
// The number of tokens generated per second.
//
double m_rate;
uint64_t m_rate;
//
// The maximum number of tokens that can be banked for future
// claim()s.
//
double m_max_tokens;
uint64_t m_max_tokens;
//
// The current number of tokens
//
double m_tokens;
uint64_t m_tokens;
//
// The last time claim() was called (or the object was created).