Skip to content

Commit

Permalink
net: make skb an optional parameter for__skb_flow_dissect()
Browse files Browse the repository at this point in the history
Fixes: commit 690e36e (net: Allow raw buffers to be passed into the flow dissector)
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
WANG Cong authored and David S. Miller committed Aug 26, 2014
1 parent 6451b3f commit 453a940
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions include/net/flow_keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ struct flow_keys {
};

bool __skb_flow_dissect(const struct sk_buff *skb, struct flow_keys *flow,
void *data, int hlen);
void *data, __be16 proto, int nhoff, int hlen);
static inline bool skb_flow_dissect(const struct sk_buff *skb, struct flow_keys *flow)
{
return __skb_flow_dissect(skb, flow, NULL, 0);
return __skb_flow_dissect(skb, flow, NULL, 0, 0, 0);
}
__be32 __skb_flow_get_ports(const struct sk_buff *skb, int thoff, u8 ip_proto,
void *data, int hlen_proto);
Expand Down
18 changes: 15 additions & 3 deletions net/core/flow_dissector.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,26 @@ __be32 __skb_flow_get_ports(const struct sk_buff *skb, int thoff, u8 ip_proto,
}
EXPORT_SYMBOL(__skb_flow_get_ports);

bool __skb_flow_dissect(const struct sk_buff *skb, struct flow_keys *flow, void *data, int hlen)
/**
* __skb_flow_dissect - extract the flow_keys struct and return it
* @skb: sk_buff to extract the flow from, can be NULL if the rest are specified
* @data: raw buffer pointer to the packet, if NULL use skb->data
* @proto: protocol for which to get the flow, if @data is NULL use skb->protocol
* @nhoff: network header offset, if @data is NULL use skb_network_offset(skb)
* @hlen: packet header length, if @data is NULL use skb_headlen(skb)
*
* The function will try to retrieve the struct flow_keys from either the skbuff
* or a raw buffer specified by the rest parameters
*/
bool __skb_flow_dissect(const struct sk_buff *skb, struct flow_keys *flow,
void *data, __be16 proto, int nhoff, int hlen)
{
int nhoff = skb_network_offset(skb);
u8 ip_proto;
__be16 proto = skb->protocol;

if (!data) {
data = skb->data;
proto = skb->protocol;
nhoff = skb_network_offset(skb);
hlen = skb_headlen(skb);
}

Expand Down

0 comments on commit 453a940

Please sign in to comment.