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

Send IPv4 GARP and IPv6 Unsolicited NA in "cmdAdd" #216

Merged

Conversation

wizhaoredhat
Copy link
Contributor

@wizhaoredhat wizhaoredhat commented Aug 10, 2022

In "cmdAdd", SRIOV-CNI would construct and send IPv4 Gratuitous ARP
and/or Unsolicited Neighbor Advertisement depending on the IP
addresses configured by IPAM. The reason why this change is needed
is for the scenario when an IP address is reused by IPAM with
different interfaces (with different link-layer addresses). This can
occur when pods are deleted and created. For performance reasons,
sending of GARP and/or Unsolicited NA would update invalid ARP/Neighbor
caches in other neighbors/nodes.

Also we set IPv4 ARP Notify and IPv6 Neighbor Discovery Notify in sysfs
for each interface. This will send GARP and/or Unsolicited NA when the
interface is either brought up or the link-layer address changes. This
is useful in cases where an application reenables the interface or the
MAC address configuration is changed.

Some new packages were added, thus go.mod and go.sum were modified
accordingly.

Mocked PciUtils for sriov tests since sriov.go would call PciUtils to
set IPv4 ARP Notify and IPv6 Neighbor Discovery.

Fixes #177

Signed-off-by: William Zhao wizhao@redhat.com

@wizhaoredhat
Copy link
Contributor Author

wizhaoredhat commented Aug 10, 2022

@adrianchiris @martinkennelly @zshi-redhat @bn222 @Eoghan1232 @s1061123 @SchSeba : When you have an opportunity it would be much appreciated if you reviewed these changes in my PR.

@wizhaoredhat
Copy link
Contributor Author

I believe there was an intermittent problem with checking out some golang libraries. I hope that is what caused the kubernetes ci to fail. Could someone help with reruning the workflow?

@coveralls
Copy link

coveralls commented Aug 14, 2022

Pull Request Test Coverage Report for Build 3003254009

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 12 of 307 (3.91%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-2.4%) to 34.347%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/sriov/sriov.go 3 10 30.0%
pkg/utils/netlink_manager.go 0 39 0.0%
pkg/utils/utils.go 0 39 0.0%
pkg/sriov/mocks/pci_utils_mock.go 9 65 13.85%
pkg/utils/packet.go 0 154 0.0%
Totals Coverage Status
Change from base Build 2992024059: -2.4%
Covered Lines: 339
Relevant Lines: 987

💛 - Coveralls

pkg/utils/utils.go Outdated Show resolved Hide resolved
pkg/utils/utils.go Outdated Show resolved Hide resolved
pkg/sriov/sriov.go Outdated Show resolved Hide resolved
pkg/utils/utils.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@SchSeba SchSeba left a comment

Choose a reason for hiding this comment

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

The PR looks good thanks for the contribution!

I have a general question if we change the sys/net file and then change the nic to up the kernel should send the request for us no?

