fix: wrong GTP length when Sequence Number is enabled and QoS is disabled #130
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bug description
If you create a configuration that make a new GTP packet with Sequence Number but you don't provide a QER IE (which is an optional IE), the resulting GTP packet's length field is off by 4.
This makes the packet total payload shorter than indicated in the header, resulting in interoperability issues (in particular, when attempting to use a custom SMF that will push a different set of PFCP rules than Free5GC's one, and where QoS management is not yet implemented).
For exemple, when creating a gNB using go-gtp, such packet is considered malformed, and is always dropped.
Bug cause
This bug results from the following:
When
ext_pdu_sess
is not initialized,sizeof(*ext_pdu_sess)
returns4
and not0
.Bug mitigation
The fix is to split the incrementation in 2 steps:
sizeof(*gtp1opt)
if an option (Sequence Number, or Extension Header) is provided;ext_pdu_sess
is well initialized before incrementingpayload_len
bysizeof(*ext_pdu_sess)
.