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)
Wed, Feb 28, 3:48 PM
Unknown Object (File)
Jan 8 2024, 7:03 PM
Unknown Object (File)
Dec 22 2023, 10:46 PM
Unknown Object (File)
Dec 12 2023, 12:55 PM
Unknown Object (File)
Oct 31 2023, 1:46 AM
Unknown Object (File)
Oct 25 2023, 5:12 PM
Unknown Object (File)
Sep 23 2023, 10:37 AM
Unknown Object (File)
Sep 15 2023, 5:04 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