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)
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)
{
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);
/*
* 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* */
/*
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 */
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,
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 */
}
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,
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 */
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,
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;
}
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);