mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-17 14:24:27 +01:00
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:
@@ -19,6 +19,8 @@ type MacvtapEndpoint struct {
|
||||
VMFds []*os.File
|
||||
VhostFds []*os.File
|
||||
PCIAddr string
|
||||
RxRateLimiter bool
|
||||
TxRateLimiter bool
|
||||
}
|
||||
|
||||
func createMacvtapNetworkEndpoint(netInfo NetworkInfo) (*MacvtapEndpoint, error) {
|
||||
@@ -121,3 +123,21 @@ func (endpoint *MacvtapEndpoint) load(s persistapi.NetworkEndpoint) {
|
||||
endpoint.PCIAddr = s.Macvtap.PCIAddr
|
||||
}
|
||||
}
|
||||
|
||||
func (endpoint *MacvtapEndpoint) GetRxRateLimiter() bool {
|
||||
return endpoint.RxRateLimiter
|
||||
}
|
||||
|
||||
func (endpoint *MacvtapEndpoint) SetRxRateLimiter() error {
|
||||
endpoint.RxRateLimiter = true
|
||||
return nil
|
||||
}
|
||||
|
||||
func (endpoint *MacvtapEndpoint) GetTxRateLimiter() bool {
|
||||
return endpoint.TxRateLimiter
|
||||
}
|
||||
|
||||
func (endpoint *MacvtapEndpoint) SetTxRateLimiter() error {
|
||||
endpoint.TxRateLimiter = true
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user