Skip to content

Commit

Permalink
Add identifiers for Synchronized sessions.
Browse files Browse the repository at this point in the history
  • Loading branch information
weiyanhua committed Aug 23, 2019
1 parent 8817a76 commit 72edfcc
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions include/conf/conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ struct ip_vs_conn_entry {
uint16_t in_af;
uint16_t out_af;
uint16_t proto;
uint16_t syncid;
union inet_addr caddr;
union inet_addr vaddr;
union inet_addr laddr;
Expand Down
1 change: 1 addition & 0 deletions include/ipvs/conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ struct dp_vs_conn {

struct dpvs_timer conn_sync_timer;
struct timeval conn_sync_timeout;
uint16_t syncid;
queueid_t qid; /* used in session synchronization*/

lcoreid_t lcore;
Expand Down
1 change: 1 addition & 0 deletions include/ipvs/sync.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ struct dp_vs_sync_conn {
struct dp_vs_seq fnat_seq;
uint32_t rs_end_seq;
uint32_t rs_end_ack;
uint16_t syncid;
};

struct dp_vs_sync_head {
Expand Down
4 changes: 4 additions & 0 deletions src/ipvs/ip_vs_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,7 @@ struct dp_vs_conn * dp_vs_conn_copy_from_sync(void *param, struct dp_vs_dest *de
new->rs_end_seq = sync_conn->rs_end_seq;
new->rs_end_ack = sync_conn->rs_end_ack;

new->syncid = sync_conn->syncid;
new->flags = sync_conn->flags | DPVS_CONN_F_SYNCED;
new->state = sync_conn->state;
new->qid = sync_conn->qid;
Expand Down Expand Up @@ -1343,6 +1344,9 @@ static inline void sockopt_fill_conn_entry(const struct dp_vs_conn *conn,
entry->lport = conn->lport;
entry->dport = conn->dport;
entry->timeout = conn->timeout.tv_sec;
if (conn->flags & DPVS_CONN_F_SYNCED) {
entry->syncid = conn->syncid;
}
}

static int sockopt_conn_get_specified(const struct ip_vs_conn_req *conn_req,
Expand Down
1 change: 1 addition & 0 deletions src/ipvs/ip_vs_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ void dp_vs_sync_conn_enqueue(struct dp_vs_conn *cp, dp_vs_sync_type type)
s->daddr = cp->daddr;
s->qid = cp->qid;
s->lcore = cp->lcore;
s->syncid = g_dp_vs_sync_conf.syncid;

rte_memcpy(&s->fnat_seq, &cp->fnat_seq, sizeof(struct dp_vs_seq));
s->rs_end_seq = cp->rs_end_seq;
Expand Down
12 changes: 9 additions & 3 deletions tools/ipvsadm/ipvsadm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1573,9 +1573,15 @@ static void print_conn_entry(const ipvs_conn_entry_t *conn_entry,
ntohs(conn_entry->dport), conn_entry->proto, format)))
goto exit;

printf("[%d]%-3s %-6s %-11s %-18s %-18s %-18s %s\n",
conn_entry->lcoreid, proto_str, time_str, conn_entry->state,
cname, vname, lname, dname);
if (conn_entry->syncid) {
printf("[%d]%-3s %-6s %-11s %-18s %-18s %-18s %-18s syncid:%d\n",
conn_entry->lcoreid, proto_str, time_str, conn_entry->state,
cname, vname, lname, dname, conn_entry->syncid);
} else {
printf("[%d]%-3s %-6s %-11s %-18s %-18s %-18s %s\n",
conn_entry->lcoreid, proto_str, time_str, conn_entry->state,
cname, vname, lname, dname);
}
exit:
if (cname)
free(cname);
Expand Down

0 comments on commit 72edfcc

Please sign in to comment.