Page MenuHomeFreeBSD

netgraph/ng_tag: Variable length data can not be set for all length
ClosedPublic

Authored by donner on Oct 24 2019, 11:27 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 2, 10:20 PM
Unknown Object (File)
Thu, Oct 31, 3:38 PM
Unknown Object (File)
Thu, Oct 17, 5:11 AM
Unknown Object (File)
Oct 4 2024, 3:00 PM
Unknown Object (File)
Oct 4 2024, 9:57 AM
Unknown Object (File)
Oct 2 2024, 1:14 AM
Unknown Object (File)
Oct 1 2024, 11:28 PM
Unknown Object (File)
Oct 1 2024, 5:16 PM

Details

Summary

ng_tag can operate on arbitrary data of mbuf_tags.
This should work for any data sets.

ngctl
+ mkpeer . tag t t
+ msg t sethookin { thisHook="t" tag_len=4 tag_data=[1] }

works. But the following does not:

+ msg t sethookin { thisHook="t" tag_len=1 tag_data=[1] }
ngctl: send msg: Invalid argument

Especially in the case of checking for mbuf_tag values, the length
of checked data is important.

The reason behind this behavior is, that the record size
is padded to the next multiple of the alignment. Therefore
it's sufficient to check for large enough data received.

PR: 241462

Test Plan
+ mkpeer . tag t t
+ msg t sethookin { thisHook="t" tag_len=4 tag_data=[1] }
+ msg t sethookin { thisHook="t" tag_len=1 tag_data=[1] }
+ msg t gethookin "t"
Rec'd response "gethookin" (2) from "[72]:":
Args:   { thisHook="t" tag_len=1 tag_data=[ 0x1 ] }

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

donner added inline comments.
sys/netgraph/ng_tag.c
366–367

Reformatted to more readability and conformance to style(9)

donner edited the summary of this revision. (Show Details)

I think you need to add people with good knowledge of the netgraph to the reviewers: JulianElischer, Gleb Smirnoff and Alexander Motin. Because apparently not all are subscribed to the network mailing list.

donner edited the summary of this revision. (Show Details)

Rebase to current

Revert errornous comparsion

kp added a subscriber: kp.

Approved by: kp (mentor)

This revision is now accepted and ready to land.Jan 18 2021, 11:56 AM