提交 0d144291 编写于 作者: P Peter Maydell

Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging

# gpg: Signature made Mon 29 Jan 2018 08:14:19 GMT
# 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:
  MAINTAINERS: update Dmitry Fleytman email
  qemu-doc: Get rid of "vlan=X" example in the documentation
  net: Allow netdevs to be used with 'hostfwd_add' and 'hostfwd_remove'
  net: Allow hubports to connect to other netdevs
  colo: compare the packet based on the tcp sequence number
  colo: modified the payload compare function
Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
......@@ -1163,7 +1163,7 @@ F: hw/scsi/mfi.h
F: tests/megasas-test.c
Network packet abstractions
M: Dmitry Fleytman <dmitry@daynix.com>
M: Dmitry Fleytman <dmitry.fleytman@gmail.com>
S: Maintained
F: include/net/eth.h
F: net/eth.c
......@@ -1171,7 +1171,7 @@ F: hw/net/net_rx_pkt*
F: hw/net/net_tx_pkt*
Vmware
M: Dmitry Fleytman <dmitry@daynix.com>
M: Dmitry Fleytman <dmitry.fleytman@gmail.com>
S: Maintained
F: hw/net/vmxnet*
F: hw/scsi/vmw_pvscsi*
......@@ -1192,12 +1192,12 @@ F: hw/mem/nvdimm.c
F: include/hw/mem/nvdimm.h
e1000x
M: Dmitry Fleytman <dmitry@daynix.com>
M: Dmitry Fleytman <dmitry.fleytman@gmail.com>
S: Maintained
F: hw/net/e1000x*
e1000e
M: Dmitry Fleytman <dmitry@daynix.com>
M: Dmitry Fleytman <dmitry.fleytman@gmail.com>
S: Maintained
F: hw/net/e1000e*
......
......@@ -1383,7 +1383,7 @@ ETEXI
{
.name = "hostfwd_add",
.args_type = "arg1:s,arg2:s?,arg3:s?",
.params = "[vlan_id name] [tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport",
.params = "[hub_id name]|[netdev_id] [tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport",
.help = "redirect TCP or UDP connections from host to guest (requires -net user)",
.cmd = hmp_hostfwd_add,
},
......@@ -1398,7 +1398,7 @@ ETEXI
{
.name = "hostfwd_remove",
.args_type = "arg1:s,arg2:s?,arg3:s?",
.params = "[vlan_id name] [tcp|udp]:[hostaddr]:hostport",
.params = "[hub_id name]|[netdev_id] [tcp|udp]:[hostaddr]:hostport",
.help = "remove host-to-guest TCP or UDP redirection",
.cmd = hmp_hostfwd_remove,
},
......
此差异已折叠。
......@@ -138,6 +138,8 @@ Connection *connection_new(ConnectionKey *key)
conn->processing = false;
conn->offset = 0;
conn->syn_flag = 0;
conn->pack = 0;
conn->sack = 0;
g_queue_init(&conn->primary_list);
g_queue_init(&conn->secondary_list);
......@@ -163,6 +165,13 @@ Packet *packet_new(const void *data, int size, int vnet_hdr_len)
pkt->size = size;
pkt->creation_ms = qemu_clock_get_ms(QEMU_CLOCK_HOST);
pkt->vnet_hdr_len = vnet_hdr_len;
pkt->tcp_seq = 0;
pkt->tcp_ack = 0;
pkt->seq_end = 0;
pkt->header_size = 0;
pkt->payload_size = 0;
pkt->offset = 0;
pkt->flags = 0;
return pkt;
}
......
......@@ -45,6 +45,15 @@ typedef struct Packet {
int64_t creation_ms;
/* Get vnet_hdr_len from filter */
uint32_t vnet_hdr_len;
uint32_t tcp_seq; /* sequence number */
uint32_t tcp_ack; /* acknowledgement number */
/* the sequence number of the last byte of the packet */
uint32_t seq_end;
uint8_t header_size; /* the header length */
uint16_t payload_size; /* the payload length */
/* record the payload offset(the length that has been compared) */
uint16_t offset;
uint8_t flags; /* Flags(aka Control bits) */
} Packet;
typedef struct ConnectionKey {
......@@ -64,6 +73,12 @@ typedef struct Connection {
/* flag to enqueue unprocessed_connections */
bool processing;
uint8_t ip_proto;
/* record the sequence number that has been compared */
uint32_t compare_seq;
/* the maximum of acknowledgement number in primary_list queue */
uint32_t pack;
/* the maximum of acknowledgement number in secondary_list queue */
uint32_t sack;
/* offset = secondary_seq - primary_seq */
tcp_seq offset;
/*
......
......@@ -13,6 +13,7 @@
*/
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "monitor/monitor.h"
#include "net/net.h"
#include "clients.h"
......@@ -140,7 +141,8 @@ static NetClientInfo net_hub_port_info = {
.cleanup = net_hub_port_cleanup,
};
static NetHubPort *net_hub_port_new(NetHub *hub, const char *name)
static NetHubPort *net_hub_port_new(NetHub *hub, const char *name,
NetClientState *hubpeer)
{
NetClientState *nc;
NetHubPort *port;
......@@ -153,7 +155,7 @@ static NetHubPort *net_hub_port_new(NetHub *hub, const char *name)
name = default_name;
}
nc = qemu_new_net_client(&net_hub_port_info, NULL, "hub", name);
nc = qemu_new_net_client(&net_hub_port_info, hubpeer, "hub", name);
port = DO_UPCAST(NetHubPort, nc, nc);
port->id = id;
port->hub = hub;
......@@ -165,11 +167,14 @@ static NetHubPort *net_hub_port_new(NetHub *hub, const char *name)
/**
* Create a port on a given hub
* @hub_id: Number of the hub
* @name: Net client name or NULL for default name.
* @hubpeer: Peer to use (if "netdev=id" has been specified)
*
* If there is no existing hub with the given id then a new hub is created.
*/
NetClientState *net_hub_add_port(int hub_id, const char *name)
NetClientState *net_hub_add_port(int hub_id, const char *name,
NetClientState *hubpeer)
{
NetHub *hub;
NetHubPort *port;
......@@ -184,7 +189,7 @@ NetClientState *net_hub_add_port(int hub_id, const char *name)
hub = net_hub_new(hub_id);
}
port = net_hub_port_new(hub, name);
port = net_hub_port_new(hub, name, hubpeer);
return &port->nc;
}
......@@ -232,7 +237,7 @@ NetClientState *net_hub_port_find(int hub_id)
}
}
nc = net_hub_add_port(hub_id, NULL);
nc = net_hub_add_port(hub_id, NULL, NULL);
return nc;
}
......@@ -286,12 +291,22 @@ int net_init_hubport(const Netdev *netdev, const char *name,
NetClientState *peer, Error **errp)
{
const NetdevHubPortOptions *hubport;
NetClientState *hubpeer = NULL;
assert(netdev->type == NET_CLIENT_DRIVER_HUBPORT);
assert(!peer);
hubport = &netdev->u.hubport;
net_hub_add_port(hubport->hubid, name);
if (hubport->has_netdev) {
hubpeer = qemu_find_netdev(hubport->netdev);
if (!hubpeer) {
error_setg(errp, "netdev '%s' not found", hubport->netdev);
return -1;
}
}
net_hub_add_port(hubport->hubid, name, hubpeer);
return 0;
}
......
......@@ -17,7 +17,8 @@
#include "qemu-common.h"
NetClientState *net_hub_add_port(int hub_id, const char *name);
NetClientState *net_hub_add_port(int hub_id, const char *name,
NetClientState *hubpeer);
NetClientState *net_hub_find_client_by_name(int hub_id, const char *name);
void net_hub_info(Monitor *mon);
void net_hub_check_clients(void);
......
......@@ -1063,7 +1063,7 @@ static int net_client_init1(const void *object, bool is_netdev, Error **errp)
/* Do not add to a vlan if it's a nic with a netdev= parameter. */
if (netdev->type != NET_CLIENT_DRIVER_NIC ||
!opts->u.nic.has_netdev) {
peer = net_hub_add_port(net->has_vlan ? net->vlan : 0, NULL);
peer = net_hub_add_port(net->has_vlan ? net->vlan : 0, NULL, NULL);
}
if (net->has_vlan && !vlan_warned) {
......
......@@ -405,16 +405,23 @@ error:
return -1;
}
static SlirpState *slirp_lookup(Monitor *mon, const char *vlan,
const char *stack)
static SlirpState *slirp_lookup(Monitor *mon, const char *hub_id,
const char *name)
{
if (vlan) {
if (name) {
NetClientState *nc;
nc = net_hub_find_client_by_name(strtol(vlan, NULL, 0), stack);
if (!nc) {
monitor_printf(mon, "unrecognized (vlan-id, stackname) pair\n");
return NULL;
if (hub_id) {
nc = net_hub_find_client_by_name(strtol(hub_id, NULL, 0), name);
if (!nc) {
monitor_printf(mon, "unrecognized (vlan-id, stackname) pair\n");
return NULL;
}
} else {
nc = qemu_find_netdev(name);
if (!nc) {
monitor_printf(mon, "unrecognized netdev id '%s'\n", name);
return NULL;
}
}
if (strcmp(nc->model, "user")) {
monitor_printf(mon, "invalid device specified\n");
......@@ -443,9 +450,12 @@ void hmp_hostfwd_remove(Monitor *mon, const QDict *qdict)
const char *arg2 = qdict_get_try_str(qdict, "arg2");
const char *arg3 = qdict_get_try_str(qdict, "arg3");
if (arg2) {
if (arg3) {
s = slirp_lookup(mon, arg1, arg2);
src_str = arg3;
} else if (arg2) {
s = slirp_lookup(mon, NULL, arg1);
src_str = arg2;
} else {
s = slirp_lookup(mon, NULL, NULL);
src_str = arg1;
......@@ -570,9 +580,12 @@ void hmp_hostfwd_add(Monitor *mon, const QDict *qdict)
const char *arg2 = qdict_get_try_str(qdict, "arg2");
const char *arg3 = qdict_get_try_str(qdict, "arg3");
if (arg2) {
if (arg3) {
s = slirp_lookup(mon, arg1, arg2);
redir_str = arg3;
} else if (arg2) {
s = slirp_lookup(mon, NULL, arg1);
redir_str = arg2;
} else {
s = slirp_lookup(mon, NULL, NULL);
redir_str = arg1;
......
......@@ -13,7 +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_tcp_info(const char *pkt, uint32_t seq, uint32_t ack, int res, uint32_t flag, int size) "side: %s seq/ack= %u/%u res= %d flags= 0x%x pkt_size: %d\n"
colo_compare_tcp_info(const char *pkt, uint32_t seq, uint32_t ack, int hdlen, int pdlen, int offset, int flags) "%s: seq/ack= %u/%u hdlen= %d pdlen= %d offset= %d flags=%d\n"
# net/filter-rewriter.c
colo_filter_rewriter_debug(void) ""
......
......@@ -410,12 +410,14 @@
# Connect two or more net clients through a software hub.
#
# @hubid: hub identifier number
# @netdev: used to connect hub to a netdev instead of a device (since 2.12)
#
# Since: 1.2
##
{ 'struct': 'NetdevHubPortOptions',
'data': {
'hubid': 'int32' } }
'hubid': 'int32',
'*netdev': 'str' } }
##
# @NetdevNetmapOptions:
......
......@@ -2000,7 +2000,7 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev,
#endif
"-netdev vhost-user,id=str,chardev=dev[,vhostforce=on|off]\n"
" configure a vhost-user network, backed by a chardev 'dev'\n"
"-netdev hubport,id=str,hubid=n\n"
"-netdev hubport,id=str,hubid=n[,netdev=nd]\n"
" configure a hub port on QEMU VLAN 'n'\n", QEMU_ARCH_ALL)
DEF("net", HAS_ARG, QEMU_OPTION_net,
"-net nic[,vlan=n][,netdev=nd][,macaddr=mac][,model=type][,name=str][,addr=str][,vectors=v]\n"
......@@ -2242,8 +2242,8 @@ qemu-system-i386 linux.img -net nic -net tap
#launch a QEMU instance with two NICs, each one connected
#to a TAP device
qemu-system-i386 linux.img \
-net nic,vlan=0 -net tap,vlan=0,ifname=tap0 \
-net nic,vlan=1 -net tap,vlan=1,ifname=tap1
-netdev tap,id=nd0,ifname=tap0 -device e1000,netdev=nd0 \
-netdev tap,id=nd1,ifname=tap1 -device rtl8139,netdev=nd1
@end example
@example
......@@ -2428,13 +2428,15 @@ vde_switch -F -sock /tmp/myswitch
qemu-system-i386 linux.img -net nic -net vde,sock=/tmp/myswitch
@end example
@item -netdev hubport,id=@var{id},hubid=@var{hubid}
@item -netdev hubport,id=@var{id},hubid=@var{hubid}[,netdev=@var{nd}]
Create a hub port on QEMU "vlan" @var{hubid}.
The hubport netdev lets you connect a NIC to a QEMU "vlan" instead of a single
netdev. @code{-net} and @code{-device} with parameter @option{vlan} create the
required hub automatically.
required hub automatically. Alternatively, you can also connect the hubport
to another netdev with ID @var{nd} by using the @option{netdev=@var{nd}}
option.
@item -netdev vhost-user,chardev=@var{id}[,vhostforce=on|off][,queues=n]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册