aboutsummaryrefslogtreecommitdiffstats
path: root/GPL/traffic_scripts
diff options
context:
space:
mode:
authorpmikus <pmikus@cisco.com>2021-06-10 08:51:19 +0000
committerpmikus <pmikus@cisco.com>2021-06-10 09:51:44 +0000
commit8b25b4e89bdba964f2a3d602b8c47f551a084724 (patch)
treeffdc167ad55fdec9857d1abb5b28d5b64c1f805a /GPL/traffic_scripts
parentf754eac4faf76fdbffac648769c03f5668f9f6a2 (diff)
FIX: Add ICMPv6MLReport2 masking
Signed-off-by: pmikus <pmikus@cisco.com> Change-Id: I1183a0ffd13c6926b3963b78630954bb6356133b
Diffstat (limited to 'GPL/traffic_scripts')
-rw-r--r--GPL/traffic_scripts/geneve_tunnel.py10
-rw-r--r--GPL/traffic_scripts/ipsec_interface.py6
-rw-r--r--GPL/traffic_scripts/ipsec_policy.py6
-rw-r--r--GPL/traffic_scripts/lisp/lisp_check.py28
-rw-r--r--GPL/traffic_scripts/lisp/lispgpe_check.py31
-rw-r--r--GPL/traffic_scripts/nat.py6
-rw-r--r--GPL/traffic_scripts/policer.py6
-rw-r--r--GPL/traffic_scripts/send_icmp_wait_for_reply.py8
-rw-r--r--GPL/traffic_scripts/srv6_encap.py6
9 files changed, 83 insertions, 24 deletions
diff --git a/GPL/traffic_scripts/geneve_tunnel.py b/GPL/traffic_scripts/geneve_tunnel.py
index 3dd40b6a3a..1270aa6663 100644
--- a/GPL/traffic_scripts/geneve_tunnel.py
+++ b/GPL/traffic_scripts/geneve_tunnel.py
@@ -30,7 +30,7 @@ import sys
from ipaddress import ip_address
from scapy.contrib.geneve import GENEVE
from scapy.layers.inet import IP, UDP
-from scapy.layers.inet6 import IPv6, ICMPv6ND_NS
+from scapy.layers.inet6 import IPv6, ICMPv6ND_NS, ICMPv6MLReport2
from scapy.layers.l2 import Ether
from scapy.packet import Raw
@@ -280,6 +280,10 @@ def main():
if rx_pkt_recv.haslayer(ICMPv6ND_NS):
# read another packet in the queue if the current one is ICMPv6ND_NS
continue
+ elif rx_pkt_recv.haslayer(ICMPv6MLReport2):
+ # read another packet in the queue if the current one is
+ # ICMPv6MLReport2
+ continue
else:
# otherwise process the current packet
break
@@ -333,6 +337,10 @@ def main():
if tx_pkt_recv.haslayer(ICMPv6ND_NS):
# read another packet in the queue if the current one is ICMPv6ND_NS
continue
+ elif tx_pkt_recv.haslayer(ICMPv6MLReport2):
+ # read another packet in the queue if the current one is
+ # ICMPv6MLReport2
+ continue
else:
# otherwise process the current packet
break
diff --git a/GPL/traffic_scripts/ipsec_interface.py b/GPL/traffic_scripts/ipsec_interface.py
index 9c28f4c06d..ee157260fa 100644
--- a/GPL/traffic_scripts/ipsec_interface.py
+++ b/GPL/traffic_scripts/ipsec_interface.py
@@ -29,7 +29,7 @@ import sys
from ipaddress import ip_address
from scapy.layers.inet import IP
-from scapy.layers.inet6 import IPv6, ICMPv6ND_NS
+from scapy.layers.inet6 import IPv6, ICMPv6ND_NS, ICMPv6MLReport2
from scapy.layers.ipsec import SecurityAssociation, ESP
from scapy.layers.l2 import Ether
from scapy.packet import Raw
@@ -271,6 +271,10 @@ def main():
if tx_pkt_recv.haslayer(ICMPv6ND_NS):
# read another packet in the queue if the current one is ICMPv6ND_NS
continue
+ elif tx_pkt_recv.haslayer(ICMPv6MLReport2):
+ # read another packet in the queue if the current one is
+ # ICMPv6MLReport2
+ continue
else:
# otherwise process the current packet
break
diff --git a/GPL/traffic_scripts/ipsec_policy.py b/GPL/traffic_scripts/ipsec_policy.py
index 0d5dcf5481..4acf0a144b 100644
--- a/GPL/traffic_scripts/ipsec_policy.py
+++ b/GPL/traffic_scripts/ipsec_policy.py
@@ -29,7 +29,7 @@ import sys
from ipaddress import ip_address
from scapy.layers.inet import IP
-from scapy.layers.inet6 import IPv6, ICMPv6ND_NS
+from scapy.layers.inet6 import IPv6, ICMPv6ND_NS, ICMPv6MLReport2
from scapy.layers.ipsec import SecurityAssociation, ESP
from scapy.layers.l2 import Ether
from scapy.packet import Raw
@@ -205,6 +205,10 @@ def main():
if rx_pkt_recv.haslayer(ICMPv6ND_NS):
# read another packet in the queue if the current one is ICMPv6ND_NS
continue
+ elif rx_pkt_recv.haslayer(ICMPv6MLReport2):
+ # read another packet in the queue if the current one is
+ # ICMPv6MLReport2
+ continue
else:
# otherwise process the current packet
break
diff --git a/GPL/traffic_scripts/lisp/lisp_check.py b/GPL/traffic_scripts/lisp/lisp_check.py
index 6612485893..88d4ad5619 100644
--- a/GPL/traffic_scripts/lisp/lisp_check.py
+++ b/GPL/traffic_scripts/lisp/lisp_check.py
@@ -34,7 +34,7 @@ from scapy.all import bind_layers, Packet
from scapy.fields import FlagsField, BitField, IntField
from scapy.layers.inet import ICMP, IP, UDP
from scapy.layers.inet6 import ICMPv6EchoRequest
-from scapy.layers.inet6 import IPv6
+from scapy.layers.inet6 import IPv6, ICMPv6ND_NS, ICMPv6MLReport2
from scapy.layers.l2 import Ether
from scapy.packet import Raw
@@ -133,13 +133,25 @@ def main():
sent_packets.append(pkt_raw)
txq.send(pkt_raw)
- if tx_if == rx_if:
- ether = rxq.recv(2, ignore=sent_packets)
- else:
- ether = rxq.recv(2)
-
- if ether is None:
- raise RuntimeError(u"ICMP echo Rx timeout")
+ while True:
+ if tx_if == rx_if:
+ ether = rxq.recv(2, ignore=sent_packets)
+ else:
+ ether = rxq.recv(2)
+
+ if ether is None:
+ raise RuntimeError(u"ICMP echo Rx timeout")
+
+ if ether.haslayer(ICMPv6ND_NS):
+ # read another packet in the queue if the current one is ICMPv6ND_NS
+ continue
+ elif ether.haslayer(ICMPv6MLReport2):
+ # read another packet in the queue if the current one is
+ # ICMPv6MLReport2
+ continue
+
+ # otherwise process the current packet
+ break
if rx_dst_mac == ether[Ether].dst and rx_src_mac == ether[Ether].src:
print(u"MAC addresses match.")
diff --git a/GPL/traffic_scripts/lisp/lispgpe_check.py b/GPL/traffic_scripts/lisp/lispgpe_check.py
index 41bc0964e6..79d2ccfab6 100644
--- a/GPL/traffic_scripts/lisp/lispgpe_check.py
+++ b/GPL/traffic_scripts/lisp/lispgpe_check.py
@@ -35,7 +35,7 @@ from scapy.all import bind_layers, Packet
from scapy.fields import FlagsField, BitField, XBitField, IntField
from scapy.layers.inet import ICMP, IP, UDP
from scapy.layers.inet6 import ICMPv6EchoRequest
-from scapy.layers.inet6 import IPv6
+from scapy.layers.inet6 import IPv6, ICMPv6ND_NS, ICMPv6MLReport2, ICMPv6ND_RA
from scapy.layers.l2 import Ether
from scapy.packet import Raw
@@ -156,13 +156,28 @@ def main():
sent_packets.append(pkt_raw)
txq.send(pkt_raw)
- if tx_if == rx_if:
- ether = rxq.recv(2, ignore=sent_packets)
- else:
- ether = rxq.recv(2)
-
- if ether is None:
- raise RuntimeError(u"ICMP echo Rx timeout")
+ while True:
+ if tx_if == rx_if:
+ ether = rxq.recv(2, ignore=sent_packets)
+ else:
+ ether = rxq.recv(2)
+
+ if ether is None:
+ raise RuntimeError(u"ICMP echo Rx timeout")
+
+ if ether.haslayer(ICMPv6ND_NS):
+ # read another packet in the queue if the current one is ICMPv6ND_NS
+ continue
+ if ether.haslayer(ICMPv6ND_RA):
+ # read another packet in the queue if the current one is ICMPv6ND_RA
+ continue
+ elif ether.haslayer(ICMPv6MLReport2):
+ # read another packet in the queue if the current one is
+ # ICMPv6MLReport2
+ continue
+
+ # otherwise process the current packet
+ break
if rx_dst_mac == ether[Ether].dst and rx_src_mac == ether[Ether].src:
print(u"MAC addresses match.")
diff --git a/GPL/traffic_scripts/nat.py b/GPL/traffic_scripts/nat.py
index d9f0330641..319d617f7c 100644
--- a/GPL/traffic_scripts/nat.py
+++ b/GPL/traffic_scripts/nat.py
@@ -30,7 +30,7 @@ import sys
import ipaddress
from scapy.layers.inet import IP, TCP, UDP
-from scapy.layers.inet6 import IPv6, ICMPv6ND_NS
+from scapy.layers.inet6 import IPv6, ICMPv6ND_NS, ICMPv6MLReport2
from scapy.layers.l2 import Ether
from scapy.packet import Raw
@@ -182,6 +182,10 @@ def main():
if ether.haslayer(ICMPv6ND_NS):
# read another packet in the queue if the current one is ICMPv6ND_NS
continue
+ elif ether.haslayer(ICMPv6MLReport2):
+ # read another packet in the queue if the current one is
+ # ICMPv6MLReport2
+ continue
else:
# otherwise process the current packet
break
diff --git a/GPL/traffic_scripts/policer.py b/GPL/traffic_scripts/policer.py
index 262d7878b6..ef78f279ad 100644
--- a/GPL/traffic_scripts/policer.py
+++ b/GPL/traffic_scripts/policer.py
@@ -31,7 +31,7 @@ import logging
from ipaddress import ip_address
from scapy.layers.l2 import Ether
from scapy.layers.inet import IP, TCP
-from scapy.layers.inet6 import IPv6, ICMPv6ND_NS
+from scapy.layers.inet6 import IPv6, ICMPv6ND_NS, ICMPv6MLReport2
from scapy.packet import Raw
from .TrafficScriptArg import TrafficScriptArg
@@ -113,6 +113,10 @@ def main():
if pkt_recv.haslayer(ICMPv6ND_NS):
# read another packet in the queue if the current one is ICMPv6ND_NS
continue
+ elif pkt_recv.haslayer(ICMPv6MLReport2):
+ # read another packet in the queue if the current one is
+ # ICMPv6MLReport2
+ continue
else:
# otherwise process the current packet
break
diff --git a/GPL/traffic_scripts/send_icmp_wait_for_reply.py b/GPL/traffic_scripts/send_icmp_wait_for_reply.py
index 70d9a99ec2..966fa60a9c 100644
--- a/GPL/traffic_scripts/send_icmp_wait_for_reply.py
+++ b/GPL/traffic_scripts/send_icmp_wait_for_reply.py
@@ -29,8 +29,8 @@ import sys
import ipaddress
from scapy.layers.inet import ICMP, IP
-from scapy.layers.inet6 import IPv6, ICMPv6EchoRequest, ICMPv6EchoReply,\
- ICMPv6ND_NS
+from scapy.layers.inet6 import ICMPv6EchoRequest, ICMPv6EchoReply,\
+ ICMPv6ND_NS, ICMPv6MLReport2
from scapy.layers.l2 import Ether
from scapy.packet import Raw
@@ -126,6 +126,10 @@ def main():
elif icmp_reply.haslayer(ICMPv6ND_NS):
# read another packet in the queue in case of ICMPv6ND_NS packet
continue
+ elif icmp_reply.haslayer(ICMPv6MLReport2):
+ # read another packet in the queue if the current one is
+ # ICMPv6MLReport2
+ continue
else:
# otherwise process the current packet
break
diff --git a/GPL/traffic_scripts/srv6_encap.py b/GPL/traffic_scripts/srv6_encap.py
index 725db9fc33..9cdfccf432 100644
--- a/GPL/traffic_scripts/srv6_encap.py
+++ b/GPL/traffic_scripts/srv6_encap.py
@@ -28,7 +28,7 @@
import sys
from scapy.layers.inet6 import IPv6, ICMPv6ND_NS, IPv6ExtHdrSegmentRouting,\
- ipv6nh
+ ipv6nh, ICMPv6MLReport2
from scapy.layers.l2 import Ether
from scapy.packet import Raw
@@ -296,6 +296,10 @@ def main():
if tx_pkt_recv.haslayer(ICMPv6ND_NS):
# read another packet in the queue if the current one is ICMPv6ND_NS
continue
+ elif tx_pkt_recv.haslayer(ICMPv6MLReport2):
+ # read another packet in the queue if the current one is
+ # ICMPv6MLReport2
+ continue
else:
# otherwise process the current packet
break
>2].lkey = rd->lkey; s[3].addr = vlib_buffer_get_va (b[3]); s[3].length = vlib_buffer_get_default_data_size (vm); s[3].lkey = rd->lkey; w[0].next = &w[0] + 1; w[0].sg_list = &s[0]; w[0].num_sge = 1; w[1].next = &w[1] + 1; w[1].sg_list = &s[1]; w[1].num_sge = 1; w[2].next = &w[2] + 1; w[2].sg_list = &s[2]; w[2].num_sge = 1; w[3].next = &w[3] + 1; w[3].sg_list = &s[3]; w[3].num_sge = 1; s += 4; w += 4; b += 4; n -= 4; } while (n >= 1) { s[0].addr = vlib_buffer_get_va (b[0]); s[0].length = vlib_buffer_get_default_data_size (vm); s[0].lkey = rd->lkey; w[0].next = &w[0] + 1; w[0].sg_list = &s[0]; w[0].num_sge = 1; s += 1; w += 1; b += 1; n -= 1; } w[-1].next = 0; /* fix next pointer in WR linked-list last item */ n = n_alloc; if (ibv_post_wq_recv (rxq->wq, wr, &w) != 0) { n = w - wr; vlib_buffer_free_from_ring (vm, rxq->bufs, slot + n, rxq->size, n_alloc - n); } rxq->tail += n; } static_always_inline void rdma_device_input_trace (vlib_main_t * vm, vlib_node_runtime_t * node, const rdma_device_t * rd, u32 n_left, const u32 * bi, u32 next_index) { u32 n_trace, i; if (PREDICT_TRUE (0 == (n_trace = vlib_get_trace_count (vm, node)))) return; i = 0; while (n_trace && n_left) { vlib_buffer_t *b; rdma_input_trace_t *tr; b = vlib_get_buffer (vm, bi[0]); vlib_trace_buffer (vm, node, next_index, b, /* follow_chain */ 0); tr = vlib_add_trace (vm, node, b, sizeof (*tr)); tr->next_index = next_index; tr->hw_if_index = rd->hw_if_index; /* next */ n_trace--; n_left--; bi++; i++; } vlib_set_trace_count (vm, node, n_trace); } static_always_inline void rdma_device_input_ethernet (vlib_main_t * vm, vlib_node_runtime_t * node, const rdma_device_t * rd, u32 next_index) { vlib_next_frame_t *nf; vlib_frame_t *f; ethernet_input_frame_t *ef; if (PREDICT_FALSE (VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT != next_index)) return; nf = vlib_node_runtime_get_next_frame (vm, node, VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT); f = vlib_get_frame (vm, nf->frame); f->flags = ETH_INPUT_FRAME_F_SINGLE_SW_IF_IDX; /* FIXME: f->flags |= ETH_INPUT_FRAME_F_IP4_CKSUM_OK; */ ef = vlib_frame_scalar_args (f); ef->sw_if_index = rd->sw_if_index; ef->hw_if_index = rd->hw_if_index; } static_always_inline u32 rdma_device_input_bufs (vlib_main_t * vm, const rdma_device_t * rd, u32 * next, u32 * bi, struct ibv_wc * wc, u32 n_left_from, vlib_buffer_t * bt) { vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b = bufs; u32 n_rx_bytes[4] = { 0 }; vlib_get_buffers (vm, bi, bufs, n_left_from); ASSERT (bt->buffer_pool_index == bufs[0]->buffer_pool_index); while (n_left_from >= 4) { if (PREDICT_TRUE (n_left_from >= 8)) { CLIB_PREFETCH (&wc[4 + 0], CLIB_CACHE_LINE_BYTES, LOAD); CLIB_PREFETCH (&wc[4 + 1], CLIB_CACHE_LINE_BYTES, LOAD); CLIB_PREFETCH (&wc[4 + 2], CLIB_CACHE_LINE_BYTES, LOAD); CLIB_PREFETCH (&wc[4 + 3], CLIB_CACHE_LINE_BYTES, LOAD); vlib_prefetch_buffer_header (b[4 + 0], STORE); vlib_prefetch_buffer_header (b[4 + 1], STORE); vlib_prefetch_buffer_header (b[4 + 2], STORE); vlib_prefetch_buffer_header (b[4 + 3], STORE); } vlib_buffer_copy_indices (next, bi, 4); vlib_buffer_copy_template (b[0], bt); vlib_buffer_copy_template (b[1], bt); vlib_buffer_copy_template (b[2], bt); vlib_buffer_copy_template (b[3], bt); b[0]->current_length = wc[0].byte_len; b[1]->current_length = wc[1].byte_len; b[2]->current_length = wc[2].byte_len; b[3]->current_length = wc[3].byte_len; n_rx_bytes[0] += wc[0].byte_len; n_rx_bytes[1] += wc[1].byte_len; n_rx_bytes[2] += wc[2].byte_len; n_rx_bytes[3] += wc[3].byte_len; next += 4; bi += 4; b += 4; wc += 4; n_left_from -= 4; } while (n_left_from >= 1) { vlib_buffer_copy_indices (next, bi, 1); vlib_buffer_copy_template (b[0], bt); b[0]->current_length = wc[0].byte_len; n_rx_bytes[0] += wc[0].byte_len; next += 1; bi += 1; b += 1; wc += 1; n_left_from -= 1; } return n_rx_bytes[0] + n_rx_bytes[1] + n_rx_bytes[2] + n_rx_bytes[3]; } static_always_inline uword rdma_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame, rdma_device_t * rd, u16 qid) { vnet_main_t *vnm = vnet_get_main (); rdma_rxq_t *rxq = vec_elt_at_index (rd->rxqs, qid); struct ibv_wc wc[VLIB_FRAME_SIZE]; vlib_buffer_t bt; u32 next_index, *to_next, n_left_to_next; u32 n_rx_packets, n_rx_bytes; u32 slot, n_tail; ASSERT (rxq->size >= VLIB_FRAME_SIZE && is_pow2 (rxq->size)); ASSERT (rxq->tail - rxq->head <= rxq->size); n_rx_packets = ibv_poll_cq (rxq->cq, VLIB_FRAME_SIZE, wc); ASSERT (n_rx_packets <= rxq->tail - rxq->head); if (PREDICT_FALSE (n_rx_packets <= 0)) { rdma_device_input_refill (vm, rd, rxq); return 0; } /* init buffer template */ clib_memset_u64 (&bt, 0, STRUCT_OFFSET_OF (vlib_buffer_t, template_end) / sizeof (u64)); vnet_buffer (&bt)->sw_if_index[VLIB_RX] = rd->sw_if_index; vnet_buffer (&bt)->sw_if_index[VLIB_TX] = ~0; bt.buffer_pool_index = rd->pool; bt.ref_count = 1; /* update buffer template for input feature arcs if any */ next_index = rd->per_interface_next_index; if (PREDICT_FALSE (vnet_device_input_have_features (rd->sw_if_index))) vnet_feature_start_device_input_x1 (rd->sw_if_index, &next_index, &bt); vlib_get_new_next_frame (vm, node, next_index, to_next, n_left_to_next); ASSERT (n_rx_packets <= n_left_to_next); /* * avoid wrap-around logic in core loop * we requested VLIB_FRAME_SIZE packets and rxq->size >= VLIB_FRAME_SIZE * => we can process all packets in 2 iterations max */ slot = rxq->head & (rxq->size - 1); n_tail = clib_min (n_rx_packets, rxq->size - slot); n_rx_bytes = rdma_device_input_bufs (vm, rd, &to_next[0], &rxq->bufs[slot], wc, n_tail, &bt); if (n_tail < n_rx_packets) n_rx_bytes += rdma_device_input_bufs (vm, rd, &to_next[n_tail], &rxq->bufs[0], wc, n_rx_packets - n_tail, &bt); rdma_device_input_ethernet (vm, node, rd, next_index); vlib_put_next_frame (vm, node, next_index, n_left_to_next - n_rx_packets); rxq->head += n_rx_packets; rdma_device_input_trace (vm, node, rd, n_rx_packets, to_next, next_index); vlib_increment_combined_counter (vnm->interface_main.combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, vm->thread_index, rd->hw_if_index, n_rx_packets, n_rx_bytes); rdma_device_input_refill (vm, rd, rxq); return n_rx_packets; } VLIB_NODE_FN (rdma_input_node) (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) { u32 n_rx = 0; rdma_main_t *rm = &rdma_main; vnet_device_input_runtime_t *rt = (void *) node->runtime_data; vnet_device_and_queue_t *dq; foreach_device_and_queue (dq, rt->devices_and_queues) { rdma_device_t *rd; rd = vec_elt_at_index (rm->devices, dq->dev_instance); if (PREDICT_TRUE (rd->flags & RDMA_DEVICE_F_ADMIN_UP)) n_rx += rdma_device_input_inline (vm, node, frame, rd, dq->queue_id); } return n_rx; } /* *INDENT-OFF* */ VLIB_REGISTER_NODE (rdma_input_node) = { .name = "rdma-input", .flags = VLIB_NODE_FLAG_TRACE_SUPPORTED, .sibling_of = "device-input", .format_trace = format_rdma_input_trace, .type = VLIB_NODE_TYPE_INPUT, .state = VLIB_NODE_STATE_DISABLED, .n_errors = RDMA_INPUT_N_ERROR, .error_strings = rdma_input_error_strings, }; /* *INDENT-ON* */ /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */