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

tests: fix invocation of send_bsr_packet.py script for python 2 #8179

Closed
wants to merge 1 commit into from

Conversation

donaldsharp
Copy link
Member

The pim test script send_bsr_packet.py appears to not work properly
with scapy and python3.

sudo /usr/bin/python ./send_bsr_packet.py "01005e00000d005056961165080045c000aa5af500000167372a46000001e000000d2400f5ce165b000001004600000101000018e1010100080800000100090a090a0096650001000909090a0096660001000708090a00966700010007070907009668000100070702070096690001000705020700966a0001000702020700966b0001000202020200966c0001000020e1010101010100000100050606050096000001000020e20101010101000001000909090900960000" enp39s0 --interval=1 --count=1
Traceback (most recent call last):
File "/home/sharpd/frr6/tests/topotests/lib/./send_bsr_packet.py", line 23, in
from scapy.all import Raw, sendp
File "/usr/local/lib/python3.9/dist-packages/scapy/all.py", line 16, in
from scapy.arch import *
File "/usr/local/lib/python3.9/dist-packages/scapy/arch/init.py", line 27, in
from scapy.arch.bpf.core import get_if_raw_addr
File "/usr/local/lib/python3.9/dist-packages/scapy/arch/bpf/core.py", line 30, in
LIBC = cdll.LoadLibrary(find_library("libc"))
File "/usr/lib/python3.9/ctypes/util.py", line 341, in find_library
_get_soname(_findLib_gcc(name)) or _get_soname(_findLib_ld(name))
File "/usr/lib/python3.9/ctypes/util.py", line 147, in _findLib_gcc
if not _is_elf(file):
File "/usr/lib/python3.9/ctypes/util.py", line 99, in _is_elf
with open(filename, 'br') as thefile:

Limit running to python2

Signed-off-by: Donald Sharp sharpd@nvidia.com

The pim test script send_bsr_packet.py appears to not work properly
with scapy and python3.

sudo /usr/bin/python ./send_bsr_packet.py "01005e00000d005056961165080045c000aa5af500000167372a46000001e000000d2400f5ce165b000001004600000101000018e1010100080800000100090a090a0096650001000909090a0096660001000708090a00966700010007070907009668000100070702070096690001000705020700966a0001000702020700966b0001000202020200966c0001000020e1010101010100000100050606050096000001000020e20101010101000001000909090900960000" enp39s0 --interval=1 --count=1
Traceback (most recent call last):
  File "/home/sharpd/frr6/tests/topotests/lib/./send_bsr_packet.py", line 23, in <module>
    from scapy.all import Raw, sendp
  File "/usr/local/lib/python3.9/dist-packages/scapy/all.py", line 16, in <module>
    from scapy.arch import *
  File "/usr/local/lib/python3.9/dist-packages/scapy/arch/__init__.py", line 27, in <module>
    from scapy.arch.bpf.core import get_if_raw_addr
  File "/usr/local/lib/python3.9/dist-packages/scapy/arch/bpf/core.py", line 30, in <module>
    LIBC = cdll.LoadLibrary(find_library("libc"))
  File "/usr/lib/python3.9/ctypes/util.py", line 341, in find_library
    _get_soname(_findLib_gcc(name)) or _get_soname(_findLib_ld(name))
  File "/usr/lib/python3.9/ctypes/util.py", line 147, in _findLib_gcc
    if not _is_elf(file):
  File "/usr/lib/python3.9/ctypes/util.py", line 99, in _is_elf
    with open(filename, 'br') as thefile:

Limit running to python2

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
@polychaeta polychaeta added the tests Topotests, make check, etc label Mar 2, 2021
Copy link

@polychaeta polychaeta 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 your contribution to FRR!

Click for style suggestions

To apply these suggestions:

curl -s https://gist.githubusercontent.com/polychaeta/8dec74e9ee7d87c4e45991fba5e33bc7/raw/92ee456eff52902b1fbeff64090f386e89155626/cr_8179_1614647807.diff | git apply

