#include <linux/if_vlan.h>
#include <net/llc_pdu.h>
#include <linux/kernel.h>
+#include <linux/jhash.h>
#include <linux/jiffies.h>
#include <linux/llc.h>
#include <linux/module.h>
#include "compat.h"
struct kmem_cache *flow_cache;
+static unsigned int hash_seed;
struct arp_eth_header
{
}
spin_lock_bh(&flow->lock);
- getnstimeofday(&flow->used);
+ ktime_get_ts(&flow->used);
flow->packet_count++;
flow->byte_count += skb->len;
flow->tcp_flags |= tcp_flags;
/* Frees 'flow' immediately. */
-void flow_free(struct sw_flow *flow)
+static void flow_free(struct sw_flow *flow)
{
if (unlikely(!flow))
return;
kmem_cache_free(flow_cache, flow);
}
+void flow_free_tbl(struct tbl_node *node)
+{
+ struct sw_flow *flow = flow_cast(node);
+ flow_free(flow);
+}
+
/* RCU callback used by flow_deferred_free. */
static void rcu_free_flow_callback(struct rcu_head *rcu)
{
return retval;
}
+struct sw_flow *flow_cast(const struct tbl_node *node)
+{
+ return container_of(node, struct sw_flow, tbl_node);
+}
+
+u32 flow_hash(const struct odp_flow_key *key)
+{
+ return jhash2((u32*)key, sizeof *key / sizeof(u32), hash_seed);
+}
+
+int flow_cmp(const struct tbl_node *node, void *key2_)
+{
+ const struct odp_flow_key *key1 = &flow_cast(node)->key;
+ const struct odp_flow_key *key2 = key2_;
+
+ return !memcmp(key1, key2, sizeof(struct odp_flow_key));
+}
+
/* Initializes the flow module.
* Returns zero if successful or a negative error code. */
int flow_init(void)
if (flow_cache == NULL)
return -ENOMEM;
+ get_random_bytes(&hash_seed, sizeof hash_seed);
+
return 0;
}