rate-limiter: add getRateLimiter/setRateLimiter in endpoint

We use tc-based or built-in rate limiter to shape network I/O traffic
and they all must be tied to one specific interface/endpoint.
In order to tell whether we've ever added rate limiter to this interface/endpoint,
we create get/set func to reveal/store such info.

Fixes: #250

Signed-off-by: Penny Zheng <penny.zheng@arm.com>
This commit is contained in:
Penny Zheng
2020-06-15 10:06:16 +00:00
parent 527c3f4634
commit 5a58ed29f1
9 changed files with 161 additions and 0 deletions

View File

@@ -21,6 +21,8 @@ type TapEndpoint struct {
EndpointProperties NetworkInfo
EndpointType EndpointType
PCIAddr string
RxRateLimiter bool
TxRateLimiter bool
}
// Properties returns the properties of the tap interface.
@@ -207,3 +209,21 @@ func (endpoint *TapEndpoint) load(s persistapi.NetworkEndpoint) {
endpoint.TapInterface = *tapif
}
}
func (endpoint *TapEndpoint) GetRxRateLimiter() bool {
return endpoint.RxRateLimiter
}
func (endpoint *TapEndpoint) SetRxRateLimiter() error {
endpoint.RxRateLimiter = true
return nil
}
func (endpoint *TapEndpoint) GetTxRateLimiter() bool {
return endpoint.TxRateLimiter
}
func (endpoint *TapEndpoint) SetTxRateLimiter() error {
endpoint.TxRateLimiter = true
return nil
}