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

make dataplanes dual (internal plus external together) #9723

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
32 changes: 32 additions & 0 deletions felix/dataplane/decorator.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright © 2024 NeuReality Ltd., and its licensors. All rights reserved.
// This software contains proprietary information of NeuReality Ltd.
// You shall use such proprietary information only as may be permitted in writing by NeuReality Ltd.
// All materials contained herein are the property of NeuReality Ltd.

// THIS SOFTWARE IS PROVIDED BY NEUREALITY “AS IS” AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL NEUREALITY OR ITS LICENSORS
// BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to use the Apache license header here (similar to in the other files in the repo). You're welcome to keep your copyright line (without "All rights reserved", which is typically used when no license is provided).

Please let me know if you have any specific concerns about submitting this under the Apache 2.0 license.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matthewdupre Thank you for pointing my attention to this, I have fixed the header. I have no concerns about submitting this PR under the Apache 2.0 license.


package dataplane

type dataplaneDriverDecorator struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps?

Suggested change
type dataplaneDriverDecorator struct {
type dataplaneDriverMultiplexer struct {

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomastigera Great points, thank you! Let me rename the decorator, and return an error in case the secondary driver returns an error.

primaryDriver DataplaneDriver
secondaryDriver DataplaneDriver
}

func (decorator dataplaneDriverDecorator) SendMessage(msg interface{}) error {
decorator.secondaryDriver.SendMessage(msg)
return decorator.primaryDriver.SendMessage(msg) // return message from the primary driver only
}

func (decorator dataplaneDriverDecorator) RecvMessage() (msg interface{}, err error) {
return decorator.primaryDriver.RecvMessage() // receive message from the primary driver only
}
28 changes: 25 additions & 3 deletions felix/dataplane/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ func StartDataplaneDriver(
return &inactive.InactiveDataplane{}, nil
}

var primaryDataplaneDriver DataplaneDriver
var primaryCmd *exec.Cmd
var secondaryDataplaneDriver DataplaneDriver
var secondaryCmd *exec.Cmd

if configParams.UseInternalDataplaneDriver {
log.Info("Using internal (linux) dataplane driver.")
// If kube ipvs interface is present, enable ipvs support. In BPF mode, we bypass kube-proxy so IPVS
Expand Down Expand Up @@ -414,13 +419,30 @@ func StartDataplaneDriver(
go aws.WaitForEC2SrcDstCheckUpdate(check, healthAggregator, updater, c)
}

return intDP, nil
} else {
primaryDataplaneDriver = intDP
primaryCmd = nil
}

if configParams.DataplaneDriver != "" {
log.WithField("driver", configParams.DataplaneDriver).Info(
"Using external dataplane driver.")

return extdataplane.StartExtDataplaneDriver(configParams.DataplaneDriver)
secondaryDataplaneDriver, secondaryCmd = extdataplane.StartExtDataplaneDriver(configParams.DataplaneDriver)
}

if primaryDataplaneDriver != nil && secondaryDataplaneDriver == nil {
return primaryDataplaneDriver, primaryCmd
}

if primaryDataplaneDriver == nil && secondaryDataplaneDriver != nil {
return secondaryDataplaneDriver, secondaryCmd
}

if primaryDataplaneDriver != nil && secondaryDataplaneDriver != nil {
return dataplaneDriverDecorator{primaryDriver: primaryDataplaneDriver, secondaryDriver: secondaryDataplaneDriver}, secondaryCmd
}

return nil, nil
}

func SupportsBPF() error {
Expand Down
Loading