Skip to content

Commit

Permalink
Make vxlan port configurable
Browse files Browse the repository at this point in the history
networkservicemesh/sdk commit message:
Make vxlan port configurable (see networkservicemesh/sdk#1091)

Signed-off-by: Zoltan Lugossy <zoltan.lugossy@est.tech>
  • Loading branch information
zolug committed Sep 29, 2021
1 parent c723379 commit 40672c0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
6 changes: 3 additions & 3 deletions pkg/networkservice/chains/xconnectns/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type xconnectNSServer struct {
}

// NewServer - returns an implementation of the xconnectns network service
func NewServer(ctx context.Context, name string, authzServer networkservice.NetworkServiceServer, tokenGenerator token.GeneratorFunc, clientURL *url.URL, vppConn Connection, tunnelIP net.IP, clientDialOptions ...grpc.DialOption) endpoint.Endpoint {
func NewServer(ctx context.Context, name string, authzServer networkservice.NetworkServiceServer, tokenGenerator token.GeneratorFunc, clientURL *url.URL, vppConn Connection, tunnelIP net.IP, tunnelPort uint16, clientDialOptions ...grpc.DialOption) endpoint.Endpoint {
rv := &xconnectNSServer{}
additionalFunctionality := []networkservice.NetworkServiceServer{
recvfd.NewServer(),
Expand All @@ -86,7 +86,7 @@ func NewServer(ctx context.Context, name string, authzServer networkservice.Netw
mechanisms.NewServer(map[string]networkservice.NetworkServiceServer{
memif.MECHANISM: memif.NewServer(vppConn, memif.WithDirectMemif()),
kernel.MECHANISM: kernel.NewServer(vppConn),
vxlan.MECHANISM: vxlan.NewServer(vppConn, tunnelIP),
vxlan.MECHANISM: vxlan.NewServer(vppConn, tunnelIP, tunnelPort),
wireguard.MECHANISM: wireguard.NewServer(vppConn, tunnelIP),
}),
pinhole.NewServer(vppConn),
Expand All @@ -104,7 +104,7 @@ func NewServer(ctx context.Context, name string, authzServer networkservice.Netw
// mechanisms
memif.NewClient(vppConn),
kernel.NewClient(vppConn),
vxlan.NewClient(vppConn, tunnelIP),
vxlan.NewClient(vppConn, tunnelIP, tunnelPort),
wireguard.NewClient(vppConn, tunnelIP),
pinhole.NewClient(vppConn),
recvfd.NewClient(),
Expand Down
4 changes: 2 additions & 2 deletions pkg/networkservice/mechanisms/vxlan/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ type vxlanClient struct {
}

// NewClient - returns a new client for the vxlan remote mechanism
func NewClient(vppConn api.Connection, tunnelIP net.IP) networkservice.NetworkServiceClient {
func NewClient(vppConn api.Connection, tunnelIP net.IP, tunnelPort uint16) networkservice.NetworkServiceClient {
return chain.NewNetworkServiceClient(
&vxlanClient{
vppConn: vppConn,
},
mtu.NewClient(vppConn, tunnelIP),
vni.NewClient(tunnelIP),
vni.NewClient(tunnelIP, tunnelPort),
)
}

Expand Down
9 changes: 4 additions & 5 deletions pkg/networkservice/mechanisms/vxlan/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ func addDel(ctx context.Context, conn *networkservice.Connection, vppConn api.Co
if isClient {
port = mechanism.SrcPort()
}
if port != vxlanDefaultPort {
return errors.Errorf("vxlan only supports port %d not port %d", vxlanDefaultPort, port)
}
_, ok := ifindex.Load(ctx, isClient)
if isAdd && ok {
return nil
Expand Down Expand Up @@ -75,19 +72,21 @@ func addDel(ctx context.Context, conn *networkservice.Connection, vppConn api.Co
WithField("vppapi", "AddNodeNext").Debug("completed")

now = time.Now()
vxlanAddDelTunnel := &vxlan.VxlanAddDelTunnel{
vxlanAddDelTunnel := &vxlan.VxlanAddDelTunnelV2{
IsAdd: isAdd,
Instance: ^uint32(0),
SrcAddress: types.ToVppAddress(mechanism.SrcIP()),
DstAddress: types.ToVppAddress(mechanism.DstIP()),
DecapNextIndex: addNextNodeRsp.NextIndex,
Vni: mechanism.VNI(),
SrcPort: port,
DstPort: port,
}
if !isClient {
vxlanAddDelTunnel.SrcAddress = types.ToVppAddress(mechanism.DstIP())
vxlanAddDelTunnel.DstAddress = types.ToVppAddress(mechanism.SrcIP())
}
rsp, err := vxlan.NewServiceClient(vppConn).VxlanAddDelTunnel(ctx, vxlanAddDelTunnel)
rsp, err := vxlan.NewServiceClient(vppConn).VxlanAddDelTunnelV2(ctx, vxlanAddDelTunnel)
if err != nil {
return errors.WithStack(err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/networkservice/mechanisms/vxlan/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ type vxlanServer struct {
}

// NewServer - returns a new server for the vxlan remote mechanism
func NewServer(vppConn api.Connection, tunnelIP net.IP) networkservice.NetworkServiceServer {
func NewServer(vppConn api.Connection, tunnelIP net.IP, tunnelPort uint16) networkservice.NetworkServiceServer {
return chain.NewNetworkServiceServer(
vni.NewServer(tunnelIP),
vni.NewServer(tunnelIP, tunnelPort),
mtu.NewServer(vppConn, tunnelIP),
&vxlanServer{
vppConn: vppConn,
Expand Down

0 comments on commit 40672c0

Please sign in to comment.