Skip to content

Collect VFP rule counters in server diagnostics - #629

Merged
Debjit (mdebjit) merged 3 commits into
microsoft:mainfrom
mdebjit:fix-vfp-rule-counter-command
Sep 1, 2026
Merged

Collect VFP rule counters in server diagnostics#629
Debjit (mdebjit) merged 3 commits into
microsoft:mainfrom
mdebjit:fix-vfp-rule-counter-command

Conversation

@mdebjit

Copy link
Copy Markdown
Contributor

Description

Summary of changes:
Capture packet counters per rule along with the rule details.

The number of matched and dropped packets for each VFP rule is already being captured, but we currently do not retrieve this information. This change will include the packet counters for each rule as part of the rule details (see sample below).

Having this additional information will make it easier to debug complex datapath issues without incurring any additional overhead for recording the counters.

Before the fix:

LAYER : FW_ADMIN_LAYER_ID
    Friendly name : FW_ADMIN_LAYER
    Priority : 14

  GROUP : FW_GROUP_IPv4_IN_ID
      Friendly name : FW_GROUP_IPv4_IN
      Priority : 1
      Direction : IN
      Type : IPv4
        Conditions:
            <none>
      Match type : Priority-based match

    RULE : 418b4399-4acf-4641-9278-7bed0fc6b129
        Priority : 1000
        Flags : 8195 terminating stateful 
        Type : allow
        Conditions:
            <none>
        Flow TTL: 240
        FlagsEx : 0 

    RULE : eb952905-a8ab-4591-86b0-202cbb575cc4
        Priority : 65532
        Flags : 8195 terminating stateful 
        Type : block
        Conditions:
            <none>
        Flow TTL: 240
        FlagsEx : 0 

After the fix:

LAYER : FW_ADMIN_LAYER_ID
    Friendly name : FW_ADMIN_LAYER
    Priority : 14

  GROUP : FW_GROUP_IPv4_IN_ID
      Friendly name : FW_GROUP_IPv4_IN
      Priority : 1
      Direction : IN
      Type : IPv4
        Conditions:
            <none>
      Match type : Priority-based match

    RULE : 418b4399-4acf-4641-9278-7bed0fc6b129
        Priority : 1000
        Flags : 8195 terminating stateful 
        Type : allow
        Conditions:
            <none>
        Flow TTL: 240
        FlagsEx : 0 

      RULE COUNTER
        Matched packets : 3
        Dropped packets : 0
        Pending packets : 0
        Dropped unified flows : 0

    RULE : eb952905-a8ab-4591-86b0-202cbb575cc4
        Priority : 65532
        Flags : 8195 terminating stateful 
        Type : block
        Conditions:
            <none>
        Flow TTL: 240
        FlagsEx : 0 

      RULE COUNTER
        Matched packets : 0
        Dropped packets : 0
        Pending packets : 0
        Dropped unified flows : 0

Note for reviewers:

  • Although this change builds on existing functionality, customers with automation that depends on the current output format may be impacted.
  • The file size for capturing VFP rules will increase, as we will add approximately five lines per rule. The trade-off between the increase in file size and the improved debuggability should more than justify this change.

Change type

  • Bug fix (non-breaking change)
  • Code style update (formatting, local variables)
  • New Feature (non-breaking change that adds new functionality without impacting existing)
  • Breaking change (fix or feature that may cause functionality impact)
  • Other

Checklist:

  • My code follows the style and contribution guidelines of this project.
  • I have tested and validated my code changes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mdebjit
Debjit (mdebjit) requested a review from a team as a code owner August 26, 2026 11:55
Copilot AI balanced review requested due to automatic review settings August 26, 2026 11:55

Copilot AI 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.

Pull request overview

Collects VFP per-rule packet counters during server diagnostics.

Changes:

  • Replaces /list-rule collection with /get-rule-counter.
  • Renames the generated diagnostic artifact accordingly.
Suppressed comments (1)

src/modules/SdnDiag.Server.psm1:408

  • The central behavior change—invoking /get-rule-counter and writing the renamed artifact—has no automated coverage in tests/offline/Server.Tests.ps1, although that file provides Pester coverage for this module. Add a mocked Get-ServerConfigState test that verifies the command arguments and exported file name so a future edit cannot silently revert or omit rule-counter collection.
                    vfpctrl /get-rule-counter /port $($port.Name) | Export-ObjectToFile -FilePath $outputDir.FullName -Prefix $port.Name -Name 'vfpctrl_get_rule_counter' -FileType txt -Force

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/modules/SdnDiag.Server.psm1
Keeps the existing <port>_vfpctrl_list_rule.txt artifact so downstream
collectors continue to find rule details, making the rule counter
collection purely additive and non-breaking.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 1, 2026 12:35

Copilot AI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI review requested due to automatic review settings September 1, 2026 13:16

Copilot AI 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.

Pull request overview

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

@mdebjit
Debjit (mdebjit) merged commit a290f4a into microsoft:main Sep 1, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants