Revert part of 2629#2715
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2715 +/- ##
==========================================
- Coverage 88.26% 88.22% -0.04%
==========================================
Files 251 251
Lines 53351 53361 +10
==========================================
- Hits 47090 47079 -11
- Misses 6261 6282 +21
|
There was a problem hiding this comment.
This wasn't used by the FlagsField
p-l-
left a comment
There was a problem hiding this comment.
I do not agree (so far) with you (but maybe I just need to be convinced).
I think it may be good to have a flexible bind_layers() that would avoid specific, less readable implementations of .guess_payload_class().
What I really like with the current implementation, is that it allows to write statements that everyone will understand at first glance (which is, or at least should be, something we should keep in mind when writing dissectors).
I do agree with you: such a change just for one situation is not worth it. But I think that this change might make it possible to rewrite several dissectors in current Scapy code so that they get more readable, and to write complex layer binds using readable and simple code.
|
I'm going to check the performance impact of such a change then make up my mind. I do agree that the use of lambdas in |
It is possible that a performance impact exists. On the other hand, Scapy's trade-off usually favors dissector's readability over performances (if you want to analyze a PCAP file and need high performances, you are probably not going to use Scapy anyway); so I guess it all depends on how bad the impact will be.
It could have waited, that is totally true. However now it is in the codebase, I don't think we should remove it, only to restore it after 2.4.4. It is an important change, but it does not break or anyhow affect things that work with 2.4.3 (that would have been a good reason to discuss the removal). |
|
I've ran some tests, this has almost no performance impact. I've re-added the changes |
guedou
left a comment
There was a problem hiding this comment.
LGTM. Why did you remove tests from smb2.uts?
|
Those tests don't test anything, and had funky spacing. I also had issue on a machine because of the ~SMB2 tag misplaced at the top |
|
I think we could have the SMB2 tests kept, with |
|
@p-l- I actually have another major issue with this proposal: using a lambda in Flags won't be edited on building. This is messed up and not what we want for The test you pointed out actually shows that this is broken: my only fix here would be to add an extra |
OK that's a killer argument IMO. |
Revert a small part of #2629
I really don't like this addition: it slowsguess_payload_classfor a marginal use case.bind_layersshould NOT allow callables.The proper way has always been to add a custom
guess_payload_classfunction when the bindings don't fit abind_layerscall.It also seems that SMB2 is currently completly broken, mostly because of how it uses the FlagsFields. This fixes it