DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Juraj Linkeš" <juraj.linkes@pantheon.tech>
To: jspewock@iol.unh.edu, alex.chapman@arm.com, npratte@iol.unh.edu,
	Luca.Vizzarro@arm.com, probb@iol.unh.edu,
	paul.szczepanek@arm.com, thomas@monjalon.net,
	Honnappa.Nagarahalli@arm.com, wathsala.vithanage@arm.com,
	yoan.picchi@foss.arm.com
Cc: dev@dpdk.org
Subject: Re: [PATCH v3 1/1] dts: Remove XML-RPC server for Scapy TG and instead use PythonShell
Date: Tue, 24 Sep 2024 12:55:29 +0200	[thread overview]
Message-ID: <0e66d03d-652b-481a-96ac-7c18337a1e07@pantheon.tech> (raw)
In-Reply-To: <20240919190229.22095-2-jspewock@iol.unh.edu>

I like how this looks. I have a number of minor comments (mainly wording 
and naming), but overall it looks very good.

On 19. 9. 2024 21:02, jspewock@iol.unh.edu wrote:
> From: Jeremy Spewock <jspewock@iol.unh.edu>
> 
> Previously all scapy commands were handled using an XML-RPC server that
> ran on the TGNode. This unnecessarily enforces a minimum Python version
> of 3.10 on the server that is being used as a traffic generator and
> complicates the implementation of scapy methods.

What is the TG's minimum Python version now? 
https://bugs.dpdk.org/show_bug.cgi?id=1388 says this will become a moot 
point, but we're still using Python on the remote node.


> diff --git a/dts/framework/remote_session/single_active_interactive_shell.py b/dts/framework/remote_session/single_active_interactive_shell.py

> @@ -93,9 +94,13 @@ def __init__(
>           timeout: float = SETTINGS.timeout,
>           app_params: Params = Params(),
>           name: str | None = None,
> +        **kwargs,
>       ) -> None:
>           """Create an SSH channel during initialization.
>   
> +        Additional key-word arguments can be passed through `kwargs` is needed to fulfill other

Typo: is -> if

And key-word should be just keyword.

Also, should we add super().__init__(), seeing as we also added it to 
TrafficGenerator?


> diff --git a/dts/framework/testbed_model/traffic_generator/scapy.py b/dts/framework/testbed_model/traffic_generator/scapy.py

> +class ScapyTrafficGenerator(PythonShell, CapturingTrafficGenerator):

> +    def __init__(self, tg_node: Node, config: ScapyTrafficGeneratorConfig, **kwargs):

The usage of privileged=True when creating the instance confused me for 
a bit, because it's not this class's argument, but rather 
SingleActiveInteractiveShell's. I thing we should document the arguments 
of SingleActiveInteractiveShell in the Keyword Args section. We probably 
need just a link to SingleActiveInteractiveShell.


> +    def _create_packet_list(self, packets: list[Packet]) -> None:

Maybe we could apply some of the ideas from the local/remote naming 
scheme I talked about in the tg devbind script patch here. Whatever 
happens on the TG could be prefixed with remote and whatever is 
happening locally would be without the prefix (or maybe whatever is 
happnening on the TG shouldn't be prefixed (or a different prefix - 
shell)? Makes sense, but then we'd need a good prefix for what's 
happening on the execution environment. Maybe this also needs to be in a 
different patch, after it's been though through with everything else in 
mind.). That would make this _create_remote_packet_list, but we're just 
setting a variable (the passed packets have already been built), so 
maybe _set_remote_packet_list?

Or maybe all of the remote methods could start with remote, making it 
_remote_set_packet_list (or _shell_set_packet_list? Doesn't sound bad.). 
Not sure which is better, maybe after renaming more of these it's going 
to be clearer.

Whatever we go with, the naming scheme should be explained in the 
class's dosctring.


> +    def _create_sniffer(
> +        self, packets_to_send: list[Packet], send_port: Port, recv_port: Port, filter_config: str
> +    ) -> None:
> +        """Create an asynchronous sniffer in the shell.
> +
> +        A list of packets to send is added to the sniffer inside of a callback function so that
> +        they are immediately sent at the time sniffing is started.

This is still a bit confusing (where are the packets added and what is 
inside the function?); We may not need the Scapy implementation details. 
We could just say the packets are sent immediately at the time sniffing 
is started. Or maybe:
A list of packets is passed to the sniffer's callback function so that 
they are immediately sent at the time sniffing is started.

It's a private method, so maybe the implementation detail could be 
valuable, even though it's not fully clear why the implication is true - 
you still need some knowledge of how the sniffer works to put everything 
together.