diff --git a/tests/topotests/lib/pim.py b/tests/topotests/lib/pim.py
index d4b835643..ef826ef45 100644
--- a/tests/topotests/lib/pim.py
+++ b/tests/topotests/lib/pim.py
@@ -1564,26 +1564,30 @@ def verify_pim_interface(tgen, topo, dut, interface=None, interface_ip=None):
         logger.info("[DUT: %s]: Verifying PIM interface status:", dut)
 
         rnode = tgen.routers()[dut]
-        show_ip_pim_interface_json = rnode.\
-            vtysh_cmd("show ip pim interface json", isjson=True)
+        show_ip_pim_interface_json = rnode.vtysh_cmd(
+            "show ip pim interface json", isjson=True
+        )
 
-        logger.info("show_ip_pim_interface_json: \n %s",
-                    show_ip_pim_interface_json)
+        logger.info("show_ip_pim_interface_json: \n %s", show_ip_pim_interface_json)
 
         if interface_ip:
             if interface in show_ip_pim_interface_json:
                 pim_intf_json = show_ip_pim_interface_json[interface]
                 if pim_intf_json["address"] != interface_ip:
-                    errormsg = ("[DUT %s]: PIM interface "
-                            "ip is not correct "
-                            "[FAILED]!! Expected : %s, Found : %s"
-                            %(dut, pim_intf_json["address"],interface_ip))
+                    errormsg = (
+                        "[DUT %s]: PIM interface "
+                        "ip is not correct "
+                        "[FAILED]!! Expected : %s, Found : %s"
+                        % (dut, pim_intf_json["address"], interface_ip)
+                    )
                     return errormsg
                 else:
-                    logger.info("[DUT %s]: PIM interface "
-                            "ip is correct "
-                            "[Passed]!! Expected : %s, Found : %s"
-                            %(dut, pim_intf_json["address"],interface_ip))
+                    logger.info(
+                        "[DUT %s]: PIM interface "
+                        "ip is correct "
+                        "[Passed]!! Expected : %s, Found : %s"
+                        % (dut, pim_intf_json["address"], interface_ip)
+                    )
                     return True
         else:
             for destLink, data in topo["routers"][dut]["links"].items():
@@ -1595,24 +1599,36 @@ def verify_pim_interface(tgen, topo, dut, interface=None, interface_ip=None):
                     pim_intf_ip = data["ipv4"].split("/")[0]
 
                     if pim_interface in show_ip_pim_interface_json:
-                        pim_intf_json = show_ip_pim_interface_json\
-                            [pim_interface]
+                        pim_intf_json = show_ip_pim_interface_json[pim_interface]
 
                     # Verifying PIM interface
-                    if pim_intf_json["address"] != pim_intf_ip and \
-                        pim_intf_json["state"] != "up":
-                        errormsg = ("[DUT %s]: PIM interface: %s "
-                                    "PIM interface ip: %s, status check "
-                                    "[FAILED]!! Expected : %s, Found : %s"
-                                    %(dut, pim_interface, pim_intf_ip,
-                                    pim_interface, pim_intf_json["state"]))
+                    if (
+                        pim_intf_json["address"] != pim_intf_ip
+                        and pim_intf_json["state"] != "up"
+                    ):
+                        errormsg = (
+                            "[DUT %s]: PIM interface: %s "
+                            "PIM interface ip: %s, status check "
+                            "[FAILED]!! Expected : %s, Found : %s"
+                            % (
+                                dut,
+                                pim_interface,
+                                pim_intf_ip,
+                                pim_interface,
+                                pim_intf_json["state"],
+                            )
+                        )
                         return errormsg
 
