Skip to content

Commit

Permalink
Multi-ip fixes. (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
edwarnicke authored May 9, 2021
1 parent f304658 commit b81f895
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
github.com/thanhpk/randstr v1.0.4
github.com/vishvananda/netlink v1.1.0
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df
golang.org/x/sys v0.0.0-20200610111108-226ff32320da
google.golang.org/grpc v1.35.0
google.golang.org/protobuf v1.25.0
)
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/networkservicemesh/sdk/pkg/tools/log"
"github.com/pkg/errors"
"github.com/vishvananda/netlink"
"golang.org/x/sys/unix"

"github.com/networkservicemesh/sdk-vpp/pkg/tools/mechutils"
)
Expand Down Expand Up @@ -57,9 +58,18 @@ func create(ctx context.Context, conn *networkservice.Connection, isClient bool)

for _, ipNet := range ipNets {
now := time.Now()
if err := handle.AddrReplace(l, &netlink.Addr{
addr := &netlink.Addr{
IPNet: ipNet,
}); err != nil {
}
// Turns out IPv6 uses Duplicate Address Detection (DAD) which
// we don't need here and which can cause it to take more than a second
// before anything *works* (even though the interface is up). This causes
// cryptic error messages. To avoid, we use the flag to disable DAD for
// any IPv6 addresses.
if ipNet != nil && ipNet.IP.To4() == nil {
addr.Flags |= unix.IFA_F_NODAD
}
if err := handle.AddrReplace(l, addr); err != nil {
return err
}
log.FromContext(ctx).
Expand Down
16 changes: 10 additions & 6 deletions pkg/networkservice/xconnect/l3xconnect/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,6 @@ func l3xcUpdate(fromSwIfIndex, toIfIndex interface_types.InterfaceIndex, nextHop
L3xc: l3xc.L3xc{
SwIfIndex: fromSwIfIndex,
IsIP6: isIP6,
NPaths: 1,
Paths: []fib_types.FibPath{
{
SwIfIndex: uint32(toIfIndex),
},
},
},
}
for _, nh := range nextHops {
Expand All @@ -121,9 +115,14 @@ func l3xcUpdate(fromSwIfIndex, toIfIndex interface_types.InterfaceIndex, nextHop
if isIP6 && nh.IP.To4() != nil {
continue
}
proto := fib_types.FIB_API_PATH_NH_PROTO_IP4
if isIP6 {
proto = fib_types.FIB_API_PATH_NH_PROTO_IP6
}
rv.L3xc.NPaths++
rv.L3xc.Paths = append(rv.L3xc.Paths, fib_types.FibPath{
SwIfIndex: uint32(toIfIndex),
Proto: proto,
Nh: fib_types.FibPathNh{
Address: types.ToVppAddress(nh.IP).Un,
},
Expand All @@ -132,9 +131,14 @@ func l3xcUpdate(fromSwIfIndex, toIfIndex interface_types.InterfaceIndex, nextHop
}
if rv.L3xc.NPaths == 0 {
rv.L3xc.NPaths = 1
proto := fib_types.FIB_API_PATH_NH_PROTO_IP4
if isIP6 {
proto = fib_types.FIB_API_PATH_NH_PROTO_IP6
}
rv.L3xc.Paths = []fib_types.FibPath{
{
SwIfIndex: uint32(toIfIndex),
Proto: proto,
},
}
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/networkservice/xconnect/l3xconnect/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ func NewServer(vppConn api.Connection) networkservice.NetworkServiceServer {
}

func (v *l3XconnectServer) Request(ctx context.Context, request *networkservice.NetworkServiceRequest) (*networkservice.Connection, error) {
if request.GetConnection().GetPayload() != payload.IP {
return next.Server(ctx).Request(ctx, request)
}
conn, err := next.Server(ctx).Request(ctx, request)
if err != nil {
return nil, err
Expand Down

0 comments on commit b81f895

Please sign in to comment.