diff mbox series

[ovs-dev] tests: Use scapy contrib BFD implementation.

Message ID 20250331153109.27231-1-fnordahl@ubuntu.com
State Accepted
Delegated to: Dumitru Ceara
Headers show
Series [ovs-dev] tests: Use scapy contrib BFD implementation. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_ovn-kubernetes success github build: passed
ovsrobot/github-robot-_Build_and_Test fail github build: failed
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/github-robot-_ovn-kubernetes success github build: passed

Commit Message

Frode Nordahl March 31, 2025, 3:31 p.m. UTC
Due to a change of behavior in scapy 2.6.x, the current CoPP system
test no longer works.

One of the changes we need to do is to switch to using sendp()
instead of send(), which requires adding Ethernet frames.

I discovered that scapy 2.6.x includes a BFD contrib module, so
while we're already updating the scapy code, let's switch to using
the BFD class in the same breath.

To ensure we catch such regresssions in the future, unpin scapy
in the CI container image.

Reported-at: https://launchpad.net/bugs/2104222
Signed-off-by: Frode Nordahl <fnordahl@ubuntu.com>
---
 tests/system-ovn.at                      | 21 +++++++++++----------
 utilities/containers/py-requirements.txt |  2 +-
 2 files changed, 12 insertions(+), 11 deletions(-)

Comments

Frode Nordahl March 31, 2025, 5:56 p.m. UTC | #1
On 31.03.2025 17:31, Frode Nordahl wrote:
> Due to a change of behavior in scapy 2.6.x, the current CoPP system
> test no longer works.
> 
> One of the changes we need to do is to switch to using sendp()
> instead of send(), which requires adding Ethernet frames.
> 
> I discovered that scapy 2.6.x includes a BFD contrib module, so
> while we're already updating the scapy code, let's switch to using
> the BFD class in the same breath.
> 
> To ensure we catch such regresssions in the future, unpin scapy
> in the CI container image.
> 
> Reported-at: https://launchpad.net/bugs/2104222
> Signed-off-by: Frode Nordahl <fnordahl@ubuntu.com>
> ---

A failure unrelated to the change at hand occurred in the 997 interconnection test.

Recheck-request: github-robot-_Build_and_Test

--
Frode Nordahl

