Skip to content

[caclmgrd] Own the dhcp_server docker0 syslog INPUT exception#412

Merged
Xichen96 merged 1 commit into
sonic-net:masterfrom
Xichen96:dev/xichenlin/caclmgrd-own-dhcp-server-syslog
Jul 22, 2026
Merged

[caclmgrd] Own the dhcp_server docker0 syslog INPUT exception#412
Xichen96 merged 1 commit into
sonic-net:masterfrom
Xichen96:dev/xichenlin/caclmgrd-own-dhcp-server-syslog

Conversation

@Xichen96

@Xichen96 Xichen96 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Why I did it

dhcp_server is the only bridge-mode container, so its syslog reaches host rsyslog over docker0. caclmgrd flushes and rebuilds the INPUT chain on every control-plane ACL change and appends a catch-all DROP, which drops that syslog traffic. The dhcp_server container script used to add/remove this docker0 ACCEPT exception itself, but caclmgrd wiped it on the next rebuild.

Container-to-host syslog forwarding uses RELP over tcp/2514 (since sonic-net/sonic-buildimage#18113), so the exception is for tcp/2514. The RELP connection is initiated by the container, so its inbound SYN is a new connection that caclmgrd's conntrack ESTABLISHED,RELATED accept does not cover — it needs an explicit ACCEPT or the RELP session never opens.

Fixes sonic-net/sonic-buildimage#27584.

This is step 2 of 3:

  1. [dhcp_server] Revert container-side docker0 syslog iptables add/del (#26637); caclmgrd to own the rule sonic-buildimage#28328 (merged) removed the old container-side add/del of the rule.
  2. This PR makes caclmgrd own the rule.
  3. [dhcp_server] Wait for caclmgrd-owned docker0 syslog rule on start/stop sonic-buildimage#28580 adds container-side feature-gated bounded waits on the rule presence/absence.
Work item tracking
  • Microsoft ADO (number only): 38745011

How I did it

Mirror the existing REDFISH FEATURE-gated mechanism:

  • Seed DhcpServerSyslogAllowed from FEATURE|dhcp_server state at init.
  • Re-emit the docker0/2514 ACCEPT rule on every rebuild while enabled, before any catch-all DROP (host namespace / IPv4 only). On feature-disable the rule is simply not re-emitted, so the next rebuild removes it.
  • Generalize the shared FEATURE-table subscriber handler (handle_redfish_feature_events -> handle_feature_state_events) to drain both redfish and dhcp_server keys in the one loop (a second popper would steal events from the redfish handling).

The rule string is byte-identical to the container-side -C check so the container can wait on presence/absence in the follow-up PR.

How to verify it

  • New unit test tests/caclmgrd/caclmgrd_dhcp_server_syslog_test.py covers: init seeding from FEATURE, rule present when enabled / absent when disabled, rule strictly before the catch-all DROP, host-namespace-only, and the FEATURE-event handler transitions.
  • Existing tests/caclmgrd/caclmgrd_redfish_acl_test.py updated for the renamed handler and still passes.
Hardware validation

Validated by manually hand-patching this caclmgrd change onto a running DUT (no image rebuild).

  • DUT / topology: bjw-can-720dt-2 (720dt, mx), dhcp_server enabled.
  • Transport: RELP tcp/2514 (host rsyslogd listens on 240.127.1.1:2514, the docker0 IP).
  • Precondition: a control-plane ACL rule was configured so caclmgrd programs its catch-all -A INPUT -j DROP.

Results:

  1. Rule programmed above the catch-all DROP (feature enabled):
    3:-A INPUT -i docker0 -p tcp -m tcp --dport 2514 -m comment --comment dhcp_server_syslog -j ACCEPT
    46:-A INPUT -j DROP
    
  2. End-to-end syslog deliverydocker exec dhcp_server logger ... reached host /var/log/syslog; the docker0 ACCEPT rule showed packet hits (2 pkts / 214 B).
  3. Feature toggleconfig feature state dhcp_server disabled removes the rule; enabled re-adds it. caclmgrd logs both transitions:
    INFO caclmgrd: Disabled dhcp_server docker0 syslog control plane ACL handling
    INFO caclmgrd: Enabled  dhcp_server docker0 syslog control plane ACL handling
    
  4. Survives control-plane ACL re-walk (the root regression, sonic-buildimage#27584) — after modifying an unrelated control-plane ACL rule (forcing caclmgrd to flush + rebuild INPUT), the docker0/2514 ACCEPT rule is still present at position 3, above the catch-all DROP.

Note: this hardware validation was performed on a 202605 image (identical caclmgrd INPUT flush/rebuild + catch-all DROP path); the code change under test is the same logic being merged here.

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

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

Backported as a coordinated set with sonic-buildimage#28328 (step 1) and #28580 (step 3) so the branch is never left with neither the container nor caclmgrd owning the rule.
Tracking issue/work item for backport/cherry-pick request (GitHub issue or Microsoft ADO): Microsoft ADO 38745011
Failure type: day-one issue (the container-owned docker0 syslog rule never survived a caclmgrd control-plane ACL rebuild)

Tested branch

  • master
  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511
  • 202512
  • 202605
  • 202608

Test result

  • 202605: 20260510.07 — hand-patched HW validation on bjw-can-720dt-2 (720dt, mx); see "Hardware validation" above (rule programmed above the catch-all DROP, end-to-end RELP syslog delivered, feature toggle add/remove, survives an unrelated control-plane ACL re-walk — bug #27584 fix). Unit tests tests/caclmgrd/caclmgrd_dhcp_server_syslog_test.py and the updated caclmgrd_redfish_acl_test.py pass.
  • master: validation pending — the caclmgrd code path is identical to 202605; a master-image run is the only remaining validation step.

Description for the changelog

[caclmgrd] Own the dhcp_server docker0 syslog INPUT exception so it survives the flush-and-rebuild.

@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@azure-pipelines

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

@Xichen96
Xichen96 force-pushed the dev/xichenlin/caclmgrd-own-dhcp-server-syslog branch from 64c85b3 to e8dac04 Compare July 16, 2026 12:44
@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates caclmgrd (the host-side control-plane ACL manager that flushes/rebuilds iptables) to own the dhcp_server syslog exception rule so it reliably persists across ACL rebuilds, preventing UDP/514 syslog traffic arriving via docker0 from being dropped by the catch-all INPUT DROP.

Changes:

  • Add DhcpServerSyslogAllowed feature-gated flag (seeded from FEATURE|dhcp_server at init) and re-emit the docker0/UDP 514 ACCEPT rule during host-namespace IPv4 ACL rebuilds.
  • Generalize the FEATURE-table event handler from redfish-only to handle_feature_state_events, handling both redfish and dhcp_server state transitions.
  • Add a focused unit test suite for the new dhcp_server syslog exception behavior and update the existing redfish test to use the renamed handler.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
scripts/caclmgrd Seeds/handles FEATURE.dhcp_server state and emits the host-only docker0 UDP/514 ACCEPT exception before any catch-all DROP; generalizes FEATURE event handling for redfish + dhcp_server.
tests/caclmgrd/caclmgrd_dhcp_server_syslog_test.py New unit tests validating seeding, rule presence/absence, ordering before catch-all DROP, host-namespace-only emission, and FEATURE event transitions.
tests/caclmgrd/caclmgrd_redfish_acl_test.py Updates test to call the renamed generalized FEATURE event handler.

@Xichen96

Xichen96 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

@StormLiangMS @yxieca @lguohan could you please review when you get a chance? This is step 2 of 3 (caclmgrd now owns the dhcp_server docker0 syslog INPUT exception; buildimage#28328 removed the old container-side add/del). Thanks!

@Xichen96
Xichen96 requested review from yxieca and removed request for Blueve July 16, 2026 13:11
@mssonicbld

Copy link
Copy Markdown

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

---Powered by SONiC BuildBot

@StormLiangMS StormLiangMS left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Xichen96 — the master-branch implementation looks good.

caclmgrd now owns and re-emits the feature-gated docker0 UDP/514 exception before the catch-all INPUT DROP, including correct enable/disable rebuild behavior and host-namespace-only scoping. CI is green and I found no source-branch code blocker.

For the 202605 request, the current cherry-pick conflicts because that branch does not contain the master redfish FEATURE-event infrastructure or its test. The backport needs a target-aware adaptation that adds only the dhcp_server handling, plus explicit 202605 test evidence.

@StormLiangMS
StormLiangMS requested a review from yyynini July 21, 2026 08:29
@mssonicbld

Copy link
Copy Markdown

This PR has backport request label(s) for branch(es): 202605, but is missing required test information. Please make sure you tick the tested branch(es) in the Tested branch section and provide test evidence (e.g., 202605: <test result>) in the Test result section as well in your PR description.

---Powered by SONiC BuildBot

Comment thread scripts/caclmgrd Outdated
dhcp_server is the only bridge-mode container, so its syslog reaches
host rsyslog over docker0. caclmgrd flushes and rebuilds the INPUT
chain on every control-plane ACL change, appending a catch-all DROP,
which drops that syslog traffic. Previously the dhcp_server container
script added/removed this exception itself, but caclmgrd wiped it on
the next rebuild (sonic-net/sonic-buildimage#27584).

Container-to-host syslog forwarding uses RELP over tcp/2514 (since
sonic-net/sonic-buildimage#18113), so the exception is for tcp/2514.
The connection is initiated by the container, so the inbound SYN is a
new connection that the conntrack ESTABLISHED,RELATED accept does not
cover -- it needs an explicit ACCEPT or the RELP session never opens.

Make caclmgrd own the exception, mirroring the existing REDFISH
FEATURE-gated mechanism:

- Seed DhcpServerSyslogAllowed from FEATURE|dhcp_server state at init.
- Re-emit the docker0/2514 ACCEPT rule on every rebuild while enabled,
  before any catch-all DROP (host namespace / IPv4 only). On
  feature-disable the rule is not re-emitted, so the next rebuild
  removes it.
- Generalize the shared FEATURE-table subscriber handler
  (handle_redfish_feature_events -> handle_feature_state_events) to
  drain both redfish and dhcp_server keys in the one loop; a second
  popper would steal events from the redfish handling.

The rule string is byte-identical to the container-side -C check so the
container can wait on presence/absence (follow-up PR).

Step 2 of 3 (buildimage#28328 removed the old container-side add/del;
a follow-up adds container-side waits). ADO: 38745011.

Signed-off-by: Xichen Lin <lukelin0907@gmail.com>
Signed-off-by: Xichen96 <lukelin0907@gmail.com>
@Xichen96
Xichen96 force-pushed the dev/xichenlin/caclmgrd-own-dhcp-server-syslog branch from e8dac04 to f913bf9 Compare July 22, 2026 03:54
@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

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

@yyynini yyynini left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@StormLiangMS

Copy link
Copy Markdown

hi @Xichen96 Do we have a SONiC-MGMT test that verifies this functionality? If no, pls open an issue to track it as a test gap, then we can merge this PR.

@Xichen96

Copy link
Copy Markdown
Contributor Author

Hi @StormLiangMS — thanks for the review.

There is existing sonic-mgmt coverage: tests/cacl/test_cacl_application.py::test_cacl_application asserts the full caclmgrd INPUT ruleset, including the dhcp_server docker0 syslog exception (added in #24696). Because this change moves ownership of that rule into caclmgrd and corrects the transport to RELP tcp/2514 (feature-gated on FEATURE.dhcp_server), that existing assertion needs a corresponding update.

I've opened a tracking issue for it: sonic-net/sonic-mgmt#26470.

This has been hardware-validated by manual patch on an mx (720dt) DUT: the rule is programmed above the catch-all DROP when the feature is enabled, container syslog reaches host rsyslog over tcp/2514, it toggles correctly on feature enable/disable, and it survives a control-plane ACL re-walk (the root regression in sonic-buildimage#27584). Happy to merge once you're good.

@Xichen96
Xichen96 merged commit 60775ab into sonic-net:master Jul 22, 2026
6 checks passed
@Xichen96 Xichen96 added the Tested for 202605 branch Tested for 202605 branch label Jul 22, 2026
@mssonicbld

Copy link
Copy Markdown

The change is not in 202605 yet. @Xichen96, please manually create the cherry pick PR for branch 202605.
You can ping the release branch owner(github account: vaibhavhd) to approve your cherry pick PR.
If this change is already in 202605, please comment "already in 202605". Thanks!

---Powered by SONiC BuildBot

Xichen96 added a commit to sonic-net/sonic-buildimage that referenced this pull request Jul 22, 2026
Step 3 of 3 of moving the dhcp_server docker0 syslog INPUT exception
ownership to caclmgrd (fixes #27584). PR1
(#28328) removed the container-side add/del; PR2 (sonic-net/sonic-host-services#412)
made caclmgrd own the rule. This replaces the removed add/del with
feature-gated bounded waits that synchronize with caclmgrd:

- preStartAction: when FEATURE|dhcp_server is enabled, wait up to 10s for
  the docker0 tcp/2514 ACCEPT rule to be present before the container
  starts, so the RELP client's first connection is not dropped by the
  control-plane catch-all DROP.
- stop(): when FEATURE|dhcp_server is disabled, wait up to 10s for the
  rule to be removed. Plain restarts / shutdown / CONFIG_DB-down skip the
  wait (positive-state gate).

The iptables -C existence check matches the canonical stored form of the
rule caclmgrd installs (identical to `iptables -S INPUT` output), so the
wait observes the rule reliably across iptables variants.

Signed-off-by: Xichen96 <lukelin0907@gmail.com>
Xichen96 added a commit to sonic-net/sonic-buildimage that referenced this pull request Jul 22, 2026
Step 3 of 3 of moving the dhcp_server docker0 syslog INPUT exception
ownership to caclmgrd (fixes #27584). PR1
(#28328) removed the container-side add/del; PR2 (sonic-net/sonic-host-services#412)
made caclmgrd own the rule. This replaces the removed add/del with
feature-gated bounded waits that synchronize with caclmgrd:

- preStartAction: when FEATURE|dhcp_server is enabled, wait up to 10s for
  the docker0 tcp/2514 ACCEPT rule to be present before the container
  starts, so the RELP client's first connection is not dropped by the
  control-plane catch-all DROP.
- stop(): when FEATURE|dhcp_server is disabled, wait up to 10s for the
  rule to be removed. Plain restarts / shutdown / CONFIG_DB-down skip the
  wait (positive-state gate).

The iptables -C existence check matches the canonical stored form of the
rule caclmgrd installs (identical to `iptables -S INPUT` output), so the
wait observes the rule reliably across iptables variants.

Signed-off-by: Xichen96 <lukelin0907@gmail.com>
Xichen96 added a commit to sonic-net/sonic-mgmt that referenced this pull request Jul 22, 2026
The dhcp_server docker0 syslog INPUT exception changed from UDP 514 to
RELP over tcp/2514, and its ownership moved from the container
start/stop script to caclmgrd, which re-installs it on every
control-plane ACL flush-and-rebuild while FEATURE|dhcp_server is enabled
(sonic-net/sonic-buildimage#28328, sonic-net/sonic-host-services#412,
sonic-net/sonic-buildimage#28580; fixes sonic-net/sonic-buildimage#27584).

Update generate_expected_rules() to assert the tcp/2514 exception
instead of the old udp/514 rule, and gate the expectation on the
FEATURE|dhcp_server state that caclmgrd keys on (read via sonic-db-cli),
rather than on mere container presence.

Signed-off-by: Xichen Lin <lukelin0907@gmail.com>
Xichen96 added a commit to sonic-net/sonic-mgmt that referenced this pull request Jul 22, 2026
The dhcp_server docker0 syslog INPUT exception changed from UDP 514 to
RELP over tcp/2514, and its ownership moved from the container
start/stop script to caclmgrd, which re-installs it on every
control-plane ACL flush-and-rebuild while FEATURE|dhcp_server is enabled
(sonic-net/sonic-buildimage#28328, sonic-net/sonic-host-services#412,
sonic-net/sonic-buildimage#28580; fixes sonic-net/sonic-buildimage#27584).

Update generate_expected_rules() to assert the tcp/2514 exception
instead of the old udp/514 rule, and gate the expectation on the
FEATURE|dhcp_server state that caclmgrd keys on (read via sonic-db-cli),
rather than on mere container presence.

Signed-off-by: Xichen Lin <lukelin0907@gmail.com>
Xichen96 added a commit to sonic-net/sonic-mgmt that referenced this pull request Jul 22, 2026
Add test_caclmgrd_dhcp_server_syslog verifying the docker0 RELP tcp/2514
INPUT exception that caclmgrd now owns (sonic-net/sonic-buildimage#28328,
sonic-net/sonic-host-services#412, sonic-net/sonic-buildimage#28580;
fixes sonic-net/sonic-buildimage#27584):

  * present above the control-plane catch-all DROP while
    FEATURE|dhcp_server is enabled,
  * survives a control-plane ACL flush-and-rebuild (forced via the
    dummy_acl_rules fixture / acl-loader), and
  * removed on feature-disable and restored on feature-enable.

The test skips when dhcp_server is not enabled on the DUT.

Signed-off-by: Xichen Lin <lukelin0907@gmail.com>
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: CACL updates remove dhcp_server syslog iptables rule

6 participants