-                    logger.info("[DUT %s]: PIM interface: %s, "
-                                "interface ip: %s, status: %s"
-                                " [PASSED]!!",
-                                dut, pim_interface, pim_intf_ip,
-                                pim_intf_json["state"])
+                    logger.info(
+                        "[DUT %s]: PIM interface: %s, "
+                        "interface ip: %s, status: %s"
+                        " [PASSED]!!",
+                        dut,
+                        pim_interface,
+                        pim_intf_ip,
+                        pim_intf_json["state"],
+                    )
 
     logger.debug("Exiting lib API: {}".format(sys._getframe().f_code.co_name))
     return True
@@ -3420,30 +3436,36 @@ def verify_igmp_interface(tgen, topo, dut, igmp_iface, interface_ip):
         if router != dut:
             continue
 
-        logger.info("[DUT: %s]: Verifying PIM interface status:",
-                    dut)
+        logger.info("[DUT: %s]: Verifying PIM interface status:", dut)
 
         rnode = tgen.routers()[dut]
-        show_ip_igmp_interface_json = \
-            run_frr_cmd(rnode, "show ip igmp interface json", isjson=True)
+        show_ip_igmp_interface_json = run_frr_cmd(
+            rnode, "show ip igmp interface json", isjson=True
+        )
 
-        if  igmp_iface in show_ip_igmp_interface_json:
+        if igmp_iface in show_ip_igmp_interface_json:
             igmp_intf_json = show_ip_igmp_interface_json[igmp_iface]
             # Verifying igmp interface
-            if  igmp_intf_json["address"] != interface_ip:
-                errormsg = ("[DUT %s]: igmp interface ip is not correct "
-                            "[FAILED]!! Expected : %s, Found : %s"
-                            %(dut, igmp_intf_json["address"], interface_ip))
+            if igmp_intf_json["address"] != interface_ip:
+                errormsg = (
+                    "[DUT %s]: igmp interface ip is not correct "
+                    "[FAILED]!! Expected : %s, Found : %s"
+                    % (dut, igmp_intf_json["address"], interface_ip)
+                )
                 return errormsg
 
-            logger.info("[DUT %s]: igmp interface: %s, "
-                        "interface ip: %s"
-                        " [PASSED]!!",
-                        dut, igmp_iface, interface_ip)
+            logger.info(
+                "[DUT %s]: igmp interface: %s, " "interface ip: %s" " [PASSED]!!",
+                dut,
+                igmp_iface,
+                interface_ip,
+            )
         else:
-            errormsg = ("[DUT %s]: igmp interface: %s "
-                        "igmp interface ip: %s, is not present "
-                        %(dut, igmp_iface, interface_ip))
+            errormsg = (
+                "[DUT %s]: igmp interface: %s "
+                "igmp interface ip: %s, is not present "
+                % (dut, igmp_iface, interface_ip)
+            )
             return errormsg
 
     logger.debug("Exiting lib API: {}".format(sys._getframe().f_code.co_name))

If you are a new contributor to FRR, please see our contributing guidelines.

After making changes, you do not need to create a new PR. You should perform an amend or interactive rebase followed by a force push.

@LabN-CI
Copy link
Collaborator

LabN-CI commented Mar 2, 2021

💚 Basic BGPD CI results: SUCCESS, 0 tests failed

Results table
_ _
Result SUCCESS git merge/8179 2a47cc5
Date 03/01/2021
Start 21:40:05
Finish 22:19:29
Run-Time 39:24
Total 1815
Pass 1815
Fail 0
Valgrind-Errors 0
Valgrind-Loss 0
Details vncregress-2021-03-01-21:40:05.txt
Log autoscript-2021-03-01-21:41:09.log.bz2
Memory 503 494 427

For details, please contact louberger

@NetDEF-CI
Copy link
Collaborator

Continuous Integration Result: SUCCESSFUL

Congratulations, this patch passed basic tests

Tested-by: NetDEF / OpenSourceRouting.org CI System

CI System Testrun URL: https://ci1.netdef.org/browse/FRR-FRRPULLREQ-17396/

This is a comment from an automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.

Copy link
Contributor

@mjstapp mjstapp left a comment

Choose a reason for hiding this comment

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

this script works fine for me, with python 3.8.5 and python3-scapy installed - maybe there's some other issue?

