- output = VatExecutor.cmd_from_template(node, "vxlan_create.vat",
- src=source_ip,
- dst=destination_ip,
- vni=vni)
- output = output[0]
-
- if output["retval"] == 0:
- sw_if_idx = output["sw_if_index"]
- if_key = Topology.add_new_port(node, "vxlan_tunnel")
- Topology.update_interface_sw_if_index(node, if_key, sw_if_idx)
- ifc_name = InterfaceUtil.vpp_get_interface_name(node, sw_if_idx)
- Topology.update_interface_name(node, if_key, ifc_name)
- return sw_if_idx
- else:
- raise RuntimeError("Unable to create VXLAN interface on node {0}"
- .format(node))
+ cmd = u"vxlan_add_del_tunnel"
+ args = dict(
+ is_add=True,
+ instance=Constants.BITWISE_NON_ZERO,
+ src_address=IPAddress.create_ip_address_object(
+ ip_address(source_ip)
+ ),
+ dst_address=IPAddress.create_ip_address_object(
+ ip_address(destination_ip)
+ ),
+ mcast_sw_if_index=Constants.BITWISE_NON_ZERO,
+ encap_vrf_id=0,
+ decap_next_index=Constants.BITWISE_NON_ZERO,
+ vni=int(vni)
+ )
+ err_msg = f"Failed to create VXLAN tunnel interface " \
+ f"on host {node[u'host']}"
+ with PapiSocketExecutor(node) as papi_exec:
+ sw_if_index = papi_exec.add(cmd, **args).get_sw_if_index(err_msg)
+
+ if_key = Topology.add_new_port(node, u"vxlan_tunnel")
+ Topology.update_interface_sw_if_index(node, if_key, sw_if_index)
+ ifc_name = InterfaceUtil.vpp_get_interface_name(node, sw_if_index)
+ Topology.update_interface_name(node, if_key, ifc_name)
+
+ return sw_if_index
+
+ @staticmethod
+ def set_vxlan_bypass(node, interface=None):
+ """Add the 'ip4-vxlan-bypass' graph node for a given interface.
+
+ By adding the IPv4 vxlan-bypass graph node to an interface, the node
+ checks for and validate input vxlan packet and bypass ip4-lookup,
+ ip4-local, ip4-udp-lookup nodes to speedup vxlan packet forwarding.
+ This node will cause extra overhead to for non-vxlan packets which is
+ kept at a minimum.
+
+ :param node: Node where to set VXLAN bypass.
+ :param interface: Numeric index or name string of a specific interface.
+ :type node: dict
+ :type interface: int or str
+ :raises RuntimeError: if it failed to set VXLAN bypass on interface.
+ """
+ sw_if_index = InterfaceUtil.get_interface_index(node, interface)
+
+ cmd = u"sw_interface_set_vxlan_bypass"
+ args = dict(
+ is_ipv6=False,
+ sw_if_index=sw_if_index,
+ enable=True
+ )
+ err_msg = f"Failed to set VXLAN bypass on interface " \
+ f"on host {node[u'host']}"
+ with PapiSocketExecutor(node) as papi_exec:
+ papi_exec.add(cmd, **args).get_replies(err_msg)