Skip to content

Commit

Permalink
Update the max connections.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsonkey committed Jun 27, 2018
1 parent 866e4fa commit 701f8db
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
8 changes: 4 additions & 4 deletions core/lb_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ conn_table_expire_cb(__attribute((unused)) struct rte_timer *timer, void *arg) {

int
lb_conn_table_init(struct lb_conn_table *ct, enum lb_proto_type type,
uint32_t lcore_id, uint32_t timeout,
uint32_t lcore_id, uint32_t timeout, uint32_t size,
void (*task_cb)(struct lb_conn *),
int (*expire_cb)(struct lb_conn *, uint32_t)) {
struct rte_hash_parameters param;
Expand All @@ -189,7 +189,7 @@ lb_conn_table_init(struct lb_conn_table *ct, enum lb_proto_type type,
memset(&param, 0, sizeof(param));
snprintf(name, sizeof(name), "ct_hash%p", ct);
param.name = name;
param.entries = LB_MAX_CONN * 2;
param.entries = size * 2;
param.key_len = sizeof(struct ipv4_4tuple);
param.hash_func = rte_hash_crc;
param.socket_id = socket_id;
Expand All @@ -202,8 +202,8 @@ lb_conn_table_init(struct lb_conn_table *ct, enum lb_proto_type type,
}

snprintf(name, sizeof(name), "ct_mp%p", ct);
ct->mp = rte_mempool_create(name, LB_MAX_CONN, sizeof(struct lb_conn), 0, 0,
NULL, NULL, NULL, NULL, socket_id,
ct->mp = rte_mempool_create(name, size, sizeof(struct lb_conn), 0, 0, NULL,
NULL, NULL, NULL, socket_id,
MEMPOOL_F_SP_PUT | MEMPOOL_F_SC_GET);
if (ct->mp == NULL) {
RTE_LOG(ERR, USER1, "%s(): Create mempool %s failed, %s\n", __func__,
Expand Down
4 changes: 1 addition & 3 deletions core/lb_conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
#include "lb_synproxy.h"
#include "lb_tcp_secret_seq.h"

#define LB_MAX_CONN (1 << 20)

#define LB_CONN_F_SYNPROXY (0x01)
#define LB_CONN_F_ACTIVE (0x02)
#define LB_CONN_F_TOA (0x4)
Expand Down Expand Up @@ -86,7 +84,7 @@ struct lb_conn *lb_conn_find(struct lb_conn_table *ct, uint32_t sip,
uint32_t dip, uint16_t sport, uint16_t dport,
uint8_t *dir);
int lb_conn_table_init(struct lb_conn_table *ct, enum lb_proto_type type,
uint32_t lcore_id, uint32_t timeout,
uint32_t lcore_id, uint32_t timeout, uint32_t size,
void (*task_cb)(struct lb_conn *),
int (*expire_cb)(struct lb_conn *, uint32_t));

Expand Down
6 changes: 5 additions & 1 deletion core/lb_proto_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
SYN(th) ? 'S' : '-', ACK(th) ? 'A' : '-', RST(th) ? 'R' : '-', \
FIN(th) ? 'F' : '-'

#define TCP_MAX_CONN (1 << 22)

#define sNO TCP_CONNTRACK_NONE
#define sSS TCP_CONNTRACK_SYN_SENT
#define sSR TCP_CONNTRACK_SYN_RECV
Expand Down Expand Up @@ -631,12 +633,14 @@ tcp_fullnat_init(void) {
uint32_t lcore_id;
struct lb_conn_table *ct;
int rc;
int size;

size = TCP_MAX_CONN / (rte_lcore_count() - 1);
RTE_LCORE_FOREACH_SLAVE(lcore_id) {
ct = &lb_conn_tbls[lcore_id];
rc = lb_conn_table_init(
ct, LB_IPPROTO_TCP, lcore_id, tcp_timeouts[TCP_CONNTRACK_NONE],
tcp_conn_timer_task_cb, tcp_conn_timer_expire_cb);
size, tcp_conn_timer_task_cb, tcp_conn_timer_expire_cb);
if (rc < 0) {
RTE_LOG(ERR, USER1, "%s(): lb_conn_table_init failed.\n", __func__);
return rc;
Expand Down
8 changes: 6 additions & 2 deletions core/lb_proto_udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "lb_format.h"
#include "lb_proto.h"

#define UDP_MAX_CONN (1 << 20)

static struct lb_conn_table lb_conn_tbls[RTE_MAX_LCORE];
static uint32_t udp_timeout = 30 * LB_CLOCK_HZ;

Expand Down Expand Up @@ -167,11 +169,13 @@ udp_fullnat_init(void) {
uint32_t lcore_id;
struct lb_conn_table *ct;
int rc;
uint32_t size;

size = UDP_MAX_CONN / (rte_lcore_count() - 1);
RTE_LCORE_FOREACH_SLAVE(lcore_id) {
ct = &lb_conn_tbls[lcore_id];
rc = lb_conn_table_init(ct, LB_IPPROTO_UDP, lcore_id, udp_timeout, NULL,
udp_conn_timer_expire_cb);
rc = lb_conn_table_init(ct, LB_IPPROTO_UDP, lcore_id, udp_timeout, size,
NULL, udp_conn_timer_expire_cb);
if (rc < 0) {
RTE_LOG(ERR, USER1, "%s(): lb_conn_table_init failed.\n", __func__);
return rc;
Expand Down

0 comments on commit 701f8db

Please sign in to comment.