Skip to content

Commit

Permalink
Merge pull request #838 from ywc689/conn-quiescent-optimization
Browse files Browse the repository at this point in the history
ipvs: expire quiescent connections after realserver was removed
  • Loading branch information
ywc689 authored Jul 14, 2022
2 parents 72db9e3 + c5e6dce commit 793e11b
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/ipvs/ip_vs_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ static struct dp_vs_conn *dp_vs_sched_persist(struct dp_vs_service *svc,
assert(svc && iph && mbuf);

conn_flags = (is_synproxy_on ? DPVS_CONN_F_SYNPROXY : 0);
conn_flags |= (svc->flags & DPVS_CONN_F_EXPIRE_QUIESCENT);

if (svc->af == AF_INET6) {
/* FIXME: Is OK to use svc->netmask as IPv6 prefix length ? */
ipv6_addr_prefix_copy(&snet.in6, &iph->saddr.in6, svc->netmask);
Expand Down Expand Up @@ -339,12 +341,12 @@ struct dp_vs_conn *dp_vs_schedule(struct dp_vs_service *svc,
ports[0], ports[1], 0, &param);
}

if (is_synproxy_on) {
if (is_synproxy_on)
flags |= DPVS_CONN_F_SYNPROXY;
}
if (svc->flags & DP_VS_SVC_F_ONEPACKET && iph->proto == IPPROTO_UDP) {
if (svc->flags & DP_VS_SVC_F_ONEPACKET && iph->proto == IPPROTO_UDP)
flags |= DPVS_CONN_F_ONE_PACKET;
}
flags |= (svc->flags & DPVS_CONN_F_EXPIRE_QUIESCENT);

conn = dp_vs_conn_new(mbuf, iph, &param, dest, flags);
if (!conn)
return NULL;
Expand Down Expand Up @@ -1013,17 +1015,15 @@ static int __dp_vs_in(void *priv, struct rte_mbuf *mbuf,
else
dir = DPVS_CONN_DIR_INBOUND;
} else {
/* assert(conn->dest->svc != NULL); */
if (conn->dest && conn->dest->svc &&
prot->conn_expire_quiescent &&
(conn->dest->svc->flags & DPVS_CONN_F_EXPIRE_QUIESCENT)) {
if (rte_atomic16_read(&conn->dest->weight) == 0) {
RTE_LOG(INFO, IPVS, "%s: the conn is quiescent, expire it right now,"
" and drop the packet!\n", __func__);
prot->conn_expire_quiescent(conn);
dp_vs_conn_put(conn);
return INET_DROP;
}
/* assert(conn->dest != NULL); */
if (prot->conn_expire_quiescent && (conn->flags & DPVS_CONN_F_EXPIRE_QUIESCENT) &&
conn->dest && (!dp_vs_dest_is_avail(conn->dest) ||
rte_atomic16_read(&conn->dest->weight) == 0)) {
RTE_LOG(INFO, IPVS, "%s: the conn is quiescent, expire it right now,"
" and drop the packet!\n", __func__);
prot->conn_expire_quiescent(conn);
dp_vs_conn_put(conn);
return INET_DROP;
}
}

Expand Down

0 comments on commit 793e11b

Please sign in to comment.