Skip to content

Commit 08ad95f

Browse files
committed
doc: document cgroup_sock_addr hooks and counter semantics
1 parent 9b9c510 commit 08ad95f

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

doc/usage/bfcli.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,8 @@ With:
340340
- ``BF_HOOK_NF_LOCAL_OUT``: similar to ``nftables`` and ``iptables`` output hook.
341341
- ``BF_HOOK_NF_POST_ROUTING``: similar to ``nftables`` and ``iptables`` postrouting hook.
342342
- ``BF_HOOK_TC_EGRESS``: egress TC hook.
343+
- ``BF_HOOK_CGROUP_SOCK_ADDR_CONNECT4``: cgroup hook for IPv4 ``connect()`` syscalls.
344+
- ``BF_HOOK_CGROUP_SOCK_ADDR_CONNECT6``: cgroup hook for IPv6 ``connect()`` syscalls.
343345
- ``$POLICY``: action taken if no rule matches the packet, either ``ACCEPT`` forward the packet to the kernel, or ``DROP`` to discard it. Note while ``CONTINUE`` is a valid verdict for rules, it is not supported for chain policy.
344346

345347
``$OPTIONS`` are hook-specific comma separated key value pairs. A given hook option can only be specified once:
@@ -358,7 +360,7 @@ With:
358360
- N/A
359361
- Interface index to attach the program to.
360362
* - ``cgpath=$CGROUP_PATH``
361-
- ``BF_HOOK_CGROUP_SKB_INGRESS``, ``BF_HOOK_CGROUP_SKB_EGRESS``
363+
- ``BF_HOOK_CGROUP_SKB_INGRESS``, ``BF_HOOK_CGROUP_SKB_EGRESS``, ``BF_HOOK_CGROUP_SOCK_ADDR_CONNECT4``, ``BF_HOOK_CGROUP_SOCK_ADDR_CONNECT6``
362364
- N/A
363365
- Path to the cgroup to attach to.
364366
* - ``family=$FAMILY``
@@ -389,7 +391,7 @@ Rules are defined such as:
389391
With:
390392
- ``$MATCHER``: zero or more matchers. Matchers are defined later.
391393
- ``log``: optional. If set, log the requested protocol headers. ``link`` will log the link (layer 2) header, ``internet`` with log the internet (layer 3) header, and ``transport`` will log the transport (layer 4) header. At least one header type is required.
392-
- ``counter``: optional literal. If set, the filter will counter the number of packets and bytes matched by the rule.
394+
- ``counter``: optional literal. If set, the filter will count the number of events matched by the rule. For packet-based hooks, this includes both the number of packets and the total bytes. For ``BF_HOOK_CGROUP_SOCK_ADDR_*`` hooks, this counts the number of ``connect()`` calls.
393395
- ``mark``: optional, ``$MARK`` must be a valid decimal or hexadecimal 32-bits value. If set, write the packet's marker value. This marker can be used later on in a rule (see ``meta.mark``) or with a TC filter.
394396
- ``$VERDICT``: action taken by the rule if the packet is matched against **all** the criteria: either ``ACCEPT``, ``DROP``, ``CONTINUE``, or ``REDIRECT``.
395397
- ``ACCEPT``: forward the packet to the kernel.
@@ -407,7 +409,7 @@ Note ``CONTINUE`` means a packet can be counted more than once if multiple rules
407409
- ``BF_HOOK_XDP``: only ``out`` direction is supported (XDP always transmits out of the target interface).
408410
- ``BF_HOOK_TC_INGRESS``, ``BF_HOOK_TC_EGRESS``: both ``in`` and ``out`` directions are supported.
409411

410-
``REDIRECT`` is **not** supported by Netfilter (``BF_HOOK_NF_*``) or cgroup_skb (``BF_HOOK_CGROUP_SKB_*``) hooks.
412+
``REDIRECT`` is **not** supported by Netfilter (``BF_HOOK_NF_*``), cgroup_skb (``BF_HOOK_CGROUP_SKB_*``), or cgroup_sock_addr (``BF_HOOK_CGROUP_SOCK_ADDR_*``) hooks.
411413

412414
Sets
413415
~~~~
@@ -539,7 +541,7 @@ Meta
539541
- ``meta.probability``
540542
- ``eq``
541543
- ``$PROBABILITY``
542-
- ``$PROBABILITY`` is a floating-point percentage value (i.e., within [0%, 100%], e.g., "50%" or "33.33%").
544+
- ``$PROBABILITY`` is a floating-point percentage value (i.e., within [0%, 100%], e.g., "50%" or "33.33%"). For ``BF_HOOK_CGROUP_SOCK_ADDR_*`` hooks, probability applies at the connection level: each ``connect()`` call is independently accepted or dropped.
543545
* - :rspan:`1` Mark
544546
- :rspan:`1` ``meta.mark``
545547
- ``eq``

doc/usage/daemon.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ Namespaces
3636

3737
The network namespace will define the available interface indexes to attach the XDP and TC chains, as well as the interface indexes to filter packets on.
3838

39-
The mount namespace is required to ensure the daemon will attach a cgroup_skb chain to the proper cgroup.
39+
The mount namespace is required to ensure the daemon will attach a cgroup_skb or cgroup_sock_addr chain to the proper cgroup.

0 commit comments

Comments
 (0)