Skip to contentSkip to conversation

[7200] net: Add support for capturing VLANs (Jan Kiszka)

Qemu-devel Anthony Liguori 1 participant 1 message Apr 21, 2009

lore
Share & tools
lore
#0 lore raw

Revision: 7200

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=7200
Author:   aliguori
Date:     2009-04-21 19:56:28 +0000 (Tue, 21 Apr 2009)

Log Message:
-----------
net: Add support for capturing VLANs (Jan Kiszka)

This patch is derived from Tristan Gingold's patch. It adds a new VLAN client type that writes all traffic on the VLAN it is attached to into a pcap file. Such a file can then be analyzed offline with Wireshark or tcpdump.

Besides rebasing and some minor cleanups, the major differences to the original version are:
- support for enabling/disabling via the monitor (host_net_add/remove)
- no special ordering of VLAN client list, qemu_send_packet now takes care of properly ordered packets
- 64k default capturing limit (I hate tcpdump's default)

Modified Paths:
--------------
trunk/monitor.c
trunk/net.c
trunk/qemu-options.hx

Modified: trunk/monitor.c
===================================================================

monitor.c +1 -1
@@ -1731,7 +1731,7 @@
     { "pci_add", "sss", pci_device_hot_add, "pci_addr=auto|[[<domain>:]<bus>:]<slot> nic|storage [[vlan=n][,macaddr=addr][,model=type]] [file=file][,if=type][,bus=nr]...", "hot-add PCI device" },
     { "pci_del", "s", pci_device_hot_remove, "pci_addr=[[<domain>:]<bus>:]<slot>", "hot remove PCI device" },
     { "host_net_add", "ss", net_host_device_add,
-      "[tap,user,socket,vde] options", "add host VLAN client" },
+      "[tap,user,socket,vde,dump] options", "add host VLAN client" },
     { "host_net_remove", "is", net_host_device_remove,
       "vlan_id name", "remove host VLAN client" },
 #endif

Modified: trunk/net.c
===================================================================

net.c +113 -2

139 lines not on this page · raw message

Modified: trunk/qemu-options.hx
===================================================================

qemu-options.hx +7 -0
@@ -745,6 +745,8 @@
     "                Use group 'groupname' and mode 'octalmode' to change default\n"
     "                ownership and permissions for communication port.\n"
 #endif
+    "-net dump[,vlan=n][,file=f][,len=n]\n"
+    "                dump traffic on vlan 'n' to file 'f' (max n bytes per packet)\n"
     "-net none       use it alone to have zero network devices; if no -net option\n"
     "                is provided, the default is '-net nic -net user'\n")
 STEXI
@@ -865,6 +867,11 @@
 qemu linux.img -net nic -net vde,sock=/tmp/myswitch
 @end example
 
+@item -net dump[,vlan=@var{n}][,file=@var{file}][,len=@var{len}]
+Dump network traffic on VLAN @var{n} to file @var{file} (@file{qemu-vlan0.pcap} by default).
+At most @var{len} bytes (64k by default) per packet are stored. The file format is
+libpcap, so it can be analyzed with tools such as tcpdump or Wireshark.
+
 @item -net none
 Indicate that no network devices should be configured. It is used to
 override the default configuration (@option{-net nic -net user}) which