>   tests/system-ovn.at                      | 21 +++++++++++----------
>   utilities/containers/py-requirements.txt |  2 +-
>   2 files changed, 12 insertions(+), 11 deletions(-)
> 
> diff --git a/tests/system-ovn.at b/tests/system-ovn.at
> index 66deeb30e..07cc31ba3 100644
> --- a/tests/system-ovn.at
> +++ b/tests/system-ovn.at
> @@ -7867,19 +7867,20 @@ bfd: bfd-meter
>   ])
> 
>   check ovn-nbctl --wait=hv --bfd lr-route-add R1 240.0.0.0/8 172.16.1.50 rp-public
> -printf "%08x" $(ovn-sbctl get bfd . disc) > /tmp/disc
> +ovn_discriminator=$(printf "%08x" $(ovn-sbctl get bfd . disc))
>   NETNS_START_TCPDUMP([server], [-nn -i s1 udp port 3784 and ip[[29]]==0x90 -Q in], [bfd])
>   ip netns exec server scapy -H <<-EOF
> -import binascii
> -f = open("/tmp/disc", "r")
> -# scapy does not support BFD protocol
> -# let's hardcode a BFD payload with the proper my-disc field read from the db
> -bfd = binascii.unhexlify("20600518a899e77b" + f.readline().strip() + "000f4240000f424000000000")
> -p = IP(src="172.16.1.50", dst="172.16.1.1") / UDP(dport = 3784, sport = 49152) / Raw(load = bfd)
> -send (p, iface='s1', loop = 0, verbose = 0, count = 100)
> -f.close()
> +from scapy.contrib import bfd
> +BFD_STA_DOWN = 1
> +BFD_FLAG_POLL = 1 << 5
> +p = (Ether(src="f0:00:00:01:02:05", dst="00:00:02:01:02:03") /
> +     IP(src="172.16.1.50", dst="172.16.1.1") /
> +     UDP(dport = 3784, sport = 49152) /
> +     bfd.BFD(sta=BFD_STA_DOWN,
> +             flags=BFD_FLAG_POLL,
> +             your_discriminator=0x$ovn_discriminator))
> +sendp (p, iface='s1', loop = 0, verbose = 0, count = 100)
>   EOF
> -rm /tmp/disc
> 
>   # 1pps
>   OVS_WAIT_UNTIL([
> diff --git a/utilities/containers/py-requirements.txt b/utilities/containers/py-requirements.txt
> index 1b55042c8..f308cc331 100644
> --- a/utilities/containers/py-requirements.txt
> +++ b/utilities/containers/py-requirements.txt
> @@ -1,6 +1,6 @@
>   flake8>=6.1.0
>   meson>=1.4,<1.5
> -scapy==2.5.0
> +scapy>=2.6.1
>   sphinx<8.0 # https://github.com/sphinx-doc/sphinx/issues/12711
>   setuptools
>   pyelftools
> --
> 2.43.0
> 
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
Dumitru Ceara April 3, 2025, 12:21 p.m. UTC | #2
On 3/31/25 5:31 PM, Frode Nordahl wrote:
> Due to a change of behavior in scapy 2.6.x, the current CoPP system
> test no longer works.
> 
> One of the changes we need to do is to switch to using sendp()
> instead of send(), which requires adding Ethernet frames.
> 
> I discovered that scapy 2.6.x includes a BFD contrib module, so
> while we're already updating the scapy code, let's switch to using
> the BFD class in the same breath.
> 
> To ensure we catch such regresssions in the future, unpin scapy
> in the CI container image.
> 
> Reported-at: https://launchpad.net/bugs/2104222
> Signed-off-by: Frode Nordahl <fnordahl@ubuntu.com>
> ---

Hi Frode,

Thanks for fixing the CI!  Applied to main, 25.03, 24.09 and 24.03.

Regards,
Dumitru
diff mbox series

Patch

diff --git a/tests/system-ovn.at b/tests/system-ovn.at
index 66deeb30e..07cc31ba3 100644
--- a/tests/system-ovn.at
+++ b/tests/system-ovn.at
@@ -7867,19 +7867,20 @@  bfd: bfd-meter
 ])
 
 check ovn-nbctl --wait=hv --bfd lr-route-add R1 240.0.0.0/8 172.16.1.50 rp-public
-printf "%08x" $(ovn-sbctl get bfd . disc) > /tmp/disc
+ovn_discriminator=$(printf "%08x" $(ovn-sbctl get bfd . disc))
 NETNS_START_TCPDUMP([server], [-nn -i s1 udp port 3784 and ip[[29]]==0x90 -Q in], [bfd])
 ip netns exec server scapy -H <<-EOF
-import binascii
-f = open("/tmp/disc", "r")
-# scapy does not support BFD protocol
-# let's hardcode a BFD payload with the proper my-disc field read from the db
-bfd = binascii.unhexlify("20600518a899e77b" + f.readline().strip() + "000f4240000f424000000000")
-p = IP(src="172.16.1.50", dst="172.16.1.1") / UDP(dport = 3784, sport = 49152) / Raw(load = bfd)
-send (p, iface='s1', loop = 0, verbose = 0, count = 100)
-f.close()
+from scapy.contrib import bfd
+BFD_STA_DOWN = 1
+BFD_FLAG_POLL = 1 << 5
+p = (Ether(src="f0:00:00:01:02:05", dst="00:00:02:01:02:03") /
+     IP(src="172.16.1.50", dst="172.16.1.1") /
+     UDP(dport = 3784, sport = 49152) /
+     bfd.BFD(sta=BFD_STA_DOWN,
+             flags=BFD_FLAG_POLL,
+             your_discriminator=0x$ovn_discriminator))
+sendp (p, iface='s1', loop = 0, verbose = 0, count = 100)
 EOF
-rm /tmp/disc
 
 # 1pps
 OVS_WAIT_UNTIL([
diff --git a/utilities/containers/py-requirements.txt b/utilities/containers/py-requirements.txt
index 1b55042c8..f308cc331 100644
--- a/utilities/containers/py-requirements.txt
+++ b/utilities/containers/py-requirements.txt
@@ -1,6 +1,6 @@ 
 flake8>=6.1.0
 meson>=1.4,<1.5
-scapy==2.5.0
+scapy>=2.6.1
 sphinx<8.0 # https://github.com/sphinx-doc/sphinx/issues/12711
 setuptools
 pyelftools