#!/usr/bin/env python3 import typing from socket import AF_INET6, inet_pton, inet_ntop import unittest from ipaddress import ip_address, IPv4Network, IPv6Network from scapy.packet import Raw from scapy.layers.l2 import Ether, ARP, Dot1Q from scapy.layers.inet import IP, UDP, ICMP from scapy.layers.inet6 import ( IPv6, ICMPv6ND_NS, ICMPv6NDOptSrcLLAddr, ICMPv6ND_NA, ICMPv6EchoRequest, ) from scapy.utils6 import in6_getnsma, in6_getnsmac from scapy.layers.vxlan import VXLAN from scapy.data import ETH_P_IP, ETH_P_IPV6 from framework import tag_fixme_vpp_workers from framework import VppTestCase, VppTestRunner from vpp_object import VppObject from vpp_interface import VppInterface from vpp_ip_route import ( VppIpRoute, VppRoutePath, VppIpTable, VppIpInterfaceAddress, VppIpInterfaceBind, find_route, FibPathProto, FibPathType, ) from vpp_l2 import ( VppBridgeDomain, VppBridgeDomainPort, VppBridgeDomainArpEntry, VppL2FibEntry, find_bridge_domain_port, VppL2Vtr, ) from vpp_sub_interface import L2_VTR_OP, VppDot1QSubint from vpp_ip import DpoProto, get_dpo_proto from vpp_papi import VppEnum, MACAddress from vpp_vxlan_gbp_tunnel import find_vxlan_gbp_tunnel, INDEX_INVALID, \ VppVxlanGbpTunnel from vpp_neighbor import VppNeighbor from vpp_acl import AclRule, VppAcl NUM_PKTS = 67 def find_gbp_endpoint(test, sw_if_index=None, ip=None, mac=None, tep=None, sclass=None, flags=None): if ip: vip = ip if mac: vmac = MACAddress(mac) eps = test.vapi.gbp_endpoint_dump() for ep in eps: if tep: src = tep[0] dst = tep[1] if src != str(ep.endpoint.tun.src) or \ dst != str(ep.endpoint.tun.dst): continue if sw_if_index: if ep.endpoint.sw_if_index != sw_if_index: continue if sclass: if ep.endpoint.sclass != sclass: continue if flags: if flags != (flags & ep.endpoint.flags): continue if ip: for eip in ep.endpoint.ips: if vip == str(eip): return True if mac: if vmac == ep.endpoint.mac: return True return False def find_gbp_vxlan(test: VppTestCase, vni): ts = test.vapi.gbp_vxlan_tunnel_dump() for t in ts: if t.tunnel.vni == vni: return True return False class VppGbpEndpoint(VppObject): """ GBP Endpoint """ @property def mac(self): return str(self.vmac) @property def ip4(self): return self._ip4 @property def fip4(self): return self._fip4 @property def ip6(self): return self._ip6 @property def fip6(self): return self._fip6 @property def ips(self): return [self.ip4, self.ip6] @property def fips(self): return [self.fip4, self.fip6] def __init__(self, test, itf, epg, recirc, ip4, fip4, ip6, fip6, flags=0, tun_src="0.0.0.0", tun_dst="0.0.0.0", mac=True): self._test = test self.itf = itf self.handle = None self.epg = epg self.recirc = recirc self._ip4 = ip4 self._fip4 = fip4 self._ip6 = ip6 self._fip6 = fip6 if mac: self.vmac = MACAddress(self.itf.remote_mac) else: self.vmac = MACAddress("00:00:00:00:00:00") self.flags = flags self.tun_src = tun_src self.tun_dst = tun_dst def encode(self): ips = [self.ip4, self.ip6] return { "sw_if_index": self.itf.sw_if_index, "ips": ips, "n_ips": len(ips), "mac": self.vmac.packed, "sclass": self.epg.sclass, "flags": self.flags, "tun": { "src": self.tun_src, "dst": self.tun_dst, }, } def add_vpp_config(self): res = self._test.vapi.gbp_endpoint_add( endpoint=self.encode(), ) self.handle = res.handle self._test.registry.register(self, self._test.logger) def remove_vpp_config(self): self._test.vapi.gbp_endpoint_del(handle=self.handle) def object_id(self): return "gbp-endpoint:[%d==%d:%s:%d]" % (self.handle, self.itf.sw_if_index, self.ip4, self.epg.sclass) def query_vpp_config(self): return find_gbp_endpoint(self._test,
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>api-parent</artifactId>
<groupId>io.fd.honeycomb.common</groupId>
<version>1.19.01-SNAPSHOT</version>
<relativePath>../../../common/api-parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>io.fd.honeycomb.it</groupId>
<artifactId>memory-benchmark-api</artifactId>
<version>1.19.01-SNAPSHOT</version>
<name>${project.artifactId}</name>
</project>