All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tom Herbert <tom@herbertland.com>
To: Or Gerlitz <ogerlitz@mellanox.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Linux Kernel Network Developers <netdev@vger.kernel.org>,
	Saeed Mahameed <saeedm@mellanox.com>,
	Roi Dayan <roid@mellanox.com>, Paul Blakey <paulb@mellanox.com>
Subject: Re: [PATCH net-next 1/4] net/flow_dissector: add support for dissection of misc ip header fields
Date: Thu, 25 May 2017 09:22:57 -0700	[thread overview]
Message-ID: <CALx6S36uJrFA+TO7RDaRAxZi0vuEEc90_TnWP8a2yNP+V3X2qQ@mail.gmail.com> (raw)
In-Reply-To: <1495718679-20693-2-git-send-email-ogerlitz@mellanox.com>

On Thu, May 25, 2017 at 6:24 AM, Or Gerlitz <ogerlitz@mellanox.com> wrote:
> Add support for dissection of ip tos and ttl and ipv6 traffic-class
> and hoplimit. Both are dissected into the same struct.
>
> Uses similar call to ip dissection function as with tcp, arp and others.
>
> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
> Reviewed-by: Jiri Pirko <jiri@mellanox.com>
> ---
>  include/net/flow_dissector.h | 11 +++++++++++
>  net/core/flow_dissector.c    | 40 ++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 51 insertions(+)
>
> diff --git a/include/net/flow_dissector.h b/include/net/flow_dissector.h
> index efe34eec..e2663e9 100644
> --- a/include/net/flow_dissector.h
> +++ b/include/net/flow_dissector.h
> @@ -165,6 +165,16 @@ struct flow_dissector_key_tcp {
>         __be16 flags;
>  };
>
> +/**
> + * struct flow_dissector_key_ip:
> + * @tos: tos
> + * @ttl: ttl
> + */
> +struct flow_dissector_key_ip {
> +       __u8    tos;
> +       __u8    ttl;
> +};
> +
>  enum flow_dissector_key_id {
>         FLOW_DISSECTOR_KEY_CONTROL, /* struct flow_dissector_key_control */
>         FLOW_DISSECTOR_KEY_BASIC, /* struct flow_dissector_key_basic */
> @@ -186,6 +196,7 @@ enum flow_dissector_key_id {
>         FLOW_DISSECTOR_KEY_ENC_PORTS, /* struct flow_dissector_key_ports */
>         FLOW_DISSECTOR_KEY_MPLS, /* struct flow_dissector_key_mpls */
>         FLOW_DISSECTOR_KEY_TCP, /* struct flow_dissector_key_tcp */
> +       FLOW_DISSECTOR_KEY_IP, /* struct flow_dissector_key_ip */
>
>         FLOW_DISSECTOR_KEY_MAX,
>  };
> diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
> index 5a45943..fc5fc45 100644
> --- a/net/core/flow_dissector.c
> +++ b/net/core/flow_dissector.c
> @@ -367,6 +367,40 @@ __skb_flow_dissect_tcp(const struct sk_buff *skb,
>         key_tcp->flags = (*(__be16 *) &tcp_flag_word(th) & htons(0x0FFF));
>  }
>
> +static void
> +__skb_flow_dissect_ipv4(const struct sk_buff *skb,
> +                       struct flow_dissector *flow_dissector,
> +                       void *target_container, void *data, const struct iphdr *iph)
> +{
> +       struct flow_dissector_key_ip *key_ip;
> +
> +       if (!dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_IP))
> +               return;
> +
> +       key_ip = skb_flow_dissector_target(flow_dissector,
> +                                          FLOW_DISSECTOR_KEY_IP,
> +                                          target_container);
> +       key_ip->tos = iph->tos;
> +       key_ip->ttl = iph->ttl;

In an encapsulation this returns the tos and ttl of the encapsulated
packet. Is that really useful to the caller? Seems more likely that
they need the outer tos and ttl for forwarding.

> +}
> +
> +static void
> +__skb_flow_dissect_ipv6(const struct sk_buff *skb,
> +                       struct flow_dissector *flow_dissector,
> +                       void *target_container, void *data, const struct ipv6hdr *iph)
> +{
> +       struct flow_dissector_key_ip *key_ip;
> +
> +       if (!dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_IP))
> +               return;
> +
> +       key_ip = skb_flow_dissector_target(flow_dissector,
> +                                          FLOW_DISSECTOR_KEY_IP,
> +                                          target_container);
> +       key_ip->tos = ipv6_get_dsfield(iph);
> +       key_ip->ttl = iph->hop_limit;
> +}
> +
>  /**
>   * __skb_flow_dissect - extract the flow_keys struct and return it
>   * @skb: sk_buff to extract the flow from, can be NULL if the rest are specified
> @@ -469,6 +503,9 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
>                         }
>                 }
>
> +               __skb_flow_dissect_ipv4(skb, flow_dissector,
> +                                       target_container, data, iph);
> +
>                 if (flags & FLOW_DISSECTOR_F_STOP_AT_L3)
>                         goto out_good;
>
> @@ -514,6 +551,9 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
>                                 goto out_good;
>                 }
>
> +               __skb_flow_dissect_ipv6(skb, flow_dissector,
> +                                       target_container, data, iph);
> +
>                 if (flags & FLOW_DISSECTOR_F_STOP_AT_L3)
>                         goto out_good;
>
> --
> 2.3.7
>

  parent reply	other threads:[~2017-05-25 16:22 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-25 13:24 [PATCH net-next 0/4] add support for dissection and matching on ip tos and ttl Or Gerlitz
2017-05-25 13:24 ` [PATCH net-next 1/4] net/flow_dissector: add support for dissection of misc ip header fields Or Gerlitz
2017-05-25 15:42   ` Tom Herbert
2017-05-27 16:29     ` Or Gerlitz
2017-05-25 16:22   ` Tom Herbert [this message]
2017-05-27 16:31     ` Or Gerlitz
2017-05-27 17:18       ` Tom Herbert
2017-05-27 20:56         ` Or Gerlitz
2017-05-30 13:10         ` Jiri Pirko
2017-05-30 16:06           ` Tom Herbert
2017-05-30 16:18             ` David Miller
2017-06-01 16:08               ` Or Gerlitz
2017-06-01 16:35                 ` David Miller
2017-05-25 13:24 ` [PATCH net-next 2/4] net/sched: cls_flower: add support for matching on ip tos and ttl Or Gerlitz
2017-05-25 13:24 ` [PATCH net-next 3/4] net/mlx5e: Offload TC matching on tcp flags Or Gerlitz
2017-05-25 13:24 ` [PATCH net-next 4/4] net/mlx5e: Offload TC matching on ip tos / traffic-class Or Gerlitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CALx6S36uJrFA+TO7RDaRAxZi0vuEEc90_TnWP8a2yNP+V3X2qQ@mail.gmail.com \
    --to=tom@herbertland.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=ogerlitz@mellanox.com \
    --cc=paulb@mellanox.com \
    --cc=roid@mellanox.com \
    --cc=saeedm@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.