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.

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
R10 FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; 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