From: Simon Horman <simon.horman@netronome.com>
To: Matteo Croce <mcroce@redhat.com>
Cc: netdev@vger.kernel.org, Jay Vosburgh <j.vosburgh@gmail.com>,
Veaceslav Falico <vfalico@gmail.com>,
Andy Gospodarek <andy@greyhouse.net>,
"David S . Miller " <davem@davemloft.net>,
Stanislav Fomichev <sdf@google.com>,
Daniel Borkmann <daniel@iogearbox.net>,
Song Liu <songliubraving@fb.com>,
Alexei Starovoitov <ast@kernel.org>,
Paul Blakey <paulb@mellanox.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 2/4] flow_dissector: skip the ICMP dissector for non ICMP packets
Date: Wed, 23 Oct 2019 11:57:59 +0200 [thread overview]
Message-ID: <20191023095758.GB8732@netronome.com> (raw)
In-Reply-To: <20191021200948.23775-3-mcroce@redhat.com>
On Mon, Oct 21, 2019 at 10:09:46PM +0200, Matteo Croce wrote:
> FLOW_DISSECTOR_KEY_ICMP is checked for every packet, not only ICMP ones.
> Even if the test overhead is probably negligible, move the
> ICMP dissector code under the big 'switch(ip_proto)' so it gets called
> only for ICMP packets.
>
> Signed-off-by: Matteo Croce <mcroce@redhat.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
> ---
> net/core/flow_dissector.c | 34 +++++++++++++++++++++++++---------
> 1 file changed, 25 insertions(+), 9 deletions(-)
>
> diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
> index affde70dad47..6443fac65ce8 100644
> --- a/net/core/flow_dissector.c
> +++ b/net/core/flow_dissector.c
> @@ -203,6 +203,25 @@ __be32 __skb_flow_get_ports(const struct sk_buff *skb, int thoff, u8 ip_proto,
> }
> EXPORT_SYMBOL(__skb_flow_get_ports);
>
> +/* If FLOW_DISSECTOR_KEY_ICMP is set, get the Type and Code from an ICMP packet
> + * using skb_flow_get_be16().
> + */
> +static void __skb_flow_dissect_icmp(const struct sk_buff *skb,
> + struct flow_dissector *flow_dissector,
> + void *target_container,
> + void *data, int thoff, int hlen)
> +{
> + struct flow_dissector_key_icmp *key_icmp;
> +
> + if (!dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_ICMP))
> + return;
> +
> + key_icmp = skb_flow_dissector_target(flow_dissector,
> + FLOW_DISSECTOR_KEY_ICMP,
> + target_container);
> + key_icmp->icmp = skb_flow_get_be16(skb, thoff, data, hlen);
> +}
> +
> void skb_flow_dissect_meta(const struct sk_buff *skb,
> struct flow_dissector *flow_dissector,
> void *target_container)
> @@ -853,7 +872,6 @@ bool __skb_flow_dissect(const struct net *net,
> struct flow_dissector_key_basic *key_basic;
> struct flow_dissector_key_addrs *key_addrs;
> struct flow_dissector_key_ports *key_ports;
> - struct flow_dissector_key_icmp *key_icmp;
> struct flow_dissector_key_tags *key_tags;
> struct flow_dissector_key_vlan *key_vlan;
> struct bpf_prog *attached = NULL;
> @@ -1295,6 +1313,12 @@ bool __skb_flow_dissect(const struct net *net,
> data, nhoff, hlen);
> break;
>
> + case IPPROTO_ICMP:
> + case IPPROTO_ICMPV6:
> + __skb_flow_dissect_icmp(skb, flow_dissector, target_container,
> + data, nhoff, hlen);
> + break;
> +
> default:
> break;
> }
> @@ -1308,14 +1332,6 @@ bool __skb_flow_dissect(const struct net *net,
> data, hlen);
> }
>
> - if (dissector_uses_key(flow_dissector,
> - FLOW_DISSECTOR_KEY_ICMP)) {
> - key_icmp = skb_flow_dissector_target(flow_dissector,
> - FLOW_DISSECTOR_KEY_ICMP,
> - target_container);
> - key_icmp->icmp = skb_flow_get_be16(skb, nhoff, data, hlen);
> - }
> -
> /* Process result of IP proto processing */
> switch (fdret) {
> case FLOW_DISSECT_RET_PROTO_AGAIN:
> --
> 2.21.0
>
next prev parent reply other threads:[~2019-10-23 9:59 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-21 20:09 [PATCH net-next 0/4] ICMP flow improvements Matteo Croce
2019-10-21 20:09 ` [PATCH net-next 1/4] flow_dissector: add meaningful comments Matteo Croce
2019-10-23 9:57 ` Simon Horman
2019-10-21 20:09 ` [PATCH net-next 2/4] flow_dissector: skip the ICMP dissector for non ICMP packets Matteo Croce
2019-10-23 9:57 ` Simon Horman [this message]
2019-10-21 20:09 ` [PATCH net-next 3/4] flow_dissector: extract more ICMP information Matteo Croce
2019-10-23 10:00 ` Simon Horman
2019-10-23 10:53 ` Matteo Croce
2019-10-23 17:55 ` Simon Horman
2019-10-25 0:27 ` Matteo Croce
2019-10-25 6:28 ` Simon Horman
2019-10-25 18:24 ` Matteo Croce
2019-10-26 7:55 ` Simon Horman
2019-10-21 20:09 ` [PATCH net-next 4/4] bonding: balance ICMP echoes in layer3+4 mode Matteo Croce
2019-10-23 10:01 ` Simon Horman
2019-10-23 16:58 ` Matteo Croce
2019-10-23 18:00 ` Simon Horman
2019-10-24 22:05 ` [PATCH net-next 0/4] ICMP flow improvements David Miller
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=20191023095758.GB8732@netronome.com \
--to=simon.horman@netronome.com \
--cc=andy@greyhouse.net \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=j.vosburgh@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mcroce@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=paulb@mellanox.com \
--cc=sdf@google.com \
--cc=songliubraving@fb.com \
--cc=vfalico@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).