base on (https://sysctl-explorer.net/net/ipv6/ndisc_notify/)

pkg/utils/utils.go Outdated Show resolved Hide resolved
@wizhaoredhat
Copy link
Contributor Author

wizhaoredhat commented Aug 16, 2022

The PR looks good thanks for the contribution!

I have a general question if we change the sys/net file and then change the nic to up the kernel should send the request for us no?

base on (https://sysctl-explorer.net/net/ipv6/ndisc_notify/)

@SchSeba
Glad to be able to contribute!

To your question, yes that is correct. This is the method that Zenghui was first prototyping. However after some debugging and testing. We found some issues:

  1. The interface must be up for IPAM to function correctly. E.g. dhcp IPAM.
    (Thus we have to down the interface after IPAM config and bring it back up)
  2. IP addresses can be lost or changed. E.g By default sysctl "keep_addr_on_down" for IPv6 is set to zero. This means that if the interface is "downed", the IPv6 address(es) configured statically are lost.
  3. Also flapping a interface link when the majority of the network configuration was completed by SRIOV-CNI and IPAM to send a gratuitous ARP or unsolicited NA seemed a bit hacky in my opinion.

Constructing the packets manually and sending them seemed like the correct path to go.

cmd/sriov/main.go Outdated Show resolved Hide resolved
@wizhaoredhat wizhaoredhat force-pushed the send_garp_and_na branch 2 times, most recently from 2d8259b to 7450a17 Compare August 19, 2022 01:02
pkg/utils/packet.go Outdated Show resolved Hide resolved
@wizhaoredhat
Copy link
Contributor Author

@adrianchiris @zshi-redhat @bn222 @s1061123 @SchSeba : Please review again at your convenience. I would like to have this feature in soon. Thanks!

pkg/utils/packet.go Outdated Show resolved Hide resolved
Copy link
Contributor

@adrianchiris adrianchiris left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @wizhaoredhat !

apologies for the late review.

cmd/sriov/main.go Outdated Show resolved Hide resolved
cmd/sriov/main.go Outdated Show resolved Hide resolved
cmd/sriov/main.go Outdated Show resolved Hide resolved
cmd/sriov/main.go Outdated Show resolved Hide resolved
cmd/sriov/main.go Outdated Show resolved Hide resolved
cmd/sriov/main.go Outdated Show resolved Hide resolved
pkg/sriov/sriov_test.go Outdated Show resolved Hide resolved
pkg/utils/utils.go Outdated Show resolved Hide resolved
pkg/utils/packet.go Outdated Show resolved Hide resolved
@bn222
Copy link
Contributor

bn222 commented Aug 29, 2022

The commit has become quite large. Would it be possible to split it up a bit?

@wizhaoredhat
Copy link
Contributor Author

Hi All,
Could this PR be merged? I think I addressed everyone's comments. Regarding the checks being not successful, I think the Linter has some issues, the problem area doesn't seem to be with my changes.

@adrianchiris @zshi-redhat @bn222 @s1061123 @SchSeba

@SchSeba
Copy link
Collaborator

SchSeba commented Sep 1, 2022

For the CI issue I have an open PR for it

#223

cmd/sriov/main.go Outdated Show resolved Hide resolved
pkg/utils/netlink_manager.go Show resolved Hide resolved
pkg/utils/utils.go Outdated Show resolved Hide resolved
pkg/sriov/sriov.go Show resolved Hide resolved
Copy link
Contributor

@adrianchiris adrianchiris left a comment

Choose a reason for hiding this comment

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

Overall looks good, once @SchSeba comments are addressed and PR rebased im LGTM

@wizhaoredhat wizhaoredhat force-pushed the send_garp_and_na branch 3 times, most recently from ec3a420 to 17c092e Compare September 6, 2022 20:42
In "cmdAdd", SRIOV-CNI would construct and send IPv4 Gratuitous ARP
and/or Unsolicited Neighbor Advertisement depending on the IP
addresses configured by IPAM. The reason why this change is needed
is for the scenario when an IP address is reused by IPAM with
different interfaces (with different link-layer addresses). This can
occur when pods are deleted and created. For performance reasons,
sending of GARP and/or Unsolicited NA would update invalid ARP/Neighbor
caches in other neighbors/nodes.

Also we set IPv4 ARP Notify and IPv6 Neighbor Discovery Notify in sysfs
for each interface. This will send GARP and/or Unsolicited NA when the
interface is either brought up or the link-layer address changes. This
is useful in cases where an application reenables the interface or the
MAC address configuration is changed.

Some new packages were added, thus go.mod and go.sum were modified
accordingly.

Mocked PciUtils for sriov tests since sriov.go would call PciUtils to
set IPv4 ARP Notify and IPv6 Neighbor Discovery.

Fixes k8snetworkplumbingwg#177

Signed-off-by: William Zhao <wizhao@redhat.com>
@adrianchiris
Copy link
Contributor

/retest

Copy link
Contributor

@adrianchiris adrianchiris left a comment

Choose a reason for hiding this comment

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

lets wait for CI to pass, otherwise LGTM

thanks for addressing my comments !

@Eoghan1232
Copy link
Collaborator

Eoghan1232 commented Sep 8, 2022

/retest

@adrianchiris could you kick off ci again ?

@wizhaoredhat
Copy link
Contributor Author

I am not sure why the Mellanox CI is failing when we only changed the test file and mocks... Any idea @adrianchiris ?

@adrianchiris
Copy link
Contributor

/retest

@adrianchiris
Copy link
Contributor

it should run properly now

@wizhaoredhat
Copy link
Contributor Author

wizhaoredhat commented Sep 8, 2022

it should run properly now

@adrianchiris
Great, could we merge this pull request now?

Copy link
Collaborator

@Eoghan1232 Eoghan1232 left a comment

Choose a reason for hiding this comment

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

lgtm

@bn222
Copy link
Contributor

bn222 commented Sep 8, 2022

/lgtm

@Eoghan1232
Copy link
Collaborator

Merging now.

@Eoghan1232 Eoghan1232 merged commit f177b8e into k8snetworkplumbingwg:master Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

enable Gratuitous ARP for SR-IOV device
7 participants