aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHongjun Ni <hongjun.ni@intel.com>2017-09-30 05:04:33 +0800
committerNeale Ranns <nranns@cisco.com>2017-10-06 08:22:50 +0000
commit4e5ceefb5522cfde1e916d84b56c318ec1ea614e (patch)
treebe38ffb9fd08d75525ef36d4094bfae3c3d3b954
parentdb93cd971320301eb21403caabada7a3ec6a4cce (diff)
Separate CP and DP fib table for PPPoE
CP table: link_table DP table: session_table Change-Id: I2adbfd8f6a63d51d00d6dd291f32aebf20d13e4d Signed-off-by: Hongjun Ni <hongjun.ni@intel.com>
-rw-r--r--src/plugins/pppoe/pppoe.c18
-rw-r--r--src/plugins/pppoe/pppoe.h55
-rw-r--r--src/plugins/pppoe/pppoe_tap_node.c49
3 files changed, 66 insertions, 56 deletions
diff --git a/src/plugins/pppoe/pppoe.c b/src/plugins/pppoe/pppoe.c
index e09ac7d993e..fe0775ff9df 100644
--- a/src/plugins/pppoe/pppoe.c
+++ b/src/plugins/pppoe/pppoe.c
@@ -280,10 +280,9 @@ int vnet_pppoe_add_del_session
pfx.fp_proto = FIB_PROTOCOL_IP6;
}
- /* Get encap_if_index and local mac address */
- pppoe_lookup_1 (&pem->session_table, &cached_key, &cached_result,
- a->client_mac, clib_host_to_net_u16 (a->session_id),
- &key, &bucket, &result);
+ /* Get encap_if_index and local mac address from link_table */
+ pppoe_lookup_1 (&pem->link_table, &cached_key, &cached_result,
+ a->client_mac, 0, &key, &bucket, &result);
a->encap_if_index = result.fields.sw_if_index;
if (a->encap_if_index == ~0)
@@ -292,6 +291,14 @@ int vnet_pppoe_add_del_session
si = vnet_get_sw_interface (vnm, a->encap_if_index);
hi = vnet_get_hw_interface (vnm, si->hw_if_index);
+ /* lookup session_table */
+ pppoe_lookup_1 (&pem->session_table, &cached_key, &cached_result,
+ a->client_mac, clib_host_to_net_u16 (a->session_id),
+ &key, &bucket, &result);
+
+ /* learn client session */
+ pppoe_learn_process (&pem->session_table, a->encap_if_index,
+ &key, &cached_key, &bucket, &result);
if (a->is_add)
{
@@ -709,6 +716,9 @@ pppoe_init (vlib_main_t * vm)
pem->vlib_main = vm;
/* Create the hash table */
+ BV (clib_bihash_init) (&pem->link_table, "pppoe link table",
+ PPPOE_NUM_BUCKETS, PPPOE_MEMORY_SIZE);
+
BV (clib_bihash_init) (&pem->session_table, "pppoe session table",
PPPOE_NUM_BUCKETS, PPPOE_MEMORY_SIZE);
diff --git a/src/plugins/pppoe/pppoe.h b/src/plugins/pppoe/pppoe.h
index b06c068f405..b79e4eaae51 100644
--- a/src/plugins/pppoe/pppoe.h
+++ b/src/plugins/pppoe/pppoe.h
@@ -99,8 +99,8 @@ typedef enum
/*
* The size of pppoe session table
*/
-#define PPPOE_NUM_BUCKETS (128 * 1024)
-#define PPPOE_MEMORY_SIZE (16<<20)
+#define PPPOE_NUM_BUCKETS (64 * 1024)
+#define PPPOE_MEMORY_SIZE (8<<20)
/* *INDENT-OFF* */
/*
@@ -147,10 +147,13 @@ typedef struct
typedef struct
{
- /* For DP: vector of encap session instances, */
+ /* Vector of encap session instances, */
pppoe_session_t *sessions;
/* For CP: vector of CP path */
+ BVT (clib_bihash) link_table;
+
+ /* For DP: vector of DP path */
BVT (clib_bihash) session_table;
/* Free vlib hw_if_indices */
@@ -226,8 +229,46 @@ pppoe_make_key (u8 * mac_address, u16 session_id)
return temp;
}
+/**
+ * Perform learning on one packet based on the mac table lookup result.
+ * */
+static_always_inline void
+pppoe_learn_process (BVT (clib_bihash) * table,
+ u32 sw_if_index0,
+ pppoe_entry_key_t * key0,
+ pppoe_entry_key_t * cached_key,
+ u32 * bucket0, pppoe_entry_result_t * result0)
+{
+ /* Check mac table lookup result */
+ if (PREDICT_TRUE (result0->fields.sw_if_index == sw_if_index0))
+ {
+ /*
+ * The entry was in the table, and the sw_if_index matched, the normal case
+ */
+ return;
+ }
+ else if (result0->fields.sw_if_index == ~0)
+ {
+ /* The entry was not in table, so add it */
+ result0->fields.sw_if_index = sw_if_index0;
+ result0->fields.session_index = ~0;
+ cached_key->raw = ~0; /* invalidate the cache */
+ }
+ else
+ {
+ /* The entry was in the table, but with the wrong sw_if_index mapping (mac move) */
+ result0->fields.sw_if_index = sw_if_index0;
+ }
+
+ /* Update the entry */
+ BVT (clib_bihash_kv) kv;
+ kv.key = key0->raw;
+ kv.value = result0->raw;
+ BV (clib_bihash_add_del) (table, &kv, 1 /* is_add */ );
+}
+
static_always_inline void
-pppoe_lookup_1 (BVT (clib_bihash) * session_table,
+pppoe_lookup_1 (BVT (clib_bihash) * table,
pppoe_entry_key_t * cached_key,
pppoe_entry_result_t * cached_result,
u8 * mac0,
@@ -251,7 +292,7 @@ pppoe_lookup_1 (BVT (clib_bihash) * session_table,
kv.key = key0->raw;
kv.value = ~0ULL;
- BV (clib_bihash_search_inline) (session_table, &kv);
+ BV (clib_bihash_search_inline) (table, &kv);
result0->raw = kv.value;
/* Update one-entry cache */
@@ -261,7 +302,7 @@ pppoe_lookup_1 (BVT (clib_bihash) * session_table,
}
static_always_inline void
-pppoe_update_1 (BVT (clib_bihash) * session_table,
+pppoe_update_1 (BVT (clib_bihash) * table,
u8 * mac0,
u16 session_id0,
pppoe_entry_key_t * key0,
@@ -275,7 +316,7 @@ pppoe_update_1 (BVT (clib_bihash) * session_table,
BVT (clib_bihash_kv) kv;
kv.key = key0->raw;
kv.value = result0->raw;
- BV (clib_bihash_add_del) (session_table, &kv, 1 /* is_add */ );
+ BV (clib_bihash_add_del) (table, &kv, 1 /* is_add */ );
}
#endif /* _PPPOE_H */
diff --git a/src/plugins/pppoe/pppoe_tap_node.c b/src/plugins/pppoe/pppoe_tap_node.c
index f1e0a50103f..92a6a2af73f 100644
--- a/src/plugins/pppoe/pppoe_tap_node.c
+++ b/src/plugins/pppoe/pppoe_tap_node.c
@@ -67,47 +67,6 @@ static u8 * format_pppoe_tap_trace (u8 * s, va_list * args)
return s;
}
-/**
- * Perform learning on one packet based on the mac table lookup result.
- * */
-static_always_inline void
-pppoe_learn_process (vlib_node_runtime_t * node,
- pppoe_main_t * pem,
- vlib_buffer_t * b0,
- u32 sw_if_index0,
- pppoe_entry_key_t * key0,
- pppoe_entry_key_t * cached_key,
- u32 * bucket0,
- pppoe_entry_result_t * result0)
-{
- /* Check mac table lookup result */
- if (PREDICT_TRUE (result0->fields.sw_if_index == sw_if_index0))
- {
- /*
- * The entry was in the table, and the sw_if_index matched, the normal case
- */
- return;
- }
- else if (result0->fields.sw_if_index == ~0)
- {
- /* The entry was not in table, so add it */
- result0->fields.sw_if_index = sw_if_index0;
- result0->fields.session_index = ~0;
- cached_key->raw = ~0; /* invalidate the cache */
- }
- else
- {
- /* The entry was in the table, but with the wrong sw_if_index mapping (mac move) */
- result0->fields.sw_if_index = sw_if_index0;
- }
-
- /* Update the entry */
- BVT (clib_bihash_kv) kv;
- kv.key = key0->raw;
- kv.value = result0->raw;
- BV (clib_bihash_add_del) (&pem->session_table, &kv, 1 /* is_add */ );
-}
-
static uword
pppoe_tap_dispatch (vlib_main_t * vm,
vlib_node_runtime_t * node,
@@ -181,7 +140,7 @@ pppoe_tap_dispatch (vlib_main_t * vm,
if(rx_sw_if_index0 == pem->tap_if_index)
{
- pppoe_lookup_1 (&pem->session_table, &cached_key, &cached_result,
+ pppoe_lookup_1 (&pem->link_table, &cached_key, &cached_result,
h0->dst_address, 0,
&key0, &bucket0, &result0);
tx_sw_if_index0 = result0.fields.sw_if_index;
@@ -203,13 +162,13 @@ pppoe_tap_dispatch (vlib_main_t * vm,
}
else
{
- pppoe_lookup_1 (&pem->session_table, &cached_key, &cached_result,
- h0->src_address, pppoe0->session_id,
+ pppoe_lookup_1 (&pem->link_table, &cached_key, &cached_result,
+ h0->src_address, 0,
&key0, &bucket0, &result0);
tx_sw_if_index0 = result0.fields.sw_if_index;
/* learn client session */
- pppoe_learn_process (node, pem, b0, rx_sw_if_index0,
+ pppoe_learn_process (&pem->link_table, rx_sw_if_index0,
&key0, &cached_key,
&bucket0, &result0);