On 07/28/2015 05:19 PM, Yang Hongyang wrote: > On 07/28/2015 12:00 PM, Yang Hongyang wrote: >> On 07/28/2015 11:28 AM, Jason Wang wrote: >>> On 07/27/2015 06:03 PM, Yang Hongyang wrote: >>>> On 07/27/2015 05:16 PM, Jason Wang wrote: >>>> [...] >>>>>>>>>> I think this won't work for the buffer case? If we want the >>>>>>>>>> buffer >>>>>>>>>> case >>>>>>>>>> to work under this, we should modify the generic netdev layer >>>>>>>>>> code, to >>>>>>>>>> check the return value of the filter function call. >>>>>>>>> >>>>>>>>> But checking return value is rather simpler than a new netdev >>>>>>>>> type, >>>>>>>>> isn't it? >>>>>>>> >>>>>>>> But how to implement a plugin which suppose to do the actual >>>>>>>> work on >>>>>>>> the packets? >>>>>>> >>>>>>> Well, the filter get the packets, so it can do everything it wants. >>>>>>> >>>>>>>> how to configure params related to the plugin? different >>>>>>>> plugins may need different params, implement as another netdev? >>>>>>> >>>>>>> I belive qmp can do this? something like -filter >>>>>>> dump,id=f0,len=10000? >>>>>> >>>>>> So you mean implement another object filter? >>>>> >>>>> Yes. >>>>> >>>>>> and the structure is like netdev? >>>>> >>>>> No, it is embedded in netdev. >>>> >>>> Ah, I see what you mean, thank you for the patience... >>>> does the command line looks like: >>>> -filter dump,id=f0,len=10000 >>>> -netdev tap,XXX,filter=dump >>>> >>>> If I need both dump and packets buffering, how will the qmp be? >>>> -filter dump,id=f0,len=10000 >>>> -filter buffer,XXX >>>> -netdev tap,XXX,filter=dump:buffer:XXX ? >>> >>> This is ok but we have several choices, e.g you may want to have a next >>> field like: >>> >>> - filter buffer,id=f0 >>> - filter dump,id=f1,len=1000,next=f0 >>> - netdev tap,XXX,filter_root=f1 >> >> This seems better, thank you! > > Sorry, when try to implement it, I found this qmp is not that good > when it > comes to dynamically add/remove filters, can I use below instead: > -netdev tap,id=bn0 > -netfilter dump,id=f0,netdev=bn0 > -netfilter buffer,id=f1,netdev=bn0 > > by this, I can introduce a QTAILQ of filters to NetClentState and > netdev_{add|del}_filter to dynamically add/remove filters.
This looks good. Thanks