summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIdo Barnea <ibarnea@cisco.com>2016-11-16 11:03:51 +0200
committerIdo Barnea <ibarnea@cisco.com>2016-11-16 11:03:51 +0200
commit122f336ffde6d3fc74acc6861322328d778d3232 (patch)
tree2fa5d0889c66608296a1b0431f2289584b77c977
parent52b8755b842c4adbb8bf923798cc1fc4fd498ae4 (diff)
Fix trex-267 - allocation of ARP packets from wrong memory socket
Signed-off-by: Ido Barnea <ibarnea@cisco.com>
-rwxr-xr-xsrc/bp_sim.h12
-rw-r--r--src/debug.cpp8
-rw-r--r--src/pre_test.cpp2
3 files changed, 15 insertions, 7 deletions
diff --git a/src/bp_sim.h b/src/bp_sim.h
index c292103b..0cf77437 100755
--- a/src/bp_sim.h
+++ b/src/bp_sim.h
@@ -1205,12 +1205,13 @@ public:
/* for simulation */
static void free_pools();
-
static inline rte_mbuf_t * pktmbuf_alloc_small(socket_id_t socket){
return ( m_mem_pool[socket].pktmbuf_alloc_small() );
}
-
+ static inline rte_mbuf_t * pktmbuf_alloc_small_by_port(uint8_t port_id) {
+ return ( m_mem_pool[m_socket.port_to_socket(port_id)].pktmbuf_alloc_small() );
+ }
/**
* try to allocate small buffers too
@@ -1228,6 +1229,13 @@ public:
return (m_mem_pool[socket].pktmbuf_alloc(size));
}
+ static inline rte_mbuf_t * pktmbuf_alloc_by_port(uint8_t port_id, uint16_t size){
+ socket_id_t socket = m_socket.port_to_socket(port_id);
+ if (size<FIRST_PKT_SIZE) {
+ return ( pktmbuf_alloc_small(socket));
+ }
+ return (m_mem_pool[socket].pktmbuf_alloc(size));
+ }
static inline bool is_learn_verify_mode(){
return ( (m_options.m_learn_mode != CParserOption::LEARN_MODE_DISABLED) && m_options.preview.get_learn_and_verify_mode_enable());
diff --git a/src/debug.cpp b/src/debug.cpp
index 8ec4f136..d0b7cf11 100644
--- a/src/debug.cpp
+++ b/src/debug.cpp
@@ -106,7 +106,7 @@ rte_mbuf_t *CTrexDebug::create_test_pkt(int ip_ver, uint16_t l4_proto, uint8_t t
0x07, 0x08, 0x50, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0a, 0x01, 0x02, 0x03, 0x04,
// bad - 0x03, 0x04, 0x06, 0x02, 0x20, 0x00, 0xBB, 0x79, 0x00, 0x00};
0x03, 0x04, 0x50, 0x02, 0x20, 0x00, 0xBB, 0x79, 0x00, 0x00};
- rte_mbuf_t *m = CGlobalInfo::pktmbuf_alloc(0, sizeof(test_pkt));
+ rte_mbuf_t *m = CGlobalInfo::pktmbuf_alloc_by_port(0, sizeof(test_pkt));
char *p = rte_pktmbuf_append(m, sizeof(test_pkt));
assert(p);
@@ -146,7 +146,7 @@ rte_mbuf_t *CTrexDebug::create_test_pkt(int ip_ver, uint16_t l4_proto, uint8_t t
utl_k12_pkt_format(stdout,pkt, pkt_size) ;
*/
- m = CGlobalInfo::pktmbuf_alloc(0, pkt_size);
+ m = CGlobalInfo::pktmbuf_alloc_by_port(0, pkt_size);
if ( unlikely(m == 0) ) {
printf("ERROR no packets \n");
return (NULL);
@@ -161,7 +161,7 @@ rte_mbuf_t *CTrexDebug::create_test_pkt(int ip_ver, uint16_t l4_proto, uint8_t t
#endif
rte_mbuf_t *CTrexDebug::create_pkt(uint8_t *pkt, int pkt_size) {
- rte_mbuf_t *m = CGlobalInfo::pktmbuf_alloc(0, pkt_size);
+ rte_mbuf_t *m = CGlobalInfo::pktmbuf_alloc_by_port(0, pkt_size);
if ( unlikely(m == 0) ) {
printf("ERROR no packets \n");
return 0;
@@ -175,7 +175,7 @@ rte_mbuf_t *CTrexDebug::create_pkt(uint8_t *pkt, int pkt_size) {
}
rte_mbuf_t *CTrexDebug::create_pkt_indirect(rte_mbuf_t *m, uint32_t new_pkt_size){
- rte_mbuf_t *d = CGlobalInfo::pktmbuf_alloc(0, 60);
+ rte_mbuf_t *d = CGlobalInfo::pktmbuf_alloc_by_port(0, 60);
assert(d);
rte_pktmbuf_attach(d, m);
diff --git a/src/pre_test.cpp b/src/pre_test.cpp
index 130d076d..76fa9a26 100644
--- a/src/pre_test.cpp
+++ b/src/pre_test.cpp
@@ -257,7 +257,7 @@ void CPretest::send_arp_req(uint16_t port_id, bool is_grat) {
int num_sent;
int verbose = CGlobalInfo::m_options.preview.getVMode();
- m[0] = CGlobalInfo::pktmbuf_alloc_small(0);
+ m[0] = CGlobalInfo::pktmbuf_alloc_small_by_port(port_id);
if ( unlikely(m[0] == 0) ) {
fprintf(stderr, "ERROR: Could not allocate mbuf for sending ARP to port:%d\n", port_id);
exit(1);