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);
230 #define foreach_copy_field \ 253 u32 hw_if_index = ~0;
254 u32 sw_if_index = ~0;
266 cached_result.
raw = ~0;
267 memset (&pfx, 0,
sizeof (pfx));
286 &key, &bucket, &result);
290 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
299 if (result.
fields.session_index != ~0)
300 return VNET_API_ERROR_TUNNEL_EXIST;
304 return VNET_API_ERROR_INVALID_DECAP_NEXT;
307 memset (t, 0,
sizeof (*t));
312 #define _(x) t->x = a->x; 322 &key, &bucket, &result);
353 (vnm, pppoe_device_class.index, t - pem->
sessions,
354 pppoe_hw_class.index, t - pem->
sessions);
381 if (result.
fields.session_index == ~0)
382 return VNET_API_ERROR_NO_SUCH_ENTRY;
396 result.
fields.session_index = ~0;
399 &key, &bucket, &result);
414 *sw_if_indexp = sw_if_index;
426 ip46_address_t client_ip;
428 u8 client_ip_set = 0;
431 u32 encap_if_index = 0;
432 u32 decap_fib_index = 0;
433 u8 client_mac[6] = { 0 };
434 u8 client_mac_set = 0;
438 u32 session_sw_if_index;
442 memset (&client_ip, 0,
sizeof client_ip);
454 else if (
unformat (line_input,
"session-id %d", &session_id))
456 else if (
unformat (line_input,
"client-ip %U",
462 else if (
unformat (line_input,
"client-ip %U",
468 else if (
unformat (line_input,
"decap-vrf-id %d", &tmp))
475 if (decap_fib_index == ~0)
495 if (client_ip_set == 0)
502 if (ipv4_set && ipv6_set)
508 if (client_mac_set == 0)
514 memset (a, 0,
sizeof (*a));
519 #define _(x) a->x = x; 535 case VNET_API_ERROR_TUNNEL_EXIST:
539 case VNET_API_ERROR_NO_SUCH_ENTRY:
545 (0,
"vnet_pppoe_add_del_session returned %d", rv);
568 .path =
"create pppoe session",
570 "create pppoe session client-ip <client-ip> session-id <nn>" 571 " client-mac <client-mac> [decap-vrf-id <nn>] [del]",
590 vlib_cli_output (vm,
"%U",format_pppoe_session, t);
609 .path =
"show pppoe session",
610 .short_help =
"show pppoe session",
621 BVT (clib_bihash) *
h = &pem->session_table;
622 BVT (clib_bihash_bucket) * b;
627 u64 total_entries = 0;
631 for (i = 0; i <
h->nbuckets; i++)
637 for (j = 0; j < (1 << b->log2_pages); j++)
641 if (
v->kvp[k].key == ~0ULL &&
v->kvp[k].value == ~0ULL)
648 "%=19s%=12s%=13s%=14s",
649 "Mac-Address",
"session_id",
"sw_if_index",
653 key.
raw =
v->kvp[k].key;
654 result.
raw =
v->kvp[k].value;
658 "%=19U%=12d%=13d%=14d",
660 clib_net_to_host_u16 (key.
fields.session_id),
661 result.
fields.sw_if_index == ~0
662 ? -1 : result.
fields.sw_if_index,
663 result.
fields.session_index == ~0
664 ? -1 : result.
fields.session_index);
672 if (total_entries == 0)
697 .path =
"show pppoe fib",
698 .short_help =
"show pppoe fib",
728 .version = VPP_BUILD_VER,
729 .description =
"PPPoE",
static_always_inline void pppoe_update_1(BVT(clib_bihash)*session_table, u8 *mac0, u16 session_id0, pppoe_entry_key_t *key0, u32 *bucket0, pppoe_entry_result_t *result0)
fib_protocol_t fp_proto
protocol type
sll srl srl sll sra u16x4 i
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)
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)
static void pppoe_fixup(vlib_main_t *vm, ip_adjacency_t *adj, vlib_buffer_t *b0)
Fixup the adj rewrite post encap.
This packet is to be rewritten and forwarded to the next processing node.
struct pppoe_entry_result_t::@367::@369 fields
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static_always_inline void pppoe_lookup_1(BVT(clib_bihash)*session_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 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)
void adj_nbr_midchain_update_rewrite(adj_index_t adj_index, adj_midchain_fixup_t fixup, adj_flags_t flags, u8 *rewrite)
adj_nbr_midchain_update_rewrite
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.
vlib_node_registration_t pppoe_tap_dispatch_node
(constructor) VLIB_REGISTER_NODE (pppoe_tap_dispatch_node)
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...)
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.
pppoe_session_t * sessions
#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)
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)
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
void adj_mcast_midchain_update_rewrite(adj_index_t adj_index, adj_midchain_fixup_t fixup, adj_flags_t flags, u8 *rewrite, u8 offset, u32 mask)
adj_mcast_midchain_update_rewrite
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,...)
struct pppoe_entry_key_t::@363::@365 fields
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, mpls_label_t *next_hop_labels, fib_route_path_flags_t path_flags)
Add one path to an entry (aka route) in the FIB.
static uword pool_elts(void *v)
Number of active elements in a pool.