19 #include <sys/ioctl.h> 29 #include <vpp/app/version.h> 48 s =
format (s,
"[%d] sw-if-index %d client-ip %U session-id %d ",
53 s =
format (s,
"encap-if-index %d decap-fib-index %d\n",
56 s =
format (s,
" local-mac %U client-mac %U",
66 u32 dev_instance = va_arg (*args,
u32);
67 return format (s,
"pppoe_session%d", dev_instance);
91 u32 dev_instance = va_arg (*args,
u32);
92 s =
format (s,
"unimplemented dev %u", dev_instance);
125 eth_hdr->
type = clib_host_to_net_u16 (ETHERNET_TYPE_PPPOE_SESSION);
132 eth_hdr->
type = clib_host_to_net_u16 (ETHERNET_TYPE_VLAN);
135 vlan->
type = clib_host_to_net_u16 (ETHERNET_TYPE_PPPOE_SESSION);
156 pppoe->
ppp_proto = clib_host_to_net_u16 (PPP_PROTOCOL_ip4);
159 pppoe->
ppp_proto = clib_host_to_net_u16 (PPP_PROTOCOL_ip6);
270 #define foreach_copy_field \ 293 u32 hw_if_index = ~0;
306 cached_result.
raw = ~0;
329 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
337 &key, &bucket, &result);
341 &key, &cached_key, &bucket, &result);
346 if (result.
fields.session_index != ~0)
347 return VNET_API_ERROR_TUNNEL_EXIST;
351 return VNET_API_ERROR_INVALID_DECAP_NEXT;
359 #define _(x) t->x = a->x; 369 &key, &bucket, &result);
400 (vnm, pppoe_device_class.index, t - pem->
sessions,
401 pppoe_hw_class.index, t - pem->
sessions);
428 if (result.
fields.session_index == ~0)
429 return VNET_API_ERROR_NO_SUCH_ENTRY;
443 result.
fields.session_index = ~0;
446 &key, &bucket, &result);
473 ip46_address_t client_ip;
475 u8 client_ip_set = 0;
478 u32 encap_if_index = 0;
479 u32 decap_fib_index = 0;
480 u8 client_mac[6] = { 0 };
481 u8 client_mac_set = 0;
485 u32 session_sw_if_index;
501 else if (
unformat (line_input,
"session-id %d", &session_id))
503 else if (
unformat (line_input,
"client-ip %U",
509 else if (
unformat (line_input,
"client-ip %U",
515 else if (
unformat (line_input,
"decap-vrf-id %d", &tmp))
522 if (decap_fib_index == ~0)
542 if (client_ip_set == 0)
549 if (ipv4_set && ipv6_set)
555 if (client_mac_set == 0)
566 #define _(x) a->x = x; 582 case VNET_API_ERROR_TUNNEL_EXIST:
586 case VNET_API_ERROR_NO_SUCH_ENTRY:
592 (0,
"vnet_pppoe_add_del_session returned %d", rv);
615 .path =
"create pppoe session",
617 "create pppoe session client-ip <client-ip> session-id <nn>" 618 " client-mac <client-mac> [decap-vrf-id <nn>] [del]",
656 .path =
"show pppoe session",
657 .short_help =
"show pppoe session",
680 "%=19s%=12s%=13s%=14s",
681 "Mac-Address",
"session_id",
"sw_if_index",
686 result.
raw = kvp->value;
689 "%=19U%=12d%=13d%=14d",
691 clib_net_to_host_u16 (key.
fields.session_id),
692 result.
fields.sw_if_index == ~0
693 ? -1 : result.
fields.sw_if_index,
694 result.
fields.session_index == ~0
695 ? -1 : result.
fields.session_index);
698 return (BIHASH_WALK_CONTINUE);
739 .path =
"show pppoe fib",
740 .short_help =
"show pppoe fib",
777 .version = VPP_BUILD_VER,
778 .description =
"PPP over Ethernet (PPPoE)",
fib_protocol_t fp_proto
protocol type
static void pppoe_fixup(vlib_main_t *vm, const ip_adjacency_t *adj, vlib_buffer_t *b0, const void *data)
Fixup the adj rewrite post encap.
enum fib_source_t_ fib_source_t
The different sources that can create a route.
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.
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)
vl_api_wireguard_peer_flags_t flags
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, vnet_sw_interface_flags_t flags)
VNET_HW_INTERFACE_CLASS(pppoe_hw_class)
vnet_main_t * vnet_get_main(void)
#define pool_foreach(VAR, POOL)
Iterate through pool.
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)
u32 vnet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u32 hw_class_index, u32 hw_instance)
static fib_source_t pppoe_fib_src
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
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_result_t::@705::@707 fields
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)
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 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
description fragment has unexpected format
Aggregate 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)
static u8 * format_pppoe_header_with_length(u8 *s, va_list *args)
fib_source_t fib_source_allocate(const char *name, fib_source_priority_t prio, fib_source_behaviour_t bh)
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.
void clib_bihash_foreach_key_value_pair(clib_bihash *h, clib_bihash_foreach_key_value_pair_cb *callback, void *arg)
Visit active (key,value) pairs in a bi-hash table.
#define FIB_SOURCE_PRIORITY_HI
Some priority values that plugins might use when they are not to concerned where in the list they'll ...
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
vlib_node_registration_t ip6_input_node
(constructor) VLIB_REGISTER_NODE (ip6_input_node)
struct vnet_sub_interface_t::@376::@377::@379 flags
static int pppoe_show_walk_cb(BVT(clib_bihash_kv) *kvp, void *arg)
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.
add paths with [mpls] path extensions
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
struct vnet_sub_interface_t::@376 eth
format_function_t format_ip46_address
#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.
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
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)
struct pppoe_entry_key_t::@701::@703 fields
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
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
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.
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)
vnet_sw_interface_type_t type
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)
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
vl_api_interface_index_t sw_if_index
static uword pool_elts(void *v)
Number of active elements in a pool.