Skip to content

Commit 102e004

Browse files
committed
all: support empty HTTP config
We don't really need an HTTP server when running syz-manager during kernel image testing and when running syz-diff automatically. Don't require the config to be set and don't start the HTTP server in this case.
1 parent 0dce240 commit 102e004

File tree

6 files changed

+25
-19
lines changed

6 files changed

+25
-19
lines changed

pkg/manager/http.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ type HTTPServer struct {
6868
}
6969

7070
func (serv *HTTPServer) Serve() {
71+
if serv.Cfg.HTTP == "" {
72+
log.Fatalf("starting a disabled HTTP server")
73+
}
7174
if serv.Pool != nil {
7275
serv.Pools = map[string]*vm.Dispatcher{"": serv.Pool}
7376
}

pkg/mgrconfig/load.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ func Complete(cfg *Config) error {
145145
cfg.TargetArch, "target",
146146
cfg.Workdir, "workdir",
147147
cfg.Syzkaller, "syzkaller",
148-
cfg.HTTP, "http",
149148
cfg.Type, "type",
150149
cfg.SSHUser, "ssh_user",
151150
); err != nil {

syz-ci/manager.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,8 +591,7 @@ func (mgr *Manager) createTestConfig(imageDir string, info *BuildInfo) (*mgrconf
591591
*mgrcfg = *mgr.managercfg
592592
mgrcfg.Name += "-test"
593593
mgrcfg.Tag = info.KernelCommit
594-
// Use designated ports not to collide with the ports of other managers.
595-
mgrcfg.HTTP = fmt.Sprintf("localhost:%v", mgr.mgrcfg.testHTTPPort)
594+
mgrcfg.HTTP = "" // Don't start the HTTP server.
596595
// For GCE VMs, we need to bind to a real networking interface, so no localhost.
597596
mgrcfg.RPC = fmt.Sprintf(":%v", mgr.mgrcfg.testRPCPort)
598597
mgrcfg.Workdir = filepath.Join(imageDir, "workdir")

syz-ci/syz-ci.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,7 @@ type ManagerConfig struct {
225225
managercfg *mgrconfig.Config
226226

227227
// Auto-assigned ports used by test instances.
228-
testHTTPPort int
229-
testRPCPort int
228+
testRPCPort int
230229
}
231230

232231
type ManagerJobs struct {
@@ -461,8 +460,6 @@ func loadManagerConfig(cfg *Config, mgr *ManagerConfig) error {
461460
managercfg.RPC = fmt.Sprintf(":%v", cfg.RPCPort)
462461
cfg.RPCPort++
463462
}
464-
mgr.testHTTPPort = cfg.ManagerPort
465-
cfg.ManagerPort++
466463
mgr.testRPCPort = cfg.RPCPort
467464
cfg.RPCPort++
468465
// Note: we don't change Compiler/Ccache because it may be just "gcc" referring

syz-manager/manager.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ func RunManager(mode *Mode, cfg *mgrconfig.Config) {
282282
mgr.cfg.Procs = 1
283283
}
284284
mgr.http = &manager.HTTPServer{
285+
// Note that if cfg.HTTP == "", we don't start the server.
285286
Cfg: cfg,
286287
StartTime: time.Now(),
287288
CrashStore: mgr.crashStore,
@@ -355,7 +356,9 @@ func RunManager(mode *Mode, cfg *mgrconfig.Config) {
355356
mgr.http.TogglePause = mgr.pool.TogglePause
356357

357358
ctx := vm.ShutdownCtx()
358-
go mgr.http.Serve()
359+
if mgr.cfg.HTTP != "" {
360+
go mgr.http.Serve()
361+
}
359362
go mgr.trackUsedFiles()
360363
go mgr.processFuzzingResults(ctx)
361364
mgr.pool.Loop(ctx)
@@ -1437,6 +1440,9 @@ func (mgr *Manager) CoverageFilter(modules []*vminfo.KernelModule) []uint64 {
14371440
}
14381441

14391442
func publicWebAddr(addr string) string {
1443+
if addr == "" {
1444+
return ""
1445+
}
14401446
_, port, err := net.SplitHostPort(addr)
14411447
if err == nil && port != "" {
14421448
if host, err := os.Hostname(); err == nil {

tools/syz-diff/diff.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,19 @@ func main() {
8787
new: new,
8888
store: store,
8989
reproAttempts: map[string]int{},
90-
http: &manager.HTTPServer{
90+
}
91+
if newCfg.HTTP != "" {
92+
diffCtx.http = &manager.HTTPServer{
9193
Cfg: newCfg,
9294
StartTime: time.Now(),
9395
DiffStore: store,
94-
},
95-
}
96-
diffCtx.http.Pools = map[string]*vm.Dispatcher{
97-
new.name: new.pool,
98-
base.name: base.pool,
96+
Pools: map[string]*vm.Dispatcher{
97+
new.name: new.pool,
98+
base.name: base.pool,
99+
},
100+
}
101+
new.http = diffCtx.http
99102
}
100-
new.http = diffCtx.http
101-
102103
diffCtx.Loop(ctx)
103104
}
104105

@@ -116,7 +117,10 @@ type diffContext struct {
116117

117118
func (dc *diffContext) Loop(ctx context.Context) {
118119
reproLoop := manager.NewReproLoop(dc, dc.new.pool.Total()-dc.new.cfg.FuzzingVMs, false)
119-
dc.http.ReproLoop = reproLoop
120+
if dc.http != nil {
121+
dc.http.ReproLoop = reproLoop
122+
go dc.http.Serve()
123+
}
120124
go func() {
121125
// Let both base and patched instances somewhat progress in fuzzing before we take
122126
// VMs away for bug reproduction.
@@ -128,10 +132,8 @@ func (dc *diffContext) Loop(ctx context.Context) {
128132

129133
go dc.base.Loop()
130134
go dc.new.Loop()
131-
go dc.http.Serve()
132135

133136
runner := &reproRunner{done: make(chan reproRunnerResult, 2), kernel: dc.base}
134-
135137
rareStat := time.NewTicker(5 * time.Minute)
136138
for {
137139
select {

0 commit comments

Comments
 (0)