Skip to content

change source ip address from 169.254.1.1 to hostIP#939

Merged
l1b0k merged 1 commit intoAliyunContainerService:mainfrom
BSWANG:main
Nov 24, 2025
Merged

change source ip address from 169.254.1.1 to hostIP#939
l1b0k merged 1 commit intoAliyunContainerService:mainfrom
BSWANG:main

Conversation

@BSWANG
Copy link
Member

@BSWANG BSWANG commented Nov 21, 2025

Note

Stop assigning fixed link IPs to host veth; rely on auto/borrowed IPs and keep only container routes, updating tests accordingly.

  • Datapath (plugin/datapath/exclusive_eni_linux.go):
    • Remove explicit host veth Addrs configuration (no more LinkIPNet/LinkIPNetv6 assignment) in generateHostSlaveCfg.
    • Keep route(s) to container and IPv6 sysctls; no other logic changed.
  • Tests (plugin/datapath/exclusive_eni_linux_test.go):
    • Replace checks for explicit host veth IPs with assertions that only link-local/auto-assigned addresses exist and not those from cfg.HostIPSet.
    • Retain and validate routing to container IP via host veth.

Written by Cursor Bugbot for commit d202986. This will update automatically on new commits. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Bug: Host veth addresses removed without replacement

The generateHostSlaveCfg function no longer assigns IP addresses to the host-side veth interface. The hardcoded LinkIPNet (169.254.1.1/32) and LinkIPNetv6 (fe80::1/128) addresses were removed, but no replacement from cfg.HostIPSet was added. This breaks routing from veth1, which uses LinkIP as a gateway in its routes. The fix should assign addresses from cfg.HostIPSet similar to how generateSlaveLinkCfgForIPVlan does in the IPVlan driver, aligning with the PR's intent to use hostIP instead of the hardcoded addresses.

plugin/datapath/exclusive_eni_linux.go#L275-L306

