[dts] [PATCH 01/17] framwork/packet: Add sniff_packet specify running

Liu, Yong yong.liu at intel.com
Thu Mar 29 04:31:24 CEST 2018


Phil,
Please go on, I think this change won't affect most of suites.  
Please also keep packet module still workable with directly call. Some of our internal tools are using it for sniffing packets.

Regards,
Marvin

> -----Original Message-----
> From: Phil Yang [mailto:Phil.Yang at arm.com]
> Sent: Wednesday, March 28, 2018 2:34 PM
> To: Liu, Yong <yong.liu at intel.com>; dts at dpdk.org
> Cc: nd <nd at arm.com>; Herbert Guan <Herbert.Guan at arm.com>
> Subject: RE: [PATCH 01/17] framwork/packet: Add sniff_packet specify
> running
> 
> Hi Marvin,
> 
> > -----Original Message-----
> > From: Liu, Yong <yong.liu at intel.com>
> > Sent: Wednesday, March 28, 2018 10:41 AM
> > To: Phil Yang <Phil.Yang at arm.com>; dts at dpdk.org
> > Cc: nd <nd at arm.com>; Herbert Guan <Herbert.Guan at arm.com>
> > Subject: RE: [PATCH 01/17] framwork/packet: Add sniff_packet specify
> running
> >
> > Hi Phil,
> > In previous design, DTS will be run on tester for simple design and
> stability.
> > In our site, I can't see the benefit of change the design. Could you
> please explain
> > why you change it?
> > Anyway we can change the design, but I think it will need some kind of
> diagnosis
> > about the impact.
> > There may be some other staff depend on the assumption that DTS is on
> the
> > tester machine.
> 
> 
> We are trying to use one machine as the controller to run DTS. The
> controller communicate with testers which listed in the crbs.cfg by SSH
> connection.
> So the DTS will not running on tester.
> 
> Since testers are connected with DUTs port by port, so I think introduce
> controller into the DTS is more flexible to manager machines. If other
> staff depend on the assumption that DTS is no the tester machine,
> sniff_packet process will also connect to the tester by SSH connection.
> Just one more SSH connection.
> However, we cannot make sure the DTS is always running on the tester.
> 
> 
> >
> > Just for this patch. In load function, DTS machine should transmit
> tester's pcap
> > file first and then analyze packets.
> 
> You are correct. Thanks to point out.
> 
> If my proposal is acceptable, I will resend the version 2 to add the
> transmit process.
> 
> Thanks.
> 
> >
> > Regards,
> > Marvin
> >
> > > -----Original Message-----
> > > From: Phil Yang [mailto:phil.yang at arm.com]
> > > Sent: Friday, March 23, 2018 4:04 PM
> > > To: dts at dpdk.org
> > > Cc: nd at arm.com; phil.yang at arm.com; Liu, Yong <yong.liu at intel.com>;
> > > herbert.guan at arm.com
> > > Subject: [PATCH 01/17] framwork/packet: Add sniff_packet specify
> > > running
> > >
> > > If tester in crb file was not the machine which running dts, the
> > > sniff_packet process will not running on tester.
> > >
> > > Create a ssh connection to the tester and run tcpdump to make sure
> > > sniff_packet process running on the machine we expected.
> > >
> > > Signed-off-by: Phil Yang <phil.yang at arm.com>
> > > ---
> > >  framework/packet.py | 34 ++++++++++++++++++++++++++++------
> > >  framework/tester.py | 34 ++++++++++++++++++++++++++++++++++
> > >  2 files changed, 62 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/framework/packet.py b/framework/packet.py index
> > > 976b82b..484e511 100755
> > > --- a/framework/packet.py
> > > +++ b/framework/packet.py
> > > @@ -812,15 +812,30 @@ def get_filter_cmd(filters=[]):
> > >          return ""
> > >
> > >
> > > -def sniff_packets(intf, count=0, timeout=5, filters=[]):
> > > +def sniff_packets(intf, count=0, timeout=5, filters=[], target=[]):
> > >      """
> > >      sniff all packets for certain port in certain seconds
> > >      """
> > >      param = ""
> > >      direct_param = r"(\s+)\[ (\S+) in\|out\|inout \]"
> > > -    tcpdump_help = subprocess.check_output("tcpdump -h; echo 0",
> > > -                                           stderr=subprocess.STDOUT,
> > > -                                           shell=True)
> > > +
> > > +    # target[] contain the remote machine info for ssh connection
> > > +    # target[0]: username
> > > +    # target[1]: ip address
> > > +    # target[2]: pass word
> > > +    if target:
> > > +        tcpdump_help_pipe = subprocess.Popen(["ssh",
> > > +                            "%s@%s" % (target[0], target[1]),
> > > +                            "tcpdump -h"],
> > > +                            stderr=subprocess.PIPE,
> > > +                            stdout=subprocess.PIPE,
> > > +                            shell=False)
> > > +        tcpdump_help = "".join(tuple(tcpdump_help_pipe.communicate()))
> > > +        tcpdump_help_pipe.wait()
> > > +    else:
> > > +        tcpdump_help = subprocess.check_output("tcpdump -h; echo 0",
> > > +                                    stderr=subprocess.STDOUT,
> > > + shell=True)
> > > +
> > >      for line in tcpdump_help.split('\n'):
> > >          m = re.match(direct_param, line)
> > >          if m:
> > > @@ -850,9 +865,16 @@ def sniff_packets(intf, count=0, timeout=5,
> > > filters=[]):
> > >      else:
> > >          cmd = sniff_cmd % options
> > >
> > > -    args = shlex.split(cmd)
> > > +    if target:
> > > +        pipe = subprocess.Popen(["ssh",
> > > +                "%s@%s" % (target[0], target[1]),
> > > +                cmd],
> > > +                stdin=subprocess.PIPE,
> > > +                shell=False)
> > > +    else:
> > > +        args = shlex.split(cmd)
> > > +        pipe = subprocess.Popen(args)
> > >
> > > -    pipe = subprocess.Popen(args)
> > >      index = str(time.time())
> > >      SNIFF_PIDS[index] = (pipe, intf, timeout)
> > >      time.sleep(1)
> > > diff --git a/framework/tester.py b/framework/tester.py index
> > > a775f68..49749de 100755
> > > --- a/framework/tester.py
> > > +++ b/framework/tester.py
> > > @@ -704,6 +704,40 @@ class Tester(Crb):
> > >              self.proc.kill()
> > >              self.proc = None
> > >
> > > +    def tcpdump_sniff_packets(self, intf, count=0, timeout=5,
> filters=[]):
> > > +        """
> > > +        Wrapper for packet module sniff_packets
> > > +        """
> > > +        # load functions in packet module
> > > +        module = __import__("packet")
> > > +        sniff_f = getattr(module, "sniff_packets")
> > > +
> > > +        target=[]
> > > +        target.append(self.get_username())
> > > +        target.append(self.get_ip_address())
> > > +        target.append(self.get_password())
> > > +        return sniff_f(intf, count, timeout, filters, target)
> > > +
> > > +    def load_tcpdump_sniff_pcap(self, index=''):
> > > +        """
> > > +        Wrapper for packet module load_sniff_pcap
> > > +        """
> > > +        # load functions in packet module
> > > +        module = __import__("packet")
> > > +        load_pcap_f = getattr(module, "load_sniff_pcap")
> > > +
> > > +        return load_pcap_f(index)
> > > +
> > > +    def load_tcpdump_sniff_packets(self, index=''):
> > > +        """
> > > +        Wrapper for packet module load_sniff_packets
> > > +        """
> > > +        # load functions in packet module
> > > +        module = __import__("packet")
> > > +        load_f = getattr(module, "load_sniff_packets")
> > > +
> > > +        return load_f(index)
> > > +
> > >      def kill_all(self, killall=False):
> > >          """
> > >          Kill all scapy process or DPDK application on tester.
> > > --
> > > 2.7.4



More information about the dts mailing list