Skip to content

Commit 19469a8

Browse files
Tom Herbertdavem330
authored andcommitted
flow_dissector: Use IPv6 flow label in flow_dissector
This patch implements the receive side to support RFC 6438 which is to use the flow label as an ECMP hash. If an IPv6 flow label is set in a packet we can use this as input for computing an L4-hash. There should be no need to parse any transport headers in this case. Signed-off-by: Tom Herbert <therbert@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 535fb8d commit 19469a8

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

net/core/flow_dissector.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ bool skb_flow_dissect(const struct sk_buff *skb, struct flow_keys *flow)
8080
case htons(ETH_P_IPV6): {
8181
const struct ipv6hdr *iph;
8282
struct ipv6hdr _iph;
83+
__be32 flow_label;
84+
8385
ipv6:
8486
iph = skb_header_pointer(skb, nhoff, sizeof(_iph), &_iph);
8587
if (!iph)
@@ -89,6 +91,21 @@ bool skb_flow_dissect(const struct sk_buff *skb, struct flow_keys *flow)
8991
flow->src = (__force __be32)ipv6_addr_hash(&iph->saddr);
9092
flow->dst = (__force __be32)ipv6_addr_hash(&iph->daddr);
9193
nhoff += sizeof(struct ipv6hdr);
94+
95+
flow_label = ip6_flowlabel(iph);
96+
if (flow_label) {
97+
/* Awesome, IPv6 packet has a flow label so we can
98+
* use that to represent the ports without any
99+
* further dissection.
100+
*/
101+
flow->n_proto = proto;
102+
flow->ip_proto = ip_proto;
103+
flow->ports = flow_label;
104+
flow->thoff = (u16)nhoff;
105+
106+
return true;
107+
}
108+
92109
break;
93110
}
94111
case htons(ETH_P_8021AD):

0 commit comments

Comments
 (0)