aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2021-11-04 00:47:37 -0400
committerRichard Henderson <richard.henderson@linaro.org>2021-11-04 00:47:37 -0400
commit752e235464d62d31f14a9790b4b24e396c86bb0e (patch)
tree50a3142b43bbf9d14d4a3210ef303458876efc9d /net
parentb1fd92137e4d485adeec8e9f292f928ff335b76c (diff)
parent64153ca613d0a50d1301eae4bd895aade001fcca (diff)
Merge remote-tracking branch 'remotes/juanquintela/tags/migration-20211102-pull-request' into staging
Migration Pull request Hi This are the pending migration patches on the list: - Provide an error message for migration_cancel by Laurent - Don't dump colo cache when a guest core is requested by Lukas - Initialise Compression_conters for new migration by Yuxiating On top of that I added another missing initialization - Colo optimizations and crash improvements by Rao. Please, apply. # gpg: Signature made Wed 03 Nov 2021 04:45:35 AM EDT # gpg: using RSA key 1899FF8EDEBF58CCEE034B82F487EF185872D723 # gpg: Good signature from "Juan Quintela <quintela@redhat.com>" [full] # gpg: aka "Juan Quintela <quintela@trasno.org>" [full] * remotes/juanquintela/tags/migration-20211102-pull-request: Optimized the function of fill_connection_key. colo: Don't dump colo cache if dump-guest-core=off Changed the last-mode to none of first start COLO Removed the qemu_fclose() in colo_process_incoming_thread colo: fixed 'Segmentation fault' when the simplex mode PVM poweroff Fixed SVM hang when do failover before PVM crash Fixed qemu crash when guest power off in COLO mode Some minor optimizations for COLO migration: Zero migration compression counters migration: initialise compression_counters for a new migration migration: provide an error message to migration_cancel() Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'net')
-rw-r--r--net/colo-compare.c4
-rw-r--r--net/colo.c31
-rw-r--r--net/colo.h6
-rw-r--r--net/filter-rewriter.c10
4 files changed, 18 insertions, 33 deletions
diff --git a/net/colo-compare.c b/net/colo-compare.c
index b100e7b51f..b8876d7fd9 100644
--- a/net/colo-compare.c
+++ b/net/colo-compare.c
@@ -170,7 +170,7 @@ static bool packet_matches_str(const char *str,
return false;
}
- return !memcmp(str, buf, strlen(str));
+ return !memcmp(str, buf, packet_len);
}
static void notify_remote_frame(CompareState *s)
@@ -264,7 +264,7 @@ static int packet_enqueue(CompareState *s, int mode, Connection **con)
pkt = NULL;
return -1;
}
- fill_connection_key(pkt, &key);
+ fill_connection_key(pkt, &key, false);
conn = connection_get(s->connection_track_table,
&key,
diff --git a/net/colo.c b/net/colo.c
index 3a3e6e89a0..1f8162f59f 100644
--- a/net/colo.c
+++ b/net/colo.c
@@ -83,19 +83,26 @@ int parse_packet_early(Packet *pkt)
return 0;
}
-void extract_ip_and_port(uint32_t tmp_ports, ConnectionKey *key, Packet *pkt)
+void extract_ip_and_port(uint32_t tmp_ports, ConnectionKey *key,
+ Packet *pkt, bool reverse)
{
+ if (reverse) {
+ key->src = pkt->ip->ip_dst;
+ key->dst = pkt->ip->ip_src;
+ key->src_port = ntohs(tmp_ports & 0xffff);
+ key->dst_port = ntohs(tmp_ports >> 16);
+ } else {
key->src = pkt->ip->ip_src;
key->dst = pkt->ip->ip_dst;
key->src_port = ntohs(tmp_ports >> 16);
key->dst_port = ntohs(tmp_ports & 0xffff);
+ }
}
-void fill_connection_key(Packet *pkt, ConnectionKey *key)
+void fill_connection_key(Packet *pkt, ConnectionKey *key, bool reverse)
{
- uint32_t tmp_ports;
+ uint32_t tmp_ports = 0;
- memset(key, 0, sizeof(*key));
key->ip_proto = pkt->ip->ip_p;
switch (key->ip_proto) {
@@ -106,29 +113,15 @@ void fill_connection_key(Packet *pkt, ConnectionKey *key)
case IPPROTO_SCTP:
case IPPROTO_UDPLITE:
tmp_ports = *(uint32_t *)(pkt->transport_header);
- extract_ip_and_port(tmp_ports, key, pkt);
break;
case IPPROTO_AH:
tmp_ports = *(uint32_t *)(pkt->transport_header + 4);
- extract_ip_and_port(tmp_ports, key, pkt);
break;
default:
break;
}
-}
-
-void reverse_connection_key(ConnectionKey *key)
-{
- struct in_addr tmp_ip;
- uint16_t tmp_port;
-
- tmp_ip = key->src;
- key->src = key->dst;
- key->dst = tmp_ip;
- tmp_port = key->src_port;
- key->src_port = key->dst_port;
- key->dst_port = tmp_port;
+ extract_ip_and_port(tmp_ports, key, pkt, reverse);
}
Connection *connection_new(ConnectionKey *key)
diff --git a/net/colo.h b/net/colo.h
index d91cd245c4..8b3e8d5a83 100644
--- a/net/colo.h
+++ b/net/colo.h
@@ -89,9 +89,9 @@ typedef struct Connection {
uint32_t connection_key_hash(const void *opaque);
int connection_key_equal(const void *opaque1, const void *opaque2);
int parse_packet_early(Packet *pkt);
-void extract_ip_and_port(uint32_t tmp_ports, ConnectionKey *key, Packet *pkt);
-void fill_connection_key(Packet *pkt, ConnectionKey *key);
-void reverse_connection_key(ConnectionKey *key);
+void extract_ip_and_port(uint32_t tmp_ports, ConnectionKey *key,
+ Packet *pkt, bool reverse);
+void fill_connection_key(Packet *pkt, ConnectionKey *key, bool reverse);
Connection *connection_new(ConnectionKey *key);
void connection_destroy(void *opaque);
Connection *connection_get(GHashTable *connection_track_table,
diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c
index cb3a96cde1..bf05023dc3 100644
--- a/net/filter-rewriter.c
+++ b/net/filter-rewriter.c
@@ -279,15 +279,7 @@ static ssize_t colo_rewriter_receive_iov(NetFilterState *nf,
*/
if (pkt && is_tcp_packet(pkt)) {
- fill_connection_key(pkt, &key);
-
- if (sender == nf->netdev) {
- /*
- * We need make tcp TX and RX packet
- * into one connection.
- */
- reverse_connection_key(&key);
- }
+ fill_connection_key(pkt, &key, sender == nf->netdev);
/* After failover we needn't change new TCP packet */
if (s->failover_mode &&