From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 8C2DF5A0C for ; Mon, 8 Jun 2015 04:21:42 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP; 07 Jun 2015 19:21:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,571,1427785200"; d="scan'208";a="504538618" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by FMSMGA003.fm.intel.com with ESMTP; 07 Jun 2015 19:21:41 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id t582LdlP032245; Mon, 8 Jun 2015 10:21:39 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t582LaeY005651; Mon, 8 Jun 2015 10:21:38 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t582LaO8005647; Mon, 8 Jun 2015 10:21:36 +0800 From: Yong Liu To: dts@dpdk.org Date: Mon, 8 Jun 2015 10:21:26 +0800 Message-Id: <1433730088-5601-3-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1433730088-5601-1-git-send-email-yong.liu@intel.com> References: <1433730088-5601-1-git-send-email-yong.liu@intel.com> Subject: [dts] [PATCH 2/4] Add vxlan protocal support in etgen module X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jun 2015 02:21:43 -0000 From: Marvin Liu Inner packets can not be handled like normal packet. Now parse_pcap function will strip vxlan inner packet and convert it to hex string. This hex string will be configured to dataBytes of protocolPad. Signed-off-by: Marvin Liu diff --git a/framework/etgen.py b/framework/etgen.py index 8270f24..fc64b70 100644 --- a/framework/etgen.py +++ b/framework/etgen.py @@ -189,11 +189,34 @@ class IxiaPacketGenerator(SSHConnection): self.send_expect("clearOwnershipAndLogout", "% ") def parse_pcap(self, fpcap): - """ - Parse packet in pcap file and convert it into tcl commands. - """ - self.send_expect("echo {print [i.command() for i in rdpcap('%s', -1)]; exit()} > dumppcap.py" % - fpcap, "% ") + dump_str1 = "cmds = []\n" + dump_str2 = "for i in rdpcap('%s', -1):\n" % fpcap + dump_str3 = " if 'Vxlan' in i.command():\n" + \ + " vxlan_str = ''\n" + \ + " l = len(i[Vxlan])\n" + \ + " vxlan = str(i[Vxlan])\n" + \ + " first = True\n" + \ + " for j in range(l):\n" + \ + " if first:\n" + \ + " vxlan_str += \"Vxlan(hexval='%02X\" %ord(vxlan[j])\n" + \ + " first = False\n" + \ + " else:\n" + \ + " vxlan_str += \" %02X\" %ord(vxlan[j])\n" + \ + " vxlan_str += \"\')\"\n" + \ + " command = re.sub(r\"Vxlan(.*)\", vxlan_str, i.command())\n" + \ + " else:\n" + \ + " command = i.command()\n" + \ + " cmds.append(command)\n" + \ + "print cmds\n" + \ + "exit()" + + f = open("dumppcap.py", "w") + f.write(dump_str1) + f.write(dump_str2) + f.write(dump_str3) + f.close() + + self.session.copy_file_to("dumppcap.py") out = self.send_expect("scapy -c dumppcap.py 2>/dev/null", "% ", 120) flows = eval(out) return flows @@ -254,7 +277,15 @@ class IxiaPacketGenerator(SSHConnection): self.add_tcl_cmd("udp config -sourcePort %d" % sport) self.add_tcl_cmd("udp config -destPort %d" % dport) self.add_tcl_cmd("udp config -length %d" % len) - self.add_tcl_cmd("udp set %d %d %d" % (self.chasId, port['card'], port['port'])) + self.add_tcl_cmd("udp set %d %d %d" % + (self.chasId, port['card'], port['port'])) + + def vxlan(self, port, hexval): + self.add_tcl_cmd("protocolPad setDefault") + self.add_tcl_cmd("protocol config -enableProtocolPad true") + self.add_tcl_cmd("protocolPad config -dataBytes \"%s\"" % hexval) + self.add_tcl_cmd("protocolPad set %d %d %d" % + (self.chasId, port['card'], port['port'])) def tcp(self, port, sport, dport, seq, ack, dataofs, reserved, flags, window, chksum, urgptr, options=None): """ @@ -297,6 +328,10 @@ class IxiaPacketGenerator(SSHConnection): match = pat.match(header) params = eval('dict(%s)' % match.group(2)) method_name = match.group(1) + if method_name == 'Vxlan': + method = getattr(self, method_name.lower()) + method(txport, **params) + break if method_name in SCAPY2IXIA: method = getattr(self, method_name.lower()) method(txport, **params) diff --git a/framework/settings.py b/framework/settings.py index 2eccc64..19ebe6b 100644 --- a/framework/settings.py +++ b/framework/settings.py @@ -124,7 +124,8 @@ HEADER_SIZE = { 'ip': 20, 'ipv6': 40, 'udp': 8, - 'tcp': 20 + 'tcp': 20, + 'vxlan': 8, } -- 1.9.3