aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2017-04-25 14:14:17 +0100
committerPeter Maydell <peter.maydell@linaro.org>2017-04-25 14:14:17 +0100
commitb8c7193fe9479a941a56863595766d4517152dae (patch)
tree611b10ecdbe3e1c7a1a89f6e14b1787027beb603 /net
parent4ba967ad7454c08d7e01b047d34d0c3d98f2a10d (diff)
parent0fc8aec7de64f2bf83a274a2a38b938ce03425d2 (diff)
Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging
# gpg: Signature made Tue 25 Apr 2017 12:22:03 BST # gpg: using RSA key 0xEF04965B398D6211 # gpg: Good signature from "Jason Wang (Jason Wang on RedHat) <jasowang@redhat.com>" # gpg: WARNING: This key is not certified with sufficiently trusted signatures! # gpg: It is not certain that the signature belongs to the owner. # Primary key fingerprint: 215D 46F4 8246 689E C77F 3562 EF04 965B 398D 6211 * remotes/jasowang/tags/net-pull-request: COLO-compare: Optimize tcp compare trace event COLO-compare: Optimize tcp compare for option field slirp: add a fake NC-SI backend aspeed: add a FTGMAC100 nic net/ftgmac100: add a 'aspeed' property net: add FTGMAC100 support hw/net: add MII definitions colo-compare: Fix old packet check bug. Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'net')
-rw-r--r--net/colo-compare.c69
-rw-r--r--net/trace-events3
2 files changed, 54 insertions, 18 deletions
diff --git a/net/colo-compare.c b/net/colo-compare.c
index 54e6d40525..03ddebe5d3 100644
--- a/net/colo-compare.c
+++ b/net/colo-compare.c
@@ -233,24 +233,54 @@ static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt)
spkt->ip->ip_sum = ppkt->ip->ip_sum;
}
- if (ptcp->th_sum == stcp->th_sum) {
+ /*
+ * Check tcp header length for tcp option field.
+ * th_off > 5 means this tcp packet have options field.
+ * The tcp options maybe always different.
+ * for example:
+ * From RFC 7323.
+ * TCP Timestamps option (TSopt):
+ * Kind: 8
+ *
+ * Length: 10 bytes
+ *
+ * +-------+-------+---------------------+---------------------+
+ * |Kind=8 | 10 | TS Value (TSval) |TS Echo Reply (TSecr)|
+ * +-------+-------+---------------------+---------------------+
+ * 1 1 4 4
+ *
+ * In this case the primary guest's timestamp always different with
+ * the secondary guest's timestamp. COLO just focus on payload,
+ * so we just need skip this field.
+ */
+ if (ptcp->th_off > 5) {
+ ptrdiff_t tcp_offset;
+ tcp_offset = ppkt->transport_header - (uint8_t *)ppkt->data
+ + (ptcp->th_off * 4);
+ res = colo_packet_compare_common(ppkt, spkt, tcp_offset);
+ } else if (ptcp->th_sum == stcp->th_sum) {
res = colo_packet_compare_common(ppkt, spkt, ETH_HLEN);
} else {
res = -1;
}
- if (res != 0 && trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {
- trace_colo_compare_pkt_info_src(inet_ntoa(ppkt->ip->ip_src),
- ntohl(stcp->th_seq),
- ntohl(stcp->th_ack),
- res, stcp->th_flags,
- spkt->size);
+ if (res && trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) {
+ char ip_src[20], ip_dst[20];
- trace_colo_compare_pkt_info_dst(inet_ntoa(ppkt->ip->ip_dst),
- ntohl(ptcp->th_seq),
- ntohl(ptcp->th_ack),
- res, ptcp->th_flags,
- ppkt->size);
+ strcpy(ip_src, inet_ntoa(ppkt->ip->ip_src));
+ strcpy(ip_dst, inet_ntoa(ppkt->ip->ip_dst));
+
+ trace_colo_compare_tcp_info(ip_src,
+ ip_dst,
+ ntohl(ptcp->th_seq),
+ ntohl(stcp->th_seq),
+ ntohl(ptcp->th_ack),
+ ntohl(stcp->th_ack),
+ res,
+ ptcp->th_flags,
+ stcp->th_flags,
+ ppkt->size,
+ spkt->size);
qemu_hexdump((char *)ppkt->data, stderr,
"colo-compare ppkt", ppkt->size);
@@ -372,10 +402,9 @@ static int colo_old_packet_check_one(Packet *pkt, int64_t *check_time)
}
}
-static void colo_old_packet_check_one_conn(void *opaque,
- void *user_data)
+static int colo_old_packet_check_one_conn(Connection *conn,
+ void *user_data)
{
- Connection *conn = opaque;
GList *result = NULL;
int64_t check_time = REGULAR_PACKET_CHECK_MS;
@@ -386,7 +415,10 @@ static void colo_old_packet_check_one_conn(void *opaque,
if (result) {
/* do checkpoint will flush old packet */
/* TODO: colo_notify_checkpoint();*/
+ return 0;
}
+
+ return 1;
}
/*
@@ -398,7 +430,12 @@ static void colo_old_packet_check(void *opaque)
{
CompareState *s = opaque;
- g_queue_foreach(&s->conn_list, colo_old_packet_check_one_conn, NULL);
+ /*
+ * If we find one old packet, stop finding job and notify
+ * COLO frame do checkpoint.
+ */
+ g_queue_find_custom(&s->conn_list, NULL,
+ (GCompareFunc)colo_old_packet_check_one_conn);
}
/*
diff --git a/net/trace-events b/net/trace-events
index 35198bc742..123cb28c63 100644
--- a/net/trace-events
+++ b/net/trace-events
@@ -13,8 +13,7 @@ colo_compare_icmp_miscompare(const char *sta, int size) ": %s = %d"
colo_compare_ip_info(int psize, const char *sta, const char *stb, int ssize, const char *stc, const char *std) "ppkt size = %d, ip_src = %s, ip_dst = %s, spkt size = %d, ip_src = %s, ip_dst = %s"
colo_old_packet_check_found(int64_t old_time) "%" PRId64
colo_compare_miscompare(void) ""
-colo_compare_pkt_info_src(const char *src, uint32_t sseq, uint32_t sack, int res, uint32_t sflag, int ssize) "src/dst: %s s: seq/ack=%u/%u res=%d flags=%x spkt_size: %d\n"
-colo_compare_pkt_info_dst(const char *dst, uint32_t dseq, uint32_t dack, int res, uint32_t dflag, int dsize) "src/dst: %s d: seq/ack=%u/%u res=%d flags=%x dpkt_size: %d\n"
+colo_compare_tcp_info(const char *src, const char *dst, uint32_t pseq, uint32_t sseq, uint32_t pack, uint32_t sack, int res, uint32_t pflag, uint32_t sflag, int psize, int ssize) "src/dst: %s/%s pseq/sseq:%u/%u pack/sack:%u/%u res=%d pflags/sflag:%x/%x psize/ssize:%d/%d \n"
# net/filter-rewriter.c
colo_filter_rewriter_debug(void) ""