Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issues left over from version 1.6.0 #120

Merged
merged 3 commits into from
Jun 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions exec/mem/mem.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func (ce *memExecutor) SetChannel(channel spec.Channel) {
const (
//processOOMScoreAdj = "/proc/%s/oom_score_adj"
//oomMinScore = "-1000"
processOOMAdj = "/proc/%s/oom_adj"
processOOMAdj = "/proc/%d/oom_adj"
oomMinAdj = "-17"
)

Expand Down Expand Up @@ -296,10 +296,12 @@ func (ce *memExecutor) start(ctx context.Context, memPercent, memReserve, memRat
// adjust process oom_score_adj to avoid being killed
if avoidBeingKilled {
scoreAdjFile := fmt.Sprintf(processOOMAdj, os.Getpid())
if _, err := os.Stat(scoreAdjFile); os.IsExist(err) {
if _, err := os.Stat(scoreAdjFile); err == nil || os.IsExist(err) {
if err := ioutil.WriteFile(scoreAdjFile, []byte(oomMinAdj), 0644); err != nil {
log.Errorf(ctx, "run burn memory by %s mode failed, cannot edit the process oom_score_adj", burnMemMode)
log.Errorf(ctx, "run burn memory by %s mode failed, cannot edit the process oom_score_adj, %v", burnMemMode, err)
}
} else {
log.Errorf(ctx, "score adjust file: %s not exists, %v", scoreAdjFile, err)
}
}

Expand Down
37 changes: 7 additions & 30 deletions exec/network/tc/network_tc.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,53 +55,30 @@ var commFlags = []spec.ExpFlagSpec{
}

const delimiter = ","
const (
Delay = "delay"
Loss = "loss"
Duplicate = "duplicate"
Corrupt = "corrupt"
Reorder = "reorder"
)

func getCommArgs(localPort, remotePort, excludePort, destinationIp, excludeIp string,
args string, ignorePeerPort, force bool) (string, *spec.Response) {
func startNet(ctx context.Context, netInterface, classRule, localPort, remotePort, excludePort, destIp, excludeIp string, force, ignorePeerPorts bool, cl spec.Channel) *spec.Response {
if localPort != "" {
localPorts, err := util.ParseIntegerListToStringSlice("local-port", localPort)
if err != nil {
return "", spec.ResponseFailWithFlags(spec.ParameterIllegal, "local-port", localPort, err)
return spec.ResponseFailWithFlags(spec.ParameterIllegal, "local-port", localPort, err)
}
args = fmt.Sprintf("%s --local-port %s", args, strings.Join(localPorts, ","))
localPort = strings.Join(localPorts, ",")
}
if remotePort != "" {
remotePorts, err := util.ParseIntegerListToStringSlice("remote-port", remotePort)
if err != nil {
return "", spec.ResponseFailWithFlags(spec.ParameterIllegal, "remote-port", remotePort, err)
return spec.ResponseFailWithFlags(spec.ParameterIllegal, "remote-port", remotePort, err)
}
args = fmt.Sprintf("%s --remote-port %s", args, strings.Join(remotePorts, ","))
remotePort = strings.Join(remotePorts, ",")
}
if excludePort != "" {
excludePorts, err := util.ParseIntegerListToStringSlice("exclude-port", excludePort)
if err != nil {
return "", spec.ResponseFailWithFlags(spec.ParameterIllegal, "exclude-port", excludePort, err)
return spec.ResponseFailWithFlags(spec.ParameterIllegal, "exclude-port", excludePort, err)
}
args = fmt.Sprintf("%s --exclude-port %s", args, strings.Join(excludePorts, ","))
}
if destinationIp != "" {
args = fmt.Sprintf("%s --destination-ip %s", args, destinationIp)
}
if excludeIp != "" {
args = fmt.Sprintf("%s --exclude-ip %s", args, excludeIp)
}
if ignorePeerPort {
args = fmt.Sprintf("%s --ignore-peer-port", args)
excludePort = strings.Join(excludePorts, ",")
}
if force {
args = fmt.Sprintf("%s --force", args)
}
return args, spec.ReturnSuccess("success")
}

func startNet(ctx context.Context, netInterface, classRule, localPort, remotePort, excludePort, destIp, excludeIp string, force, ignorePeerPorts bool, cl spec.Channel) *spec.Response {
// check device txqueuelen size, if the size is zero, then set the value to 1000
response := preHandleTxqueue(ctx, netInterface, cl)
if !response.Success {
Expand Down