Skip to content

pmon: tolerate /dev reordering and bus hot-plug#27852

Open
ashwnsri wants to merge 1 commit into
sonic-net:masterfrom
ashwnsri:pmon-dev-reorder-hotplug
Open

pmon: tolerate /dev reordering and bus hot-plug#27852
ashwnsri wants to merge 1 commit into
sonic-net:masterfrom
ashwnsri:pmon-dev-reorder-hotplug

Conversation

@ashwnsri

@ashwnsri ashwnsri commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Why I did it

Aimed at #25142

pmon runs against a fixed --device list captured at 'docker create', which breaks in two ways: a block-device partition (e.g. sda1) named in kernel probe order can disappear after a disk reorder and fail 'docker start', and a bus node that appears after create (i2c/cpld/fpga/ipmi/uio/spidev/gpiochip/mtd) is denied and invisible to the container.

How I did it

Pass reorder-invariant whole disks, pre-authorize the hot-plug device classes, and keep the container's /dev in sync at runtime. The change is strictly narrower than --privileged and adds no /dev bind-mount.

files/build_templates/docker_image_ctl.j2

  • get_pmon_device_mounts(): skip block-device partitions and pass the reorder-invariant whole disk instead.
  • get_pmon_device_cgroup_rules() (new): emit 'c :* rwm' for each hot-pluggable bus class so a sibling created after 'docker create' (e.g. an i2c bus behind a mux on optic insert) is already permitted.
  • start(): pass those rules as --device-cgroup-rule on docker create.
  • postStartAction(): call pmon-dev-bridge.sh resync to converge /dev.

files/image_config/pmon/pmon-dev-bridge.sh (new)

  • Helper that mirrors allowed character bus nodes into the running pmon container(s): 'resync' converges every allowed node on start; 'event add|remove' handles a single udev hot-plug event via mknod/rm.

files/image_config/udev/rules.d/99-pmon-dev-bridge.rules (new)

  • udev rule forwarding add/remove uevents to pmon-dev-bridge.sh so the container's device view tracks hot-plug after creation.

files/build_templates/sonic_debian_extension.j2

  • Install pmon-dev-bridge.sh to /usr/local/bin (mode 755) at image build time.

How to verify it

All checks are read-only except the dynamic-bridge demonstration, which is container-only
and fully reversible
— the host /dev is never modified. Run on a device built from /
flashed with this fix. Results: pmon-how-to-verify-it.md.

Which release branch to backport (provide reason below if selected)

  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511
  • 202605

Tested branch (Please provide the tested image version)

  • masterI20260609135544_asrinivasan

Description for the changelog

pmon: tolerate /dev reordering and bus hot-plug (fixes #25142)

Aimed at sonic-net#25142

pmon runs against a fixed --device list captured at 'docker create',
which breaks in two ways: a block-device partition (e.g. sda1) named in
kernel probe order can disappear after a disk reorder and fail
'docker start', and a bus node that appears after create
(i2c/cpld/fpga/ipmi/uio/spidev/gpiochip/mtd) is denied and invisible to
the container. Pass reorder-invariant whole disks, pre-authorize the
hot-plug device classes, and keep the container's /dev in sync at
runtime. The change is strictly narrower than --privileged and adds no
/dev bind-mount.

files/build_templates/docker_image_ctl.j2
  - get_pmon_device_mounts(): skip block-device partitions and pass the
    reorder-invariant whole disk instead.
  - get_pmon_device_cgroup_rules() (new): emit 'c <major>:* rwm' for each
    hot-pluggable bus class so a sibling created after 'docker create'
    (e.g. an i2c bus behind a mux on optic insert) is already permitted.
  - start(): pass those rules as --device-cgroup-rule on docker create.
  - postStartAction(): call pmon-dev-bridge.sh resync to converge /dev.

files/image_config/pmon/pmon-dev-bridge.sh (new)
  - Helper that mirrors allowed character bus nodes into the running
    pmon container(s): 'resync' converges every allowed node on start;
    'event add|remove' handles a single udev hot-plug event via mknod/rm.

files/image_config/udev/rules.d/99-pmon-dev-bridge.rules (new)
  - udev rule forwarding add/remove uevents to pmon-dev-bridge.sh so the
    container's device view tracks hot-plug after creation.

files/build_templates/sonic_debian_extension.j2
  - Install pmon-dev-bridge.sh to /usr/local/bin (mode 755) at image
    build time.

Signed-off-by: Ashwin Srinivasan <asrinivasan@juniper.net>
@ashwnsri ashwnsri requested a review from lguohan as a code owner June 12, 2026 08:11
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@ashwnsri

Copy link
Copy Markdown
Contributor Author

/azpw retry

@mssonicbld

Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) jobs...

@mssonicbld

Copy link
Copy Markdown
Collaborator

This PR has backport request for branch(es): 202605.
Added label(s) for branch(es) 202605.

---Powered by SONiC BuildBot

@ashwnsri

Copy link
Copy Markdown
Contributor Author

/azpw retry

@mssonicbld

Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) jobs...

@ashwnsri

Copy link
Copy Markdown
Contributor Author

/azp run Azure.sonic-buildimage

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@ashwnsri ashwnsri requested a review from vvolam June 14, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: PMON missing access to necessary devices for platform monitoring post privilege removal

2 participants