No vector allocation during buffer copy
Change-Id: I7e8556af833ca0e00fadc96dcd2077ff1104541b Signed-off-by: Neale Ranns <nranns@cisco.com>
This commit is contained in:
committed by
Damjan Marion
parent
0856b97b49
commit
9d676afbb7
@@ -476,7 +476,6 @@ vlib_buffer_copy (vlib_main_t * vm, vlib_buffer_t * b)
|
||||
{
|
||||
vlib_buffer_t *s, *d, *fd;
|
||||
uword n_alloc, n_buffers = 1;
|
||||
u32 *new_buffers = 0;
|
||||
u32 flag_mask = VLIB_BUFFER_NEXT_PRESENT | VLIB_BUFFER_TOTAL_LENGTH_VALID;
|
||||
int i;
|
||||
|
||||
@@ -486,8 +485,8 @@ vlib_buffer_copy (vlib_main_t * vm, vlib_buffer_t * b)
|
||||
n_buffers++;
|
||||
s = vlib_get_buffer (vm, s->next_buffer);
|
||||
}
|
||||
u32 new_buffers[n_buffers];
|
||||
|
||||
vec_validate (new_buffers, n_buffers - 1);
|
||||
n_alloc = vlib_buffer_alloc (vm, new_buffers, n_buffers);
|
||||
|
||||
/* No guarantee that we'll get all the buffers we asked for */
|
||||
@@ -495,7 +494,6 @@ vlib_buffer_copy (vlib_main_t * vm, vlib_buffer_t * b)
|
||||
{
|
||||
if (n_alloc > 0)
|
||||
vlib_buffer_free (vm, new_buffers, n_alloc);
|
||||
vec_free (new_buffers);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -526,7 +524,6 @@ vlib_buffer_copy (vlib_main_t * vm, vlib_buffer_t * b)
|
||||
d->flags = s->flags & flag_mask;
|
||||
}
|
||||
|
||||
vec_free (new_buffers);
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,9 +28,7 @@
|
||||
static inline mpls_fib_t*
|
||||
mpls_fib_get (fib_node_index_t index)
|
||||
{
|
||||
if (!pool_is_free_index(mpls_main.fibs, index))
|
||||
return (&(pool_elt_at_index(mpls_main.fibs, index)->mpls));
|
||||
return (NULL);
|
||||
return (&(pool_elt_at_index(mpls_main.fibs, index)->mpls));
|
||||
}
|
||||
|
||||
extern u32 mpls_fib_table_find_or_create_and_lock(u32 table_id);
|
||||
|
||||
+38
-9
@@ -8,7 +8,7 @@ from vpp_ip_route import VppIpMRoute, VppMRoutePath, VppMFibSignal
|
||||
|
||||
from scapy.packet import Raw
|
||||
from scapy.layers.l2 import Ether
|
||||
from scapy.layers.inet import IP, UDP, getmacbyip
|
||||
from scapy.layers.inet import IP, UDP, getmacbyip, ICMP
|
||||
from scapy.layers.inet6 import IPv6, getmacbyip6
|
||||
from util import ppp
|
||||
|
||||
@@ -70,16 +70,17 @@ class TestIPMcast(VppTestCase):
|
||||
i.resolve_arp()
|
||||
i.resolve_ndp()
|
||||
|
||||
def create_stream_ip4(self, src_if, src_ip, dst_ip):
|
||||
def create_stream_ip4(self, src_if, src_ip, dst_ip, payload_size=0):
|
||||
pkts = []
|
||||
# default to small packet sizes
|
||||
p = (Ether(dst=src_if.local_mac, src=src_if.remote_mac) /
|
||||
IP(src=src_ip, dst=dst_ip) /
|
||||
UDP(sport=1234, dport=1234))
|
||||
if not payload_size:
|
||||
payload_size = 64 - len(p)
|
||||
p = p / Raw('\xa5' * payload_size)
|
||||
|
||||
for i in range(0, N_PKTS_IN_STREAM):
|
||||
info = self.create_packet_info(src_if, src_if)
|
||||
payload = self.info_to_payload(info)
|
||||
p = (Ether(dst=src_if.local_mac, src=src_if.remote_mac) /
|
||||
IP(src=src_ip, dst=dst_ip) /
|
||||
UDP(sport=1234, dport=1234) /
|
||||
Raw(payload))
|
||||
info.data = p.copy()
|
||||
pkts.append(p)
|
||||
return pkts
|
||||
|
||||
@@ -237,6 +238,7 @@ class TestIPMcast(VppTestCase):
|
||||
|
||||
#
|
||||
# a stream that matches the route for (1.1.1.1,232.1.1.1)
|
||||
# small packets
|
||||
#
|
||||
self.vapi.cli("clear trace")
|
||||
tx = self.create_stream_ip4(self.pg0, "1.1.1.1", "232.1.1.1")
|
||||
@@ -254,6 +256,33 @@ class TestIPMcast(VppTestCase):
|
||||
self.verify_capture_ip4(self.pg6, tx)
|
||||
self.verify_capture_ip4(self.pg7, tx)
|
||||
|
||||
# no replications on Pg0
|
||||
self.pg0.assert_nothing_captured(
|
||||
remark="IP multicast packets forwarded on PG0")
|
||||
self.pg3.assert_nothing_captured(
|
||||
remark="IP multicast packets forwarded on PG3")
|
||||
|
||||
#
|
||||
# a stream that matches the route for (1.1.1.1,232.1.1.1)
|
||||
# large packets
|
||||
#
|
||||
self.vapi.cli("clear trace")
|
||||
tx = self.create_stream_ip4(self.pg0, "1.1.1.1", "232.1.1.1",
|
||||
payload_size=1024)
|
||||
self.pg0.add_stream(tx)
|
||||
|
||||
self.pg_enable_capture(self.pg_interfaces)
|
||||
self.pg_start()
|
||||
|
||||
# We expect replications on Pg1->7
|
||||
self.verify_capture_ip4(self.pg1, tx)
|
||||
self.verify_capture_ip4(self.pg2, tx)
|
||||
self.verify_capture_ip4(self.pg3, tx)
|
||||
self.verify_capture_ip4(self.pg4, tx)
|
||||
self.verify_capture_ip4(self.pg5, tx)
|
||||
self.verify_capture_ip4(self.pg6, tx)
|
||||
self.verify_capture_ip4(self.pg7, tx)
|
||||
|
||||
# no replications on Pg0
|
||||
self.pg0.assert_nothing_captured(
|
||||
remark="IP multicast packets forwarded on PG0")
|
||||
|
||||
Reference in New Issue
Block a user