Skip to content
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
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,60 @@ Every command has `--help`. A device is selected by `--station NAME` (resolved w
| `--timeout` | `PROFINETCTL_TIMEOUT` | `5s` | time limit of one request |
| `--pcap FILE` | | | record every frame sent and received (open it with Wireshark) |
| `--debug` | | | go-profinet's diagnostics on stderr, and the causes of an error |
| `--allow-operation OP`, `--allow-read-index`, `--allow-write-index`, `--allow-dcp-block`, `--allow-list-file FILE`, `--allow-nothing` | | | restrict what profinetctl may send: see [Allow-list](#allow-list) |

### Allow-list

The `--allow-*` flags restrict what profinetctl may send, with go-profinet's own allow-list (`controller.Allowlist`, and for the DCP Sets `dcp.SetAllowlist`; go-profinet's [SECURITY.md](https://github.com/otfabric/go-profinet/blob/main/SECURITY.md), "What a controller may send"). It is a local measure, checked before anything is sent: it authenticates nobody and decides nothing about the device; it keeps a script or an operator from sending what they should not. Without any of these flags there is no allow-list, and profinetctl sends what it sent before.

| Flag | Meaning |
|------|---------|
| `--allow-operation OP` | the classes of operation allowed (repeatable, or comma-separated), as go-profinet names them: `connect` (the Connect of an AR: an IOCAR or a device access AR), `read` (a record in an AR), `read-implicit` (a record without an AR), `write` (each record write), `prm-begin`, `prm-end` (the end of a parameterization), `other-control` (any other Control but Release), `dcp-set` (a DCP Set) |
| `--allow-read-index I` | restricts `read` and `read-implicit` to this record index or range `FIRST-LAST` (decimal or `0x` hex, repeatable); without it, every index of an allowed read |
| `--allow-write-index I` | restricts `write` likewise |
| `--allow-dcp-block BLOCK` | restricts `dcp-set` to this block (repeatable): go-profinet's name of it, case-insensitive (`Device/NameOfStation`, `IP/Parameter`, `IP/FullSuite`, `Control/Signal`, `Control/ResetToFactory`, `DHCP/61`, ...), or `OPTION/SUBOPTION` in numbers (`2/2`); without it, every block of an allowed Set |
| `--allow-list-file FILE` | the allow-list as a JSON file with the same fields, instead of the flags above: `{"operations": ["read-implicit", "dcp-set"], "read_indexes": [{"first": "0xAFF0", "last": "0xAFFF"}], "write_indexes": [{"first": 16}], "dcp_blocks": ["Device/NameOfStation"]}`; an index is a number or a string as the flags take it, `last` defaults to `first`, an unknown field is an error |
| `--allow-nothing` | an allow-list that allows nothing: every request it covers is refused |

- **An empty allow-list allows nothing** (go-profinet's rule). Only `--allow-nothing` makes one, and it takes no other allow-list flag. A file that names no operation is refused (exit 3), and so is an index range or a DCP block whose operation the list does not allow (`--allow-read-index` without `read` or `read-implicit`: exit 2, in a file exit 3): a mistake cannot turn into a list that allows nothing, or into an empty list that allows everything.
- **A refusal** exits `12` with kind and code `policy_denied`; nothing was sent. With `--format json` the error object names the `operation`, the `record` (`api`, `slot`, `subslot`, `index`) of a read or a write or the DCP `block`, and the `target` (`station`, `mac`, `ip`) ([docs/exitcodes.md](docs/exitcodes.md), [docs/json-output.md](docs/json-output.md)). A command whose result has several parts (`device info`, `status`, I&M1–4 of `im read`, `topology`, `topology check`) reports a refused part as a part that failed (exit 7). A refused re-parameterization (`connect --reparam`) is reported in its `reparameterized` event, and the AR runs on.
- **Not covered**, so always sent: DCP Identify and Get (`discover`, `identify`, `name get`, `ip get`, finding a device by `--station`), LLDP, the transaction brackets of a DCP Set (Control/Start and Control/Stop), Release (`disconnect`, the end of an AR), and what belongs to an AR once its Connect was allowed: the answer to ApplicationReady, alarm acknowledgements and the cyclic frames.
- **The AR commands** (`connect`, `ar`, `iocr`, `io`, `alarms`, and `record write` and `im write` with `--gsdml` or `--model`) are checked before anything is sent: their Connect, the write of each parameter record, PrmEnd and, with `--assign-ip`, the DCP Set of `IP/Parameter`. One of them refused, and no AR is attempted.

What the commands send:

| Command | Needs |
|---------|-------|
| `name set` | `dcp-set` of `Device/NameOfStation` |
| `ip set` | `dcp-set` of `IP/Parameter` |
| `signal` | `dcp-set` of `Control/Signal` |
| `reset` | `dcp-set` of `Control/ResetToFactory` |
| `record read`, `im read`, `diagnostics`, `device info`, `status`, `mrp status`, `topology`, `topology check` | `read-implicit` of their records |
| `record write`, `im write` | `connect` and `write` (a device access AR); with `--gsdml` or `--model` also `prm-end` |
| `connect`, `ar`, `iocr`, `io`, `alarms` | `connect`, `write` (the parameter records), `prm-end`; `--assign-ip`: `dcp-set` of `IP/Parameter`; `--reparam`: `prm-begin` as well |

```console
$ sudo profinetctl -i eth0 record read -s io-rack-1 --index 0xAFF0 --allow-operation read-implicit --allow-read-index 0xF000-0xF0FF
error: read 0/0/0x0001 index 0xAFF0: controller: read-implicit 0/0/0x0001 index 0xAFF0: profinet: not allowed by the local allow-list; nothing was sent
$ echo $?
12
$ sudo profinetctl -i eth0 signal -s io-rack-1 --allow-nothing -o json
{
"error": {
"kind": "policy_denied",
"code": "policy_denied",
"message": "DCP Signal: dcp: set Control/Signal: profinet: not allowed by the local allow-list; nothing was sent",
"reason": "policy_denied",
"operation": "dcp-set",
"block": "Control/Signal",
"target": {
"station": "io-rack-1",
"mac": "00:0e:cf:12:34:56",
"ip": "192.168.0.10"
}
}
}
```

## Connecting as IO-Controller

Expand Down Expand Up @@ -198,6 +252,7 @@ $ sudo profinetctl -i eth0 connect -s io-rack-1 --gsdml device.xml --plug 3=0x30
| 9 | permission: the host denies raw Ethernet access |
| 10 | output or internal error |
| 11 | not found: no device answers to the station name |
| 12 | policy denied: the allow-list (`--allow-*`) refused a request; nothing was sent |
| 130 | interrupted (Ctrl-C) before a result |

Details in [docs/exitcodes.md](docs/exitcodes.md).
Expand Down
48 changes: 48 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,54 @@ ending with a `---` line and no `---` line inside a section

---

## v0.23.0

**Date:** 2026-12-01
**Previous release:** v0.22.3

profinetctl exposes go-profinet's allow-list (engineering policy 1.7,
SEC-R02): what profinetctl may send, checked before anything is sent.
Still built on go-profinet v0.28.0. Without the new flags nothing
changes: there is no allow-list, and the commands send what they sent
before.

### Added

- **Allow-list flags** (global): `--allow-operation` (go-profinet's
operation classes `connect`, `read`, `read-implicit`, `write`,
`prm-begin`, `prm-end`, `other-control`, `dcp-set`; repeatable),
`--allow-read-index` and `--allow-write-index` (record index ranges
`FIRST-LAST`), `--allow-dcp-block` (DCP Set blocks such as
`Device/NameOfStation`), `--allow-list-file` (the same as a JSON file)
and `--allow-nothing`. They set `controller.Allowlist` on the
controller of the AR commands and on the record clients, and the
`dcp.SetAllowlist` go-profinet's controller derives from it on the DCP
requester of `name set`, `ip set`, `signal` and `reset`. DCP Identify
and Get, LLDP, Release and what belongs to an established AR are not
covered (go-profinet SECURITY.md, "What a controller may send"); the
README's "Allow-list" section lists what each command needs.
- **An empty allow-list allows nothing**, as in go-profinet, and only
`--allow-nothing` gives one: an `--allow-list-file` without operations
is refused (exit 3), and so is an index range or a DCP block whose
operation the list does not allow (exit 2 with the flags, 3 in a file).

### Exit codes and JSON output

- **New exit code `12`** (kind and code `policy_denied`): the allow-list
refused a request; nothing of it was sent, and an AR command attempted
no AR. The JSON error object adds `"reason": "policy_denied"`,
`operation`, `record` (`api`, `slot`, `subslot`, `index`) or `block`,
and `target` (`station`, `mac`, `ip`). A command whose result has
several parts (`device info`, `status`, I&M1–4 of `im read`,
`topology`, `topology check`) reports a refused part as a part that
failed (exit 7). The other codes are unchanged (docs/exitcodes.md,
docs/json-output.md).
- A malformed allow-list flag or file is invalid input (exit 3:
`invalid_input`, `input_file_open_failed`); a combination the flags
exclude is a usage error (exit 2: `invalid_flag_combination`).

---

## v0.22.3

**Date:** 2026-11-30
Expand Down
4 changes: 4 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ Read-only commands (`discover`, `identify`, `name get`, `ip get`, `record read`,

A command that names a device with `--station` acts only on a device whose answer carries that station name. When more than 4096 devices answer the DCP Identify of that lookup, the station cannot be told apart: the command sends nothing more and exits 6 (`duplicate_station_name`). Above 4096 answers, `discover` and `topology` show the devices of the first 4096, marked truncated (exit code 7). `topology` reads only the devices whose IP address lies in a subnet of the interface (`--read-any-address` reads the others too), and its reads end after 2 × `--timeout`.

### Restricting what profinetctl sends

The `--allow-*` flags (README, "Allow-list") give profinetctl go-profinet's allow-list: the operation classes, record index ranges and DCP Set blocks it may send. A request outside it is refused before it is sent (exit code 12). It is a local restriction of the tool, for a script or an operator that should only read, or only name devices: it authenticates nobody, does not protect a device from anyone else on the network, and does not cover DCP Identify and Get, LLDP, Release or the cyclic data of an AR it allowed. Without the flags there is no allow-list.

### Privileges

profinetctl needs raw Ethernet access (root, CAP_NET_RAW, `/dev/bpf*` or Npcap). Prefer granting the capability to the binary (`setcap cap_net_raw,cap_net_admin+ep`) over running it as root, and do not grant it on shared hosts.
Expand Down
Loading
Loading