Skip to content

Commit

Permalink
Merge pull request #675 from nokia/ipvlan-garp
Browse files Browse the repository at this point in the history
ipvlan: Send Gratuitous ARP after IPs are set
  • Loading branch information
dcbw authored Nov 24, 2021
2 parents f1f128e + d5a6569 commit 0920090
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion plugins/main/ipvlan/ipvlan.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ import (
"encoding/json"
"errors"
"fmt"
"net"
"runtime"

"github.com/j-keck/arping"
"github.com/vishvananda/netlink"

"github.com/containernetworking/cni/pkg/skel"
Expand Down Expand Up @@ -254,7 +256,21 @@ func cmdAdd(args *skel.CmdArgs) error {
result.Interfaces = []*current.Interface{ipvlanInterface}

err = netns.Do(func(_ ns.NetNS) error {
return ipam.ConfigureIface(args.IfName, result)
if err := ipam.ConfigureIface(args.IfName, result); err != nil {
return err
}

contVeth, err := net.InterfaceByName(args.IfName)
if err != nil {
return fmt.Errorf("failed to look up %q: %v", args.IfName, err)
}

for _, ipc := range result.IPs {
if ipc.Address.IP.To4() != nil {
_ = arping.GratuitousArpOverIface(ipc.Address.IP, *contVeth)
}
}
return nil
})
if err != nil {
return err
Expand Down

0 comments on commit 0920090

Please # to comment.