BPF Archive on lore.kernel.org
 help / color / Atom feed
From: Petar Penkov <ppenkov.kernel@gmail.com>
To: Yoshiki Komachi <komachi.yoshiki@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>, Andrii Nakryiko <andriin@fb.com>,
	Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>
Subject: Re: [PATCH bpf 1/2] flow_dissector: Fix to use new variables for port ranges in bpf hook
Date: Thu, 16 Jan 2020 09:45:08 -0800
Message-ID: <CAGdtWsQ4aigyJUjBxmFQ8C5zU_4p-t0K2=uwVg2NxdUQuh-WoQ@mail.gmail.com> (raw)
In-Reply-To: <20200116085133.392205-2-komachi.yoshiki@gmail.com>

On Thu, Jan 16, 2020 at 1:13 AM Yoshiki Komachi
<komachi.yoshiki@gmail.com> wrote:
>
> This patch applies new flag (FLOW_DISSECTOR_KEY_PORTS_RANGE) and
> field (tp_range) to BPF flow dissector to generate appropriate flow
> keys when classified by specified port ranges.
>
> Fixes: 8ffb055beae5 ("cls_flower: Fix the behavior using port ranges with hw-offload")
> Signed-off-by: Yoshiki Komachi <komachi.yoshiki@gmail.com>
> ---
>  net/core/flow_dissector.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
> index 2dbbb03..06bbcc3 100644
> --- a/net/core/flow_dissector.c
> +++ b/net/core/flow_dissector.c
> @@ -876,10 +876,17 @@ static void __skb_flow_bpf_to_target(const struct bpf_flow_keys *flow_keys,
>                 key_control->addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS;
>         }
>
> -       if (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_PORTS)) {
> +       if (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_PORTS))
>                 key_ports = skb_flow_dissector_target(flow_dissector,
>                                                       FLOW_DISSECTOR_KEY_PORTS,
>                                                       target_container);
> +       else if (dissector_uses_key(flow_dissector,
> +                                   FLOW_DISSECTOR_KEY_PORTS_RANGE))
> +               key_ports = skb_flow_dissector_target(flow_dissector,
> +                                                     FLOW_DISSECTOR_KEY_PORTS_RANGE,
> +                                                     target_container);
> +
> +       if (key_ports) {

If the flow dissector uses neither FLOW_DISSECTOR_KEY_PORTS_RANGE, nor
FLOW_DISSECTOR_KEY_PORTS, I believe key_ports would be used
uninitialized here. We should probably explicitly set it to NULL at
the top of this function.

>                 key_ports->src = flow_keys->sport;
>                 key_ports->dst = flow_keys->dport;
>         }
> --
> 1.8.3.1
>

  reply index

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-16  8:51 [PATCH bpf 0/2] Fix the classification based on " Yoshiki Komachi
2020-01-16  8:51 ` [PATCH bpf 1/2] flow_dissector: Fix to use new variables for " Yoshiki Komachi
2020-01-16 17:45   ` Petar Penkov [this message]
2020-01-17  1:50     ` Yoshiki Komachi
2020-01-16  8:51 ` [PATCH bpf 2/2] selftests/bpf: Add test based on port range for BPF flow dissector Yoshiki Komachi
2020-01-16 17:42   ` Petar Penkov

Reply instructions:

You may reply publically 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='CAGdtWsQ4aigyJUjBxmFQ8C5zU_4p-t0K2=uwVg2NxdUQuh-WoQ@mail.gmail.com' \
    --to=ppenkov.kernel@gmail.com \
    --cc=andriin@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=kafai@fb.com \
    --cc=komachi.yoshiki@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.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

BPF Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/bpf/0 bpf/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 bpf bpf/ https://lore.kernel.org/bpf \
		bpf@vger.kernel.org
	public-inbox-index bpf

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.bpf


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git