Skip to content

ipvs: Optimize TOA insertion performance using memmove #1026

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions src/ipvs/ip_vs_proto_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,8 @@ static int tcp_in_add_toa(struct dp_vs_conn *conn, struct rte_mbuf *mbuf,
uint32_t mtu;
struct tcpopt_addr *toa;
uint32_t tcp_opt_len;
uint8_t *p, *q, *tail;
uint8_t *src, *dst, *tail;
size_t move_len;
struct route_entry *rt;
struct route6 *rt6;

Expand Down Expand Up @@ -541,15 +542,11 @@ static int tcp_in_add_toa(struct dp_vs_conn *conn, struct rte_mbuf *mbuf,
* now add address option
*/

/* move data down, including existing tcp options
* @p is last data byte,
* @q is new position of last data byte */
p = tail - 1;
q = p + tcp_opt_len;
while (p >= ((uint8_t *)tcph + sizeof(struct tcphdr))) {
*q = *p;
p--, q--;
}
/* move data down, including existing tcp options */
src = (uint8_t *)tcph + sizeof(struct tcphdr);
dst = src + tcp_opt_len;
move_len = tail - src;
memmove(dst, src, move_len);

/* insert toa right after TCP basic header */
toa = (struct tcpopt_addr *)(tcph + 1);
Expand Down