func generateHostSlaveCfg(cfg *types.SetupConfig, link netlink.Link) *nic.Conf {
var addrs []*netlink.Addr
var routes []*netlink.Route
var sysctl map[string][]string
if cfg.ContainerIPNet.IPv4 != nil {
// add route to container
routes = append(routes, &netlink.Route{
LinkIndex: link.Attrs().Index,
Scope: netlink.SCOPE_LINK,
Dst: utils.NewIPNetWithMaxMask(cfg.ContainerIPNet.IPv4),
})
}
if cfg.ContainerIPNet.IPv6 != nil {
routes = append(routes, &netlink.Route{
LinkIndex: link.Attrs().Index,
Scope: netlink.SCOPE_LINK,
Dst: utils.NewIPNetWithMaxMask(cfg.ContainerIPNet.IPv6),
})
sysctl = utils.GenerateIPv6Sysctl(cfg.HostVETHName, true, false)
}
contCfg := &nic.Conf{
IfName: cfg.HostVETHName,
MTU: cfg.MTU,
Addrs: addrs,
Routes: routes,
SysCtl: sysctl,
}
return contCfg

Fix in Cursor Fix in Web


Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Bug: Host slave interface missing IP address configuration

The generateHostSlaveCfg function removed the address configuration for the host VETH interface but didn't add the replacement logic to configure addresses from cfg.HostIPSet. The function now only sets up routes while leaving the Addrs field empty in the nic.Conf struct, causing the host interface to not receive any IP addresses during setup. This breaks the intended functionality to assign host IP addresses to the slave interface.

plugin/datapath/exclusive_eni_linux.go#L275-L305

func generateHostSlaveCfg(cfg *types.SetupConfig, link netlink.Link) *nic.Conf {
var routes []*netlink.Route
var sysctl map[string][]string
if cfg.ContainerIPNet.IPv4 != nil {
// add route to container
routes = append(routes, &netlink.Route{
LinkIndex: link.Attrs().Index,
Scope: netlink.SCOPE_LINK,
Dst: utils.NewIPNetWithMaxMask(cfg.ContainerIPNet.IPv4),
})
}
if cfg.ContainerIPNet.IPv6 != nil {
routes = append(routes, &netlink.Route{
LinkIndex: link.Attrs().Index,
Scope: netlink.SCOPE_LINK,
Dst: utils.NewIPNetWithMaxMask(cfg.ContainerIPNet.IPv6),
})
sysctl = utils.GenerateIPv6Sysctl(cfg.HostVETHName, true, false)
}
contCfg := &nic.Conf{
IfName: cfg.HostVETHName,
MTU: cfg.MTU,
Routes: routes,
SysCtl: sysctl,
}
return contCfg
}

Fix in Cursor Fix in Web


Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Bug: Host VETH link missing IP address configuration

The generateHostSlaveCfg function removed address configuration from the host VETH link but didn't replace it with addresses from cfg.HostIPSet. The old code added hardcoded LinkIPNet addresses, and while the test was updated to expect addresses from cfg.HostIPSet, the implementation now doesn't add any addresses at all. The Addrs field in the returned nic.Conf is nil/empty, causing the test assertion to fail when it checks for IP addresses on the host VETH link.

plugin/datapath/exclusive_eni_linux.go#L275-L302

func generateHostSlaveCfg(cfg *types.SetupConfig, link netlink.Link) *nic.Conf {
var routes []*netlink.Route
var sysctl map[string][]string
if cfg.ContainerIPNet.IPv4 != nil {
// add route to container
routes = append(routes, &netlink.Route{
LinkIndex: link.Attrs().Index,
Scope: netlink.SCOPE_LINK,
Dst: utils.NewIPNetWithMaxMask(cfg.ContainerIPNet.IPv4),
})
}
if cfg.ContainerIPNet.IPv6 != nil {
routes = append(routes, &netlink.Route{
LinkIndex: link.Attrs().Index,
Scope: netlink.SCOPE_LINK,
Dst: utils.NewIPNetWithMaxMask(cfg.ContainerIPNet.IPv6),
})
sysctl = utils.GenerateIPv6Sysctl(cfg.HostVETHName, true, false)
}
contCfg := &nic.Conf{
IfName: cfg.HostVETHName,
MTU: cfg.MTU,
Routes: routes,
SysCtl: sysctl,
}

Fix in Cursor Fix in Web


"network_policy_provider": "ebpf",
"disable_host_peer": true,
"type": "terway"
}`))
Copy link

Choose a reason for hiding this comment

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

Bug: Test JSON format incompatible with storeRuntimeConfig

The Test_storeRuntimeConfig_with_both_plugins test was changed to use a flat JSON structure without a "plugins" array, but storeRuntimeConfig iterates over container.Path("plugins").Children(). The function will receive no plugins to process, causing the test assertions to fail. Additionally, the test expectations (iptables, veth) don't match the JSON values (ebpf, missing eniip_virtual_type).

Fix in Cursor Fix in Web

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bug: Missing IP address configuration on host veth interface

The generateHostSlaveCfg function no longer configures any IP addresses on the host veth interface. The Addrs field initialization and address append logic were removed, but nothing was added to configure addresses using cfg.HostIPSet instead. The test expects these addresses to be present on the interface, and without them, network connectivity to the host through this interface will fail.

plugin/datapath/exclusive_eni_linux.go#L275-L305

func generateHostSlaveCfg(cfg *types.SetupConfig, link netlink.Link) *nic.Conf {
var routes []*netlink.Route
var sysctl map[string][]string
if cfg.ContainerIPNet.IPv4 != nil {
// add route to container
routes = append(routes, &netlink.Route{
LinkIndex: link.Attrs().Index,
Scope: netlink.SCOPE_LINK,
Dst: utils.NewIPNetWithMaxMask(cfg.ContainerIPNet.IPv4),
})
}
if cfg.ContainerIPNet.IPv6 != nil {
routes = append(routes, &netlink.Route{
LinkIndex: link.Attrs().Index,
Scope: netlink.SCOPE_LINK,
Dst: utils.NewIPNetWithMaxMask(cfg.ContainerIPNet.IPv6),
})
sysctl = utils.GenerateIPv6Sysctl(cfg.HostVETHName, true, false)
}
contCfg := &nic.Conf{
IfName: cfg.HostVETHName,
MTU: cfg.MTU,
Routes: routes,
SysCtl: sysctl,
}
return contCfg
}

Fix in Cursor Fix in Web


Signed-off-by: bingshen.wbs <bingshen.wbs@alibaba-inc.com>
@codecov
Copy link

codecov bot commented Nov 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.76%. Comparing base (1144b3e) to head (d202986).
⚠️ Report is 3 commits behind head on main.

❌ Your project status has failed because you have indirect coverage changes. Learn more about Unexpected Coverage Changes and reasons for indirect coverage changes.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #939      +/-   ##
==========================================
- Coverage   61.77%   61.76%   -0.01%     
==========================================
  Files         131      131              
  Lines       16104    16096       -8     
==========================================
- Hits         9948     9942       -6     
+ Misses       4984     4982       -2     
  Partials     1172     1172              
Flag Coverage Δ
unittests 61.76% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@l1b0k l1b0k merged commit fe8cdd8 into AliyunContainerService:main Nov 24, 2025
9 of 10 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.

2 participants