mbox series

[RFC,0/5] Initial refactor for hwsim frame processing

Message ID 20230630191812.2884637-1-prestwoj@gmail.com (mailing list archive)
Headers show
Series Initial refactor for hwsim frame processing | expand

Message

James Prestwood June 30, 2023, 7:18 p.m. UTC
I wanted to put this out there just as an idea before I get too
invested in extending it. The code itself needs cleanup (explained
later) but I wanted some feedback on the general idea.

Eventually I'd like to extend this to support remote communication
with multiple hwsim instances, e.g. via a multicast socket. As a
starting point the rules code fit nicely as a frame processing
module.

Cleanup:
 - Find solution for the IWD_MODULE_DEPENDS issue
 - Add getters for radio/interface info objects, possibly
   for hwsim_frame too rather than everything exposed in
   hwsim.h.
 - The hwsim_frame cleanup in rules needs to be changed. Prior
   hwsim_frame_unref() would send tx_info but now this needs
   to be handled in rules.c. Currently we peek into the refcount
   and see if it will be destroyed on unref, and send tx_info
   then.

The dbus dependency patches by themselves are actually useful so
feel free to merge those if they look ok. If you don't like the
preprocessor define thats fine, its a minimal amount of code
duplicated between iwd/hwsim so its not _that_ bad as it stands
today.

Note: These were done on top of the ADD/DEL mac changes so if
they don't apply that is likely the issue. Again, just looking
for a yay or nay on this concept.

James Prestwood (5):
  dbus: remove dependency on agent
  dbus: remove iwd.h dependency
  hwsim: use dbus.c module
  hwsim: refactor rules processing into separate file
  module: temporary hack to allow for no module dependencies

 Makefile.am   |    9 +-
 src/agent.c   |   12 +-
 src/agent.h   |    2 -
 src/dbus.c    |   43 +-
 src/dbus.h    |    4 +
 src/module.c  |    6 +
 tools/hwsim.c | 1115 +++----------------------------------------------
 tools/hwsim.h |   99 +++++
 tools/rules.c | 1017 ++++++++++++++++++++++++++++++++++++++++++++
 9 files changed, 1224 insertions(+), 1083 deletions(-)
 create mode 100644 tools/hwsim.h
 create mode 100644 tools/rules.c

Comments

Denis Kenzior July 6, 2023, 4:36 a.m. UTC | #1
Hi James,

On 6/30/23 14:18, James Prestwood wrote:
> I wanted to put this out there just as an idea before I get too
> invested in extending it. The code itself needs cleanup (explained
> later) but I wanted some feedback on the general idea.

No real objection, but if you're moving 1kloc of code around, make sure that any 
moves are separated from overall refinements and other changes.  For example, if 
you're exporting API functions or structures for use in (newly created) modules, 
do that first.

> 
> Eventually I'd like to extend this to support remote communication
> with multiple hwsim instances, e.g. via a multicast socket. As a
> starting point the rules code fit nicely as a frame processing
> module.

I assume you saw https://github.com/Raizo62/vwifi ?

> 
> Cleanup:
>   - Find solution for the IWD_MODULE_DEPENDS issue

Well, you need to put something into the section if you don't invoke 
IWD_MODULE_DEPENDS at least once.

>   - Add getters for radio/interface info objects, possibly
>     for hwsim_frame too rather than everything exposed in
>     hwsim.h.

That would be preferable.

>   - The hwsim_frame cleanup in rules needs to be changed. Prior
>     hwsim_frame_unref() would send tx_info but now this needs
>     to be handled in rules.c. Currently we peek into the refcount
>     and see if it will be destroyed on unref, and send tx_info
>     then.

Hmm, not sure I follow yet?

Also, iwd/tools/* is for executables that get built from single files.  I guess 
we could relax that, but it may be better to have hwsim live in its own 
directory, similar to ead & iwmon.

Regards,
-Denis
James Prestwood July 10, 2023, 5:13 p.m. UTC | #2
Hi Denis,

On 7/5/23 9:36 PM, Denis Kenzior wrote:
> Hi James,
> 
> On 6/30/23 14:18, James Prestwood wrote:
>> I wanted to put this out there just as an idea before I get too
>> invested in extending it. The code itself needs cleanup (explained
>> later) but I wanted some feedback on the general idea.
> 
> No real objection, but if you're moving 1kloc of code around, make sure 
> that any moves are separated from overall refinements and other 
> changes.  For example, if you're exporting API functions or structures 
> for use in (newly created) modules, do that first.

Yep definitely.

> 
>>
>> Eventually I'd like to extend this to support remote communication
>> with multiple hwsim instances, e.g. via a multicast socket. As a
>> starting point the rules code fit nicely as a frame processing
>> module.
> 
> I assume you saw https://github.com/Raizo62/vwifi ?

I had not seen that one, but its pretty close to what I'm looking for. 
Still would need some specific modifications but its at least being 
maintained somewhat. Definitely worth looking into.

There is also a similar project, but its old and doesn't look 
particularly finished:

https://github.com/cmu-sei/welled

> 
>>
>> Cleanup:
>>   - Find solution for the IWD_MODULE_DEPENDS issue
> 
> Well, you need to put something into the section if you don't invoke 
> IWD_MODULE_DEPENDS at least once.
> 
>>   - Add getters for radio/interface info objects, possibly
>>     for hwsim_frame too rather than everything exposed in
>>     hwsim.h.
> 
> That would be preferable.
> 
>>   - The hwsim_frame cleanup in rules needs to be changed. Prior
>>     hwsim_frame_unref() would send tx_info but now this needs
>>     to be handled in rules.c. Currently we peek into the refcount
>>     and see if it will be destroyed on unref, and send tx_info
>>     then.
> 
> Hmm, not sure I follow yet?

Just minor details really, I need to just look at it closer once its in 
a more finished state.

> 
> Also, iwd/tools/* is for executables that get built from single files.  
> I guess we could relax that, but it may be better to have hwsim live in 
> its own directory, similar to ead & iwmon.

Ok that does make more sense.

> 
> Regards,
> -Denis