On 03/02/2016 02:47 PM, Jason Wang wrote:
On 02/29/2016 08:23 PM, Zhang Chen wrote:
In this unit test,we will test the filter redirector function.
Start qemu with:
"-netdev tap,id=qtest-bn0 "
Please don't use tap since it needs
- CAP_NET_ADMIN
- if-up script
Neither of above could not be true for a qtest environment.
"-device rtl8139,netdev=qtest-bn0,id=qtest-e0 "
"-chardev socket,id=redirector0,path=%s,server,nowait "
"-chardev socket,id=redirector1,path=%s,server,nowait "
"-object filter-redirector,id=qtest-f1,netdev=qtest-bn0,"
"queue=tx,indev=redirector1 "
"-object filter-redirector,id=qtest-f0,netdev=qtest-bn0,"
"queue=tx,outdev=redirector0 "
We inject packet to -chardev redirector1,then filter-redirector
will pass it to filter, another filter-redirector get it and
redirect it to redirector0,we read packet from redirector0
and compare to what we inject.
Looks correct but I think queue='rx' should also be tested here. How about:
- using backend
- redirect tx traffic to a chardev, then inject packet from socket and
read it from chardev
- redirect from another chardev to rx traffic, then inject packet from
chardev and read if from socket?
hi, Jason
IIUC, a full UT for redirector should include following cases.
How about they:
rd[n]: redirctor n
Case 1, tx traffic flow:
qemu side | test side
|
+---------+ | +-------+
| backend <---------------+ sock0 |
+----+----+ | +-------+
| |
+----v----+ +-------+ |
| rd0 +->+chardev| |
+---------+ +---+---+ |
| |
+---------+ | |
| rd1 <------+ |
+----+----+ |
| |
+----v----+ | +-------+
| rd2 +--------------->sock1 |
+---------+ | +-------+
+
--------------------------------------
Case 2, rx traffic flow
qemu side | test side
|
+---------+ | +-------+
| backend +---------------> sock1 |
+----^----+ | +-------+
| |
+----+----+ +-------+ |
| rd0 +->+chardev| |
+---------+ +---+---+ |
^ |
+---------+ | |
| rd1 +------+ |
+----^----+ |
| |
+----+----+ | +-------+
| rd2 <---------------+sock0 |
+---------+ | +-------+
+
Thanks
Li Zhijian