parser: send key as integer on the dfa of sysv mqueue

The key of SYSV message queues is an integer and the kernel uses an
integer to store the key. In order to improve performance when
travelling the DFA in the kernel, we should use an integer instead of
the string.

Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
This commit is contained in:
Georgia Garcia 2023-01-11 21:58:03 +00:00
parent 223036d952
commit 106b3d16da

View file

@ -244,13 +244,19 @@ int mqueue_rule::gen_policy_re(Profile &prof)
if (qtype != mqueue_posix) {
std::ostringstream buffer;
buffer << "\\x" << std::setfill('0') << std::setw(2) << std::hex << AA_CLASS_SYSV_MQUEUE;
buf.assign(buffer.str());
if (qname) {
if (!convert_entry(buf, qname))
goto fail;
int key;
sscanf(qname, "%d", &key);
u32 tmp = htobe32((u32) key);
u8 *byte = (u8 *) &tmp;
for (int i = 0; i < 4; i++){
buffer << "\\x" << std::setfill('0') << std::setw(2) << std::hex << static_cast<unsigned int>(byte[i]);
}
} else {
buf += default_match_pattern;
buffer << "....";
}
buf.assign(buffer.str());
vec[0] = buf.c_str();
if (label) {