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);
239 #define foreach_copy_field \ 262 u32 hw_if_index = ~0;
275 cached_result.
raw = ~0;
298 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
306 &key, &bucket, &result);
310 &key, &cached_key, &bucket, &result);
315 if (result.
fields.session_index != ~0)
316 return VNET_API_ERROR_TUNNEL_EXIST;
320 return VNET_API_ERROR_INVALID_DECAP_NEXT;
328 #define _(x) t->x = a->x; 338 &key, &bucket, &result);
369 (vnm, pppoe_device_class.index, t - pem->
sessions,
370 pppoe_hw_class.index, t - pem->
sessions);
397 if (result.
fields.session_index == ~0)
398 return VNET_API_ERROR_NO_SUCH_ENTRY;
412 result.
fields.session_index = ~0;
415 &key, &bucket, &result);
442 ip46_address_t client_ip;
444 u8 client_ip_set = 0;
447 u32 encap_if_index = 0;
448 u32 decap_fib_index = 0;
449 u8 client_mac[6] = { 0 };
450 u8 client_mac_set = 0;
454 u32 session_sw_if_index;
470 else if (
unformat (line_input,
"session-id %d", &session_id))
472 else if (
unformat (line_input,
"client-ip %U",
478 else if (
unformat (line_input,
"client-ip %U",
484 else if (
unformat (line_input,
"decap-vrf-id %d", &tmp))
491 if (decap_fib_index == ~0)
511 if (client_ip_set == 0)
518 if (ipv4_set && ipv6_set)
524 if (client_mac_set == 0)
535 #define _(x) a->x = x; 551 case VNET_API_ERROR_TUNNEL_EXIST:
555 case VNET_API_ERROR_NO_SUCH_ENTRY:
561 (0,
"vnet_pppoe_add_del_session returned %d", rv);
584 .path =
"create pppoe session",
586 "create pppoe session client-ip <client-ip> session-id <nn>" 587 " client-mac <client-mac> [decap-vrf-id <nn>] [del]",
606 vlib_cli_output (vm,
"%U",format_pppoe_session, t);
625 .path =
"show pppoe session",
626 .short_help =
"show pppoe session",
649 "%=19s%=12s%=13s%=14s",
650 "Mac-Address",
"session_id",
"sw_if_index",
655 result.
raw = kvp->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);
706 .path =
"show pppoe fib",
707 .short_help =
"show pppoe fib",
740 .version = VPP_BUILD_VER,
741 .description =
"PPP over Ethernet (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.
struct pppoe_entry_result_t::@560::@562 fields
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)
VNET_HW_INTERFACE_CLASS(pppoe_hw_class)
vnet_main_t * vnet_get_main(void)
vnet_interface_main_t interface_main
#define PPPOE_MEMORY_SIZE
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
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 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 void pppoe_show_walk_cb(BVT(clib_bihash_kv) *kvp, void *arg)
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)
vnet_link_t ia_link
link/ether-type 1 bytes
VNET_DEVICE_CLASS(pppoe_device_class, static)
#define clib_memcpy(d, s, n)
Adjacency to punt this packet.
static void pppoe_update_adj(vnet_main_t *vnm, u32 sw_if_index, adj_index_t ai)
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 ...
vnet_sw_interface_flags_t flags
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 with alignment A.
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.
void clib_bihash_foreach_key_value_pair(clib_bihash *h, void *callback, void *arg)
Visit active (key,value) pairs in a bi-hash table.
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)
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.
static void vnet_interface_counter_unlock(vnet_interface_main_t *im)
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
#define VLIB_CLI_COMMAND(x,...)
This packets follow a mid-chain adjacency.
static void vnet_interface_counter_lock(vnet_interface_main_t *im)
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
int vnet_pppoe_add_del_session(vnet_pppoe_add_del_session_args_t *a, u32 *sw_if_indexp)
struct pppoe_show_walk_ctx_t_ pppoe_show_walk_ctx_t
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.
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, vnet_hw_interface_flags_t flags)
struct pppoe_entry_key_t::@556::@558 fields
u32 decap_fib_index
FIB indices - inner IP packet lookup here.
VLIB buffer representation.
#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)
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)
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, vnet_sw_interface_flags_t flags)
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
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.
static uword pool_elts(void *v)
Number of active elements in a pool.