> +        sniffer_commands = [
> +            f"{self._sniffer_name} = AsyncSniffer(",
> +            f"iface='{recv_port.logical_name}',",
> +            "store=True,",
> +            "started_callback=lambda *args: sendp(",

As far as I can tell, we're not using the args, so we can just use 
"lambda: sendp()"

> +            (
> +                f"{self._python_indentation}{self._send_packet_list_name},"

Is the indentation needed here?


> @@ -335,32 +204,19 @@ def _send_packets_and_capture(

I think we can improve the order of methods in the class. I'd put 
_send_packets() and _send_packets_and_capture() after the public 
methods. These two methods are the most important ones (implementing the 
abstract methods). The other methods should come after that in the order 
they're used in _send_packets() and _send_packets_and_capture().

>           self,
>           packets: list[Packet],
>           send_port: Port,
> -        receive_port: Port,
> +        recv_port: Port,
>           filter_config: PacketFilteringConfig,
>           duration: float,
> -        capture_name: str = _get_default_capture_name(),
>       ) -> list[Packet]:

> +        """Implementation for sending packets and capturing any received traffic.
> +
> +        This method first creates an asynchronous sniffer that holds the packets to send, then
> +        starts and stops and starts said sniffer.

This looks like a typo: starts and stops and starts.

Maybe we could add that we collect the received packets from the sniffer 
once we've stopped it.


> diff --git a/dts/framework/testbed_model/traffic_generator/traffic_generator.py b/dts/framework/testbed_model/traffic_generator/traffic_generator.py

> @@ -16,23 +16,29 @@

> +class TrafficGenerator(MultiInheritanceBaseClass, ABC):

> +    def __init__(self, tg_node: Node, config: TrafficGeneratorConfig, **kwargs):
>           """Initialize the traffic generator.
>   
> +        Additional key-word arguments can be passed through `kwargs` if needed for fulfilling other
> +        constructors in the case of multiple-inheritance.
> +

The wording in this sentence is slightly different that the one in 
SingleActiveInteractiveShell. Let's unify them.


  reply	other threads:[~2024-09-24 10:55 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-05 17:52 [RFC PATCH v1 0/2] dts: replace XML-RPC server jspewock
2024-06-05 17:52 ` [RFC PATCH v1 1/2] dts: Add interactive shell for managing Scapy jspewock
2024-06-11 11:12   ` Juraj Linkeš
2024-06-17 19:45     ` Jeremy Spewock
2024-06-05 17:52 ` [RFC PATCH v1 2/2] dts: Remove XML-RPC server for Scapy TG and instead us ScapyShell jspewock
2024-06-11 10:46   ` Juraj Linkeš
2024-06-17 19:57     ` Jeremy Spewock
2024-06-20 23:11 ` [PATCH v1 0/1] dts: replace XML-RPC server jspewock
2024-06-20 23:11   ` [PATCH v1 1/1] dts: Remove XML-RPC server for Scapy TG and instead use PythonShell jspewock
2024-06-21 14:14     ` Juraj Linkeš
2024-06-24 20:54       ` Jeremy Spewock
2024-06-25 21:11 ` [PATCH v2 0/1] dts: replace XML-RPC server jspewock
2024-06-25 21:11   ` [PATCH v2 1/1] dts: Remove XML-RPC server for Scapy TG and instead use PythonShell jspewock
2024-09-12  4:00     ` Patrick Robb
2024-09-19 19:02 ` [PATCH v3 0/1] dts: replace XML-RPC server jspewock
2024-09-19 19:02   ` [PATCH v3 1/1] dts: Remove XML-RPC server for Scapy TG and instead use PythonShell jspewock
2024-09-24 10:55     ` Juraj Linkeš [this message]
2024-09-24 16:34       ` Jeremy Spewock
2024-09-25  7:49         ` Juraj Linkeš
2024-09-25 17:37 ` [PATCH v4 0/1] dts: replace XML-RPC server jspewock
2024-09-25 17:37   ` [PATCH v4 1/1] dts: Remove XML-RPC server for Scapy TG and instead use PythonShell jspewock
2024-09-26  9:12     ` Juraj Linkeš
2024-09-26 14:54       ` Jeremy Spewock
2024-09-27  9:35         ` Juraj Linkeš
2024-09-26 14:55       ` Jeremy Spewock
2024-09-26 16:50 ` [PATCH v5 0/1] dts: replace XML-RPC server jspewock
2024-09-26 16:50   ` [PATCH v5 1/1] dts: use PythonShell for Scapy instead of XML-RPC jspewock
2024-09-27  9:42     ` Juraj Linkeš
2024-09-27 11:47     ` Luca Vizzarro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0e66d03d-652b-481a-96ac-7c18337a1e07@pantheon.tech \
    --to=juraj.linkes@pantheon.tech \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=Luca.Vizzarro@arm.com \
    --cc=alex.chapman@arm.com \
    --cc=dev@dpdk.org \
    --cc=jspewock@iol.unh.edu \
    --cc=npratte@iol.unh.edu \
    --cc=paul.szczepanek@arm.com \
    --cc=probb@iol.unh.edu \
    --cc=thomas@monjalon.net \
    --cc=wathsala.vithanage@arm.com \
    --cc=yoan.picchi@foss.arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).