Skip to content

Commit

Permalink
Ensure kernel sends GARPs to avoid communication failures (#4649)
Browse files Browse the repository at this point in the history
Signed-off-by: Cyclinder Kuo <[email protected]>
  • Loading branch information
cyclinder committed Feb 24, 2025
1 parent d794aa4 commit c835d2f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions cmd/spiderpool/cmd/command_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,30 @@ func CmdAdd(args *skel.CmdArgs) (err error) {
logger.Error(err.Error())
}

// CNI will set the interface to up, and the kernel only sends GARPs/Unsolicited NA when the interface
// goes from down to up or when the link-layer address changes on the interfaces. in order to the
// kernel send GARPs/Unsolicited NA when the interface goes from down to up.
// see https://github.com/spidernet-io/spiderpool/issues/4650
var ipRes []net.IP
for _, i := range ipamResponse.Payload.Ips {
if i.Address != nil && *i.Address != "" {
ipa, _, err := net.ParseCIDR(*i.Address)
if err != nil {
logger.Error(err.Error())
continue
}
ipRes = append(ipRes, ipa)
}
}

err = netns.Do(func(netNS ns.NetNS) error {
return networking.AnnounceIPs(logger, args.IfName, ipRes)
})

if err != nil {
logger.Error(err.Error())
}

// Assemble the result of IPAM request response.
result, err := assembleResult(conf.CNIVersion, args.IfName, ipamResponse)
if err != nil {
Expand Down

0 comments on commit c835d2f

Please sign in to comment.