Commit 59fb9b62 authored by Yoshiki Komachi's avatar Yoshiki Komachi Committed by Daniel Borkmann

flow_dissector: Fix to use new variables for port ranges in bpf hook

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: 8ffb055b ("cls_flower: Fix the behavior using port ranges with hw-offload")
Signed-off-by: default avatarYoshiki Komachi <komachi.yoshiki@gmail.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarPetar Penkov <ppenkov@google.com>
Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20200117070533.402240-2-komachi.yoshiki@gmail.com
parent b23bfa56
...@@ -834,10 +834,10 @@ static void __skb_flow_bpf_to_target(const struct bpf_flow_keys *flow_keys, ...@@ -834,10 +834,10 @@ static void __skb_flow_bpf_to_target(const struct bpf_flow_keys *flow_keys,
struct flow_dissector *flow_dissector, struct flow_dissector *flow_dissector,
void *target_container) void *target_container)
{ {
struct flow_dissector_key_ports *key_ports = NULL;
struct flow_dissector_key_control *key_control; struct flow_dissector_key_control *key_control;
struct flow_dissector_key_basic *key_basic; struct flow_dissector_key_basic *key_basic;
struct flow_dissector_key_addrs *key_addrs; struct flow_dissector_key_addrs *key_addrs;
struct flow_dissector_key_ports *key_ports;
struct flow_dissector_key_tags *key_tags; struct flow_dissector_key_tags *key_tags;
key_control = skb_flow_dissector_target(flow_dissector, key_control = skb_flow_dissector_target(flow_dissector,
...@@ -876,10 +876,17 @@ static void __skb_flow_bpf_to_target(const struct bpf_flow_keys *flow_keys, ...@@ -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; 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, key_ports = skb_flow_dissector_target(flow_dissector,
FLOW_DISSECTOR_KEY_PORTS, FLOW_DISSECTOR_KEY_PORTS,
target_container); 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) {
key_ports->src = flow_keys->sport; key_ports->src = flow_keys->sport;
key_ports->dst = flow_keys->dport; key_ports->dst = flow_keys->dport;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment