Skip to content

Conversation

mugeshsp
Copy link

@mugeshsp mugeshsp commented Sep 29, 2025

Reason for Change:
Enables dual NIC feature support in Azure Container Networking by adding the ability to skip default routes and improving ARP proxy configuration for transparent VLAN clients. This enhancement allows for better network isolation and custom routing scenarios in multi-interface container environments.

Requirements:

Notes:
This PR includes three main commits:

  1. Added SkipDefaultRoutes field to network container request/response contracts
  2. Implemented ARP proxy setting and custom subnet route addition for VLAN interfaces

@mugeshsp mugeshsp requested review from a team as code owners September 29, 2025 16:53
@Copilot Copilot AI review requested due to automatic review settings September 29, 2025 16:53
@mugeshsp mugeshsp requested a review from a team as a code owner September 29, 2025 16:53
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enables dual NIC support in transparent VLAN by adding the ability to skip default routes and improving ARP proxy configuration for transparent VLAN clients. This enhancement allows for better network isolation and custom routing scenarios in multi-interface container environments.

  • Added SkipDefaultRoutes field to network container request/response contracts
  • Implemented ARP proxy setting and custom subnet route addition for VLAN interfaces
  • Enabled dual NIC feature support on Linux platform

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
network/transparent_vlan_endpointclient_linux.go Added ARP proxy configuration and custom routing logic with SkipDefaultRoutes support
cns/restserver/util.go Propagated SkipDefaultRoutes field in network container responses and IP configuration
cns/NetworkContainerContract.go Added SkipDefaultRoutes field to request/response contracts and updated string representation
cni/network/network_linux.go Enabled dual NIC feature support for Linux platform
cni/network/multitenancy.go Added SkipDefaultRoutes field to interface info configuration

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +405 to +406
cmd := fmt.Sprintf("echo 1 > /proc/sys/net/ipv4/conf/%v/proxy_arp", ifName)
_, err := client.plClient.ExecuteRawCommand(cmd)
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

Using shell command execution with string formatting could be vulnerable to command injection if ifName contains malicious characters. Consider using a safer approach or validating the interface name against a whitelist of allowed characters.

Copilot uses AI. Check for mistakes.

// Route 2: default via 169.254.2.1 dev <linkToName>
func (client *TransparentVlanEndpointClient) addCustomRoutes(linkToName string, gatewayIP net.IP, subnetCIDR net.IPNet, table int) error {
// Add route for virtualgwip (ip route add <gatewayIP> dev <linkToName>)
gWIP, gwNet, _ := net.ParseCIDR(gatewayIP.String() + "/32")
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

Error values from net.ParseCIDR are being ignored. These parsing operations could fail and should be handled to prevent potential runtime panics or incorrect network configuration.

Suggested change
gWIP, gwNet, _ := net.ParseCIDR(gatewayIP.String() + "/32")
gWIP, gwNet, err := net.ParseCIDR(gatewayIP.String() + "/32")
if err != nil {
return errors.Wrapf(err, "failed to parse CIDR for gatewayIP %s", gatewayIP.String())
}

Copilot uses AI. Check for mistakes.

@mugeshsp mugeshsp requested review from QxBytes and tamilmani1989 and removed request for QxBytes September 30, 2025 16:18
return errors.Wrap(err, "failed container ns add custom routes")
}
return nil
} else {
Copy link
Member

Choose a reason for hiding this comment

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

can remove else

Copy link
Author

Choose a reason for hiding this comment

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

Removed else

return errors.Wrap(err, "failed container ns add default routes")
if epInfo.SkipDefaultRoutes {
logger.Info("Skipping adding default routes in container ns as requested")
if err := client.addCustomRoutes(client.containerVethName, epInfo.Subnets[0].Gateway, epInfo.Subnets[0].Prefix, 0); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

i think we decided not to add any custom routes. let the orchestrator add it

Copy link
Author

Choose a reason for hiding this comment

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

Removed addition of custom routes.

Comment on lines 407 to 412
if err != nil {
logger.Error("Failed to set ARP proxy", zap.String("interface", ifName), zap.Error(err))
} else {
logger.Info("ARP proxy enabled", zap.String("interface", ifName))
}
return err
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if err != nil {
logger.Error("Failed to set ARP proxy", zap.String("interface", ifName), zap.Error(err))
} else {
logger.Info("ARP proxy enabled", zap.String("interface", ifName))
}
return err
if err != nil {
logger.Error("Failed to set ARP proxy", zap.String("interface", ifName), zap.Error(err))
return err
}
return nil

Copy link
Author

Choose a reason for hiding this comment

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

Updated

@tamilmani1989
Copy link
Member

@mugeshsp please fix lint errors

@mugeshsp mugeshsp force-pushed the mugeshsp/pg-dual-nic branch from 850cadc to 6fde3f8 Compare October 6, 2025 11:02
@mugeshsp
Copy link
Author

mugeshsp commented Oct 6, 2025

@microsoft-github-policy-service agree company="Microsoft"

@mugeshsp
Copy link
Author

mugeshsp commented Oct 6, 2025

@mugeshsp please fix lint errors

Fixed the lint errors

Comment on lines 425 to 430
if err := client.setArpProxy(client.vnetVethName); err != nil {
logger.Error("setArpProxy failed with", zap.Error(err))
return err
}

return nil
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if err := client.setArpProxy(client.vnetVethName); err != nil {
logger.Error("setArpProxy failed with", zap.Error(err))
return err
}
return nil
return client.setArpProxy(client.vnetVethName)

Copy link
Author

Choose a reason for hiding this comment

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

Updated

@paulyufan2 paulyufan2 enabled auto-merge October 9, 2025 16:08
@paulyufan2
Copy link
Contributor

/azp run Azure Container Networking PR

Copy link

Azure Pipelines successfully started running 1 pipeline(s).


func platformInit(cniConfig *cni.NetworkConfig) {}

// isDualNicFeatureSupported returns if the dual nic feature is supported. Currently it's only supported for windows hnsv2 path
Copy link
Contributor

@QxBytes QxBytes Sep 30, 2025

Choose a reason for hiding this comment

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

nit: could you also update the comment here if linux now supports dual nic?

}

// Set ARP proxy on the vlan interface to respond to ARP requests for the gateway IP
func (client *TransparentVlanEndpointClient) setArpProxy(ifName string) error {
Copy link
Contributor

@QxBytes QxBytes Sep 30, 2025

Choose a reason for hiding this comment

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

nit: for the comment, the function itself is not necessarily on the vlan interface, just whatever interface is passed in

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.

4 participants