Skip to content

Commit

Permalink
lisp: Use IP addresses rather than flow on hash failure.
Browse files Browse the repository at this point in the history
When calculating the source port for the UDP header, LISP primarily
uses skb_get_hash() but needs a backup in case this fails. The
current backup is a hash of the entire flow key but this includes
many fields that probably would not be considered to be part of a
flow in many situations. It assumes that all fields, including those
not used, are zeroed out which will soon not be the case.

This switches to using a hash of the IP addresses instead, which
solves both problems. These should always be present since LISP
encapsulates L3 packets.

Signed-off-by: Jesse Gross <[email protected]>
Acked-by: Thomas Graf <[email protected]>
  • Loading branch information
jessegross committed Jun 13, 2014
1 parent b96986e commit 31125eb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions datapath/vport-lisp.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,15 @@ static u16 get_src_port(struct net *net, struct sk_buff *skb)
if (!hash) {
struct sw_flow_key *pkt_key = OVS_CB(skb)->pkt_key;

hash = jhash2((const u32 *)pkt_key,
sizeof(*pkt_key) / sizeof(u32), 0);
if (skb->protocol == htons(ETH_P_IP))
hash = jhash2((const u32 *)&pkt_key->ipv4.addr,
sizeof(pkt_key->ipv4.addr) / sizeof(u32), 0);
else if (skb->protocol == htons(ETH_P_IPV6))
hash = jhash2((const u32 *)&pkt_key->ipv6.addr,
sizeof(pkt_key->ipv6.addr) / sizeof(u32), 0);
else
pr_warn_once("LISP inner protocol is not IP when "
"calculating hash.\n");
}

inet_get_local_port_range(net, &low, &high);
Expand Down

0 comments on commit 31125eb

Please sign in to comment.