-
Notifications
You must be signed in to change notification settings - Fork 260
feat: Add SNAT bridge to Native, decouple SNAT bridge #1506
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
Merged
Merged
Changes from all commits
Commits
Show all changes
91 commits
Select commit
Hold shift + click to select a range
8f64c08
Native Endpoint Client Add Endpoints
QxBytes 2b3cb7a
AddEndpointRules, ConfigureContainerInterfacesAndRoutes
QxBytes a85c365
Changed interface names, log statements
QxBytes f08f0b7
Renaming, using lib to set ns
QxBytes 8531563
Namespace "path" is /var/run/netns/<NS>
QxBytes 3752a41
Loopback set up, Remove auto kernel subnet route
QxBytes 3f6507d
Cannot set link to up if it's in another NS
QxBytes d38d06b
Multiple containers on same VNET NS
QxBytes 1f8d37f
Delete Endpoint routes on Delete
QxBytes 7f8b802
Minimizing netns usage
QxBytes b622049
Moving NS Exec Code
QxBytes c1e60a1
Further minimized netns.Set usage
QxBytes ddd5213
Moved helper methods down, drafted tests
QxBytes f4b5fd7
Removed DevName from Route Info, more tests
QxBytes 4c280c2
Test existing vnet ns, delete endpoint
QxBytes 7ac1a95
NetNS interface for testing
QxBytes 32b4d98
Separated tests by namespace
QxBytes 9a488f9
Endpoints delete if they cannot be moved into NS
QxBytes 7c8838b
Namespace netns tests
QxBytes 4e4def5
Added Native Client to deleteEndpointImpl
QxBytes 7e593d9
Deletion of Endpoints Impl and Tests
QxBytes be0191a
Cleaned code (Tests ok)
QxBytes 1f40dd8
Moved mock/netns to package (Tests ok)
QxBytes 0552493
Fixing Netns (wip)
QxBytes 2c2aac5
Using errors.Wrap for error context (wip)
QxBytes 248a90c
Removed sentence case (wip)
QxBytes 3e8e719
Removing variable predeclaration
QxBytes a3b6277
Removed NewNativeEndpointClient
QxBytes 536a022
Removed generics from ExecuteInNS
QxBytes 9193600
Removed uintptr from mocknetns, tests compile
QxBytes 095fdc9
Fix tests, lint
QxBytes 4a63471
Fixes from linter
QxBytes c291f1c
Replacing references to ethX with vlan veth
QxBytes 97022b8
Removed unnecessary log
QxBytes c40d4e8
Removed unnecessary mac, fix tests
QxBytes c58059b
Mockns method name enum
QxBytes a724dc5
Unable to use GetNetworkInterfaceByName due to NS
QxBytes 062aa9f
Fixes from linter
QxBytes a0676b2
Assume if NS exists, vlan veth exists
QxBytes efdfb96
Fixes for Linter
QxBytes 7349b8d
Snat refactor
QxBytes adb23b2
Fix delete tests
QxBytes a775d93
Fix delete tests bug
QxBytes 4f750ef
More snat refactor
QxBytes 580bffd
Breaking, prepping for Native Snat
QxBytes 88a2a50
Go mod tidy for linting
QxBytes d7c159e
Add fields to native endpoint client for snat
QxBytes 97f99ac
Merge branch 't-allew/develop' into t-allew/snat
QxBytes b4c1b41
Using New() func to create Native Client
QxBytes 257ab8c
Snat defaults
QxBytes f6a013c
Insert SNAT entry points
QxBytes 059363c
Native Snat error handling
QxBytes 6c390d3
Breaking, decouple ovsctl from snat
QxBytes 9cb6a51
Delete unecessary ovssnat files
QxBytes 9c150bd
No lint on vishvananda netns
QxBytes ef4b49f
Build linux only for netns package
QxBytes df83ada
Remove nolint to see if linter fails
QxBytes aa5baed
Breaking, removed bridgeName
QxBytes 6a1a06c
If native uses snat bridge, should also get IP
QxBytes f3bc95b
Breaking, Decouple or Wrap snat route
QxBytes 2d854b8
Check to see if snat triggered
QxBytes 8f2db2f
Snat behaviors specific to ovs/native
QxBytes faef1ab
Pass the pointer
QxBytes 9fa80a9
Renaming to make consts public
QxBytes 0bc785a
Breaking, moving ovs specific parts of snat to ovs
QxBytes 71dc1e4
Remove enable infra vnet (Tests ok)
QxBytes 49eb30c
Move add port to after exists() check
QxBytes ba901c5
Moved netns interface to caller, generalized tests
QxBytes 33f4941
Typos
QxBytes 228ba63
Reordered if statement, unwrapped arp
QxBytes ee1eddc
Merge branch 't-allew/develop' into t-allew/snat
QxBytes 5c2a77d
Linted, wrapping errors
QxBytes c3e781f
Go fumpt entire network package
QxBytes 0fa38bf
Code markers removed, clean (Tests ok)
QxBytes 18f9652
Renamed veth, fixed logs
QxBytes 7e44c85
Made deleteEndpoints logic clearer, renamed error
QxBytes 1807094
Renamed eth0 to primaryHostIfName, vlanEth to vlanIf
QxBytes 9347d07
Merge branch 't-allew/develop' into t-allew/snat
QxBytes a99cb45
Deleted debug log
QxBytes 4c30a22
Merge branch 'master' into t-allew/snat
QxBytes 124c409
Corrected merge (hardware addr) (Tests ok)
QxBytes eef4fd6
Merge branch 'master' into t-allew/snat
QxBytes fed7864
Renamed vlan veth to hostExtIf_vlanID, Disabled RA
QxBytes 51879e2
Renamed Native to TransparentVlan
QxBytes 5b187bc
Make file updated
QxBytes c259490
Create azure-windows-multitenancy-transparent-vlan.conflist
QxBytes 21c26a4
Unified snat err format
QxBytes 1f18c1f
Rename to transparent-vlan
QxBytes dd57afe
Route table support added to local netlink
QxBytes b2674dc
Moved SNAT to end of function
QxBytes 6f1c50a
Defer deleting vlan interface on failure
QxBytes 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
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 |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| { | ||
| "cniVersion":"0.3.0", | ||
| "name":"azure", | ||
| "plugins":[ | ||
| { | ||
| "type":"azure-vnet", | ||
| "mode":"transparent-vlan", | ||
| "bridge":"azure0", | ||
| "multiTenancy":true, | ||
| "infraVnetAddressSpace":"", | ||
| "podNamespaceForDualNetwork":[], | ||
| "enableExactMatchForPodName": false, | ||
| "enableSnatOnHost":true, | ||
| "ipam":{ | ||
| "type":"azure-cns" | ||
| }, | ||
| "dns":{ | ||
| "nameservers":[] | ||
| } | ||
| }, | ||
| { | ||
| "type":"portmap", | ||
| "capabilities":{ | ||
| "portMappings":true | ||
| }, | ||
| "snat":true | ||
| } | ||
| ] | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| { | ||
| "cniVersion": "0.3.0", | ||
| "name": "azure", | ||
| "plugins": [ | ||
| { | ||
| "type": "azure-vnet", | ||
| "mode": "transparent-vlan", | ||
| "bridge": "azure0", | ||
| "multiTenancy":true, | ||
| "enableSnatOnHost":true, | ||
| "enableExactMatchForPodName": true, | ||
| "capabilities": { | ||
| "portMappings": true | ||
| }, | ||
| "ipam": { | ||
| "type": "azure-cns" | ||
| }, | ||
| "dns": { | ||
| "Nameservers": [ | ||
| "10.0.0.10", | ||
| "168.63.129.16" | ||
| ], | ||
| "Search": [ | ||
| "svc.cluster.local" | ||
| ] | ||
| }, | ||
| "AdditionalArgs": [ | ||
| { | ||
| "Name": "EndpointPolicy", | ||
| "Value": { | ||
| "Type": "OutBoundNAT", | ||
| "ExceptionList": [ | ||
| "10.240.0.0/16", | ||
| "10.0.0.0/8" | ||
| ] | ||
| } | ||
| }, | ||
| { | ||
| "Name": "EndpointPolicy", | ||
| "Value": { | ||
| "Type": "ROUTE", | ||
| "DestinationPrefix": "10.0.0.0/8", | ||
| "NeedEncap": true | ||
| } | ||
| } | ||
| ], | ||
| "windowsSettings": { | ||
| "hnsTimeoutDurationInSeconds" : 120 | ||
| } | ||
| } | ||
| ] | ||
| } |
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
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 |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| package network | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "github.com/Azure/azure-container-networking/log" | ||
| "github.com/Azure/azure-container-networking/netlink" | ||
| "github.com/Azure/azure-container-networking/network/networkutils" | ||
| "github.com/Azure/azure-container-networking/network/snat" | ||
| "github.com/Azure/azure-container-networking/platform" | ||
| "github.com/pkg/errors" | ||
| ) | ||
|
|
||
| func GetSnatHostIfName(epInfo *EndpointInfo) string { | ||
| return fmt.Sprintf("%s%s", snatVethInterfacePrefix, epInfo.Id[:7]) | ||
| } | ||
|
|
||
| func GetSnatContIfName(epInfo *EndpointInfo) string { | ||
| return fmt.Sprintf("%s%s-2", snatVethInterfacePrefix, epInfo.Id[:7]) | ||
| } | ||
|
|
||
| func AddSnatEndpoint(snatClient *snat.Client) error { | ||
| if err := snatClient.CreateSnatEndpoint(); err != nil { | ||
| return errors.Wrap(err, "failed to add snat endpoint") | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func AddSnatEndpointRules(snatClient *snat.Client, hostToNC, ncToHost bool, nl netlink.NetlinkInterface, plc platform.ExecClient) error { | ||
| // Allow specific Private IPs via Snat Bridge | ||
| if err := snatClient.AllowIPAddressesOnSnatBridge(); err != nil { | ||
| return errors.Wrap(err, "failed to allow ip addresses on snat bridge") | ||
| } | ||
|
|
||
| // Block Private IPs via Snat Bridge | ||
| if err := snatClient.BlockIPAddressesOnSnatBridge(); err != nil { | ||
| return errors.Wrap(err, "failed to block ip addresses on snat bridge") | ||
| } | ||
| nuc := networkutils.NewNetworkUtils(nl, plc) | ||
| if err := nuc.EnableIPForwarding(snat.SnatBridgeName); err != nil { | ||
| return errors.Wrap(err, "failed to enable ip forwarding") | ||
| } | ||
|
|
||
| if hostToNC { | ||
| if err := snatClient.AllowInboundFromHostToNC(); err != nil { | ||
| return errors.Wrap(err, "failed to allow inbound from host to nc") | ||
| } | ||
| } | ||
|
|
||
| if ncToHost { | ||
| if err := snatClient.AllowInboundFromNCToHost(); err != nil { | ||
| return errors.Wrap(err, "failed to allow inbound from nc to host") | ||
| } | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func MoveSnatEndpointToContainerNS(snatClient *snat.Client, netnsPath string, nsID uintptr) error { | ||
| if err := snatClient.MoveSnatEndpointToContainerNS(netnsPath, nsID); err != nil { | ||
| return errors.Wrap(err, "failed to move snat endpoint to container ns") | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func SetupSnatContainerInterface(snatClient *snat.Client) error { | ||
| if err := snatClient.SetupSnatContainerInterface(); err != nil { | ||
| return errors.Wrap(err, "failed to setup snat container interface") | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func ConfigureSnatContainerInterface(snatClient *snat.Client) error { | ||
| if err := snatClient.ConfigureSnatContainerInterface(); err != nil { | ||
| return errors.Wrap(err, "failed to configure snat container interface") | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func DeleteSnatEndpoint(snatClient *snat.Client) error { | ||
| if err := snatClient.DeleteSnatEndpoint(); err != nil { | ||
| return errors.Wrap(err, "failed to delete snat endpoint") | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func DeleteSnatEndpointRules(snatClient *snat.Client, hostToNC, ncToHost bool) { | ||
| if hostToNC { | ||
| err := snatClient.DeleteInboundFromHostToNC() | ||
| if err != nil { | ||
| log.Errorf("failed to delete inbound from host to nc rules") | ||
| } | ||
| } | ||
|
|
||
| if ncToHost { | ||
| err := snatClient.DeleteInboundFromNCToHost() | ||
| if err != nil { | ||
| log.Errorf("failed to delete inbound from nc to host rules") | ||
| } | ||
| } | ||
| } | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.