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

15 Коммитов

Автор SHA1 Сообщение Дата
QxBytes fc4da42d66
refactor: create safer command execution method (#2899)
* rename ExecuteCommand to ExecuteRawCommand

* add safer execute command method

* fix windows platform command test

* add uts and comments

* address feedback

* add parent context to execute command
2024-08-06 21:36:55 +00:00
QxBytes 6c6c4a4a7e
chore: remove redundant logs (#2642)
* initial log cleanup

* address feedback

* undo modifying deprecated mode files
2024-03-20 20:55:38 +00:00
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
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
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 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
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
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
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
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
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