flow_dissector: extract more ICMP information

The ICMP flow dissector currently parses only the Type and Code fields.
Some ICMP packets (echo, timestamp) have a 16 bit Identifier field which
is used to correlate packets.
Add such field in flow_dissector_key_icmp and replace skb_flow_get_be16()
with a more complex function which populate this field.

Signed-off-by: Matteo Croce <mcroce@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Matteo Croce
2019-10-29 14:50:52 +01:00
committed by David S. Miller
parent 3b336d6f4e
commit 5dec597e5c
2 changed files with 61 additions and 32 deletions

View File

@@ -6,6 +6,8 @@
#include <linux/in6.h>
#include <uapi/linux/if_ether.h>
struct sk_buff;
/**
* struct flow_dissector_key_control:
* @thoff: Transport header offset
@@ -156,19 +158,16 @@ struct flow_dissector_key_ports {
/**
* flow_dissector_key_icmp:
* @ports: type and code of ICMP header
* icmp: ICMP type (high) and code (low)
* type: ICMP type
* code: ICMP code
* id: session identifier
*/
struct flow_dissector_key_icmp {
union {
__be16 icmp;
struct {
u8 type;
u8 code;
};
struct {
u8 type;
u8 code;
};
u16 id;
};
/**
@@ -282,6 +281,7 @@ struct flow_keys {
struct flow_dissector_key_vlan cvlan;
struct flow_dissector_key_keyid keyid;
struct flow_dissector_key_ports ports;
struct flow_dissector_key_icmp icmp;
/* 'addrs' must be the last member */
struct flow_dissector_key_addrs addrs;
};
@@ -316,6 +316,9 @@ static inline bool flow_keys_have_l4(const struct flow_keys *keys)
}
u32 flow_hash_from_keys(struct flow_keys *keys);
void skb_flow_get_icmp_tci(const struct sk_buff *skb,
struct flow_dissector_key_icmp *key_icmp,
void *data, int thoff, int hlen);
static inline bool dissector_uses_key(const struct flow_dissector *flow_dissector,
enum flow_dissector_key_id key_id)