* @brief Fixup the adj rewrite post encap. Insert the packet's length
*/
static void
-pppoe_fixup (vlib_main_t * vm, ip_adjacency_t * adj, vlib_buffer_t * b0)
+pppoe_fixup (vlib_main_t * vm,
+ ip_adjacency_t * adj, vlib_buffer_t * b0, const void *data)
{
+ const pppoe_session_t *t;
pppoe_header_t *pppoe0;
- pppoe0 = vlib_buffer_get_current (b0);
+ /* update the rewrite string */
+ pppoe0 = vlib_buffer_get_current (b0) + sizeof (ethernet_header_t);
pppoe0->length = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0)
- sizeof (pppoe_header_t)
+ + sizeof (pppoe0->ppp_proto)
- sizeof (ethernet_header_t));
+ /* Swap to the the packet's output interface to the encap (not the
+ * session) interface */
+ t = data;
+ vnet_buffer (b0)->sw_if_index[VLIB_TX] = t->encap_if_index;
}
static void
ASSERT (ADJ_INDEX_INVALID != ai);
adj = adj_get (ai);
+ session_id = pem->session_index_by_sw_if_index[sw_if_index];
+ t = pool_elt_at_index (pem->sessions, session_id);
switch (adj->lookup_next_index)
{
case IP_LOOKUP_NEXT_ARP:
case IP_LOOKUP_NEXT_GLEAN:
- adj_nbr_midchain_update_rewrite (ai, pppoe_fixup,
+ case IP_LOOKUP_NEXT_BCAST:
+ adj_nbr_midchain_update_rewrite (ai, pppoe_fixup, t,
ADJ_FLAG_NONE,
pppoe_build_rewrite (vnm,
sw_if_index,
* Construct a partial rewrite from the known ethernet mcast dest MAC
* There's no MAC fixup, so the last 2 parameters are 0
*/
- adj_mcast_midchain_update_rewrite (ai, pppoe_fixup,
+ adj_mcast_midchain_update_rewrite (ai, pppoe_fixup, t,
ADJ_FLAG_NONE,
pppoe_build_rewrite (vnm,
sw_if_index,
break;
}
- session_id = pem->session_index_by_sw_if_index[sw_if_index];
- t = pool_elt_at_index (pem->sessions, session_id);
interface_tx_dpo_add_or_lock (vnet_link_to_dpo_proto (adj->ia_link),
t->encap_if_index, &dpo);
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)
{
};
/* *INDENT-ON* */
+typedef struct pppoe_show_walk_ctx_t_
+{
+ vlib_main_t *vm;
+ u8 first_entry;
+ u32 total_entries;
+} pppoe_show_walk_ctx_t;
+
+static void
+pppoe_show_walk_cb (BVT (clib_bihash_kv) * kvp, void *arg)
+{
+ pppoe_show_walk_ctx_t *ctx = arg;
+ pppoe_entry_result_t result;
+ pppoe_entry_key_t key;
+
+ if (ctx->first_entry)
+ {
+ ctx->first_entry = 0;
+ vlib_cli_output (ctx->vm,
+ "%=19s%=12s%=13s%=14s",
+ "Mac-Address", "session_id", "sw_if_index",
+ "session_index");
+ }
+
+ key.raw = kvp->key;
+ result.raw = kvp->value;
+
+ vlib_cli_output (ctx->vm,
+ "%=19U%=12d%=13d%=14d",
+ format_ethernet_address, key.fields.mac,
+ clib_net_to_host_u16 (key.fields.session_id),
+ result.fields.sw_if_index == ~0
+ ? -1 : result.fields.sw_if_index,
+ result.fields.session_index == ~0
+ ? -1 : result.fields.session_index);
+ ctx->total_entries++;
+}
+
/** Display the contents of the PPPoE Fib. */
static clib_error_t *
show_pppoe_fib_command_fn (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
pppoe_main_t *pem = &pppoe_main;
- BVT (clib_bihash) * h = &pem->session_table;
- BVT (clib_bihash_bucket) * b;
- BVT (clib_bihash_value) * v;
- pppoe_entry_key_t key;
- pppoe_entry_result_t result;
- u32 first_entry = 1;
- u64 total_entries = 0;
- int i, j, k;
- u8 *s = 0;
+ pppoe_show_walk_ctx_t ctx = {
+ .first_entry = 1,
+ .vm = vm,
+ };
- for (i = 0; i < h->nbuckets; i++)
- {
- b = &h->buckets[i];
- if (b->offset == 0)
- continue;
- v = BV (clib_bihash_get_value) (h, b->offset);
- for (j = 0; j < (1 << b->log2_pages); j++)
- {
- for (k = 0; k < BIHASH_KVP_PER_PAGE; k++)
- {
- if (v->kvp[k].key == ~0ULL && v->kvp[k].value == ~0ULL)
- continue;
-
- if (first_entry)
- {
- first_entry = 0;
- vlib_cli_output (vm,
- "%=19s%=12s%=13s%=14s",
- "Mac-Address", "session_id", "sw_if_index",
- "session_index");
- }
-
- key.raw = v->kvp[k].key;
- result.raw = v->kvp[k].value;
-
-
- vlib_cli_output (vm,
- "%=19U%=12d%=13d%=14d",
- format_ethernet_address, key.fields.mac,
- clib_net_to_host_u16 (key.fields.session_id),
- result.fields.sw_if_index == ~0
- ? -1 : result.fields.sw_if_index,
- result.fields.session_index == ~0
- ? -1 : result.fields.session_index);
- vec_reset_length (s);
- total_entries++;
- }
- v++;
- }
- }
+ BV (clib_bihash_foreach_key_value_pair)
+ (&pem->session_table, pppoe_show_walk_cb, &ctx);
- if (total_entries == 0)
+ if (ctx.total_entries == 0)
vlib_cli_output (vm, "no pppoe fib entries");
else
- vlib_cli_output (vm, "%lld pppoe fib entries", total_entries);
+ vlib_cli_output (vm, "%lld pppoe fib entries", ctx.total_entries);
- vec_free (s);
return 0;
}
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);
pppoe_input_node.index);
ethernet_register_input_type (vm, ETHERNET_TYPE_PPPOE_DISCOVERY,
- pppoe_tap_dispatch_node.index);
+ pppoe_cp_dispatch_node.index);
return 0;
}