Граф коммитов

215 Коммитов

Автор SHA1 Сообщение Дата
QxBytes 0c8f78a2f0
refactor: add receiver to iptables and create interface (#2421)
* Move network utils functions with iptables to new file

* Add receiver to iptables and create interface

* Resolve conflicts from rebasing

* Add changes for building on windows

* Address linter issues

* Address windows linter issues

* Invert if condition for linter nesting

* Scope iptables interfaces to package

* Rename iptables client to avoid stuttering

* Move EnableIPForwarding to snat linux

* Rename ipTablesClientInterface to ipTablesClient

* Address linter issues from moving enable ip forwarding function

* Rename after rebase
2023-12-14 09:27:17 -08:00
Behzad Mirkhanzadeh c4fe3a8fa7
feat: Dev stateless cni (#2276)
* feat: 🌈 StatelessCNI: Adding getEndpoint and UpdateEndpoint API to CNS (#2102)

* Adding getEndpoint and UpdateEndpoint API to CNS with the respective clients in support of stateless CNI.

* Updating the unit tests and address the comments.

* Addressing the comments.

* Addressing the coments regarding CNS support for Stateless CNI

* Adddressing the PR comments

* 🌈 feat: adding flags for stateless cni (#2103)

feat: stateless cni

* 🌈 feat: StatelessCNI: Applying stateless CNI mode changes in network package. (#2197)

* Apllying stateless CNI mode in network package.

* Addresing the commetns.

* feat: create stateless cni binary for swift (#2275)

* enabling CNS telemetry

* Master rebase changes

* CNI Telemetry enabled on CNS

* Stateless CNI changes.

* making change to CNSendpointStorePath

* Updating makefile to avoid creating statless CNI release.

---------

Co-authored-by: Vipul Singh <vipul21sept@gmail.com>
2023-12-12 00:15:54 +00:00
QxBytes 9a74d51709
fix: disable ipv6 on transparent vlan mode network create (#2419)
Disable ipv6 on transparent vlan mode network create
2023-12-01 14:29:52 -08:00
QxBytes 2382637912
fix: block wireserver port 80 traffic in multitenancy (#2395)
* Add vm and vnet ns block wireserver port 80 rule

* Use existing variable for known ip

* Move code to networkutils

* Address feedback

* Address iptables version feedback

* Address protocol and format feedback

* Add comments

* Remove cidr in case ipv6 is used
2023-11-29 13:37:45 -08:00
rayaisaiah 74a67b306c
fix: Changed the SetPolicySetting struct value to correct name in Windows NPM (#2386)
Created a new PR in non forked ACN repoo that changed the setPolicy struct PolicyType to Type in Windows NPM.
2023-11-15 01:23:56 +00:00
Jaeryn 44e5f37394
refactor: remove cniTypesCurr.Result dependency in InterfaceInfo (#2361)
* refactor: remove cniTypesCurr.Result dependency in InterfaceInfo

* update baremetal

* add interface in cni result conversion func

* update gateway route

---------

Co-authored-by: Jaeryn <tsch@microsoft.com>
2023-11-14 18:30:18 +00:00
QxBytes 4e6cc2ff1e
fix: wait for vnet ns to create and ensure veths are inside namespace instead of assuming (#2341)
* Make initial changes to enable forwarding

Reuse existing code to enable ip forwarding

Add forwarding message

Add transparent vlan config to dropgz

Add enable ip forward to each network namespace for redundancy

* Add general run with retries function

* Migrate existing code to use retry function

* Add retries for checking of vnet and container veth creation

* Add preliminary repair item fixes

* Clarify log message

* Fix unit tests, move ensure clean populate vm to add endpoints, remove ip forwarding fix as it is in other branch

* Move setting link netns and confirmation to function

* Add tests for setLinkNetNSAndConfirm

* Address linter issues

* Add vm ns to vnet namespace log statement

* Fix after rebasing in swift refactoring changes from master

* Address feedback and check error message

* Address feedback

* Address linter issue

* Address log feedback

* Address feedback by asserting any error is an interface not found error
2023-11-10 16:07:40 -08:00
Jaeryn 4168c62faa
test: validate secondary endpoint client failure (#2345)
test: validate secondary endpoint client failure will prevent endpoint creation

Co-authored-by: Jaeryn <tsch@microsoft.com>
2023-11-03 23:32:40 +00:00
QxBytes 428edb98ee
fix: enable ip forward on transparent vlan network create (#2335)
* Enable ipv4 forwarding on network creation

* Add multitenancy transparent vlan conflist to dropgz

* Test if applying fix each time works

* Address linter issues

* Revert "Test if applying fix each time works"

This reverts commit 8989dedc2e.

* Remove overlap in adding dropgz conflist

* Add unit test if forwarding fails

* Make error handling consistent with ipv6 forwarding

* Address linter issue
2023-11-02 16:45:34 -07:00
Jaeryn 83fca75334
feat: cni refactor for swift v2 (#2330)
* feat: update contracts to support swift 2

* add comments

* rename AddressType to NICType

* update contract names and comments

* address comments

* feat: update invokers to support swift 2

* address comments

* address comments

* refactor cns invoker per comments

* update invokers based on contract change

* update test

* update with contract changes

* fix linter errs

* fix naming

* fix linter

* fix linter

* address comments

* update tests

* add tests

* address nit comments

* add comments

* address comments

* fix casing

* address comments

* feat: update invokers to support swift 2

* address comments

* feat: update invokers to support swift 2

* feat: update invokers to support swift 2

* feat: update endpoint clients for swift 2

* address comments

* fix lint errs

* update endpoint clients based on contract changes

* update tests

* only skip adding default route

* modify AddEndpoints per comments

* address comments

* update deleteendpoint

* enter ns before moving interface back to vm ns

* update delete endpoint test

* add namespace interface for testing

* fix lint

* fix lint

* add comment

* add extra delete endpoint test

* update test

* feat: update invokers to support swift 2

* address comments

* address comments

* feat: refactor endpoint create/delete flow for swift 2

* address comments

* address comments

* address linter

* update based on contract changes

* update with contract changes

* add more tests and address comments

* modify AddEndpoints per comments

* update test for invoker add and endpoint client add failure

* address comments

* fix lint

* update windows tests

* update refactor with namespace interface

* fix lint

* rebasing fixes

* address comments

---------

Co-authored-by: Jaeryn <tsch@microsoft.com>
2023-11-01 19:50:35 +00:00
Paul Yu 95cade1087
[CNI] Migrate zap logger for acn ipam package (#2299)
migration zap logger for acn ipam package
2023-10-28 04:38:36 +00:00
John Payne 29502bc7d0
fix: Pipeline agent image update from 18.04 to 22.04 | AzSecPack (#2327)
* Use ResolveCtl for Ubuntu22.04

* test: debug

* test: XDG dir

* ci: Remove sudo for testvalidate

* ci: remove sudo dualstack

* ci: remove test scripts

* fix: lint

---------

Co-authored-by: Sheyla Trudo <shtrudo@microsoft.com>
2023-10-26 15:54:08 -07:00
Paul Yu ae37d40982
[CNI] zap logger for platform package (#2233)
* zap logger for platform package
2023-10-13 12:08:58 -07:00
Paul Yu 246fee4bd0
[CNI] restruct CNI logger (#2226)
* small change for zap log restruct
2023-09-19 23:02:28 +00:00
Paul Yu 44dc74e5ec
[CNI] Migrate network and platform package logging to zap (#2209)
* network package zap logger

* add zaplogger for platform
2023-09-16 00:14:44 +00:00
Paul Yu ec9d41e906
hotfix for adding duplicated routes (#2161) 2023-08-21 19:33:10 +00:00
tamilmani1989 63548ede34
chore: Removing CNI logs that are not useful (#2065)
removed logs that's spamming and not useful

Co-authored-by: Ramiro <64089641+ramiro-gamarra@users.noreply.github.com>
2023-07-20 14:21:21 -04:00
tamilmani1989 193b644fd2
[Fix] update gw ip to 169.254.2.1 for transparent-vlan as its conflicting with other cni (#2064)
update gw ip to 169.254.2.1 as its conflicting with other cni
2023-07-19 12:52:27 -07:00
Hunter Gregory ebddca18bd
perf: [NPM] [LINUX] add NetPols in background (#1969)
* wip: apply dirty NetPols every 500ms in Linux

* only build npm linux image

* fix: check for empty cache

* feat: toggle for netpol interval. default 500 ms

* ci: remove stages "build binaries" and "run windows tests"

* wip: max batched netpols (toggle-specified)

* ci: remove manifest build/push for win npm

* wip: handle ipset deletion properly and max batch for delete too

* fix: correct remove policy

* fix: only remove policy if it was in kernel

* finalize toggles, allowing ability to turn off iptablesInBackground

* ci: conf + cyc use PR's configmaps

* fix: lints

* fix dp toggle: iptablesInBackground

* fix lock typo and config logging

* fix background thread. add comments. only add tmp ref when enabled

* copy pod selector list

* fix: removepolicy needs namespace too

* rename opInfo to event

* fix: fix references and prevent concurrent map read/write

* tmp: debug logging

* fix: missing set references by swap keys and values

* Revert "tmp: debug logging"

This reverts commit 70ed34c714ea4a6d009a1fe90a7168be4bedd5bf.

* fix: add podSelectorList to fake NetPol

* log: do not print error when failing to delete non-existent nft rule

* log: verbose iptables bootup

* log: use fmt.Errorf for clean logging

* log: never return error for iptables in background and fix some lints

* fix: activate/deactivate azure chain rules

* fix: correctly decrement netpols in kernel

* ci: run UTs again

* ci: update profiles. default to placefirst=false

* address comment: rename batch to pendingPolicy

* refactor: make dirty cache  OS-specific

* test: UTs

* test: put UT cfg back to placefirst to not break things

* ci: update cyclonus workflows

* fmt: address comment & lint

* fmt: rename numInKernel to policiesInKernel

* log: switch to fmt.Errorf

* fmt: whitespace

* feat: resiliency to errors while reconciling dirty netpols

* log: temporarily print everything for ipset restore

* fix: remove nomatch from ipset -D for cidr blocks

* test: UTs for non-happy path

* test: fix hns fake

* fix: don't change windows. let it delete ipsets when removing policies

* fix windows lint

* fix: ignore chain doesn't exist errors for iptables -D

* feat: latency and failure metrics

* test: update exit code for UT

* metrics: new metrics should go in node-metrics path

* style: simplify nesting

* style: move identical windows & linux code to shared file

* ci: remove v1 conformance and cyclonus

* feat: add NetPols in background from the DP (revert background code in pMgr)

* style: remove "background" from iptables metrics

* revert changes in ipsetmanager, const.go, and dp.Remove/UpdatePolicy

* style: whitespace

* perf: use len() instead of creating slice from map

* remove verbosity for iptables bootup

* build: add return statement

* style: whitespace

* build: fix variable shadowing

* build: fix more import shadowing

* build: windows pointer issue and UT issue

* test: fix UT for iptables error code 2

* ci: enable linux scale test

* ci: revert to master pipeline.yaml

* revert changes to chain-management. do changes in PR #2012

* log: change wording

* test: UTs for netpol in background

* log: wording

* feat: apply ipsets for each netpol individually

* config: rearrange ConfigMap & update capz yaml

* fix: windows bootup phase logic for addpolicy

* feat: restrict netpol in background to linux + nftables

* test: skip nftables check for UT

* style: netpols[0] instead of loop

* log: address log comments

* style: lint for long line

---------

Co-authored-by: Vamsi Kalapala <vakr@microsoft.com>
2023-07-19 09:13:52 -07:00
Ramiro 5593e97bc9
Removing addition of default routes before HNS network creation (#2059)
removing addition of default routes before hns network creation
2023-07-17 23:47:06 +00:00
Steven Nguyen 672cce9460
update: add pod info to windows endpoint (#2040) 2023-07-05 11:51:48 -07:00
Paul Yu a68d6382f4
add v6 port mapping policy to dualstack overlay (#1989)
* cosmic v6 port mapping policy fix
2023-06-08 03:27:56 +00:00
Paul Johnston bcca3fe2f3
Remove redundant routes in dualstackoverlay for windows nodes (#2002)
Remove redundant routes in overlay for windows nodes
2023-06-07 13:38:08 -07:00
Hunter Gregory 04f92857f2
feat: [WIN-NPM] metrics for latencies and failures (#1959)
* implement metrics

* add npm prefix

* rename windows files

* metrics pkg UTs

* allow reinitializing prometheus metrics

* fix: hns wrapper should not throw error for empty SetPolicy values

* test: metric UTs in dataplane

* fix: record list endpoint latency always

* remove flaky UT

* feat: metric for max ipset members

* fix lint

* fix lint 2

* fix build

* fix lint 3

* simplify conditionals and protect against maxMembers becoming negative

* remove bottom 4 histogram buckets. start at 16 ms

* reset metrics for ipset UTs

* style: don't check for windows dp in *_windows.go files

* build: remove unused import

* test: reset windows metrics in UT
2023-06-05 12:43:39 -07:00
Paul Yu b02110f59a
Dualstack overlay cni (#1925) 2023-04-29 14:50:44 -07:00
tamilmani1989 a82b312995
Set constant mac for host veth interface in transparent vlan mode (#1906)
* set constant mac for host veth interface

* fixed a race issue in transparent-vlan where delete can happen after add and removes route add by ADD call

* moved log to place where its executed

* enable proxy arp on bridge to allow public connectivity from apipa interface

* validate newly created namespace is not same as host namespace

* addressed comments and added UTs

* fixed cni delete call for linux multitenancy

* lint fixes

* windows lint fixes

* lint fixes

* fix issues with network namespace creation and vlan interface creation

* Removed deletehostveth flag and delete host veth on delete endpoint trigger

* lint fix

* address comment
2023-04-17 14:26:00 -07:00
tamilmani1989 1ec3abdaf9
Delete host veth interface on endpoint creation error in transparent-vlan mode (#1892)
* deletion of host veth interface on error in transparent_vlan mode

* fixed a typo character

* Fix lint issues

* Windows lint fix

* Windows lint fix

* add netio import

* Fixed newly added ut

* reverting pre-push change

* fix a typo
2023-04-13 08:43:44 +00:00
Hunter Gregory 626582661c
fix: [WIN-NPM] filter HNS endpoints (#1848)
* filter endpoints

* UTs

* fix: fake wrapper never tracked Flags for remote endpoints

* fix lints and address comment

* fix lints

* fix lint

* golint timeout from 10 to 15m

* undo golint timeout change. needs to happen in master

* try to fix lints in hnsv2wraper

* wrap checks
2023-04-06 12:32:58 -07:00
tamilmani1989 2caddd1387
Skip removing vnet namespace in Linux CNI Multitenancy (#1841)
merging it since this PR already passes e2e once
2023-03-09 12:44:20 -08:00
Hunter Gregory 2832b50375
feat: [NPM-WIN] support for CAPZ windows testing (#1752)
* set kubeconfig on capz

* update dockerfile

* test network name Calico

* add base acls

* add WindowsNetworkName toggle and revert hard coded Calico parts

* update base acls for calico and add UTs

* capitalize calico network name

* fix connectivity. try with host allow acls

* revert change to policy_windows.go

* more UTs and add base ACLs for other "new endpoint" scenario

* run all UTs

* update npm image to .42

* add log line

* allow traffic going inter-node

* Revert "allow traffic going inter-node"

This reverts commit e1014822d5.

* add long-runner pod for testing vfp tags in capz

* fix lints
2023-03-02 13:24:31 -08:00
Paul Yu 4b7a692a6a
add func GetNumEndpointsInNetNs() to support to get number of endpoints for deletion (#1828)
* add GetNumEndpointsInNetNs()

* fix gofumpt issue

* fix comments

* fix an UT

* combine two UTs

* combine two UTs
2023-03-01 21:43:51 -05:00
Behzad Mirkhanzadeh 667af455d4
Revert "fix: Adding a defer func to connecttoTelemetryservice() to prevent CNI fro…" (#1819)
* Revert "fix: Adding a defer func to connecttoTelemetryservice() to prevent CNI fro… (#1800)"

This reverts commit 879b6441c9.

* Revert "fix: repair windows cni lock issue (#1712)"

This reverts commit 7b647be285.

* mend
2023-02-24 19:06:24 +00:00
Behzad Mirkhanzadeh 7b647be285
fix: repair windows cni lock issue (#1712)
* Moving the lock from InitializeKeyValueStore() function to restore/save functions to improve cni performance on windows.

* fix: use defer function to unlock statefile.

* fix: fixing the IPAM lock and defer func

* fix: Optimizing cni file lock by moving SetSdnRemoteArpMacAddress() on startup for CRD and MultitenantCRD mode.

* adding store lock on telemetry service start to avoid race condition on windows.
2023-01-07 08:03:09 +00:00
Hunter Gregory e3ffab843d
test: [WIN-NPM] dataplane test framework (#1652)
* wip with StrictlyHasSetPolicies approach

* better approaching of getting all set policies

* wip for rigorous win dp UTs

* marshal setpolicies in hns mock and dont short circuit in UTs

* policy stuff and update test cases

* marshal ACLs in hns mock

* more UTs and minor refinements

* option to apply dp or not

* address cmp.Equal and t.Helper comments

* dpEvent returns error and better defined concurrency

* remove unnecessary logic in concurrent test code

* approach #3 emulating cyclonus

* namespace method for podmetadata

* refactor Action structure and TestCase wait group behavior

* hnsactions and renaming a file

* refactor to Serial and ThreadedTestCase structs, and move files to dp pkg

* hns latency hard coded to be the same for all threaded test cases

* fix build error after rebasing

* export fake hns network id

* address comments on multierr and terminology

* add comment about pod metadata in controller

* pod update and delete actions

* move ApplyDPAction to top

* namespace actions and rename some fields of UpdatePod

* adding code comments

* reconcile action

* fix bug in key-val ipsets

* implement all previous test cases

* fix incorrect error wrapping in dataplane.go

* multi-job tests are working. updated terminology from routine to job

* MultiErrManager instead of dependency for multierr

* return to the channel approach for multierr, now using FailNow instead of asserting on channel length

* fix some lints

* fix more lints
2022-10-31 11:20:39 -05:00
Mathew Merrick 80162b02e3
run Windows UT's (#1554)
* run windows UT's

* container image

* remove container

* coverage

* run windows UT's

* container image

* remove container

* coverage

* fix UTs round 1

* passing UTs for policies pkg

* use canary pool

* remove bash from windows

* fixed unit test

* added skip for windows dp translate policy tests

* lint updates and remove dataplane_windows_test.go

* updated failing tests

* fix lint issue

* fixed remaining tests

* lint update

* undo last change

* format update

* lint fix

Co-authored-by: Hunter Gregory <hunterlgregory@gmail.com>
Co-authored-by: Vamsi Kalapala <vakr@microsoft.com>
Co-authored-by: CK <ckov931@gmail.com>
Co-authored-by: Cristina Kovacs <99916704+ck319@users.noreply.github.com>
2022-10-20 12:50:28 -07:00
Vamsi Kalapala 3e6ca73113
[NPM][Fix] Adding redundant check to ignore endpoint not found while … (#1560)
* [NPM][Fix] Adding redundant check to ignore endpoint not found while removing policies

* adding error in logline

* adding error in logline

* making sure applyDP error is handled correctly

* revert changes in controllers, covered in a different PR

* adding UTs
2022-09-01 14:15:56 -07:00
Vipul Singh ce24db68c3
fix: Reverting the hardware address to use NUD_PERMANENT for ipv6 cases (#1535)
* Adding constant hardware address to the veth

* update the variable and error log message

* Removing the shadow variable

* Removing the shadow variable

* Adding the hardware ad address while endpoint creation

* Refactoring based on the comments

* Updated based on comments

* removing merge conflicts

* update the function parameter

* Addressing comments

* go lint errors

* updating the IPAddr variable

* updating the state to NUD PROBE for transparent endpoint

* Reverting the hardware address to use NUD_PERMANENT

Co-authored-by: root <root@DESKTOP-IS3TR2T.redmond.corp.microsoft.com>
2022-08-19 00:24:46 -07:00
Vipul Singh afcb977aa8
fix: Adding a constant hardware address to the veth (#1524)
* Adding constant hardware address to the veth

* update the variable and error log message

* Removing the shadow variable

* Removing the shadow variable

* Adding the hardware ad address while endpoint creation

* Refactoring based on the comments

* Updated based on comments

* removing merge conflicts

* update the function parameter

* Addressing comments

* go lint errors

* updating the IPAddr variable

* updating the state to NUD PROBE for transparent endpoint

Co-authored-by: root <root@DESKTOP-IS3TR2T.redmond.corp.microsoft.com>
2022-08-17 10:53:57 -07:00
QxBytes ebbd31ce09
feat: Enable same VM same VNET packet tunneling to host for Transparent Vlan (#1529)
* Disabled rp filter to enable packet tunneling

Tests ok (all basic functionality, 2 VMs, NS, delete, add)

* Added tests

* Typo

* Typo

* No need to disable rp filter in VM NS
2022-08-16 14:49:26 -07:00
QxBytes a19e5fb5cd
feat: Add SNAT bridge to Native, decouple SNAT bridge (#1506)
* Native Endpoint Client Add Endpoints

* AddEndpointRules, ConfigureContainerInterfacesAndRoutes

* Changed interface names, log statements

nw.extIf.Name > eth0 (eth0)
eth0.vlanid > eth0.X (eth0.1)
%s%s hostIfName > vnet (A1veth0)
%s%s-2 contIfName > container (B1veth0)

* Renaming, using lib to set ns

* Namespace "path" is /var/run/netns/<NS>

* Loopback set up, Remove auto kernel subnet route

* Cannot set link to up if it's in another NS

* Multiple containers on same VNET NS

* Delete Endpoint routes on Delete

* Minimizing netns usage

* Moving NS Exec Code

* Further minimized netns.Set usage

* Moved helper methods down, drafted tests

* Removed DevName from Route Info, more tests

* Test existing vnet ns, delete endpoint

* NetNS interface for testing

* Separated tests by namespace

* Endpoints delete if they cannot be moved into NS

* Namespace netns tests

* Added Native Client to deleteEndpointImpl

* Deletion of Endpoints Impl and Tests

* Cleaned code (Tests ok)

* Moved mock/netns to package (Tests ok)

* Fixing Netns (wip)

Moved netnsinterface to consumer package (network).
Removed "Netns" from "NewNetns" and "NewMockNetns" as it is unambiguous.
Changed uintptr to int and casted the int to uintptr when needed later.

* Using errors.Wrap for error context (wip)

* Removed sentence case (wip)

* Removing variable predeclaration

* Removed NewNativeEndpointClient

Directly instantiating struct because nothing special happens in NewNativeEndpointClient

* Removed generics from ExecuteInNS

* Removed uintptr from mocknetns, tests compile

Forgot to remove uintptr from mocknetns

* Fix tests, lint

* Fixes from linter

Works on VMSS

* Replacing references to ethX with vlan veth

* Removed unnecessary log

* Removed unnecessary mac, fix tests

* Mockns method name enum

* Unable to use GetNetworkInterfaceByName due to NS

If I use GetNetworkInterface, I need to be in the vnet NS, but that means I will need to call ExecuteInNS, which causes tests to fail.

* Fixes from linter

* Assume if NS exists, vlan veth exists

Tests ok

* Fixes for Linter

* Snat refactor

* Fix delete tests

* Fix delete tests bug

* More snat refactor

* Breaking, prepping for Native Snat

Delete native endpoint snat route linux to remove errors and in theory, ovs should work fine again.

* Go mod tidy for linting

Hopefully this fixes the windows lint error

* Add fields to native endpoint client for snat

* Using New() func to create Native Client

Creation of the native endpoint client is too complicated to directly instantiate.

* Snat defaults

* Insert SNAT entry points

* Native Snat error handling

* Breaking, decouple ovsctl from snat

Proposed Solution implementation
Moved ovsctlClient.AddPortOnOVSBridge to ovs_endpoint_snatroute_linux.go. Removed ovsctlclient from NewSnatClient. Removed ovsctlClient from testing file.

* Delete unecessary ovssnat files

* No lint on vishvananda netns

Maybe this will fix the windows linter?

* Build linux only for netns package

Maybe this fixes the linter error?

* Remove nolint to see if linter fails

* Breaking, removed bridgeName

bridgeName refers to the OVS Switch I believe

* If native uses snat bridge, should also get IP

* Breaking, Decouple or Wrap snat route

* Check to see if snat triggered

* Snat behaviors specific to ovs/native

* Pass the pointer

Add/Delete ok

* Renaming to make consts public

* Breaking, moving ovs specific parts of snat to ovs

* Remove enable infra vnet (Tests ok)

Tested:
Allow Host to NC only
Allow NC to Host only
Allow both
Wget
Ping between containers

Warning: Enable snat is still hard coded to true!!!

* Move add port to after exists() check

* Moved netns interface to caller, generalized tests

Tests ok, Native ok

* Typos

* Reordered if statement, unwrapped arp

Tests ok, ping ok, wget ok

* Linted, wrapping errors

* Go fumpt entire network package

* Code markers removed, clean (Tests ok)

OVS & Native:
-	Ping between two containers same VM, no packets on bridge
-	Ping between two containers diff VM, no packets on bridge
-	Ping other container not in vnet, no packets on bridge
-	Ping snat to container, packets on bridge
-	Ping container to snat, packets on bridge
-	Tcpdump confirmed on azSnatBr
-	Deletion of containers deletes appropriate interfaces

* Renamed veth, fixed logs

* Made deleteEndpoints logic clearer, renamed error

* Renamed eth0 to primaryHostIfName, vlanEth to vlanIf

* Deleted debug log

* Corrected merge (hardware addr) (Tests ok)

* Renamed vlan veth to hostExtIf_vlanID, Disabled RA

eth0.2 makes disable RA look for a folder eth0 and then another sub folder "2". ("eth0/2") However, it should look for a folder named "eth0.2" literally. To solve this, we change the naming scheme to use an underscore instead. (Tests ok)

* Renamed Native to TransparentVlan

Confirmed basic functionality on VM with correct mode

* Make file updated

* Create azure-windows-multitenancy-transparent-vlan.conflist

* Unified snat err format

* Rename to transparent-vlan

* Route table support added to local netlink

* Moved SNAT to end of function

* Defer deleting vlan interface on failure
2022-08-10 13:50:26 -07:00
QxBytes ce14b0b6f5
style: Go fumpt entire network package (#1507)
no code changes..so bypassing e2e
2022-08-03 15:09:00 -07:00
QxBytes d57e24ee25
feat: Add native linux endpoint client to prep removing OVS (#1471)
* Native Endpoint Client Add Endpoints

* AddEndpointRules, ConfigureContainerInterfacesAndRoutes

* Changed interface names, log statements

nw.extIf.Name > eth0 (eth0)
eth0.vlanid > eth0.X (eth0.1)
%s%s hostIfName > vnet (A1veth0)
%s%s-2 contIfName > container (B1veth0)

* Renaming, using lib to set ns

* Namespace "path" is /var/run/netns/<NS>

* Loopback set up, Remove auto kernel subnet route

* Cannot set link to up if it's in another NS

* Multiple containers on same VNET NS

* Delete Endpoint routes on Delete

* Minimizing netns usage

* Moving NS Exec Code

* Further minimized netns.Set usage

* Moved helper methods down, drafted tests

* Removed DevName from Route Info, more tests

* Test existing vnet ns, delete endpoint

* NetNS interface for testing

* Separated tests by namespace

* Endpoints delete if they cannot be moved into NS

* Namespace netns tests

* Added Native Client to deleteEndpointImpl

* Deletion of Endpoints Impl and Tests

* Cleaned code (Tests ok)

* Moved mock/netns to package (Tests ok)

* Fixing Netns (wip)

Moved netnsinterface to consumer package (network).
Removed "Netns" from "NewNetns" and "NewMockNetns" as it is unambiguous.
Changed uintptr to int and casted the int to uintptr when needed later.

* Using errors.Wrap for error context (wip)

* Removed sentence case (wip)

* Removing variable predeclaration

* Removed NewNativeEndpointClient

Directly instantiating struct because nothing special happens in NewNativeEndpointClient

* Removed generics from ExecuteInNS

* Removed uintptr from mocknetns, tests compile

Forgot to remove uintptr from mocknetns

* Fix tests, lint

* Fixes from linter

Works on VMSS

* Replacing references to ethX with vlan veth

* Removed unnecessary log

* Removed unnecessary mac, fix tests

* Mockns method name enum

* Unable to use GetNetworkInterfaceByName due to NS

If I use GetNetworkInterface, I need to be in the vnet NS, but that means I will need to call ExecuteInNS, which causes tests to fail.

* Fixes from linter

* Assume if NS exists, vlan veth exists

Tests ok

* Fixes for Linter

* Fix delete tests

* Fix delete tests bug

* Go mod tidy for linting

Hopefully this fixes the windows lint error

* No lint on vishvananda netns

Maybe this will fix the windows linter?

* Build linux only for netns package

Maybe this fixes the linter error?

* Remove nolint to see if linter fails

* Moved netns interface to caller, generalized tests

Tests ok, Native ok

* Typos

* Reordered if statement, unwrapped arp

Tests ok, ping ok, wget ok

* Renamed veth, fixed logs

* Made deleteEndpoints logic clearer, renamed error

* Renamed eth0 to primaryHostIfName, vlanEth to vlanIf
2022-08-02 14:54:10 -07:00
tamilmani1989 ba3bbe0f26
Remove azure-vnet-telemetry for windows multitenancy (#1430)
* Remove azure-vne-telemetry for windows multitenancy and telemetry service for windows multitenancy will be started from cns.

* start telemetry service from cns

* lint and log fix

* minor change

* addressed comment
2022-07-01 15:09:39 -07:00
aegal 251edbfd04
Alegal/add timeout to hns calls (#1369)
* initial implemenation with timeout

* initial implemenation with timeout hns

* modify test

* modify code slightly

* updating to read in timeout flag and settings

* updating to read in timeout settings

* remove extra space

* correct a typo

* timeout value greater than zero for detection

* add couple ut's and remove needless code

* including timeout in hnsv1

* wip

* address comments

* address comments

* supress linter errors and update conflist

* fix linter and ensure we don't regress our tests

* updating with p.r feedback

* addressing comments

* updating linter warning

* update to address TM's comments

* fix lint error

* correct a linter spacing complaint

* remove fmt.sprintf
2022-05-25 14:18:46 -07:00
tamilmani1989 75e1239132
Remove duplicate logs (#1375)
* removed cni read config log

* removed duplicated and spam logs

* addressed comment

* commit

* reverting back to old permission

* revert files baxck to original state

* addressing hunter comments
2022-05-19 10:00:52 -07:00
aegal 2157d7ad2c
Skip network creation if network already exists in HNS (#1300)
* skip network creation if network already exists

* address comments

* address feedback
2022-04-14 13:41:14 -07:00
tamilmani1989 6ec42039d7
ignore removenamespace endpoint error (#1272) 2022-03-10 09:58:30 -08:00
Matthew Long 580c3e4072
feat: don't use CNS for CNI DEL command in windows multitenancy (#1216)
* feat: don't use CNS for CNI DEL command in windows multitenancy

* go fmt

* go fmt take 2

* fix: don't fallback to CNS for getNetwork or deleteHostNCApipaEndpoint, handle errNetworkNotFound

* test: add test for FindNetworkIDFromNetNs

* fix: getNetworkName needs to fallback to CNS when not found in state file for ADD

* fix: simplify the deleteHostNCApipaEndpoint function

* fix: linter

* fix: cnm should compile

* fix: always return retriable error for endpoint deletion failure

* fix: handle npe in cns/hnsclient by not using that package

* fix: logging

* fix: don't try cns if there is no multitenancy client

* fix: don't call CNS twice during ADD cmd

* fix: use hns wrapper, add some logging, don't return error when endpoint is already deleted
2022-02-03 19:14:31 -08:00
tamilmani1989 82f4b391a1
feat: [CNI] Enable DSR policy for windows singletenancy (AKS) by default (#1116)
* added dsr changes for windows

* fixed lint and added unit test
removed unused error

* skip adding dsr policy for hnsv1

* addressed comments
lint fix

* fixed windows uts
2021-11-29 10:12:32 -08:00
Vamsi Kalapala 303e237688
fix: adding relevant platform suffix to ignore errors in windows (#1119) 2021-11-23 09:18:17 -08:00