summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_bond.py4
-rw-r--r--test/test_dhcp.py22
-rw-r--r--test/test_gbp.py91
-rw-r--r--test/test_ip4_irb.py4
-rw-r--r--test/test_l2_fib.py5
-rw-r--r--test/test_l2bd_arp_term.py3
-rw-r--r--test/test_nat.py14
-rw-r--r--test/test_p2p_ethernet.py12
-rw-r--r--test/test_pppoe.py1
-rwxr-xr-xtest/test_util.py6
-rw-r--r--test/util.py4
-rw-r--r--test/vpp_interface.py15
-rw-r--r--test/vpp_l2.py26
-rw-r--r--test/vpp_mac.py50
-rw-r--r--test/vpp_neighbor.py6
-rw-r--r--test/vpp_papi_provider.py7
-rw-r--r--test/vpp_pppoe_interface.py6
17 files changed, 108 insertions, 168 deletions
diff --git a/test/test_bond.py b/test/test_bond.py
index b955f899190..9926d230564 100644
--- a/test/test_bond.py
+++ b/test/test_bond.py
@@ -7,8 +7,8 @@ from framework import VppTestCase, VppTestRunner
from scapy.packet import Raw
from scapy.layers.l2 import Ether
from scapy.layers.inet import IP, UDP
-from vpp_mac import mactobinary
from vpp_bond_interface import VppBondInterface
+from vpp_papi import MACAddress
class TestBondInterface(VppTestCase):
@@ -56,7 +56,7 @@ class TestBondInterface(VppTestCase):
# create interface (BondEthernet0)
# self.logger.info("create bond")
bond0_mac = "02:fe:38:30:59:3c"
- mac = mactobinary(bond0_mac)
+ mac = MACAddress(bond0_mac).packed
bond0 = VppBondInterface(self,
mode=3,
lb=1,
diff --git a/test/test_dhcp.py b/test/test_dhcp.py
index db3e3f3bab0..3d00f1b8468 100644
--- a/test/test_dhcp.py
+++ b/test/test_dhcp.py
@@ -8,7 +8,6 @@ from framework import VppTestCase, VppTestRunner, running_extended_tests
from vpp_neighbor import VppNeighbor
from vpp_ip_route import find_route, VppIpTable
from util import mk_ll_addr
-from vpp_mac import mactobinary, binarytomac
from scapy.layers.l2 import Ether, getmacbyip, ARP
from scapy.layers.inet import IP, UDP, ICMP
from scapy.layers.inet6 import IPv6, in6_getnsmac
@@ -20,6 +19,7 @@ from scapy.layers.dhcp6 import DHCP6, DHCP6_Solicit, DHCP6_RelayForward, \
from socket import AF_INET, AF_INET6
from scapy.utils import inet_pton, inet_ntop
from scapy.utils6 import in6_ptop
+from vpp_papi import mac_pton
DHCP4_CLIENT_PORT = 68
DHCP4_SERVER_PORT = 67
@@ -1218,7 +1218,7 @@ class TestDHCP(VppTestCase):
UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_CLIENT_PORT) /
BOOTP(op=1,
yiaddr=self.pg3.local_ip4,
- chaddr=mactobinary(self.pg3.local_mac)) /
+ chaddr=mac_pton(self.pg3.local_mac)) /
DHCP(options=[('message-type', 'offer'),
('server_id', self.pg3.remote_ip4),
'end']))
@@ -1238,7 +1238,7 @@ class TestDHCP(VppTestCase):
IP(src=self.pg3.remote_ip4, dst="255.255.255.255") /
UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_CLIENT_PORT) /
BOOTP(op=1, yiaddr=self.pg3.local_ip4,
- chaddr=mactobinary(self.pg3.local_mac)) /
+ chaddr=mac_pton(self.pg3.local_mac)) /
DHCP(options=[('message-type', 'ack'),
('subnet_mask', "255.255.255.0"),
('router', self.pg3.remote_ip4),
@@ -1267,7 +1267,7 @@ class TestDHCP(VppTestCase):
# remove the left over ARP entry
self.vapi.ip_neighbor_add_del(self.pg3.sw_if_index,
- mactobinary(self.pg3.remote_mac),
+ mac_pton(self.pg3.remote_mac),
self.pg3.remote_ip4,
is_add=0)
#
@@ -1315,7 +1315,7 @@ class TestDHCP(VppTestCase):
IP(src=self.pg3.remote_ip4, dst=self.pg3.local_ip4) /
UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_CLIENT_PORT) /
BOOTP(op=1, yiaddr=self.pg3.local_ip4,
- chaddr=mactobinary(self.pg3.local_mac)) /
+ chaddr=mac_pton(self.pg3.local_mac)) /
DHCP(options=[('message-type', 'ack'),
('subnet_mask', "255.255.255.0"),
('router', self.pg3.remote_ip4),
@@ -1373,7 +1373,7 @@ class TestDHCP(VppTestCase):
IP(src=self.pg3.remote_ip4, dst=self.pg3.local_ip4) /
UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_CLIENT_PORT) /
BOOTP(op=1, yiaddr=self.pg3.local_ip4,
- chaddr=mactobinary(self.pg3.local_mac)) /
+ chaddr=mac_pton(self.pg3.local_mac)) /
DHCP(options=[('message-type', 'offer'),
('server_id', self.pg3.remote_ip4),
'end']))
@@ -1394,7 +1394,7 @@ class TestDHCP(VppTestCase):
IP(src=self.pg3.remote_ip4, dst=self.pg3.local_ip4) /
UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_CLIENT_PORT) /
BOOTP(op=1, yiaddr=self.pg3.local_ip4,
- chaddr=mactobinary(self.pg3.local_mac)) /
+ chaddr=mac_pton(self.pg3.local_mac)) /
DHCP(options=[('message-type', 'ack'),
('subnet_mask', "255.255.255.0"),
('router', self.pg3.remote_ip4),
@@ -1423,7 +1423,7 @@ class TestDHCP(VppTestCase):
# remove the left over ARP entry
self.vapi.ip_neighbor_add_del(self.pg3.sw_if_index,
- mactobinary(self.pg3.remote_mac),
+ mac_pton(self.pg3.remote_mac),
self.pg3.remote_ip4,
is_add=0)
@@ -1481,7 +1481,7 @@ class TestDHCP(VppTestCase):
UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_CLIENT_PORT) /
BOOTP(op=1,
yiaddr=self.pg3.local_ip4,
- chaddr=mactobinary(self.pg3.local_mac)) /
+ chaddr=mac_pton(self.pg3.local_mac)) /
DHCP(options=[('message-type', 'offer'),
('server_id', self.pg3.remote_ip4),
('lease_time', lease_time),
@@ -1502,7 +1502,7 @@ class TestDHCP(VppTestCase):
IP(src=self.pg3.remote_ip4, dst='255.255.255.255') /
UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_CLIENT_PORT) /
BOOTP(op=1, yiaddr=self.pg3.local_ip4,
- chaddr=mactobinary(self.pg3.local_mac)) /
+ chaddr=mac_pton(self.pg3.local_mac)) /
DHCP(options=[('message-type', 'ack'),
('subnet_mask', '255.255.255.0'),
('router', self.pg3.remote_ip4),
@@ -1530,7 +1530,7 @@ class TestDHCP(VppTestCase):
# remove the left over ARP entry
self.vapi.ip_neighbor_add_del(self.pg3.sw_if_index,
- mactobinary(self.pg3.remote_mac),
+ mac_pton(self.pg3.remote_mac),
self.pg3.remote_ip4,
is_add=0)
diff --git a/test/test_gbp.py b/test/test_gbp.py
index efac2de6756..d587759fffa 100644
--- a/test/test_gbp.py
+++ b/test/test_gbp.py
@@ -14,9 +14,8 @@ from vpp_vxlan_gbp_tunnel import *
from vpp_sub_interface import VppDot1QSubint
from vpp_ip import *
-from vpp_mac import *
from vpp_papi_provider import L2_PORT_TYPE
-from vpp_papi import VppEnum
+from vpp_papi import VppEnum, MACAddress
from scapy.packet import Raw
from scapy.layers.l2 import Ether, ARP, Dot1Q
@@ -35,7 +34,7 @@ def find_gbp_endpoint(test, sw_if_index=None, ip=None, mac=None):
if ip:
vip = VppIpAddress(ip)
if mac:
- vmac = VppMacAddress(mac)
+ vmac = MACAddress(mac)
eps = test.vapi.gbp_endpoint_dump()
@@ -48,7 +47,7 @@ def find_gbp_endpoint(test, sw_if_index=None, ip=None, mac=None):
if vip == eip:
return True
if mac:
- if vmac == ep.endpoint.mac:
+ if vmac.packed == ep.endpoint.mac:
return True
return False
@@ -67,12 +66,8 @@ class VppGbpEndpoint(VppObject):
"""
@property
- def bin_mac(self):
- return self.vmac.bytes
-
- @property
def mac(self):
- return self.vmac.address
+ return str(self.vmac)
@property
def mac(self):
@@ -118,9 +113,9 @@ class VppGbpEndpoint(VppObject):
self._fip6 = VppIpAddress(fip6)
if mac:
- self.vmac = VppMacAddress(self.itf.remote_mac)
+ self.vmac = MACAddress(self.itf.remote_mac)
else:
- self.vmac = VppMacAddress("00:00:00:00:00:00")
+ self.vmac = MACAddress("00:00:00:00:00:00")
self.flags = flags
self.tun_src = VppIpAddress(tun_src)
@@ -130,7 +125,7 @@ class VppGbpEndpoint(VppObject):
res = self._test.vapi.gbp_endpoint_add(
self.itf.sw_if_index,
[self.ip4.encode(), self.ip6.encode()],
- self.vmac.encode(),
+ self.vmac.packed,
self.epg.epg,
self.flags,
self.tun_src.encode(),
@@ -414,7 +409,7 @@ class VppGbpContractNextHop():
def encode(self):
return {'ip': self.ip.encode(),
- 'mac': self.mac.encode(),
+ 'mac': self.mac.packed,
'bd_id': self.bd.bd.bd_id,
'rd_id': self.rd.rd_id}
@@ -584,7 +579,7 @@ class TestGBP(VppTestCase):
self.create_pg_interfaces(range(9))
self.create_loopback_interfaces(8)
- self.router_mac = VppMacAddress("00:11:22:33:44:55")
+ self.router_mac = MACAddress("00:11:22:33:44:55")
for i in self.pg_interfaces:
i.admin_up()
@@ -671,7 +666,7 @@ class TestGBP(VppTestCase):
rx = self.send_and_expect(src, tx, dst)
for r in rx:
- self.assertEqual(r[Ether].src, self.router_mac.address)
+ self.assertEqual(r[Ether].src, str(self.router_mac))
self.assertEqual(r[Ether].dst, dst.remote_mac)
self.assertEqual(r[IP].dst, dst_ip)
self.assertEqual(r[IP].src, src_ip)
@@ -681,7 +676,7 @@ class TestGBP(VppTestCase):
rx = self.send_and_expect(src, tx, dst)
for r in rx:
- self.assertEqual(r[Ether].src, self.router_mac.address)
+ self.assertEqual(r[Ether].src, str(self.router_mac))
self.assertEqual(r[Ether].dst, dst.remote_mac)
self.assertEqual(r[IPv6].dst, dst_ip)
self.assertEqual(r[IPv6].src, src_ip)
@@ -797,7 +792,7 @@ class TestGBP(VppTestCase):
VppIpInterfaceBind(self, epg.bvi, epg.rd.t6).add_vpp_config()
self.vapi.sw_interface_set_mac_address(
epg.bvi.sw_if_index,
- self.router_mac.bytes)
+ self.router_mac.packed)
# The BVIs are NAT inside interfaces
self.vapi.nat44_interface_add_del_feature(epg.bvi.sw_if_index,
@@ -818,10 +813,10 @@ class TestGBP(VppTestCase):
# add the BD ARP termination entry for BVI IP
epg.bd_arp_ip4 = VppBridgeDomainArpEntry(self, epg.bd.bd,
- self.router_mac.address,
+ str(self.router_mac),
epg.bvi_ip4)
epg.bd_arp_ip6 = VppBridgeDomainArpEntry(self, epg.bd.bd,
- self.router_mac.address,
+ str(self.router_mac),
epg.bvi_ip6)
epg.bd_arp_ip4.add_vpp_config()
epg.bd_arp_ip6.add_vpp_config()
@@ -977,13 +972,13 @@ class TestGBP(VppTestCase):
# packets to non-local L3 destinations dropped
#
pkt_intra_epg_220_ip4 = (Ether(src=self.pg0.remote_mac,
- dst=self.router_mac.address) /
+ dst=str(self.router_mac)) /
IP(src=eps[0].ip4.address,
dst="10.0.0.99") /
UDP(sport=1234, dport=1234) /
Raw('\xa5' * 100))
pkt_inter_epg_222_ip4 = (Ether(src=self.pg0.remote_mac,
- dst=self.router_mac.address) /
+ dst=str(self.router_mac)) /
IP(src=eps[0].ip4.address,
dst="10.0.1.99") /
UDP(sport=1234, dport=1234) /
@@ -992,7 +987,7 @@ class TestGBP(VppTestCase):
self.send_and_assert_no_replies(self.pg0, pkt_intra_epg_220_ip4 * 65)
pkt_inter_epg_222_ip6 = (Ether(src=self.pg0.remote_mac,
- dst=self.router_mac.address) /
+ dst=str(self.router_mac)) /
IPv6(src=eps[0].ip6.address,
dst="2001:10::99") /
UDP(sport=1234, dport=1234) /
@@ -1120,7 +1115,7 @@ class TestGBP(VppTestCase):
UDP(sport=1234, dport=1234) /
Raw('\xa5' * 100))
pkt_inter_epg_220_to_222 = (Ether(src=self.pg0.remote_mac,
- dst=self.router_mac.address) /
+ dst=str(self.router_mac)) /
IP(src=eps[0].ip4.address,
dst=eps[3].ip4.address) /
UDP(sport=1234, dport=1234) /
@@ -1201,7 +1196,7 @@ class TestGBP(VppTestCase):
self.send_and_expect_routed(eps[0].itf,
pkt_inter_epg_220_to_222 * 65,
eps[3].itf,
- self.router_mac.address)
+ str(self.router_mac))
#
# remove both contracts, traffic stops in both directions
@@ -1272,7 +1267,7 @@ class TestGBP(VppTestCase):
# From an EP to an outside addess: IN2OUT
#
pkt_inter_epg_220_to_global = (Ether(src=self.pg0.remote_mac,
- dst=self.router_mac.address) /
+ dst=str(self.router_mac)) /
IP(src=eps[0].ip4.address,
dst="1.1.1.1") /
UDP(sport=1234, dport=1234) /
@@ -1307,7 +1302,7 @@ class TestGBP(VppTestCase):
eps[0].fip4.address)
pkt_inter_epg_220_to_global = (Ether(src=self.pg0.remote_mac,
- dst=self.router_mac.address) /
+ dst=str(self.router_mac)) /
IPv6(src=eps[0].ip6.address,
dst="6001::1") /
UDP(sport=1234, dport=1234) /
@@ -1321,7 +1316,7 @@ class TestGBP(VppTestCase):
#
# From a global address to an EP: OUT2IN
#
- pkt_inter_epg_220_from_global = (Ether(src=self.router_mac.address,
+ pkt_inter_epg_220_from_global = (Ether(src=str(self.router_mac),
dst=self.pg0.remote_mac) /
IP(dst=eps[0].fip4.address,
src="1.1.1.1") /
@@ -1347,7 +1342,7 @@ class TestGBP(VppTestCase):
eps[0].itf,
eps[0].ip4.address)
- pkt_inter_epg_220_from_global = (Ether(src=self.router_mac.address,
+ pkt_inter_epg_220_from_global = (Ether(src=str(self.router_mac),
dst=self.pg0.remote_mac) /
IPv6(dst=eps[0].fip6.address,
src="6001::1") /
@@ -1364,7 +1359,7 @@ class TestGBP(VppTestCase):
# IN2OUT2IN
#
pkt_intra_epg_220_global = (Ether(src=self.pg0.remote_mac,
- dst=self.router_mac.address) /
+ dst=str(self.router_mac)) /
IP(src=eps[0].ip4.address,
dst=eps[1].fip4.address) /
UDP(sport=1234, dport=1234) /
@@ -1377,7 +1372,7 @@ class TestGBP(VppTestCase):
eps[1].ip4.address)
pkt_intra_epg_220_global = (Ether(src=self.pg0.remote_mac,
- dst=self.router_mac.address) /
+ dst=str(self.router_mac)) /
IPv6(src=eps[0].ip6.address,
dst=eps[1].fip6.address) /
UDP(sport=1234, dport=1234) /
@@ -2039,7 +2034,7 @@ class TestGBP(VppTestCase):
rd1 = VppGbpRouteDomain(self, 2, t4, t6, tun_ip4_uu, tun_ip6_uu)
rd1.add_vpp_config()
- self.loop0.set_mac(self.router_mac.address)
+ self.loop0.set_mac(self.router_mac)
#
# Bind the BVI to the RD
@@ -2476,7 +2471,7 @@ class TestGBP(VppTestCase):
rd1 = VppGbpRouteDomain(self, 2, t4, t6)
rd1.add_vpp_config()
- self.loop0.set_mac(self.router_mac.address)
+ self.loop0.set_mac(self.router_mac)
#
# Bind the BVI to the RD
@@ -2840,19 +2835,19 @@ class TestGBP(VppTestCase):
# an L3 switch packet between local EPs in different EPGs
# different dest ports on each so the are LB hashed differently
#
- p4 = [(Ether(src=ep1.mac, dst=self.router_mac.address) /
+ p4 = [(Ether(src=ep1.mac, dst=str(self.router_mac)) /
IP(src=ep1.ip4.address, dst=ep2.ip4.address) /
UDP(sport=1234, dport=1234) /
Raw('\xa5' * 100)),
- (Ether(src=ep2.mac, dst=self.router_mac.address) /
+ (Ether(src=ep2.mac, dst=str(self.router_mac)) /
IP(src=ep2.ip4.address, dst=ep1.ip4.address) /
UDP(sport=1234, dport=1234) /
Raw('\xa5' * 100))]
- p6 = [(Ether(src=ep1.mac, dst=self.router_mac.address) /
+ p6 = [(Ether(src=ep1.mac, dst=str(self.router_mac)) /
IPv6(src=ep1.ip6.address, dst=ep2.ip6.address) /
UDP(sport=1234, dport=1234) /
Raw('\xa5' * 100)),
- (Ether(src=ep2.mac, dst=self.router_mac.address) /
+ (Ether(src=ep2.mac, dst=str(self.router_mac)) /
IPv6(src=ep2.ip6.address, dst=ep1.ip6.address) /
UDP(sport=1234, dport=1234) /
Raw('\xa5' * 100))]
@@ -2907,7 +2902,7 @@ class TestGBP(VppTestCase):
dst=self.pg7.local_ip4) /
UDP(sport=1234, dport=48879) /
VXLAN(vni=444, gpid=221, flags=0x88) /
- Ether(src="00:22:22:22:22:33", dst=self.router_mac.address) /
+ Ether(src="00:22:22:22:22:33", dst=str(self.router_mac)) /
IP(src="10.0.0.88", dst=ep1.ip4.address) /
UDP(sport=1234, dport=1234) /
Raw('\xa5' * 100))
@@ -2925,7 +2920,7 @@ class TestGBP(VppTestCase):
dst=self.pg7.local_ip4) /
UDP(sport=1234, dport=48879) /
VXLAN(vni=444, gpid=221, flags=0x88) /
- Ether(src="00:22:22:22:22:33", dst=self.router_mac.address) /
+ Ether(src="00:22:22:22:22:33", dst=str(self.router_mac)) /
IPv6(src="2001:10::88", dst=ep1.ip6.address) /
UDP(sport=1234, dport=1234) /
Raw('\xa5' * 100))
@@ -2940,11 +2935,11 @@ class TestGBP(VppTestCase):
#
# L3 switch from local to remote EP
#
- p4 = [(Ether(src=ep1.mac, dst=self.router_mac.address) /
+ p4 = [(Ether(src=ep1.mac, dst=str(self.router_mac)) /
IP(src=ep1.ip4.address, dst="10.0.0.88") /
UDP(sport=1234, dport=1234) /
Raw('\xa5' * 100))]
- p6 = [(Ether(src=ep1.mac, dst=self.router_mac.address) /
+ p6 = [(Ether(src=ep1.mac, dst=str(self.router_mac)) /
IPv6(src=ep1.ip6.address, dst="2001:10::88") /
UDP(sport=1234, dport=1234) /
Raw('\xa5' * 100))]
@@ -3027,7 +3022,7 @@ class TestGBP(VppTestCase):
rd1 = VppGbpRouteDomain(self, 2, t4, t6)
rd1.add_vpp_config()
- self.loop0.set_mac(self.router_mac.address)
+ self.loop0.set_mac(self.router_mac)
#
# Bind the BVI to the RD
@@ -3104,12 +3099,12 @@ class TestGBP(VppTestCase):
# packets destined to unkown addresses in the BVI's subnet
# are ARP'd for
#
- p4 = (Ether(src=self.pg0.remote_mac, dst=self.router_mac.address) /
+ p4 = (Ether(src=self.pg0.remote_mac, dst=str(self.router_mac)) /
Dot1Q(vlan=100) /
IP(src="10.0.0.1", dst="10.0.0.88") /
UDP(sport=1234, dport=1234) /
Raw('\xa5' * 100))
- p6 = (Ether(src=self.pg0.remote_mac, dst=self.router_mac.address) /
+ p6 = (Ether(src=self.pg0.remote_mac, dst=str(self.router_mac)) /
Dot1Q(vlan=100) /
IPv6(src="2001:10::1", dst="2001:10::88") /
UDP(sport=1234, dport=1234) /
@@ -3165,7 +3160,7 @@ class TestGBP(VppTestCase):
dst=self.pg7.local_ip4) /
UDP(sport=1234, dport=48879) /
VXLAN(vni=444, gpid=220, flags=0x88) /
- Ether(src=self.pg0.remote_mac, dst=self.router_mac.address) /
+ Ether(src=self.pg0.remote_mac, dst=str(self.router_mac)) /
IP(src="10.0.0.101", dst="10.0.0.1") /
UDP(sport=1234, dport=1234) /
Raw('\xa5' * 100))
@@ -3193,7 +3188,7 @@ class TestGBP(VppTestCase):
dst=self.pg7.local_ip4) /
UDP(sport=1234, dport=48879) /
VXLAN(vni=444, gpid=220, flags=0x88) /
- Ether(src=self.pg0.remote_mac, dst=self.router_mac.address) /
+ Ether(src=self.pg0.remote_mac, dst=str(self.router_mac)) /
IP(src="10.0.0.101", dst="10.220.0.1") /
UDP(sport=1234, dport=1234) /
Raw('\xa5' * 100))
@@ -3221,7 +3216,7 @@ class TestGBP(VppTestCase):
dst=self.pg7.local_ip4) /
UDP(sport=1234, dport=48879) /
VXLAN(vni=444, gpid=220, flags=0x88) /
- Ether(src=self.pg0.remote_mac, dst=self.router_mac.address) /
+ Ether(src=self.pg0.remote_mac, dst=str(self.router_mac)) /
IP(src="10.0.0.101", dst="10.200.0.1") /
UDP(sport=1234, dport=1234) /
Raw('\xa5' * 100))
@@ -3234,7 +3229,7 @@ class TestGBP(VppTestCase):
#
# from the the subnet in EPG 220 beyond the external to remote
#
- p4 = (Ether(src=self.pg0.remote_mac, dst=self.router_mac.address) /
+ p4 = (Ether(src=self.pg0.remote_mac, dst=str(self.router_mac)) /
Dot1Q(vlan=100) /
IP(src="10.220.0.1", dst=rep.ip4.address) /
UDP(sport=1234, dport=1234) /
@@ -3257,7 +3252,7 @@ class TestGBP(VppTestCase):
# from the the subnet in EPG 200 beyond the external to remote
# dropped due to no contract
#
- p4 = (Ether(src=self.pg0.remote_mac, dst=self.router_mac.address) /
+ p4 = (Ether(src=self.pg0.remote_mac, dst=str(self.router_mac)) /
Dot1Q(vlan=100) /
IP(src="10.200.0.1", dst=rep.ip4.address) /
UDP(sport=1234, dport=1234) /
diff --git a/test/test_ip4_irb.py b/test/test_ip4_irb.py
index a7fe7875053..8c3830c2d81 100644
--- a/test/test_ip4_irb.py
+++ b/test/test_ip4_irb.py
@@ -31,7 +31,7 @@ from scapy.layers.l2 import Ether
from scapy.layers.inet import IP, UDP
from framework import VppTestCase, VppTestRunner
-from vpp_mac import mactobinary
+from vpp_papi import MACAddress
from vpp_papi_provider import L2_PORT_TYPE
@@ -265,7 +265,7 @@ class TestIpIrb(VppTestCase):
self.send_and_verify_l2_to_ip()
# change the BVI's mac and resed traffic
- self.loop0.set_mac("00:00:00:11:11:33")
+ self.loop0.set_mac(MACAddress("00:00:00:11:11:33"))
self.send_and_verify_l2_to_ip()
# check it wasn't flooded
diff --git a/test/test_l2_fib.py b/test/test_l2_fib.py
index 436aa10c3ec..1cee58982e5 100644
--- a/test/test_l2_fib.py
+++ b/test/test_l2_fib.py
@@ -69,6 +69,7 @@ from scapy.layers.inet import IP, UDP
from framework import VppTestCase, VppTestRunner
from util import Host, ppp
+from vpp_papi import mac_pton
# from src/vnet/l2/l2_fib.h
MAC_EVENT_ACTION_ADD = 0
@@ -205,7 +206,7 @@ class TestL2fib(VppTestCase):
swif = pg_if.sw_if_index
for host in hosts[swif]:
self.vapi.l2fib_add_del(
- host.mac, bd_id, swif, static_mac=1)
+ mac_pton(host.mac), bd_id, swif, static_mac=1)
def delete_l2_fib_entry(self, bd_id, hosts):
"""
@@ -218,7 +219,7 @@ class TestL2fib(VppTestCase):
swif = pg_if.sw_if_index
for host in hosts[swif]:
self.vapi.l2fib_add_del(
- host.mac, bd_id, swif, is_add=0)
+ mac_pton(host.mac), bd_id, swif, is_add=0)
def flush_int(self, swif, learned_hosts):
"""
diff --git a/test/test_l2bd_arp_term.py b/test/test_l2bd_arp_term.py
index f25be57d8e4..2321aa7c094 100644
--- a/test/test_l2bd_arp_term.py
+++ b/test/test_l2bd_arp_term.py
@@ -20,7 +20,6 @@ from scapy.layers.inet6 import IPv6, UDP, ICMPv6ND_NS, ICMPv6ND_RS, \
from framework import VppTestCase, VppTestRunner
from util import Host, ppp
-from vpp_mac import VppMacAddress, mactobinary
class TestL2bdArpTerm(VppTestCase):
@@ -72,7 +71,7 @@ class TestL2bdArpTerm(VppTestCase):
for e in entries:
ip = e.ip4 if is_ipv6 == 0 else e.ip6
self.vapi.bd_ip_mac_add_del(bd_id=bd_id,
- mac=VppMacAddress(e.mac).encode(),
+ mac=e.mac,
ip=ip,
is_ipv6=is_ipv6,
is_add=is_add)
diff --git a/test/test_nat.py b/test/test_nat.py
index a7ca6d3a6e0..9879b762cc9 100644
--- a/test/test_nat.py
+++ b/test/test_nat.py
@@ -18,7 +18,7 @@ from util import ppp
from ipfix import IPFIX, Set, Template, Data, IPFIXDecoder
from time import sleep
from util import ip4_range
-from vpp_mac import mactobinary
+from vpp_papi import mac_pton
from syslog_rfc5424_parser import SyslogMessage, ParseError
from syslog_rfc5424_parser.constants import SyslogFacility, SyslogSeverity
from vpp_papi_provider import SYSLOG_SEVERITY
@@ -2952,11 +2952,11 @@ class TestNAT44(MethodHolder):
""" NAT44 interfaces without configured IP address """
self.vapi.ip_neighbor_add_del(self.pg7.sw_if_index,
- mactobinary(self.pg7.remote_mac),
+ mac_pton(self.pg7.remote_mac),
self.pg7.remote_ip4n,
is_static=1)
self.vapi.ip_neighbor_add_del(self.pg8.sw_if_index,
- mactobinary(self.pg8.remote_mac),
+ mac_pton(self.pg8.remote_mac),
self.pg8.remote_ip4n,
is_static=1)
@@ -2994,11 +2994,11 @@ class TestNAT44(MethodHolder):
""" NAT44 interfaces without configured IP address - 1:1 NAT """
self.vapi.ip_neighbor_add_del(self.pg7.sw_if_index,
- mactobinary(self.pg7.remote_mac),
+ mac_pton(self.pg7.remote_mac),
self.pg7.remote_ip4n,
is_static=1)
self.vapi.ip_neighbor_add_del(self.pg8.sw_if_index,
- mactobinary(self.pg8.remote_mac),
+ mac_pton(self.pg8.remote_mac),
self.pg8.remote_ip4n,
is_static=1)
@@ -3040,11 +3040,11 @@ class TestNAT44(MethodHolder):
self.icmp_id_out = 30608
self.vapi.ip_neighbor_add_del(self.pg7.sw_if_index,
- mactobinary(self.pg7.remote_mac),
+ mac_pton(self.pg7.remote_mac),
self.pg7.remote_ip4n,
is_static=1)
self.vapi.ip_neighbor_add_del(self.pg8.sw_if_index,
- mactobinary(self.pg8.remote_mac),
+ mac_pton(self.pg8.remote_mac),
self.pg8.remote_ip4n,
is_static=1)
diff --git a/test/test_p2p_ethernet.py b/test/test_p2p_ethernet.py
index f08d0cc2b1f..34a4c24f655 100644
--- a/test/test_p2p_ethernet.py
+++ b/test/test_p2p_ethernet.py
@@ -13,7 +13,7 @@ from framework import VppTestCase, VppTestRunner
from vpp_sub_interface import VppP2PSubint
from vpp_ip import DpoProto
from vpp_ip_route import VppIpRoute, VppRoutePath
-from vpp_mac import mactobinary
+from vpp_papi import mac_pton
class P2PEthernetAPI(VppTestCase):
@@ -33,12 +33,12 @@ class P2PEthernetAPI(VppTestCase):
i.admin_up()
def create_p2p_ethernet(self, parent_if, sub_id, remote_mac):
- p2p = VppP2PSubint(self, parent_if, sub_id, mactobinary(remote_mac))
+ p2p = VppP2PSubint(self, parent_if, sub_id, mac_pton(remote_mac))
self.p2p_sub_ifs.append(p2p)
def delete_p2p_ethernet(self, parent_if, remote_mac):
self.vapi.delete_p2pethernet_subif(parent_if.sw_if_index,
- mactobinary(remote_mac))
+ mac_pton(remote_mac))
def test_api(self):
"""delete/create p2p subif"""
@@ -79,7 +79,7 @@ class P2PEthernetAPI(VppTestCase):
try:
macs.append(':'.join(re.findall('..', '{:02x}'.format(mac+i))))
self.vapi.create_p2pethernet_subif(self.pg2.sw_if_index,
- mactobinary(macs[i-1]),
+ mac_pton(macs[i-1]),
i)
except Exception:
self.logger.info("Failed to create subif %d %s" % (
@@ -144,7 +144,7 @@ class P2PEthernetIPV6(VppTestCase):
super(P2PEthernetIPV6, self).tearDown()
def create_p2p_ethernet(self, parent_if, sub_id, remote_mac):
- p2p = VppP2PSubint(self, parent_if, sub_id, mactobinary(remote_mac))
+ p2p = VppP2PSubint(self, parent_if, sub_id, mac_pton(remote_mac))
p2p.admin_up()
p2p.config_ip6()
p2p.disable_ipv6_ra()
@@ -389,7 +389,7 @@ class P2PEthernetIPV4(VppTestCase):
return dst_if.get_capture(count)
def create_p2p_ethernet(self, parent_if, sub_id, remote_mac):
- p2p = VppP2PSubint(self, parent_if, sub_id, mactobinary(remote_mac))
+ p2p = VppP2PSubint(self, parent_if, sub_id, mac_pton(remote_mac))
p2p.admin_up()
p2p.config_ip4()
return p2p
diff --git a/test/test_pppoe.py b/test/test_pppoe.py
index 615b7a0c880..b181f6bced7 100644
--- a/test/test_pppoe.py
+++ b/test/test_pppoe.py
@@ -14,7 +14,6 @@ from scapy.layers.ppp import PPPoE, PPPoED, PPP
from scapy.layers.inet import IP, UDP
from scapy.layers.inet6 import IPv6
from scapy.volatile import RandMAC, RandIP
-from vpp_mac import mactobinary
from util import ppp, ppc
import socket
diff --git a/test/test_util.py b/test/test_util.py
index 49095d85931..01ba8623952 100755
--- a/test/test_util.py
+++ b/test/test_util.py
@@ -3,15 +3,15 @@
import unittest
from framework import VppTestCase, VppTestRunner
-from vpp_mac import mactobinary, binarytomac
+from vpp_papi import mac_pton, mac_ntop
class TestUtil (VppTestCase):
""" MAC to binary and back """
def test_mac_to_binary(self):
mac = 'aa:bb:cc:dd:ee:ff'
- b = mactobinary(mac)
- mac2 = binarytomac(b)
+ b = mac_pton(mac)
+ mac2 = mac_ntop(b)
self.assertEqual(type(mac), type(mac2))
self.assertEqual(mac2, mac)
diff --git a/test/util.py b/test/util.py
index a3ec6e3326b..9652b803f1d 100644
--- a/test/util.py
+++ b/test/util.py
@@ -14,7 +14,7 @@ from scapy.layers.inet6 import IPv6, IPv6ExtHdrFragment, IPv6ExtHdrRouting,\
from scapy.utils import hexdump
from socket import AF_INET6
from io import BytesIO
-from vpp_mac import mactobinary
+from vpp_papi import mac_pton
def ppp(headline, packet):
@@ -130,7 +130,7 @@ class Host(object):
@property
def bin_mac(self):
""" MAC address """
- return mactobinary(self._mac)
+ return mac_pton(self._mac)
@property
def ip4(self):
diff --git a/test/vpp_interface.py b/test/vpp_interface.py
index 3235d3f68c6..719f77b36c7 100644
--- a/test/vpp_interface.py
+++ b/test/vpp_interface.py
@@ -5,7 +5,7 @@ from abc import abstractmethod, ABCMeta
from six import moves
from util import Host, mk_ll_addr
-from vpp_mac import mactobinary, binarytomac
+from vpp_papi import mac_pton, mac_ntop
class VppInterface(object):
@@ -191,11 +191,10 @@ class VppInterface(object):
self._hosts_by_ip6 = {}
def set_mac(self, mac):
- self._local_mac = mac
- self._local_ip6_ll = mk_ll_addr(mac)
+ self._local_mac = str(mac)
+ self._local_ip6_ll = mk_ll_addr(self._local_mac)
self.test.vapi.sw_interface_set_mac_address(
- self.sw_if_index,
- mactobinary(self._local_mac))
+ self.sw_if_index, mac.packed)
def set_sw_if_index(self, sw_if_index):
self._sw_if_index = sw_if_index
@@ -234,7 +233,7 @@ class VppInterface(object):
if intf.sw_if_index == self.sw_if_index:
self._name = intf.interface_name.split(b'\0',
1)[0].decode('utf8')
- self._local_mac = binarytomac(intf.l2_address)
+ self._local_mac = mac_ntop(intf.l2_address)
self._dump = intf
break
else:
@@ -274,7 +273,7 @@ class VppInterface(object):
:param vrf_id: The FIB table / VRF ID. (Default value = 0)
"""
for host in self._remote_hosts:
- macn = mactobinary(host.mac)
+ macn = mac_pton(host.mac)
ipn = host.ip4n
self.test.vapi.ip_neighbor_add_del(
self.sw_if_index, macn, ipn)
@@ -305,7 +304,7 @@ class VppInterface(object):
:param vrf_id: The FIB table / VRF ID. (Default value = 0)
"""
for host in self._remote_hosts:
- macn = mactobinary(host.mac)
+ macn = mac_pton(host.mac)
ipn = host.ip6n
self.test.vapi.ip_neighbor_add_del(
self.sw_if_index, macn, ipn, is_ipv6=1)
diff --git a/test/vpp_l2.py b/test/vpp_l2.py
index e2f3760f1d1..182f2ce7419 100644
--- a/test/vpp_l2.py
+++ b/test/vpp_l2.py
@@ -5,8 +5,8 @@
from vpp_object import *
from vpp_ip import VppIpAddress
-from vpp_mac import VppMacAddress, mactobinary
from vpp_lo_interface import VppLoInterface
+from vpp_papi import MACAddress
class L2_PORT_TYPE:
@@ -39,7 +39,7 @@ def find_bridge_domain_port(test, bd_id, sw_if_index):
def find_bridge_domain_arp_entry(test, bd_id, mac, ip):
- vmac = VppMacAddress(mac)
+ vmac = MACAddress(mac)
vip = VppIpAddress(ip)
if vip.version == 4:
@@ -50,17 +50,17 @@ def find_bridge_domain_arp_entry(test, bd_id, mac, ip):
arps = test.vapi.bd_ip_mac_dump(bd_id)
for arp in arps:
# do IP addr comparison too once .api is fixed...
- if vmac.bytes == arp.mac_address and \
+ if vmac.packed == arp.mac_address and \
vip.bytes == arp.ip_address[:n]:
return True
return False
def find_l2_fib_entry(test, bd_id, mac, sw_if_index):
- vmac = VppMacAddress(mac)
+ vmac = MACAddress(mac)
lfs = test.vapi.l2_fib_table_dump(bd_id)
for lf in lfs:
- if vmac.bytes == lf.mac and sw_if_index == lf.sw_if_index:
+ if vmac.packed == lf.mac and sw_if_index == lf.sw_if_index:
return True
return False
@@ -143,13 +143,13 @@ class VppBridgeDomainArpEntry(VppObject):
def __init__(self, test, bd, mac, ip):
self._test = test
self.bd = bd
- self.mac = VppMacAddress(mac)
+ self.mac = MACAddress(mac)
self.ip = VppIpAddress(ip)
def add_vpp_config(self):
self._test.vapi.bd_ip_mac_add_del(
self.bd.bd_id,
- self.mac.encode(),
+ self.mac.packed,
self.ip.encode(),
is_add=1)
self._test.registry.register(self, self._test.logger)
@@ -157,14 +157,14 @@ class VppBridgeDomainArpEntry(VppObject):
def remove_vpp_config(self):
self._test.vapi.bd_ip_mac_add_del(
self.bd.bd_id,
- self.mac.encode(),
+ self.mac.packed,
self.ip.encode(),
is_add=0)
def query_vpp_config(self):
return find_bridge_domain_arp_entry(self._test,
self.bd.bd_id,
- self.mac.address,
+ self.mac.packed,
self.ip.address)
def __str__(self):
@@ -180,7 +180,7 @@ class VppL2FibEntry(VppObject):
static_mac=0, filter_mac=0, bvi_mac=-1):
self._test = test
self.bd = bd
- self.mac = VppMacAddress(mac)
+ self.mac = MACAddress(mac)
self.itf = itf
self.static_mac = static_mac
self.filter_mac = filter_mac
@@ -191,7 +191,7 @@ class VppL2FibEntry(VppObject):
def add_vpp_config(self):
self._test.vapi.l2fib_add_del(
- self.mac.address,
+ self.mac.packed,
self.bd.bd_id,
self.itf.sw_if_index,
is_add=1,
@@ -202,7 +202,7 @@ class VppL2FibEntry(VppObject):
def remove_vpp_config(self):
self._test.vapi.l2fib_add_del(
- self.mac.address,
+ self.mac.packed,
self.bd.bd_id,
self.itf.sw_if_index,
is_add=0)
@@ -210,7 +210,7 @@ class VppL2FibEntry(VppObject):
def query_vpp_config(self):
return find_l2_fib_entry(self._test,
self.bd.bd_id,
- self.mac.address,
+ self.mac.packed,
self.itf.sw_if_index)
def __str__(self):
diff --git a/test/vpp_mac.py b/test/vpp_mac.py
deleted file mode 100644
index b20bf54634c..00000000000
--- a/test/vpp_mac.py
+++ /dev/null
@@ -1,50 +0,0 @@
-"""
- MAC Types
-
-"""
-import binascii
-
-
-def mactobinary(mac):
- """ Convert the : separated format into binary packet data for the API """
- return binascii.unhexlify(mac.replace(':', ''))
-
-
-def binarytomac(binary):
- """ Convert binary packed data in a : separated string """
- x = b':'.join(binascii.hexlify(binary)[i:i + 2]
- for i in range(0, 12, 2))
- return str(x.decode('ascii'))
-
-
-class VppMacAddress():
- def __init__(self, addr):
- self._address = addr
-
- def encode(self):
- return {
- 'bytes': self.bytes
- }
-
- @property
- def bytes(self):
- return mactobinary(self.address)
-
- @property
- def address(self):
- return self._address
-
- def __str__(self):
- return self.address
-
- def __eq__(self, other):
- if isinstance(other, self.__class__):
- return self.address == other.address
- elif hasattr(other, "bytes"):
- # vl_api_mac_addres_t
- return self.bytes == other.bytes
- else:
- raise TypeError("Comparing VppMacAddress:%s"
- "with unknown type: %s" %
- (self, other))
- return False
diff --git a/test/vpp_neighbor.py b/test/vpp_neighbor.py
index 46854c9ba8c..7815a286fef 100644
--- a/test/vpp_neighbor.py
+++ b/test/vpp_neighbor.py
@@ -6,7 +6,7 @@
from socket import inet_pton, inet_ntop, AF_INET, AF_INET6
from vpp_object import *
-from vpp_mac import mactobinary
+from vpp_papi import mac_pton
def find_nbr(test, sw_if_index, ip_addr, is_static=0, inet=AF_INET, mac=None):
@@ -22,7 +22,7 @@ def find_nbr(test, sw_if_index, ip_addr, is_static=0, inet=AF_INET, mac=None):
if nbr_addr == n.ip_address[:s] \
and is_static == n.is_static:
if mac:
- if n.mac_address == mactobinary(mac):
+ if n.mac_address == mac_pton(mac):
return True
else:
return True
@@ -38,7 +38,7 @@ class VppNeighbor(VppObject):
af=AF_INET, is_static=False, is_no_fib_entry=0):
self._test = test
self.sw_if_index = sw_if_index
- self.mac_addr = mactobinary(mac_addr)
+ self.mac_addr = mac_pton(mac_addr)
self.af = af
self.is_static = is_static
self.is_no_fib_entry = is_no_fib_entry
diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py
index 4812cb6ef70..0a33c1eb2ac 100644
--- a/test/vpp_papi_provider.py
+++ b/test/vpp_papi_provider.py
@@ -4,7 +4,7 @@ import time
from collections import deque
from six import moves
-from vpp_mac import mactobinary
+from vpp_papi import mac_pton
from hook import Hook
from vpp_l2 import L2_PORT_TYPE
@@ -223,9 +223,6 @@ class VppPapiProvider(object):
"""
return cli + "\n" + str(self.cli(cli))
- def _convert_mac(self, mac):
- return mactobinary(mac)
-
def show_version(self):
""" """
return self.api(self.papi.show_version, {})
@@ -643,7 +640,7 @@ class VppPapiProvider(object):
interface. (Default value = 0)
"""
return self.api(self.papi.l2fib_add_del,
- {'mac': self._convert_mac(mac),
+ {'mac': mac,
'bd_id': bd_id,
'sw_if_index': sw_if_index,
'is_add': is_add,
diff --git a/test/vpp_pppoe_interface.py b/test/vpp_pppoe_interface.py
index 28d8a714972..9be92327dcf 100644
--- a/test/vpp_pppoe_interface.py
+++ b/test/vpp_pppoe_interface.py
@@ -1,7 +1,7 @@
from vpp_interface import VppInterface
import socket
-from vpp_mac import mactobinary
+from vpp_papi import mac_pton
class VppPppoeInterface(VppInterface):
@@ -20,7 +20,7 @@ class VppPppoeInterface(VppInterface):
def add_vpp_config(self):
cip = socket.inet_pton(socket.AF_INET, self.client_ip)
- cmac = mactobinary(self.client_mac)
+ cmac = mac_pton(self.client_mac)
r = self.test.vapi.pppoe_add_del_session(
cip, cmac,
session_id=self.session_id,
@@ -30,7 +30,7 @@ class VppPppoeInterface(VppInterface):
def remove_vpp_config(self):
cip = socket.inet_pton(socket.AF_INET, self.client_ip)
- cmac = mactobinary(self.client_mac)
+ cmac = mac_pton(self.client_mac)
self.unconfig()
self.test.vapi.pppoe_add_del_session(
cip, cmac,