Skip to content
Open
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
39 changes: 31 additions & 8 deletions pkg/daemon/ipc.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@
// write. The reqID parameter is kept in handler signatures for potential
// future use but is not transmitted on the wire.
func (c *ipcConn) writeReply(cmd byte, _ uint64, payload []byte) error {
buf := make([]byte, 1+len(payload))

Check failure

Code scanning / CodeQL

Size computation for allocation may overflow High

This operation, which is used in an
allocation
, involves a
potentially large value
and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
This operation, which is used in an
allocation
, involves a potentially large value and might overflow.
buf[0] = cmd
copy(buf[1:], payload)
return c.ipcWrite(buf)
Expand Down Expand Up @@ -1660,18 +1660,41 @@
netID = binary.BigEndian.Uint16(rest[0:2])
}

var result map[string]interface{}
if pr := s.findPolicyRunner(netID); pr != nil {
result = pr.ForceCycle()
} else if me := s.findManagedEngine(netID); me != nil {
result = me.ForceCycle()
} else {
// PILOT-309: ForceCycle is synchronous and calls fetchMembers →
// ListNodes which is a network call with no timeout. A hung/slow
// registry would wedge the IPC handler goroutine indefinitely.
// Run the cycle in a background goroutine with a 5s deadline.
pr := s.findPolicyRunner(netID)
me := s.findManagedEngine(netID)
if pr == nil && me == nil {
s.sendError(conn, reqID, "managed: no active managed networks")
return
}

data, _ := json.Marshal(result)
s.ipcWriteManagedOK(conn, reqID, data)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

type cycleResult struct {
data map[string]interface{}
}
ch := make(chan cycleResult, 1)
go func() {
var r map[string]interface{}
if pr != nil {
r = pr.ForceCycle()
} else {
r = me.ForceCycle()
}
ch <- cycleResult{data: r}
}()

select {
case cr := <-ch:
data, _ := json.Marshal(cr.data)
s.ipcWriteManagedOK(conn, reqID, data)
case <-ctx.Done():
s.sendError(conn, reqID, "managed: force cycle timed out after 5s")
}

case SubManagedReconcile:
// [2-byte netID]. Poll the registry for the network's member list
Expand Down
Loading