mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-30 23:06:27 +00: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:
parent
527c3f4634
commit
5a58ed29f1
@ -18,6 +18,8 @@ type BridgedMacvlanEndpoint struct {
|
||||
EndpointProperties NetworkInfo
|
||||
EndpointType EndpointType
|
||||
PCIAddr string
|
||||
RxRateLimiter bool
|
||||
TxRateLimiter bool
|
||||
}
|
||||
|
||||
func createBridgedMacvlanNetworkEndpoint(idx int, ifName string, interworkingModel NetInterworkingModel) (*BridgedMacvlanEndpoint, error) {
|
||||
@ -136,3 +138,21 @@ func (endpoint *BridgedMacvlanEndpoint) load(s persistapi.NetworkEndpoint) {
|
||||
endpoint.NetPair = *netpair
|
||||
}
|
||||
}
|
||||
|
||||
func (endpoint *BridgedMacvlanEndpoint) GetRxRateLimiter() bool {
|
||||
return endpoint.RxRateLimiter
|
||||
}
|
||||
|
||||
func (endpoint *BridgedMacvlanEndpoint) SetRxRateLimiter() error {
|
||||
endpoint.RxRateLimiter = true
|
||||
return nil
|
||||
}
|
||||
|
||||
func (endpoint *BridgedMacvlanEndpoint) GetTxRateLimiter() bool {
|
||||
return endpoint.TxRateLimiter
|
||||
}
|
||||
|
||||
func (endpoint *BridgedMacvlanEndpoint) SetTxRateLimiter() error {
|
||||
endpoint.TxRateLimiter = true
|
||||
return nil
|
||||
}
|
||||
|
@ -29,6 +29,11 @@ type Endpoint interface {
|
||||
|
||||
save() persistapi.NetworkEndpoint
|
||||
load(persistapi.NetworkEndpoint)
|
||||
|
||||
GetRxRateLimiter() bool
|
||||
SetRxRateLimiter() error
|
||||
GetTxRateLimiter() bool
|
||||
SetTxRateLimiter() error
|
||||
}
|
||||
|
||||
// EndpointType identifies the type of the network endpoint.
|
||||
|
@ -18,6 +18,8 @@ type IPVlanEndpoint struct {
|
||||
EndpointProperties NetworkInfo
|
||||
EndpointType EndpointType
|
||||
PCIAddr string
|
||||
RxRateLimiter bool
|
||||
TxRateLimiter bool
|
||||
}
|
||||
|
||||
func createIPVlanNetworkEndpoint(idx int, ifName string) (*IPVlanEndpoint, error) {
|
||||
@ -139,3 +141,21 @@ func (endpoint *IPVlanEndpoint) load(s persistapi.NetworkEndpoint) {
|
||||
endpoint.NetPair = *netpair
|
||||
}
|
||||
}
|
||||
|
||||
func (endpoint *IPVlanEndpoint) GetRxRateLimiter() bool {
|
||||
return endpoint.RxRateLimiter
|
||||
}
|
||||
|
||||
func (endpoint *IPVlanEndpoint) SetRxRateLimiter() error {
|
||||
endpoint.RxRateLimiter = true
|
||||
return nil
|
||||
}
|
||||
|
||||
func (endpoint *IPVlanEndpoint) GetTxRateLimiter() bool {
|
||||
return endpoint.TxRateLimiter
|
||||
}
|
||||
|
||||
func (endpoint *IPVlanEndpoint) SetTxRateLimiter() error {
|
||||
endpoint.TxRateLimiter = true
|
||||
return nil
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -231,3 +231,21 @@ func (endpoint *PhysicalEndpoint) load(s persistapi.NetworkEndpoint) {
|
||||
endpoint.VendorDeviceID = s.Physical.VendorDeviceID
|
||||
}
|
||||
}
|
||||
|
||||
// unsupported
|
||||
func (endpoint *PhysicalEndpoint) GetRxRateLimiter() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (endpoint *PhysicalEndpoint) SetRxRateLimiter() error {
|
||||
return fmt.Errorf("rx rate limiter is unsupported for physical endpoint")
|
||||
}
|
||||
|
||||
// unsupported
|
||||
func (endpoint *PhysicalEndpoint) GetTxRateLimiter() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (endpoint *PhysicalEndpoint) SetTxRateLimiter() error {
|
||||
return fmt.Errorf("tx rate limiter is unsupported for physical endpoint")
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ type TuntapEndpoint struct {
|
||||
EndpointProperties NetworkInfo
|
||||
EndpointType EndpointType
|
||||
PCIAddr string
|
||||
RxRateLimiter bool
|
||||
TxRateLimiter bool
|
||||
}
|
||||
|
||||
// Properties returns the properties of the tap interface.
|
||||
@ -212,3 +214,21 @@ func (endpoint *TuntapEndpoint) load(s persistapi.NetworkEndpoint) {
|
||||
endpoint.TuntapInterface = *tuntapif
|
||||
}
|
||||
}
|
||||
|
||||
func (endpoint *TuntapEndpoint) GetRxRateLimiter() bool {
|
||||
return endpoint.RxRateLimiter
|
||||
}
|
||||
|
||||
func (endpoint *TuntapEndpoint) SetRxRateLimiter() error {
|
||||
endpoint.RxRateLimiter = true
|
||||
return nil
|
||||
}
|
||||
|
||||
func (endpoint *TuntapEndpoint) GetTxRateLimiter() bool {
|
||||
return endpoint.TxRateLimiter
|
||||
}
|
||||
|
||||
func (endpoint *TuntapEndpoint) SetTxRateLimiter() error {
|
||||
endpoint.TxRateLimiter = true
|
||||
return nil
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ type VethEndpoint struct {
|
||||
EndpointProperties NetworkInfo
|
||||
EndpointType EndpointType
|
||||
PCIAddr string
|
||||
RxRateLimiter bool
|
||||
TxRateLimiter bool
|
||||
}
|
||||
|
||||
func createVethNetworkEndpoint(idx int, ifName string, interworkingModel NetInterworkingModel) (*VethEndpoint, error) {
|
||||
@ -162,3 +164,21 @@ func (endpoint *VethEndpoint) load(s persistapi.NetworkEndpoint) {
|
||||
endpoint.NetPair = *netpair
|
||||
}
|
||||
}
|
||||
|
||||
func (endpoint *VethEndpoint) GetRxRateLimiter() bool {
|
||||
return endpoint.RxRateLimiter
|
||||
}
|
||||
|
||||
func (endpoint *VethEndpoint) SetRxRateLimiter() error {
|
||||
endpoint.RxRateLimiter = true
|
||||
return nil
|
||||
}
|
||||
|
||||
func (endpoint *VethEndpoint) GetTxRateLimiter() bool {
|
||||
return endpoint.TxRateLimiter
|
||||
}
|
||||
|
||||
func (endpoint *VethEndpoint) SetTxRateLimiter() error {
|
||||
endpoint.TxRateLimiter = true
|
||||
return nil
|
||||
}
|
||||
|
@ -169,3 +169,21 @@ func (endpoint *VhostUserEndpoint) load(s persistapi.NetworkEndpoint) {
|
||||
endpoint.PCIAddr = s.VhostUser.PCIAddr
|
||||
}
|
||||
}
|
||||
|
||||
// unsupported
|
||||
func (endpoint *VhostUserEndpoint) GetRxRateLimiter() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (endpoint *VhostUserEndpoint) SetRxRateLimiter() error {
|
||||
return fmt.Errorf("rx rate limiter is unsupported for vhost user endpoint")
|
||||
}
|
||||
|
||||
// unsupported
|
||||
func (endpoint *VhostUserEndpoint) GetTxRateLimiter() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (endpoint *VhostUserEndpoint) SetTxRateLimiter() error {
|
||||
return fmt.Errorf("tx rate limiter is unsupported for vhost user endpoint")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user