- 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))
+ src_address = ip_address(unicode(source_ip))
+ dst_address = ip_address(unicode(destination_ip))
+
+ cmd = 'vxlan_add_del_tunnel'
+ args = dict(is_add=1,
+ is_ipv6=1 if src_address.version == 6 else 0,
+ instance=Constants.BITWISE_NON_ZERO,
+ src_address=src_address.packed,
+ dst_address=dst_address.packed,
+ mcast_sw_if_index=Constants.BITWISE_NON_ZERO,
+ encap_vrf_id=0,
+ decap_next_index=Constants.BITWISE_NON_ZERO,
+ vni=int(vni))
+ err_msg = 'Failed to create VXLAN tunnel interface on host {host}'.\
+ format(host=node['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, '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 = 'sw_interface_set_vxlan_bypass'
+ args = dict(is_ipv6=0,
+ sw_if_index=sw_if_index,
+ enable=1)
+ err_msg = 'Failed to set VXLAN bypass on interface on host {host}'.\
+ format(host=node['host'])
+ with PapiSocketExecutor(node) as papi_exec:
+ papi_exec.add(cmd, **args).get_replies(err_msg)