@donaldsharp
Copy link
Member Author

donaldsharp commented Mar 3, 2021

yeah shits broken for 3.9

sharpd@eva ~/f/t/t/lib (master)> sudo /usr/bin/python3.8 ./send_bsr_packet.py
[sudo] password for sharpd: 
usage: send_bsr_packet.py [-h] [--interval INTERVAL] [--count COUNT] packet iface
send_bsr_packet.py: error: the following arguments are required: packet, iface
sharpd@eva ~/f/t/t/lib (master) [2]> sudo /usr/bin/python ./send_bsr_packet.py
Traceback (most recent call last):
  File "/home/sharpd/frr5/tests/topotests/lib/./send_bsr_packet.py", line 23, in <module>
    from scapy.all import Raw, sendp
  File "/usr/local/lib/python3.9/dist-packages/scapy/all.py", line 16, in <module>
    from scapy.arch import *
  File "/usr/local/lib/python3.9/dist-packages/scapy/arch/__init__.py", line 27, in <module>
    from scapy.arch.bpf.core import get_if_raw_addr
  File "/usr/local/lib/python3.9/dist-packages/scapy/arch/bpf/core.py", line 30, in <module>
    LIBC = cdll.LoadLibrary(find_library("libc"))
  File "/usr/lib/python3.9/ctypes/util.py", line 341, in find_library
    _get_soname(_findLib_gcc(name)) or _get_soname(_findLib_ld(name))
  File "/usr/lib/python3.9/ctypes/util.py", line 147, in _findLib_gcc
    if not _is_elf(file):
  File "/usr/lib/python3.9/ctypes/util.py", line 99, in _is_elf
    with open(filename, 'br') as thefile:
FileNotFoundError: [Errno 2] No such file or directory: b'liblibc.a'
sharpd@eva ~/f/t/t/lib (master) [1]> sudo /usr/bin/python3.9 ./send_bsr_packet.py
Traceback (most recent call last):
  File "/home/sharpd/frr5/tests/topotests/lib/./send_bsr_packet.py", line 23, in <module>
    from scapy.all import Raw, sendp
  File "/usr/local/lib/python3.9/dist-packages/scapy/all.py", line 16, in <module>
    from scapy.arch import *
  File "/usr/local/lib/python3.9/dist-packages/scapy/arch/__init__.py", line 27, in <module>
    from scapy.arch.bpf.core import get_if_raw_addr
  File "/usr/local/lib/python3.9/dist-packages/scapy/arch/bpf/core.py", line 30, in <module>
    LIBC = cdll.LoadLibrary(find_library("libc"))
  File "/usr/lib/python3.9/ctypes/util.py", line 341, in find_library
    _get_soname(_findLib_gcc(name)) or _get_soname(_findLib_ld(name))
  File "/usr/lib/python3.9/ctypes/util.py", line 147, in _findLib_gcc
    if not _is_elf(file):
  File "/usr/lib/python3.9/ctypes/util.py", line 99, in _is_elf
    with open(filename, 'br') as thefile:
FileNotFoundError: [Errno 2] No such file or directory: b'liblibc.a'

@qlyoung
Copy link
Member

qlyoung commented Mar 3, 2021

This is a regression in Python 3.9. Scapy has already worked around it with a commit provided by our friend Vincent Bernat.

secdev/scapy@46fa40f

The issue for this workaround is

secdev/scapy#3100

We have a few options:

  1. Do nothing and wait until scapy pushes a new release, probably this month.
  2. Require installing scapy from GH source until they push a new release, probably this month.
  3. Merge this and then remember to unmerge it when scapy updates
  4. Use python 3.8 until scapy pushes a new release

IMO 3 is the best one. Just set your system python to 3.8.

@donaldsharp
Copy link
Member Author

I'm not going to muck with python version and just let the os itself decide what should be installed. I'll just live with this bullshit

@donaldsharp donaldsharp closed this Mar 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Topotests, make check, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants