Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-ip fixes. #203

Merged
merged 1 commit into from
May 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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