本文整理汇总了Python中vpp_ip_route.VppIpRoute类的典型用法代码示例。如果您正苦于以下问题:Python VppIpRoute类的具体用法?Python VppIpRoute怎么用?Python VppIpRoute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VppIpRoute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_tcp_transfer
def test_tcp_transfer(self):
""" TCP echo client/server transfer """
# Add inter-table routes
ip_t01 = VppIpRoute(self, self.loop1.local_ip4, 32,
[VppRoutePath("0.0.0.0",
0xffffffff,
nh_table_id=1)])
ip_t10 = VppIpRoute(self, self.loop0.local_ip4, 32,
[VppRoutePath("0.0.0.0",
0xffffffff,
nh_table_id=0)], table_id=1)
ip_t01.add_vpp_config()
ip_t10.add_vpp_config()
# Start builtin server and client
uri = "tcp://" + self.loop0.local_ip4 + "/1234"
error = self.vapi.cli("test echo server appns 0 fifo-size 4 uri " +
uri)
if error:
self.logger.critical(error)
self.assertNotIn("failed", error)
error = self.vapi.cli("test echo client mbytes 10 appns 1 " +
"fifo-size 4 no-output test-bytes " +
"syn-timeout 2 uri " + uri)
if error:
self.logger.critical(error)
self.assertNotIn("failed", error)
# Delete inter-table routes
ip_t01.remove_vpp_config()
ip_t10.remove_vpp_config()
示例2: test_ip6_rx_p2p_subif_route
def test_ip6_rx_p2p_subif_route(self):
"""route rx ip6 packet not matching p2p subinterface"""
self.logger.info("FFP_TEST_START_0003")
self.pg0.config_ip6()
route_3 = VppIpRoute(self, "9000::", 64,
[VppRoutePath(self.pg1._remote_hosts[0].ip6,
self.pg1.sw_if_index,
proto=DpoProto.DPO_PROTO_IP6)],
is_ip6=1)
route_3.add_vpp_config()
self.packets.append(
self.create_stream(src_mac="02:03:00:00:ff:ff",
dst_mac=self.pg0.local_mac,
src_ip="a000::100",
dst_ip="9000::100"))
self.send_packets(self.pg0, self.pg1)
self.pg0.unconfig_ip6()
route_3.remove_vpp_config()
self.logger.info("FFP_TEST_FINISH_0003")
示例3: test_quic_transfer
def test_quic_transfer(self):
""" QUIC echo client/server transfer """
# Add inter-table routes
ip_t01 = VppIpRoute(self, self.loop1.local_ip4, 32,
[VppRoutePath("0.0.0.0",
0xffffffff,
nh_table_id=2)], table_id=1)
ip_t10 = VppIpRoute(self, self.loop0.local_ip4, 32,
[VppRoutePath("0.0.0.0",
0xffffffff,
nh_table_id=1)], table_id=2)
ip_t01.add_vpp_config()
ip_t10.add_vpp_config()
self.logger.debug(self.vapi.cli("show ip fib"))
# Start builtin server and client
uri = "quic://%s/1234" % self.loop0.local_ip4
error = self.vapi.cli("test echo server appns 1 fifo-size 4 uri %s" %
uri)
if error:
self.logger.critical(error)
self.assertNotIn("failed", error)
error = self.vapi.cli("test echo client bytes 1024 appns 2 " +
"fifo-size 4 test-bytes no-output " +
"uri %s" % uri)
self.logger.critical(error)
if error:
self.logger.critical(error)
self.assertNotIn("failed", error)
# Delete inter-table routes
ip_t01.remove_vpp_config()
ip_t10.remove_vpp_config()
示例4: test_PPPoE_Del_Twice
def test_PPPoE_Del_Twice(self):
""" PPPoE Delete Same Session Twice Test """
self.vapi.cli("clear trace")
#
# Add a route that resolves the server's destination
#
route_sever_dst = VppIpRoute(self, "100.1.1.100", 32,
[VppRoutePath(self.pg1.remote_ip4,
self.pg1.sw_if_index)])
route_sever_dst.add_vpp_config()
# Send PPPoE Discovery
tx0 = self.create_stream_pppoe_discovery(self.pg0, self.pg1,
self.pg0.remote_mac)
self.pg0.add_stream(tx0)
self.pg_start()
# Send PPPoE PPP LCP
tx1 = self.create_stream_pppoe_lcp(self.pg0, self.pg1,
self.pg0.remote_mac,
self.session_id)
self.pg0.add_stream(tx1)
self.pg_start()
# Create PPPoE session
pppoe_if = VppPppoeInterface(self,
self.pg0.remote_ip4,
self.pg0.remote_mac,
self.session_id)
pppoe_if.add_vpp_config()
# Delete PPPoE session
pppoe_if.remove_vpp_config()
#
# The double del (del the same session twice) should fail,
# and we should still be able to use the original
#
try:
pppoe_if.remove_vpp_config()
except Exception:
pass
else:
self.fail("Double GRE tunnel del does not fail")
#
# test case cleanup
#
# Delete a route that resolves the server's destination
route_sever_dst.remove_vpp_config()
示例5: test_6rd_bgp_tunnel
def test_6rd_bgp_tunnel(self):
""" 6rd BGP tunnel """
rv = self.vapi.ipip_6rd_add_tunnel(0, 0, inet_pton(AF_INET6, '2002::'),
inet_pton(AF_INET, '0.0.0.0'),
self.pg0.local_ip4n, 16, 0, False)
self.tunnel_index = rv.sw_if_index
default_route = VppIpRoute(
self, "DEAD::", 16, [VppRoutePath("2002:0808:0808::",
self.tunnel_index,
proto=DpoProto.DPO_PROTO_IP6)],
is_ip6=1)
default_route.add_vpp_config()
ip4_route = VppIpRoute(self, "8.0.0.0", 8,
[VppRoutePath(self.pg1.remote_ip4, 0xFFFFFFFF)])
ip4_route.add_vpp_config()
# Via recursive route 6 -> 4
p = (Ether(src=self.pg0.remote_mac,
dst=self.pg0.local_mac) /
IPv6(src="1::1", dst="DEAD:BEEF::1") /
UDP(sport=1234, dport=1234))
p_reply = (IP(src=self.pg0.local_ip4, dst="8.8.8.8",
proto='ipv6') /
IPv6(src='1::1', dst='DEAD:BEEF::1', nh='UDP'))
rx = self.send_and_expect(self.pg0, p * 10, self.pg1)
for p in rx:
self.validate_6in4(p, p_reply)
# Via recursive route 4 -> 6 (Security check must be disabled)
p_ip6 = (IPv6(src="DEAD:BEEF::1", dst=self.pg1.remote_ip6) /
UDP(sport=1234, dport=1234))
p = (Ether(src=self.pg0.remote_mac,
dst=self.pg0.local_mac) /
IP(src="8.8.8.8", dst=self.pg0.local_ip4) /
p_ip6)
p_reply = p_ip6
rx = self.send_and_expect(self.pg0, p * 10, self.pg1)
for p in rx:
self.validate_4in6(p, p_reply)
ip4_route.remove_vpp_config()
default_route.remove_vpp_config()
self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
示例6: test_no_p2p_subif
def test_no_p2p_subif(self):
"""standard routing without p2p subinterfaces"""
self.logger.info("FFP_TEST_START_0001")
route_8000 = VppIpRoute(self, "8000::", 64,
[VppRoutePath(self.pg0.remote_ip6,
self.pg0.sw_if_index,
proto=DpoProto.DPO_PROTO_IP6)],
is_ip6=1)
route_8000.add_vpp_config()
self.packets = [(Ether(dst=self.pg1.local_mac,
src=self.pg1.remote_mac) /
IPv6(src="3001::1", dst="8000::100") /
UDP(sport=1234, dport=1234) /
Raw('\xa5' * 100))]
self.send_packets(self.pg1, self.pg0)
self.logger.info("FFP_TEST_FINISH_0001")
示例7: test_ip6_rx_p2p_subif_drop
def test_ip6_rx_p2p_subif_drop(self):
"""drop rx packet not matching p2p subinterface"""
self.logger.info("FFP_TEST_START_0004")
route_9001 = VppIpRoute(self, "9000::", 64,
[VppRoutePath(self.pg1._remote_hosts[0].ip6,
self.pg1.sw_if_index,
proto=DpoProto.DPO_PROTO_IP6)],
is_ip6=1)
route_9001.add_vpp_config()
self.packets.append(
self.create_stream(src_mac="02:03:00:00:ff:ff",
dst_mac=self.pg0.local_mac,
src_ip="a000::100",
dst_ip="9000::100"))
# no packet received
self.send_packets(self.pg0, self.pg1, count=0)
self.logger.info("FFP_TEST_FINISH_0004")
示例8: test_ip4_rx_p2p_subif_route
def test_ip4_rx_p2p_subif_route(self):
"""route rx packet not matching p2p subinterface"""
self.logger.info("FFP_TEST_START_0003")
route_9001 = VppIpRoute(self, "9.0.0.0", 24,
[VppRoutePath(self.pg1.remote_ip4,
self.pg1.sw_if_index)])
route_9001.add_vpp_config()
self.packets.append(
self.create_stream(src_mac="02:01:00:00:ff:ff",
dst_mac=self.pg0.local_mac,
src_ip="8.0.0.100",
dst_ip="9.0.0.100"))
self.send_packets(self.pg0, self.pg1)
route_9001.remove_vpp_config()
self.logger.info("FFP_TEST_FINISH_0003")
示例9: test_ip4_rx_p2p_subif
def test_ip4_rx_p2p_subif(self):
"""receive ipv4 packet via p2p subinterface"""
self.logger.info("FFP_TEST_START_0002")
route_9000 = VppIpRoute(self, "9.0.0.0", 16,
[VppRoutePath(self.pg1.remote_ip4,
self.pg1.sw_if_index)])
route_9000.add_vpp_config()
self.packets.append(
self.create_stream(src_mac=self.pg0._remote_hosts[0].mac,
dst_mac=self.pg0.local_mac,
src_ip=self.p2p_sub_ifs[0].remote_ip4,
dst_ip="9.0.0.100"))
self.send_packets(self.pg0, self.pg1, self.packets)
self.assert_packet_counter_equal('p2p-ethernet-input', 1)
route_9000.remove_vpp_config()
self.logger.info("FFP_TEST_FINISH_0002")
示例10: setup_tunnel
def setup_tunnel(self):
# IPv6 transport
rv = self.vapi.ipip_add_tunnel(
src_address=self.pg0.local_ip6n,
dst_address=self.pg1.remote_ip6n, tc_tos=255)
sw_if_index = rv.sw_if_index
self.tunnel_if_index = sw_if_index
self.vapi.sw_interface_set_flags(sw_if_index, 1)
self.vapi.sw_interface_set_unnumbered(
sw_if_index=self.pg0.sw_if_index,
unnumbered_sw_if_index=sw_if_index)
# Add IPv4 and IPv6 routes via tunnel interface
ip4_via_tunnel = VppIpRoute(
self, "130.67.0.0", 16,
[VppRoutePath("0.0.0.0",
sw_if_index,
proto=DpoProto.DPO_PROTO_IP4)], is_ip6=0)
ip4_via_tunnel.add_vpp_config()
ip6_via_tunnel = VppIpRoute(
self, "dead::", 16,
[VppRoutePath("::",
sw_if_index,
proto=DpoProto.DPO_PROTO_IP6)], is_ip6=1)
ip6_via_tunnel.add_vpp_config()
self.tunnel_ip6_via_tunnel = ip6_via_tunnel
self.tunnel_ip4_via_tunnel = ip4_via_tunnel
示例11: test_ip6_rx_p2p_subif
def test_ip6_rx_p2p_subif(self):
"""receive ipv6 packet via p2p subinterface"""
self.logger.info("FFP_TEST_START_0002")
route_9001 = VppIpRoute(self, "9001::", 64,
[VppRoutePath(self.pg1.remote_ip6,
self.pg1.sw_if_index,
proto=DpoProto.DPO_PROTO_IP6)],
is_ip6=1)
route_9001.add_vpp_config()
self.packets.append(
self.create_stream(src_mac=self.pg0._remote_hosts[0].mac,
dst_mac=self.pg0.local_mac,
src_ip=self.p2p_sub_ifs[0].remote_ip6,
dst_ip="9001::100"))
self.send_packets(self.pg0, self.pg1, self.packets)
self.assert_packet_counter_equal('p2p-ethernet-input', 1)
route_9001.remove_vpp_config()
self.logger.info("FFP_TEST_FINISH_0002")
示例12: config_network
def config_network(self, params):
self.net_objs = []
self.tun_if = self.pg0
self.tra_if = self.pg2
self.logger.info(self.vapi.ppcli("show int addr"))
self.tra_spd = VppIpsecSpd(self, self.tra_spd_id)
self.tra_spd.add_vpp_config()
self.net_objs.append(self.tra_spd)
self.tun_spd = VppIpsecSpd(self, self.tun_spd_id)
self.tun_spd.add_vpp_config()
self.net_objs.append(self.tun_spd)
b = VppIpsecSpdItfBinding(self, self.tra_spd,
self.tra_if)
b.add_vpp_config()
self.net_objs.append(b)
b = VppIpsecSpdItfBinding(self, self.tun_spd,
self.tun_if)
b.add_vpp_config()
self.net_objs.append(b)
for p in params:
self.config_ah_tra(p)
config_tra_params(p, self.encryption_type)
for p in params:
self.config_ah_tun(p)
for p in params:
d = DpoProto.DPO_PROTO_IP6 if p.is_ipv6 else DpoProto.DPO_PROTO_IP4
r = VppIpRoute(self, p.remote_tun_if_host, p.addr_len,
[VppRoutePath(self.tun_if.remote_addr[p.addr_type],
0xffffffff,
proto=d)],
is_ip6=p.is_ipv6)
r.add_vpp_config()
self.net_objs.append(r)
self.logger.info(self.vapi.ppcli("show ipsec all"))
示例13: test_segment_manager_alloc
def test_segment_manager_alloc(self):
""" Session Segment Manager Multiple Segment Allocation """
# Add inter-table routes
ip_t01 = VppIpRoute(self, self.loop1.local_ip4, 32,
[VppRoutePath("0.0.0.0",
0xffffffff,
nh_table_id=1)])
ip_t10 = VppIpRoute(self, self.loop0.local_ip4, 32,
[VppRoutePath("0.0.0.0",
0xffffffff,
nh_table_id=0)], table_id=1)
ip_t01.add_vpp_config()
ip_t10.add_vpp_config()
# Start builtin server and client with small private segments
uri = "tcp://" + self.loop0.local_ip4 + "/1234"
error = self.vapi.cli("test echo server appns 0 fifo-size 64 " +
"private-segment-size 1m uri " + uri)
if error:
self.logger.critical(error)
self.assertNotIn("failed", error)
error = self.vapi.cli("test echo client nclients 100 appns 1 " +
"no-output fifo-size 64 syn-timeout 2 " +
"private-segment-size 1m uri " + uri)
if error:
self.logger.critical(error)
self.assertNotIn("failed", error)
if self.vpp_dead:
self.assert_equal(0)
# Delete inter-table routes
ip_t01.remove_vpp_config()
ip_t10.remove_vpp_config()
示例14: test_bier_load_balance
def test_bier_load_balance(self):
"""BIER load-balance"""
#
# Add a BIER table for sub-domain 0, set 0, and BSL 256
#
bti = VppBierTableID(0, 0, BIERLength.BIER_LEN_64)
bt = VppBierTable(self, bti, 77)
bt.add_vpp_config()
#
# packets with varying entropy
#
pkts = []
for ii in range(257):
pkts.append((Ether(dst=self.pg0.local_mac,
src=self.pg0.remote_mac) /
MPLS(label=77, ttl=255) /
BIER(length=BIERLength.BIER_LEN_64,
entropy=ii,
BitString=scapy.compat.chb(255)*16) /
IPv6(src=self.pg0.remote_ip6,
dst=self.pg0.remote_ip6) /
UDP(sport=1234, dport=1234) /
Raw()))
#
# 4 next hops
#
nhs = [{'ip': "10.0.0.1", 'label': 201},
{'ip': "10.0.0.2", 'label': 202},
{'ip': "10.0.0.3", 'label': 203},
{'ip': "10.0.0.4", 'label': 204}]
for nh in nhs:
ipr = VppIpRoute(
self, nh['ip'], 32,
[VppRoutePath(self.pg1.remote_ip4,
self.pg1.sw_if_index,
labels=[VppMplsLabel(nh['label'])])])
ipr.add_vpp_config()
bier_route = VppBierRoute(
self, bti, 1,
[VppRoutePath(nhs[0]['ip'], 0xffffffff,
labels=[VppMplsLabel(101)]),
VppRoutePath(nhs[1]['ip'], 0xffffffff,
labels=[VppMplsLabel(101)])])
bier_route.add_vpp_config()
rx = self.send_and_expect(self.pg0, pkts, self.pg1)
#
# we should have recieved a packet from each neighbor
#
for nh in nhs[:2]:
self.assertTrue(sum(p[MPLS].label == nh['label'] for p in rx))
#
# add the other paths
#
bier_route.update_paths(
[VppRoutePath(nhs[0]['ip'], 0xffffffff,
labels=[VppMplsLabel(101)]),
VppRoutePath(nhs[1]['ip'], 0xffffffff,
labels=[VppMplsLabel(101)]),
VppRoutePath(nhs[2]['ip'], 0xffffffff,
labels=[VppMplsLabel(101)]),
VppRoutePath(nhs[3]['ip'], 0xffffffff,
labels=[VppMplsLabel(101)])])
rx = self.send_and_expect(self.pg0, pkts, self.pg1)
for nh in nhs:
self.assertTrue(sum(p[MPLS].label == nh['label'] for p in rx))
#
# remove first two paths
#
bier_route.remove_path(VppRoutePath(nhs[0]['ip'], 0xffffffff,
labels=[VppMplsLabel(101)]))
bier_route.remove_path(VppRoutePath(nhs[1]['ip'], 0xffffffff,
labels=[VppMplsLabel(101)]))
rx = self.send_and_expect(self.pg0, pkts, self.pg1)
for nh in nhs[2:]:
self.assertTrue(sum(p[MPLS].label == nh['label'] for p in rx))
#
# remove the last of the paths, deleteing the entry
#
bier_route.remove_all_paths()
self.send_and_assert_no_replies(self.pg0, pkts)
示例15: test_map_e
def test_map_e(self):
""" MAP-E """
#
# Add a route to the MAP-BR
#
map_br_pfx = "2001::"
map_br_pfx_len = 64
map_route = VppIpRoute(self,
map_br_pfx,
map_br_pfx_len,
[VppRoutePath(self.pg1.remote_ip6,
self.pg1.sw_if_index,
proto=DpoProto.DPO_PROTO_IP6)],
is_ip6=1)
map_route.add_vpp_config()
#
# Add a domain that maps from pg0 to pg1
#
map_dst = '2001::/64'
map_src = '3000::1/128'
client_pfx = '192.168.0.0/16'
self.vapi.map_add_domain(map_dst, client_pfx, map_src)
# Enable MAP on interface.
self.vapi.map_if_enable_disable(is_enable=1,
sw_if_index=self.pg0.sw_if_index,
is_translation=0)
# Ensure MAP doesn't steal all packets!
v4 = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) /
IP(src=self.pg0.remote_ip4, dst=self.pg0.remote_ip4) /
UDP(sport=20000, dport=10000) /
Raw('\xa5' * 100))
rx = self.send_and_expect(self.pg0, v4*1, self.pg0)
v4_reply = v4[1]
v4_reply.ttl -= 1
for p in rx:
self.validate(p[1], v4_reply)
#
# Fire in a v4 packet that will be encapped to the BR
#
v4 = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) /
IP(src=self.pg0.remote_ip4, dst='192.168.1.1') /
UDP(sport=20000, dport=10000) /
Raw('\xa5' * 100))
self.send_and_assert_encapped(v4, "3000::1", "2001::c0a8:0:0")
# Enable MAP on interface.
self.vapi.map_if_enable_disable(is_enable=1,
sw_if_index=self.pg1.sw_if_index,
is_translation=0)
# Ensure MAP doesn't steal all packets
v6 = (Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac) /
IPv6(src=self.pg1.remote_ip6, dst=self.pg1.remote_ip6) /
UDP(sport=20000, dport=10000) /
Raw('\xa5' * 100))
rx = self.send_and_expect(self.pg1, v6*1, self.pg1)
v6_reply = v6[1]
v6_reply.hlim -= 1
for p in rx:
self.validate(p[1], v6_reply)
#
# Fire in a V6 encapped packet.
# expect a decapped packet on the inside ip4 link
#
p = (Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac) /
IPv6(dst='3000::1', src="2001::1") /
IP(dst=self.pg0.remote_ip4, src='192.168.1.1') /
UDP(sport=20000, dport=10000) /
Raw('\xa5' * 100))
self.pg1.add_stream(p)
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
rx = self.pg0.get_capture(1)
rx = rx[0]
self.assertFalse(rx.haslayer(IPv6))
self.assertEqual(rx[IP].src, p[IP].src)
self.assertEqual(rx[IP].dst, p[IP].dst)
#
# Pre-resolve. No API for this!!
#
self.vapi.ppcli("map params pre-resolve ip6-nh 4001::1")
self.send_and_assert_no_replies(self.pg0, v4,
"resovled via default route")
#
# Add a route to 4001::1. Expect the encapped traffic to be
# sent via that routes next-hop
#.........这里部分代码省略.........