Skip to content

Commit

Permalink
Use string array instead of map
Browse files Browse the repository at this point in the history
Signed-off-by: Mauricio Vásquez <mauricio@kinvolk.io>
  • Loading branch information
mauriciovasquezbernal committed Dec 4, 2020
1 parent e0f6871 commit c4cdab6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
12 changes: 6 additions & 6 deletions config-linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ The following parameters can be specified to set up seccomp:
If sending to this socket fails, the runtime MUST [generate an error](runtime.md#errors).
If the `SCMP_ACT_NOTIFY` action is not used this value is ignored.

The runtime sends the following file descriptors using `SCM_RIGHTS` and set their corresponding indexes in the `fdIndexes` map of the [container process state](#containerprocessstate):
The runtime sends the following file descriptors using `SCM_RIGHTS` and set their names in the `fds` array of the [container process state](#containerprocessstate):

* **`seccompFd`** (int, REQUIRED) is the seccomp file descriptor returned by the seccomp syscall.
* **`pidFd`** (int, OPTIONAL) is the process file descriptor (e.g as returned by `pidfd_open(2)` or by `clone(2)` with the `CLONE_PID` flag).
Expand Down Expand Up @@ -713,7 +713,7 @@ If more than one `sendmsg(2)` is used, the file descriptors MUST be sent only in
The container processs state includes the following properties:

* **`ociVersion`** (string, REQUIRED) is version of the Open Container Initiative Runtime Specification with which the container processs state complies.
* **`fdIndexes`** (map, OPTIONAL) are the indexes of the file descriptors in the `SCM_RIGHTS` array.
* **`fds`** (array, OPTIONAL) is a string array containing the names of the file descriptors passed. The index of the name in this array corresponds to index of the file descriptor the `SCM_RIGHTS` array.
* **`pid`** (int, REQUIRED) is the container process ID, as seen by the runtime.
* **`metadata`** (string, OPTIONAL) opaque metadata.
* **`state`** (map, REQUIRED) is the [state](runtime.md#state) of the container.
Expand All @@ -723,10 +723,10 @@ Example:
```json
{
"ociVersion": "0.2.0",
"fdIndexes": {
"seccompFd": 0,
"pidFd": 1
},
"fds": [
"seccompFd",
"pidFd"
],
"pid": 4422,
"metadata": "MKNOD=/dev/null,/dev/net/tun;BPF_MAP_TYPES=hash,array",
"state": {
Expand Down
17 changes: 8 additions & 9 deletions specs-go/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,21 @@ type State struct {
Annotations map[string]string `json:"annotations,omitempty"`
}

// FdIndexKey is the key used in the FdIndexes map of the ContainerProcessState struct.
type FdIndexKey string

const (
// SeccompFdIndexKey is the index of the seccomp notify file descriptor.
SeccompFdIndexKey FdIndexKey = "seccompFd"
// PidFdIndexKey is the index of the target process file descriptor.
PidFdIndexKey FdIndexKey = "pidFd"
// SeccompFdName is the name of the seccomp notify file descriptor.
SeccompFdName string = "seccompFd"
// PidFdName is the name of the target process file descriptor.
PidFdName string = "pidFd"
)

// ContainerProcessState holds information about the state of a container process.
type ContainerProcessState struct {
// Version is the version of the specification that is supported.
Version string `json:"ociVersion"`
// FdIndexes is a map containing the indexes of the file descriptors in the `SCM_RIGHTS` array.
FdIndexes map[FdIndexKey]int `json:"fdIndexes"`
// Fds is a string array containing the names of the file descriptors passed.
// The index of the name in this array corresponds to index of the file
// descriptor the `SCM_RIGHTS` array.
Fds []string `json:"fds"`
// Pid is the process ID as seen by the runtime.
Pid int `json:"pid"`
// Opaque metadata.
Expand Down

0 comments on commit c4cdab6

Please sign in to comment.