19 #include <sys/ioctl.h> 29 #include <vpp/app/version.h> 46 s =
format (s,
"[%d] sw-if-index %d client-ip %U session-id %d ",
51 s =
format (s,
"encap-if-index %d decap-fib-index %d\n",
54 s =
format (s,
" local-mac %U client-mac %U",
64 u32 dev_instance = va_arg (*args,
u32);
65 return format (s,
"pppoe_session%d", dev_instance);
72 clib_warning (
"you shouldn't be here, leaking buffers...");
98 u32 dev_instance = va_arg (*args,
u32);
99 s =
format (s,
"unimplemented dev %u", dev_instance);
122 eth_hdr->
type = clib_host_to_net_u16 (ETHERNET_TYPE_PPPOE_SESSION);
133 pppoe->
ppp_proto = clib_host_to_net_u16 (PPP_PROTOCOL_ip4);
136 pppoe->
ppp_proto = clib_host_to_net_u16 (PPP_PROTOCOL_ip6);
238 #define foreach_copy_field \ 261 u32 hw_if_index = ~0;
262 u32 sw_if_index = ~0;
274 cached_result.
raw = ~0;
275 memset (&pfx, 0,
sizeof (pfx));
297 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
305 &key, &bucket, &result);
309 &key, &cached_key, &bucket, &result);
314 if (result.
fields.session_index != ~0)
315 return VNET_API_ERROR_TUNNEL_EXIST;
319 return VNET_API_ERROR_INVALID_DECAP_NEXT;
322 memset (t, 0,
sizeof (*t));
327 #define _(x) t->x = a->x; 337 &key, &bucket, &result);
368 (vnm, pppoe_device_class.index, t - pem->
sessions,
369 pppoe_hw_class.index, t - pem->
sessions);
396 if (result.
fields.session_index == ~0)
397 return VNET_API_ERROR_NO_SUCH_ENTRY;
411 result.
fields.session_index = ~0;
414 &key, &bucket, &result);
429 *sw_if_indexp = sw_if_index;
441 ip46_address_t client_ip;
443 u8 client_ip_set = 0;
446 u32 encap_if_index = 0;
447 u32 decap_fib_index = 0;
448 u8 client_mac[6] = { 0 };
449 u8 client_mac_set = 0;
453 u32 session_sw_if_index;
457 memset (&client_ip, 0,
sizeof client_ip);
469 else if (
unformat (line_input,
"session-id %d", &session_id))
471 else if (
unformat (line_input,
"client-ip %U",
477 else if (
unformat (line_input,
"client-ip %U",
483 else if (
unformat (line_input,
"decap-vrf-id %d", &tmp))
490 if (decap_fib_index == ~0)
510 if (client_ip_set == 0)
517 if (ipv4_set && ipv6_set)
523 if (client_mac_set == 0)
529 memset (a, 0,
sizeof (*a));
534 #define _(x) a->x = x; 550 case VNET_API_ERROR_TUNNEL_EXIST:
554 case VNET_API_ERROR_NO_SUCH_ENTRY:
560 (0,
"vnet_pppoe_add_del_session returned %d", rv);
583 .path =
"create pppoe session",
585 "create pppoe session client-ip <client-ip> session-id <nn>" 586 " client-mac <client-mac> [decap-vrf-id <nn>] [del]",
605 vlib_cli_output (vm,
"%U",format_pppoe_session, t);
624 .path =
"show pppoe session",
625 .short_help =
"show pppoe session",
636 BVT (clib_bihash) *
h = &pem->session_table;
637 BVT (clib_bihash_bucket) * b;
646 for (i = 0; i <
h->nbuckets; i++)
652 for (j = 0; j < (1 << b->log2_pages); j++)
656 if (
v->kvp[k].key == ~0ULL &&
v->kvp[k].value == ~0ULL)
663 "%=19s%=12s%=13s%=14s",
664 "Mac-Address",
"session_id",
"sw_if_index",
668 key.
raw =
v->kvp[k].key;
669 result.
raw =
v->kvp[k].value;
673 "%=19U%=12d%=13d%=14d",
675 clib_net_to_host_u16 (key.
fields.session_id),
676 result.
fields.sw_if_index == ~0
677 ? -1 : result.
fields.sw_if_index,
678 result.
fields.session_index == ~0
679 ? -1 : result.
fields.session_index);
687 if (total_entries == 0)
712 .path =
"show pppoe fib",
713 .short_help =
"show pppoe fib",
746 .version = VPP_BUILD_VER,
747 .description =
"PPPoE",
fib_protocol_t fp_proto
protocol type
fib_node_index_t fib_table_entry_path_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, dpo_proto_t next_hop_proto, const ip46_address_t *next_hop, u32 next_hop_sw_if_index, u32 next_hop_fib_index, u32 next_hop_weight, fib_mpls_label_t *next_hop_labels, fib_route_path_flags_t path_flags)
Add one path to an entry (aka route) in the FIB.
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
#define BIHASH_KVP_PER_PAGE
VNET_HW_INTERFACE_CLASS(pppoe_hw_class)
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)
Perform learning on one packet based on the mac table lookup result.
vnet_main_t * vnet_get_main(void)
vnet_interface_main_t interface_main
#define PPPOE_MEMORY_SIZE
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
This packet is to be rewritten and forwarded to the next processing node.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static clib_error_t * pppoe_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
#define VNET_HW_INTERFACE_FLAG_LINK_UP
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
format_function_t format_vnet_sw_if_index_name
static clib_error_t * show_pppoe_fib_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Display the contents of the PPPoE Fib.
clib_error_t * pppoe_init(vlib_main_t *vm)
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
vnet_link_t ia_link
link/ether-type 1 bytes
VNET_DEVICE_CLASS(pppoe_device_class, static)
Adjacency to punt this packet.
static void pppoe_update_adj(vnet_main_t *vnm, u32 sw_if_index, adj_index_t ai)
static_always_inline void pppoe_lookup_1(BVT(clib_bihash)*table, pppoe_entry_key_t *cached_key, pppoe_entry_result_t *cached_result, u8 *mac0, u16 session_id0, pppoe_entry_key_t *key0, u32 *bucket0, pppoe_entry_result_t *result0)
static ip_adjacency_t * adj_get(adj_index_t adj_index)
Get a pointer to an adjacency object from its index.
u8 * format_ethernet_address(u8 *s, va_list *args)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define VLIB_INIT_FUNCTION(x)
dpo_proto_t vnet_link_to_dpo_proto(vnet_link_t linkt)
vlib_combined_counter_main_t * combined_sw_if_counters
A high priority source a plugin can use.
Aggregrate type for a prefix.
#define clib_error_return(e, args...)
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
u16 fp_len
The mask length.
static bool pppoe_decap_next_is_valid(pppoe_main_t *pem, u32 is_ip6, u32 decap_fib_index)
u32 vnet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u32 hw_class_index, u32 hw_instance)
static u8 * format_pppoe_header_with_length(u8 *s, va_list *args)
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
#define ADJ_INDEX_INVALID
Invalid ADJ index - used when no adj is known likewise blazoned capitals INVALID speak volumes where ...
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static void vlib_zero_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
Clear a combined counter Clears the set of per-thread counters.
vlib_node_registration_t ip4_input_node
Global ip4 input node.
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
static uword dummy_interface_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
vlib_node_registration_t ip6_input_node
(constructor) VLIB_REGISTER_NODE (ip6_input_node)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
#define pool_put(P, E)
Free an object E in pool P.
This packet matches an "interface route" and packets need to be passed to ARP to find rewrite string ...
vlib_simple_counter_main_t * sw_if_counters
void interface_tx_dpo_add_or_lock(dpo_proto_t proto, u32 sw_if_index, dpo_id_t *dpo)
The data-path object representing transmitting the packet on a n interface.
void clib_bihash_init(clib_bihash *h, char *name, u32 nbuckets, uword memory_size)
initialize a bounded index extensible hash table
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P (general version).
This packet matches an "incomplete adjacency" and packets need to be passed to ARP to find rewrite st...
Adjacency to drop this packet.
vlib_node_registration_t pppoe_input_node
(constructor) VLIB_REGISTER_NODE (pppoe_input_node)
#define vec_free(V)
Free vector's memory (no header).
Multicast Midchain Adjacency.
static clib_error_t * pppoe_add_del_session_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define PPPOE_NUM_BUCKETS
#define clib_warning(format, args...)
void adj_nbr_midchain_update_rewrite(adj_index_t adj_index, adj_midchain_fixup_t fixup, const void *fixup_data, adj_flags_t flags, u8 *rewrite)
adj_nbr_midchain_update_rewrite
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
#define clib_memcpy(a, b, c)
static void vnet_interface_counter_unlock(vnet_interface_main_t *im)
#define VNET_SW_INTERFACE_FLAG_HIDDEN
u8 * format_pppoe_session(u8 *s, va_list *args)
u32 adj_index_t
An index for adjacencies.
void adj_mcast_midchain_update_rewrite(adj_index_t adj_index, adj_midchain_fixup_t fixup, const void *fixup_data, adj_flags_t flags, u8 *rewrite, u8 offset, u32 mask)
adj_mcast_midchain_update_rewrite
pppoe_session_t * sessions
static_always_inline void pppoe_update_1(BVT(clib_bihash)*table, u8 *mac0, u16 session_id0, pppoe_entry_key_t *key0, u32 *bucket0, pppoe_entry_result_t *result0)
#define VLIB_CLI_COMMAND(x,...)
This packets follow a mid-chain adjacency.
static void vnet_interface_counter_lock(vnet_interface_main_t *im)
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
uword unformat_ethernet_address(unformat_input_t *input, va_list *args)
void adj_nbr_midchain_stack(adj_index_t adj_index, const dpo_id_t *next)
adj_nbr_midchain_stack
enum vnet_link_t_ vnet_link_t
Link Type: A description of the protocol of packets on the link.
static u8 * format_pppoe_name(u8 *s, va_list *args)
vlib_node_registration_t pppoe_cp_dispatch_node
(constructor) VLIB_REGISTER_NODE (pppoe_cp_dispatch_node)
static void vlib_zero_simple_counter(vlib_simple_counter_main_t *cm, u32 index)
Clear a simple counter Clears the set of per-thread u16 counters, and the u64 counter.
dpo_proto_t fib_proto_to_dpo(fib_protocol_t fib_proto)
void fib_table_entry_path_remove(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, dpo_proto_t next_hop_proto, const ip46_address_t *next_hop, u32 next_hop_sw_if_index, u32 next_hop_fib_index, u32 next_hop_weight, fib_route_path_flags_t path_flags)
remove one path to an entry (aka route) in the FIB.
void ethernet_register_input_type(vlib_main_t *vm, ethernet_type_t type, u32 node_index)
u32 * session_index_by_sw_if_index
template key/value backing page structure
int vnet_pppoe_add_del_session(vnet_pppoe_add_del_session_args_t *a, u32 *sw_if_indexp)
This packets needs to go to ICMP error.
This packet is for one of our own IP addresses.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define foreach_copy_field
static u8 * pppoe_build_rewrite(vnet_main_t *vnm, u32 sw_if_index, vnet_link_t link_type, const void *dst_address)
ip_lookup_next_t lookup_next_index
Next hop after ip4-lookup.
u32 decap_fib_index
FIB indices - inner IP packet lookup here.
#define DPO_INVALID
An initialiser for DPOs declared on the stack.
a point 2 point interface
static clib_error_t * show_pppoe_session_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
struct pppoe_entry_key_t::@488::@490 fields
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
static void * clib_bihash_get_value(clib_bihash *h, uword offset)
Get pointer to value page given its clib mheap offset.
u32 * free_pppoe_session_hw_if_indices
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header, unspecified alignment)
#define CLIB_CACHE_LINE_BYTES
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static void pppoe_fixup(vlib_main_t *vm, ip_adjacency_t *adj, vlib_buffer_t *b0, const void *data)
Fixup the adj rewrite post encap.
struct pppoe_entry_result_t::@492::@494 fields
static uword pool_elts(void *v)
Number of active elements in a pool.