mbox series

[iproute2-next,0/2] tc: add NLM_F_ECHO support for actions and filters

Message ID 20240124153456.117048-1-victor@mojatatu.com (mailing list archive)
Headers show
Series tc: add NLM_F_ECHO support for actions and filters | expand

Message

Victor Nogueira Jan. 24, 2024, 3:34 p.m. UTC
Continuing on what Hangbin Liu started [1], this patch set adds support for
the NLM_F_ECHO flag for tc actions and filters. For qdiscs it will require
some kernel surgery, and we'll send it soon after this surgery is merged.

When user space configures the kernel with netlink messages, it can set
NLM_F_ECHO flag to request the kernel to send the applied configuration
back to the caller. This allows user space to receive back configuration
information that is populated by the kernel. Often because there are
parameters that can only be set by the kernel which become visible with the
echo, or because user space lets the kernel choose a default value.

To illustrate a use case where the kernel will give us a default value,
the example below shows the user not specifying the action index:

    tc -echo actions add action mirred egress mirror dev lo
  
    total acts 0
    Added action
          action order 1: mirred (Egress Mirror to device lo) pipe
          index 1 ref 1 bind 0
          not_in_hw

Note that the echoed response indicates that the kernel gave us a value
of index 1

[1] https://lore.kernel.org/netdev/20220916033428.400131-2-liuhangbin@gmail.com/

Victor Nogueira (2):
  tc: add NLM_F_ECHO support for actions
  tc: Add NLM_F_ECHO support for filters

 man/man8/tc.8  |  6 +++++-
 tc/m_action.c  | 25 ++++++++++++++++++++++---
 tc/tc.c        |  6 +++++-
 tc/tc_filter.c |  8 +++++++-
 4 files changed, 39 insertions(+), 6 deletions(-)

Comments

Hangbin Liu Jan. 25, 2024, 2:37 a.m. UTC | #1
On Wed, Jan 24, 2024 at 12:34:54PM -0300, Victor Nogueira wrote:
> Continuing on what Hangbin Liu started [1], this patch set adds support for
> the NLM_F_ECHO flag for tc actions and filters. For qdiscs it will require
> some kernel surgery, and we'll send it soon after this surgery is merged.
> 
> When user space configures the kernel with netlink messages, it can set
> NLM_F_ECHO flag to request the kernel to send the applied configuration
> back to the caller. This allows user space to receive back configuration
> information that is populated by the kernel. Often because there are
> parameters that can only be set by the kernel which become visible with the
> echo, or because user space lets the kernel choose a default value.
> 
> To illustrate a use case where the kernel will give us a default value,
> the example below shows the user not specifying the action index:
> 
>     tc -echo actions add action mirred egress mirror dev lo
>   
>     total acts 0
>     Added action
>           action order 1: mirred (Egress Mirror to device lo) pipe
>           index 1 ref 1 bind 0
>           not_in_hw
> 
> Note that the echoed response indicates that the kernel gave us a value
> of index 1
> 

Looks good to me.

Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>
patchwork-bot+netdevbpf@kernel.org Jan. 30, 2024, 3:50 p.m. UTC | #2
Hello:

This series was applied to iproute2/iproute2-next.git (main)
by David Ahern <dsahern@kernel.org>:

On Wed, 24 Jan 2024 12:34:54 -0300 you wrote:
> Continuing on what Hangbin Liu started [1], this patch set adds support for
> the NLM_F_ECHO flag for tc actions and filters. For qdiscs it will require
> some kernel surgery, and we'll send it soon after this surgery is merged.
> 
> When user space configures the kernel with netlink messages, it can set
> NLM_F_ECHO flag to request the kernel to send the applied configuration
> back to the caller. This allows user space to receive back configuration
> information that is populated by the kernel. Often because there are
> parameters that can only be set by the kernel which become visible with the
> echo, or because user space lets the kernel choose a default value.
> 
> [...]

Here is the summary with links:
  - [iproute2-next,1/2] tc: add NLM_F_ECHO support for actions
    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=071144c0bbb9
  - [iproute2-next,2/2] tc: Add NLM_F_ECHO support for filters
    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=cf0eae9a9fc4

You are awesome, thank you!