From ddcd0929e3550ea0e376b0c73e50d617b40b9d50 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 30 Dec 2015 18:24:26 +0100 Subject: prog: give more priority to generic socket syscalls --- prog/prio.go | 15 +++++++++++++++ sys/decl.go | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/prog/prio.go b/prog/prio.go index 35e296b83..61afedd60 100644 --- a/prog/prio.go +++ b/prog/prio.go @@ -130,6 +130,21 @@ func calcStaticPriorities() [][]float32 { } } } + + // Sockets essentially form another level of classification. And we want + // more priority for generic socket calls (e.g. recvmsg) against particular + // protocol socket calls (e.g. AF_ALG bind). But it is not expressable with + // the above uses thing, because we don't want more priority for different + // protocols (e.g. AF_ALF vs AF_BLUETOOTH). + for c0, w0 := range uses[fmt.Sprintf("res%v-%v", sys.ResFD, sys.FdSock)] { + for _, sk := range sys.SocketSubkinds() { + for c1, w1 := range uses[fmt.Sprintf("res%v-%v", sys.ResFD, sk)] { + prios[c0][c1] += w0 * w1 + prios[c1][c0] += w0 * w1 + } + } + } + // Self-priority (call wrt itself) is assigned to the maximum priority // this call has wrt other calls. This way the priority is high, but not too high. for c0, pp := range prios { diff --git a/sys/decl.go b/sys/decl.go index 8b01669e3..2e3d42218 100644 --- a/sys/decl.go +++ b/sys/decl.go @@ -137,6 +137,11 @@ func ResourceSubkinds(kind ResourceKind) []ResourceSubkind { } } +func SocketSubkinds() []ResourceSubkind { + return []ResourceSubkind{FdAlg, FdAlgConn, FdNfcRaw, FdNfcLlcp, FdBtHci, FdBtSco, + FdBtL2cap, FdBtRfcomm, FdBtHidp, FdBtCmtp, FdBtBnep, FdUnix, FdSctp} +} + const ( InvalidFD = ^uintptr(0) BogusFD = uintptr(100000 - 1) -- cgit mrf-deployment