-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpfilter: add in "Quick Start" guide within the "Usage" page #177
Conversation
6de6520
to
b55f4b3
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #177 +/- ##
==========================================
- Coverage 28.54% 26.93% -1.61%
==========================================
Files 54 57 +3
Lines 4618 4900 +282
==========================================
+ Hits 1318 1320 +2
- Misses 3300 3580 +280 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Ryan B Sullivan <[email protected]>
b55f4b3
to
5dc54fb
Compare
doc/usage/index.rst
Outdated
.. code-block:: bash | ||
|
||
> cd path/to/bpfilter/ | ||
> sudo ./build/output/bpfilter -t -v debug --no-iptables |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use long options here, it's easier to understand for people learning about bpfilter
.
doc/usage/index.rst
Outdated
|
||
.. code-block:: bash | ||
|
||
> cd path/to/bpfilter/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path/to/bpfilter/
-> path/to/bpfilter/repo
doc/usage/index.rst
Outdated
.. note:: | ||
If you run into errors here there may be problems with your system worth diagnosing before continuing | ||
|
||
Now let's try changing the filter from ``{192.168.1.1} ACCEPT`` to ``DENY`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DENY
-> DROP
doc/usage/index.rst
Outdated
--- 192.168.1.1 ping statistics --- | ||
4 packets transmitted, 0 packets received, 100.0% packet loss | ||
|
||
Congratulations you have now officially used ``bpfilter`` to systematically filter out your own packets. For documentation for more complex filtering options please check under the ``DEVELOPERS`` links and good luck! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"DEVELOPERS
link`" -> "DEVELOPERS
section"
doc/usage/index.rst
Outdated
|
||
sudo ./build/output/bfcli --str "chain BF_HOOK_NF_LOCAL_IN policy ACCEPT rule ip4.saddr in {192.168.1.1} DROP" | ||
|
||
You should now observe a change in the behavior of ``ping`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"behavior of ping
" -> "behavior of ping
."
doc/usage/index.rst
Outdated
> cd path/to/bpfilter/ | ||
> sudo ./build/output/bfcli --str "chain BF_HOOK_NF_LOCAL_IN policy ACCEPT rule ip4.saddr in {192.168.1.1} ACCEPT" | ||
|
||
The above program is just to make sure that ``bfcli`` is able to communicate with ``bpfilter``, when you run the commands you should see output from ``bpfilter`` registering that a filter has been loaded. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Detail what the command is doing: "The above command will...", also for a quick example, I would avoid using a set ({...}
) and use a single address instead (ip4.saddr eq 192.168.1.1
).
Signed-off-by: Ryan Sullivan <[email protected]>
@qdeslandes let me know if the additions are acceptable or if more detail is needed |
doc/usage/index.rst
Outdated
|
||
.. note:: | ||
|
||
This is only to be used as an example and a more interactive test to familiarize you with ``bpfilter``, more in-depth information can be found throughout the docs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"throughout the docs" -> "throughout the documentation"
doc/usage/index.rst
Outdated
|
||
.. code-block:: bash | ||
|
||
> cd path/to/bpfilter/repo/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This path should be the same for all the examples. It might be simpler to remove the cd
command from the code blocks and mention something along the lines of "we assume the following commands are run from the bpfilter
source directory".
doc/usage/index.rst
Outdated
> cd path/to/bpfilter/ | ||
> sudo ./build/output/bfcli --str "chain BF_HOOK_NF_LOCAL_IN policy ACCEPT rule ip4.saddr eq 192.168.1.1 ACCEPT" | ||
|
||
The above command is just to make sure that ``bfcli`` is able to communicate with ``bpfilter``, but it's still worth working through it. This command is telling ``bpfilter`` to check incoming traffic from the ``BF_HOOK_NF_LOCAL_IN`` hook location and accept those connections. Then the command asks ``bpfilter`` to check to see if the incoming IP address is equal to ``192.168.1.1`` (yourself) and to accept the connection if that is true. When you run the commands you should see output from ``bpfilter`` registering that a filter has been loaded. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part is confusing and inaccurate:
- "
bpfilter
to check incoming traffic": it sends a request tobpfilter
to create a new filter.bpfilter
itself doesn't process the traffic - "accept those connections": "connections" when it comes to packet filtering have a very specific meaning (e.g. TCP connection),
bpfilter
's programs works at the packet level - "asks
bpfilter
to check":bpfilter
won't check anything but generate a program that does - "
192.168.1.1
(yourself)": that is very specific to one's network.
I would prefer something simpler and more straightforward such as:
The command above will send a request to the bpfilter
daemon to create a chain and attach it to the BF_HOOK_NF_LOCAL_IN
hook, located after the packet has been routed in the kernel network stack. A single rule is defined, which will accept the packet if its source IPv4 address is 192.168.1.1
. If the rule doesn't match the packet, the chain's policy is applied and the packet is accepted. In its current shape, the chain will always accept incoming packets.
> ping 192.168.1.1 | ||
... [attempting to ping] ... | ||
--- 192.168.1.1 ping statistics --- | ||
4 packets transmitted, 0 packets received, 100.0% packet loss |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We define a rule to block a specific IP and the ping fails, but does this do what you expect it to do? The command above creates a filter for BF_HOOK_LOCAL_IN
, i.e. an input hook, meaning packets coming to the local host with the source IP 192.168.1.1
are accepted. It won't block packets going out of the local host, but the answer coming back from 192.168.1.1
.
doc/usage/index.rst
Outdated
--- 192.168.1.1 ping statistics --- | ||
4 packets transmitted, 0 packets received, 100.0% packet loss | ||
|
||
Congratulations you have now officially used ``bpfilter`` to systematically filter out your own packets. For documentation for more complex filtering options please check under the ``DEVELOPERS`` section and good luck! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
systematically filter out your own packets
We only filter packets coming from 192.168.1.1
.
Signed-off-by: Ryan B Sullivan <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there, one last nit. Also, please fix the command regarding the usage of the long options in the examples.
doc/usage/index.rst
Outdated
@@ -56,7 +59,7 @@ While the ``bpfilter`` daemon runs, now we will open up a separate window to use | |||
> cd path/to/bpfilter/ | |||
> sudo ./build/output/bfcli --str "chain BF_HOOK_NF_LOCAL_IN policy ACCEPT rule ip4.saddr eq 192.168.1.1 ACCEPT" | |||
|
|||
The above command is just to make sure that ``bfcli`` is able to communicate with ``bpfilter``, but it's still worth working through it. This command is telling ``bpfilter`` to check incoming traffic from the ``BF_HOOK_NF_LOCAL_IN`` hook location and accept those connections. Then the command asks ``bpfilter`` to check to see if the incoming IP address is equal to ``192.168.1.1`` (yourself) and to accept the connection if that is true. When you run the commands you should see output from ``bpfilter`` registering that a filter has been loaded. | |||
The command above will send a request to the bpfilter daemon to create a chain and attach it to the BF_HOOK_NF_LOCAL_IN hook, located after the packet has been routed in the kernel network stack. A single rule is defined, which will accept the packet if its source IPv4 address is 192.168.1.1. If the rule doesn't match the packet, the chain's policy is applied and the packet is accepted. In its current shape, the chain will always accept incoming packets. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use double backticks around BF_HOOK_NF_LOCAL_IN and the IP address.
…in explanatory section Signed-off-by: Ryan B Sullivan <[email protected]>
Hey, @qdeslandes just wanted to ping regarding this |
Signed-off-by: Ryan B Sullivan <[email protected]>
Hi @ryanbsull , Non-code changes are usually not the most straightforward for some reason, thanks for pushing through, I appreciate your contribution. This change is now merged! |
Thanks! |
No description provided.