This commit is contained in:
yunwei37
2024-01-17 19:23:04 +00:00
parent 67583a22f2
commit eb868c0c10
4 changed files with 8 additions and 2 deletions

View File

@@ -491,6 +491,9 @@ bpf_printk("%d len %d buffer: %s", payload_offset, payload_length, lin
return 0;
}
</code></pre>
<blockquote>
<p>注意bpf_strncmp 这个内核 helper 在 5.17 版本中才被引入,如果你的内核版本低于 5.17,可以手动匹配字符串来实现相同的功能。</p>
</blockquote>
<p>这段代码使用<code>bpf_strncmp</code>函数比较<code>line_buffer</code>中的数据与HTTP请求方法GET、POST、PUT、DELETE、HTTP是否匹配。如果不匹配说明不是HTTP请求直接返回0放弃处理。</p>
<pre><code class="language-c">e = bpf_ringbuf_reserve(&amp;rb, sizeof(*e), 0);
if (!e)

View File

@@ -4853,6 +4853,9 @@ bpf_printk(&quot;%d len %d buffer: %s&quot;, payload_offset, payload_length, lin
return 0;
}
</code></pre>
<blockquote>
<p>注意bpf_strncmp 这个内核 helper 在 5.17 版本中才被引入,如果你的内核版本低于 5.17,可以手动匹配字符串来实现相同的功能。</p>
</blockquote>
<p>这段代码使用<code>bpf_strncmp</code>函数比较<code>line_buffer</code>中的数据与HTTP请求方法GET、POST、PUT、DELETE、HTTP是否匹配。如果不匹配说明不是HTTP请求直接返回0放弃处理。</p>
<pre><code class="language-c">e = bpf_ringbuf_reserve(&amp;rb, sizeof(*e), 0);
if (!e)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long