Skip to content

Commit e468ada

Browse files
committed
convert corr to float
Signed-off-by: YangKeao <[email protected]>
1 parent 00ff8f5 commit e468ada

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

pkg/client/client.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import "C"
2020

2121
import (
2222
"errors"
23+
"math"
2324
"os"
2425
"syscall"
2526
"unsafe"
@@ -55,7 +56,7 @@ func (c *Client) GetVersion() int {
5556
return int(version)
5657
}
5758

58-
func (c *Client) InjectIOEMDelay(devPath string, op int, pidNs uint, delay int64, jitter int64, corr uint32) (int, error) {
59+
func (c *Client) InjectIOEMDelay(devPath string, op int, pidNs uint, delay int64, jitter int64, corr float64) (int, error) {
5960
dev := C.uint32_t(0)
6061
if len(devPath) > 0 {
6162
info, err := os.Stat(devPath)
@@ -71,7 +72,7 @@ func (c *Client) InjectIOEMDelay(devPath string, op int, pidNs uint, delay int64
7172
}
7273

7374
ioem_injection := C.ioem_matcher_arg_new(C.uint32_t(dev), C.int(op), C.uint(pidNs))
74-
delay_arg := C.ioem_injector_delay_arg_new(C.int64_t(delay), C.int64_t(jitter), C.uint32_t(corr))
75+
delay_arg := C.ioem_injector_delay_arg_new(C.int64_t(delay), C.int64_t(jitter), C.uint32_t(math.Floor(corr*math.MaxInt32)))
7576

7677
id := C.add_injection(C.int(c.fd), 0, unsafe.Pointer(&ioem_injection), 0, unsafe.Pointer(&delay_arg))
7778
if id < 0 {

pkg/cmd/inject/ioem/delay/delay.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var dev_path string
2727
var op int
2828
var pidNs uint
2929
var delay, corr int64
30-
var jitter uint32
30+
var jitter float64
3131

3232
var Delay = &cobra.Command{
3333
Use: "delay",
@@ -57,5 +57,5 @@ func init() {
5757
Delay.MarkFlagRequired("delay")
5858

5959
Delay.Flags().Int64Var(&corr, "corr", 0, "correlation of the randominess of latency")
60-
Delay.Flags().Uint32Var(&jitter, "jitter", 0, "jitter of the latency")
60+
Delay.Flags().Float64Var(&jitter, "jitter", 0, "jitter of the latency")
6161
}

0 commit comments

Comments
 (0)