Skip to content

Commit 67a900c

Browse files
jpirkodavem330
authored andcommitted
flow_dissector: introduce support for Ethernet addresses
Signed-off-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b924933 commit 67a900c

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

include/net/flow_dissector.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <linux/types.h>
55
#include <linux/skbuff.h>
66
#include <linux/in6.h>
7+
#include <uapi/linux/if_ether.h>
78

89
/**
910
* struct flow_dissector_key_basic:
@@ -54,12 +55,24 @@ struct flow_dissector_key_ipv6_addrs {
5455
struct in6_addr dst;
5556
};
5657

58+
/**
59+
* struct flow_dissector_key_eth_addrs:
60+
* @src: source Ethernet address
61+
* @dst: destination Ethernet address
62+
*/
63+
struct flow_dissector_key_eth_addrs {
64+
/* (dst,src) must be grouped, in the same way than in ETH header */
65+
unsigned char dst[ETH_ALEN];
66+
unsigned char src[ETH_ALEN];
67+
};
68+
5769
enum flow_dissector_key_id {
5870
FLOW_DISSECTOR_KEY_BASIC, /* struct flow_dissector_key_basic */
5971
FLOW_DISSECTOR_KEY_IPV4_ADDRS, /* struct flow_dissector_key_addrs */
6072
FLOW_DISSECTOR_KEY_IPV6_HASH_ADDRS, /* struct flow_dissector_key_addrs */
6173
FLOW_DISSECTOR_KEY_PORTS, /* struct flow_dissector_key_ports */
6274
FLOW_DISSECTOR_KEY_IPV6_ADDRS, /* struct flow_dissector_key_ipv6_addrs */
75+
FLOW_DISSECTOR_KEY_ETH_ADDRS, /* struct flow_dissector_key_eth_addrs */
6376

6477
FLOW_DISSECTOR_KEY_MAX,
6578
};

net/core/flow_dissector.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/if_pppox.h>
1515
#include <linux/ppp_defs.h>
1616
#include <linux/stddef.h>
17+
#include <linux/if_ether.h>
1718
#include <net/flow_dissector.h>
1819
#include <scsi/fc/fc_fcoe.h>
1920

@@ -138,6 +139,17 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
138139
FLOW_DISSECTOR_KEY_BASIC,
139140
target_container);
140141

142+
if (skb_flow_dissector_uses_key(flow_dissector,
143+
FLOW_DISSECTOR_KEY_ETH_ADDRS)) {
144+
struct ethhdr *eth = eth_hdr(skb);
145+
struct flow_dissector_key_eth_addrs *key_eth_addrs;
146+
147+
key_eth_addrs = skb_flow_dissector_target(flow_dissector,
148+
FLOW_DISSECTOR_KEY_ETH_ADDRS,
149+
target_container);
150+
memcpy(key_eth_addrs, &eth->h_dest, sizeof(*key_eth_addrs));
151+
}
152+
141153
again:
142154
switch (proto) {
143155
case htons(ETH_P_IP): {

0 commit comments

Comments
 (0)