Project

General

Profile

Actions

Optimization #3524

closed
PA

Remove unsafe Rust code for ALPROTO_X constants

Optimization #3524: Remove unsafe Rust code for ALPROTO_X constants

Added by Philippe Antoine about 6 years ago. Updated almost 3 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Target version:
-
Effort:
Difficulty:
Label:

Description

Now, these constants are defined in C enumeration `AppProtoEnum`

In Rust, we use a global variable ('`static mut`) whose value we get as a return of a C function call.
As a global variable, we must use `unsafe` every time we read it

We should either :
- export these from C to Rust with bindgen
- move this enum to Rust and export it to C with cbindgen (cbindgen is already used)


Related issues 1 (0 open1 closed)

Related to Suricata - Task #5053: app-layer: dynamic alproto IDsClosedPhilippe AntoineActions

NP Updated by Nick Price almost 6 years ago Actions #1

Got started on this - moved the enum to Rust and am exporting it with cbindgen

Looks like there are a few "cyclic header dependencies" that will have to be sorted out - other than that it's just a question of safely accessing/mutating the global variables

PA Updated by Philippe Antoine almost 6 years ago Actions #2

Thanks for working on this and letting us know

VJ Updated by Victor Julien almost 6 years ago Actions #3

  • Status changed from New to Assigned
  • Assignee set to Nick Price
  • Target version set to TBD

NP Updated by Nick Price almost 6 years ago Actions #4

Think I've got everything sorted except the header cross-dependencies - once that's done I'll run the test suites and make a PR - hopefully what I did makes sense :P

PA Updated by Philippe Antoine over 5 years ago Actions #5

Hello Nick, where are you with this ? Could you create a draft PR ?

PA Updated by Philippe Antoine over 3 years ago Actions #6

  • Status changed from Assigned to In Review
  • Assignee changed from Nick Price to Philippe Antoine

PA Updated by Philippe Antoine about 3 years ago Actions #7

  • Target version changed from TBD to 8.0.0-beta1

PA Updated by Philippe Antoine almost 3 years ago Actions #8

  • Related to Task #5053: app-layer: dynamic alproto IDs added

PA Updated by Philippe Antoine almost 3 years ago Actions #9

  • Status changed from In Review to Rejected

Closing in favor of #5053

We cannot have a finite rust enumeration if we want dynamic registration...

VJ Updated by Victor Julien almost 3 years ago Actions #10

  • Assignee deleted (Philippe Antoine)
  • Target version deleted (8.0.0-beta1)

PA Updated by Philippe Antoine almost 3 years ago Actions #11

@Jason Ish should we use lazy_static crate ?
Because these are initialized at runtime, but then, they are constants

JI Updated by Jason Ish almost 3 years ago Actions #12

We already depend on lazy_static, so if it solves the problem, sure, its there.

Actions

Also available in: PDF Atom