Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 15, 2025

Summary

This PR removes the intermediate IPSet data structures from the Windows NPM Lite datapath for CIDR blocks, enabling direct CIDR-to-HNS ACL rule translation. This optimization eliminates unnecessary IPSet creation and management for CIDR-based network policies on Windows.

Problem

Currently, Windows NPM Lite processes CIDR-based network policies through an inefficient flow:

NetworkPolicy → IPSets → HNS ACL Rules

Where IPSets are created as intermediate data structures to hold CIDR blocks before translating them to HNS rules. This creates unnecessary overhead and complexity for simple CIDR-based policies.

Solution

This PR implements a direct CIDR approach for Windows NPM Lite:

NetworkPolicy → Direct CIDR in ACL → HNS ACL Rules

Key Changes

  1. Extended SetInfo structure - Added CIDRs []string field to store direct CIDR values
  2. Modified translation layer - Updated ipBlockRule() function to bypass IPSet creation when Windows NPM Lite is enabled
  3. Enhanced ACL conversion - Updated getAddrListFromSetInfo() to return direct CIDR values instead of IPSet hashed names

Example

Before this change, HNS ACL rules referenced IPSet names:

LocalAddresses: "azure-npm-a1b2c3d4"  // IPSet hashed name

After this change, HNS ACL rules use direct CIDR values:

LocalAddresses: "192.168.1.0/24"  // Direct CIDR value

Backward Compatibility

  • Traditional Windows mode: No changes, continues using IPSets
  • Linux: Zero impact, IPSet functionality preserved
  • Windows NPM Lite: Only CIDR blocks use direct approach, other types (NamedPorts, etc.) unchanged

Testing

  • All existing tests pass (34 translation tests, 30+ policy tests)
  • New tests added specifically for Windows NPM Lite CIDR functionality
  • Verified both traditional and direct CIDR approaches work correctly

Fixes #3941.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copy link
Contributor Author

Copilot AI commented Aug 15, 2025

@rejain456 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

@Copilot Copilot AI changed the title [WIP] [Windows NPM Lite] Removing IPSets Reference from DataPath for Cidr Blocks [Windows NPM Lite] Remove IPSets reference from DataPath for CIDR blocks Aug 15, 2025
@Copilot Copilot AI requested a review from rejain456 August 15, 2025 20:36
Copilot finished work on behalf of rejain456 August 15, 2025 20:36
Copy link

This pull request is stale because it has been open for 2 weeks with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the stale Stale due to inactivity. label Aug 30, 2025
Copy link

github-actions bot commented Sep 7, 2025

Pull request closed due to inactivity.

@github-actions github-actions bot closed this Sep 7, 2025
@github-actions github-actions bot deleted the copilot/fix-3941 branch September 7, 2025 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Stale due to inactivity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Windows NPM Lite] Removing IPSets Reference from DataPath for Cidr Blocks
2 participants