diff options
author | Jan Gelety <jgelety@cisco.com> | 2017-09-08 11:38:38 +0200 |
---|---|---|
committer | Tibor Frank <tifrank@cisco.com> | 2017-09-18 12:05:49 +0000 |
commit | 2a848f49308868dfe6fa3a9cb78bd085f8c16f40 (patch) | |
tree | 180c45ea5db2cc095c65d3b698a3e05a6ee819fe /resources/traffic_scripts/send_tcp_udp.py | |
parent | 6928a6be42016a6c5edade6369041670fe544f39 (diff) |
Ignore unexpected ICMPv6 Neighbor Discovery - Neighbor Solicitation packets
We need to adapt all functional traffic scripts related to functional
IPv6 tests to ingore receiving of unexpected ICMPv6ND_NS
(ICMPv6 Neighbor Discovery - Neighbor Solicitation) packets that are
sent automatically and we cannot avoid to receive them.
The reason is to prevent false negative test results in case of csit
functional tests that could block creation of new operational branch
(csit weekly jobs), usage of new vpp builds (csit semiweekly jobs)
and merging patches - csit as well as vpp.
Change-Id: I43c90e7c766762fa769a81661338759a11b401a1
Signed-off-by: Jan Gelety <jgelety@cisco.com>
Diffstat (limited to 'resources/traffic_scripts/send_tcp_udp.py')
-rwxr-xr-x | resources/traffic_scripts/send_tcp_udp.py | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/resources/traffic_scripts/send_tcp_udp.py b/resources/traffic_scripts/send_tcp_udp.py index 77f918213f..4cba73286a 100755 --- a/resources/traffic_scripts/send_tcp_udp.py +++ b/resources/traffic_scripts/send_tcp_udp.py @@ -19,9 +19,9 @@ from one interface to the other. import sys import ipaddress -from scapy.layers.inet import IP, UDP, TCP -from scapy.layers.inet6 import IPv6 from scapy.all import Ether +from scapy.layers.inet import IP, UDP, TCP +from scapy.layers.inet6 import IPv6, ICMPv6ND_NS from resources.libraries.python.PacketVerifier import RxQueue, TxQueue from resources.libraries.python.TrafficScriptArg import TrafficScriptArg @@ -62,9 +62,8 @@ def valid_ipv6(ip): def main(): """Send TCP or UDP packet from one traffic generator interface to the other. """ - args = TrafficScriptArg( - ['tx_mac', 'rx_mac', 'src_ip', 'dst_ip', 'protocol', - 'source_port', 'destination_port']) + args = TrafficScriptArg(['tx_mac', 'rx_mac', 'src_ip', 'dst_ip', 'protocol', + 'source_port', 'destination_port']) src_mac = args.get_arg('tx_mac') dst_mac = args.get_arg('rx_mac') @@ -77,7 +76,6 @@ def main(): source_port = args.get_arg('source_port') destination_port = args.get_arg('destination_port') - ip_version = None if valid_ipv4(src_ip) and valid_ipv4(dst_ip): ip_version = IP elif valid_ipv6(src_ip) and valid_ipv6(dst_ip): @@ -90,7 +88,7 @@ def main(): elif protocol.upper() == 'UDP': protocol = UDP else: - raise ValueError("Invalid type of protocol!") + raise ValueError("Invalid protocol type!") rxq = RxQueue(rx_if) txq = TxQueue(tx_if) @@ -100,19 +98,27 @@ def main(): protocol(sport=int(source_port), dport=int(destination_port))) txq.send(pkt_raw) - ether = rxq.recv(2) - if ether is None: - raise RuntimeError("TCP/UDP Rx timeout") + while True: + ether = rxq.recv(2) + if ether is None: + raise RuntimeError('TCP/UDP Rx timeout') + + if ether.haslayer(ICMPv6ND_NS): + # read another packet in the queue if the current one is ICMPv6ND_NS + continue + else: + # otherwise process the current packet + break - if 'TCP' in ether: + if TCP in ether: print ("TCP packet received.") - elif 'UDP' in ether: + elif UDP in ether: print ("UDP packet received.") else: - raise RuntimeError("Not an TCP or UDP packet received {0}" - .format(ether.__repr__())) + raise RuntimeError("Not an TCP or UDP packet received {0}". + format(ether.__repr__())) sys.exit(0) |