-
Notifications
You must be signed in to change notification settings - Fork 31
Avoid handling mac duplication during deletion #150
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
Open
mlguerrero12
wants to merge
1
commit into
k8snetworkplumbingwg:master
Choose a base branch
from
mlguerrero12:removehandleduplicatemacs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,9 +29,10 @@ import ( | |
| "github.com/containernetworking/cni/pkg/version" | ||
| "github.com/containernetworking/plugins/pkg/ipam" | ||
| "github.com/containernetworking/plugins/pkg/ns" | ||
| "github.com/intel/bond-cni/bond/util" | ||
| "github.com/vishvananda/netlink" | ||
| "github.com/vishvananda/netns" | ||
|
|
||
| "github.com/intel/bond-cni/bond/util" | ||
| ) | ||
|
|
||
| type bondingConfig struct { | ||
|
|
@@ -143,10 +144,15 @@ func createBondedLink(bondName string, bondConf *bondingConfig, netNsHandle *net | |
|
|
||
| // loop over the linkObjectsToBond, set each DOWN, update the interface MASTER & set it UP again. | ||
| // again we use the netNsHandle to interfact with these links in the namespace provided. return error | ||
| func attachLinksToBond(bondLinkObj *netlink.Bond, linkObjectsToBond []netlink.Link, netNsHandle *netlink.Handle) error { | ||
| err := util.HandleMacDuplicates(linkObjectsToBond, netNsHandle) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to handle duplicated macs on link slaves, error: %+v", err) | ||
| func attachLinksToBond(bondLinkObj *netlink.Bond, linkObjectsToBond []netlink.Link, mode string, netNsHandle *netlink.Handle) error { | ||
| var err error | ||
|
|
||
| bondMode := netlink.StringToBondMode(mode) | ||
| if bondMode == netlink.BOND_MODE_BALANCE_TLB || bondMode == netlink.BOND_MODE_BALANCE_ALB { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we have a test to cover this new change that we handle mac duplication only for this two modes? |
||
| err = util.HandleMacDuplicates(linkObjectsToBond, netNsHandle) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to handle duplicated macs on link slaves, error: %+v", err) | ||
| } | ||
| } | ||
|
|
||
| bondLinkIndex := bondLinkObj.Index | ||
|
|
@@ -283,12 +289,13 @@ func createBond(bondName string, bondConf *bondingConfig, nspath string, ns ns.N | |
| if bondConf.FailOverMac < 0 || bondConf.FailOverMac > 2 { | ||
| return nil, fmt.Errorf("FailOverMac mode should be 0, 1 or 2 actual: %+v", bondConf.FailOverMac) | ||
| } | ||
|
|
||
| bondLinkObj, err := createBondedLink(bondName, bondConf, netNsHandle) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to create bonded link (%+v), error: %+v", bondName, err) | ||
| } | ||
|
|
||
| err = attachLinksToBond(bondLinkObj, linkObjectsToBond, netNsHandle) | ||
| err = attachLinksToBond(bondLinkObj, linkObjectsToBond, bondConf.Mode, netNsHandle) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to attached links to bond, error: %+v", err) | ||
| } | ||
|
|
@@ -433,19 +440,6 @@ func cmdDel(args *skel.CmdArgs) error { | |
| return fmt.Errorf("failed to deattached links from bond, error: %+v", err) | ||
| } | ||
|
|
||
| // Fetch slave links again to have the latest state | ||
| // For instance, Active-backup mode with fail_over_mac=0 reverts the mac address of backup slaves | ||
| for i := range linkObjectsToDeattach { | ||
| linkObjectsToDeattach[i], err = netNsHandle.LinkByName(linkObjectsToDeattach[i].Attrs().Name) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to find link (%+v), error: %+v", linkObjectsToDeattach[i].Attrs().Name, err) | ||
| } | ||
| } | ||
|
|
||
| if err = util.HandleMacDuplicates(linkObjectsToDeattach, netNsHandle); err != nil { | ||
| return fmt.Errorf("failed to validate deattached links macs, error: %+v", err) | ||
| } | ||
|
|
||
| err = netNsHandle.LinkDel(linkObjToDel) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to delete bonded link (%+v), error: %+v", linkObjToDel.Attrs().Name, err) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ import ( | |
| "bytes" | ||
| "crypto/rand" | ||
| "fmt" | ||
|
|
||
| "github.com/vishvananda/netlink" | ||
| ) | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just nice to have we should switch to project to
github.com/k8snetworkplumbingwg/bond-cni