Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 278280
b: refs/heads/master
c: 4d77d2b
h: refs/heads/master
v: v3
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Nov 29, 2011
1 parent c1a5fd7 commit 8d10683
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c3940999b29ca7d6ad9b37b827a058c90fd51992
refs/heads/master: 4d77d2b567ec66a443792d99e96ac760991d80d0
1 change: 1 addition & 0 deletions trunk/include/net/flow_keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define _NET_FLOW_KEYS_H

struct flow_keys {
/* (src,dst) must be grouped, in the same way than in IP header */
__be32 src;
__be32 dst;
union {
Expand Down
13 changes: 11 additions & 2 deletions trunk/net/core/flow_dissector.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
#include <linux/ppp_defs.h>
#include <net/flow_keys.h>

/* copy saddr & daddr, possibly using 64bit load/store
* Equivalent to : flow->src = iph->saddr;
* flow->dst = iph->daddr;
*/
static void iph_to_flow_copy_addrs(struct flow_keys *flow, const struct iphdr *iph)
{
BUILD_BUG_ON(offsetof(typeof(*flow), dst) !=
offsetof(typeof(*flow), src) + sizeof(flow->src));
memcpy(&flow->src, &iph->saddr, sizeof(flow->src) + sizeof(flow->dst));
}

bool skb_flow_dissect(const struct sk_buff *skb, struct flow_keys *flow)
{
Expand All @@ -31,8 +41,7 @@ bool skb_flow_dissect(const struct sk_buff *skb, struct flow_keys *flow)
ip_proto = 0;
else
ip_proto = iph->protocol;
flow->src = iph->saddr;
flow->dst = iph->daddr;
iph_to_flow_copy_addrs(flow, iph);
nhoff += iph->ihl * 4;
break;
}
Expand Down

0 comments on commit 8d10683

Please sign in to comment.