25 #include <vpp/app/version.h> 63 (eth->
src_address, vrrp_src_mac_prefix, sizeof (vrrp_src_mac_prefix));
77 #define VRRP4_MCAST_ADDR_AS_U8 { 224, 0, 0, 18 } 78 #define VRRP6_MCAST_ADDR_AS_U8 \ 79 { 0xff, 0x2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x12 } 100 const ip46_address_t *
dst)
112 ip4->
length = clib_host_to_net_u16 (
sizeof (*ip4) +
119 return sizeof (*ip4);
137 return sizeof (*ip6);
148 int word_size =
sizeof (
uword);
163 for (i = 0; i < (2 * addr_len); i += word_size)
165 if (word_size ==
sizeof (
u64))
174 clib_host_to_net_u32 (len + (proto << 16)));
189 ip46_address_t *vr_addr;
202 len =
sizeof (*vrrp) + n_addrs *
sizeof (ip6_address_t);;
213 vrrp->vrrp_version_and_type = 0x31;
220 hdr_addr = (
void *) (vrrp + 1);
276 int i, n_buffers = 1;
277 u32 node_index, *to_next, *bi = 0;
290 clib_warning (
"Unicast VR configuration corrupted for %U",
307 for (i = 0; i < n_buffers; i++)
317 b->
flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
353 icmp6_neighbor_solicitation_or_advertisement_header_t *na;
354 icmp6_neighbor_discovery_ethernet_link_layer_address_option_t *ll_opt;
355 int payload_length, bogus_length;
356 int rewrite_bytes = 0;
367 rewrite_bytes +=
vec_len (rewrite);
384 IP6_MULTICAST_SCOPE_link_local,
385 IP6_MULTICAST_GROUP_ID_all_hosts);
391 na = (icmp6_neighbor_solicitation_or_advertisement_header_t *) (ip6 + 1);
393 (icmp6_neighbor_discovery_ethernet_link_layer_address_option_t *) (na +
396 payload_length =
sizeof (*na) +
sizeof (*ll_opt);
400 na->icmp.type = ICMP6_neighbor_advertisement;
401 na->target_address = *addr6;
402 na->advertisement_flags = clib_host_to_net_u32
406 ll_opt->header.type =
407 ICMP6_NEIGHBOR_DISCOVERY_OPTION_target_link_layer_address;
408 ll_opt->header.n_data_u64s = 1;
418 .
bytes = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff,},
434 broadcast_mac.
bytes);
435 rewrite_bytes =
vec_len (rewrite);
447 arp->
l2_type = clib_host_to_net_u16 (ETHERNET_ARP_HARDWARE_TYPE_ethernet);
448 arp->
l3_type = clib_host_to_net_u16 (ETHERNET_TYPE_IP4);
451 arp->
opcode = clib_host_to_net_u16 (ETHERNET_ARP_OPCODE_request);
475 clib_warning (
"Unable to send gratuitous ARP for VR %U - no addresses",
495 for (i = 0; i < n_buffers; i++)
498 ip46_address_t *
addr;
504 b->
flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
524 #define IGMP4_MCAST_ADDR_AS_U8 { 224, 0, 0, 22 } 529 .protocol = IP_PROTOCOL_IGMP,
549 ip4_options = (
u8 *) (ip4 + 1);
550 ip4_options[0] = 0x94;
551 ip4_options[1] = 0x04;
552 ip4_options[2] = 0x0;
553 ip4_options[3] = 0x0;
560 report->
header.
type = IGMP_TYPE_membership_report_v3;
564 report->
n_groups = clib_host_to_net_u16 (1);
570 group->
type = IGMP_MEMBERSHIP_GROUP_change_to_exclude;
591 ip6_hop_by_hop_ext_t ext_hdr;
592 ip6_router_alert_option_t alert;
593 ip6_padN_option_t
pad;
594 icmp46_header_t
icmp;
596 u16 num_addr_records;
597 icmp6_multicast_address_record_t records[0];
598 }) icmp6_multicast_listener_report_header_t;
605 icmp6_multicast_listener_report_header_t *rh;
606 icmp6_multicast_address_record_t *rr;
607 ip46_address_t *vr_addr;
608 int bogus_length, n_addrs;
612 payload_length =
sizeof (*rh) + (n_addrs *
sizeof (*rr));
614 b->
error = ICMP6_ERROR_NONE;
617 rh = (icmp6_multicast_listener_report_header_t *) (ip6 + 1);
618 rr = (icmp6_multicast_address_record_t *) (rh + 1);
623 clib_host_to_net_u32 (0x60000000);
625 ip6->
protocol = IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS;
627 IP6_MULTICAST_SCOPE_link_local,
628 IP6_MULTICAST_GROUP_ID_mldv2_routers);
635 rh->ext_hdr.next_hdr = IP_PROTOCOL_ICMP6;
636 rh->ext_hdr.n_data_u64s = 0;
646 rh->icmp.type = ICMP6_multicast_listener_report_v2;
647 rh->icmp.checksum = 0;
650 rh->num_addr_records = clib_host_to_net_u16 (n_addrs);
656 rr->aux_data_len_u32s = 0;
659 (&rr->mcast_addr, &vrrp6_mcast_addr.ip6, sizeof (ip6_address_t));
668 rr->aux_data_len_u32s = 0;
671 id = clib_net_to_host_u32 (vr_addr->ip6.as_u32[3]) & 0x00ffffff;
688 u32 bi = 0, *to_next;
708 b->
flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
718 vrrp_icmp6_mlr_pkt_build (vr, b);
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
static uword vnet_sw_interface_is_up(vnet_main_t *vnm, u32 sw_if_index)
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
igmp_membership_group_v3_type_t type
static u8 vrrp_vr_is_unicast(vrrp_vr_t *vr)
u8 pad[3]
log2 (size of the packing page block)
static void vlib_buffer_reset(vlib_buffer_t *b)
Reset current header & length to state they were in when packet was received.
vnet_main_t * vnet_get_main(void)
adj_index_t mcast_adj_index[2]
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
static const u8 vrrp_src_mac_prefix[4]
#define ICMP6_NEIGHBOR_ADVERTISEMENT_FLAG_ROUTER
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static void vlib_buffer_chain_increase_length(vlib_buffer_t *first, vlib_buffer_t *last, i32 len)
u16 current_length
Nbytes between current data and the end of this buffer.
static ip_csum_t ip_csum_with_carry(ip_csum_t sum, ip_csum_t x)
static int vrrp_adv_payload_build(vrrp_vr_t *vr, vlib_buffer_t *b, int shutdown)
vlib_node_registration_t ip4_lookup_node
(constructor) VLIB_REGISTER_NODE (ip4_lookup_node)
#define clib_memcpy(d, s, n)
vlib_node_registration_t ip4_rewrite_mcast_node
(constructor) VLIB_REGISTER_NODE (ip4_rewrite_mcast_node)
vlib_node_registration_t ip6_rewrite_mcast_node
(constructor) VLIB_REGISTER_NODE (ip6_rewrite_mcast_node)
#define static_always_inline
static int vrrp_adv_l3_build(vrrp_vr_t *vr, vlib_buffer_t *b, const ip46_address_t *dst)
#define VRRP4_MCAST_ADDR_AS_U8
#define ICMP6_NEIGHBOR_ADVERTISEMENT_FLAG_OVERRIDE
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
int vrrp_vr_multicast_group_join(vrrp_vr_t *vr)
static const ip46_address_t vrrp4_mcast_addr
vlib_error_t error
Error code for buffers to be enqueued to error handler.
const mac_address_t broadcast_mac
#define VRRP6_MCAST_ADDR_AS_U8
u8 * format_vrrp_vr_key(u8 *s, va_list *args)
static __clib_warn_unused_result u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
#define IP6_MLDP_ALERT_TYPE
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
vl_api_mac_address_t src_addr
vrrp_vr_runtime_t runtime
typedef CLIB_PACKED(struct { ip6_hop_by_hop_ext_t ext_hdr;ip6_router_alert_option_t alert;ip6_padN_option_t pad;icmp46_header_t icmp;u16 rsvd;u16 num_addr_records;icmp6_multicast_address_record_t records[0];})
static u8 vrrp_vr_is_ipv6(vrrp_vr_t *vr)
sll srl srl sll sra u16x4 i
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
static const u8 vrrp6_dst_mac[6]
static int vrrp_adv_l2_build_multicast(vrrp_vr_t *vr, vlib_buffer_t *b)
static void vrrp_igmp_pkt_build(vrrp_vr_t *vr, vlib_buffer_t *b)
static u8 vrrp_vr_priority(vrrp_vr_t *vr)
static void vrrp4_garp_pkt_build(vrrp_vr_t *vr, vlib_buffer_t *b, ip4_address_t *ip4)
u16 ip6_tcp_udp_icmp_compute_checksum(vlib_main_t *vm, vlib_buffer_t *p0, ip6_header_t *ip0, int *bogus_lengthp)
vlib_node_registration_t ip6_lookup_node
(constructor) VLIB_REGISTER_NODE (ip6_lookup_node)
int vrrp_adv_send(vrrp_vr_t *vr, int shutdown)
enum vnet_link_t_ vnet_link_t
Link Type: A description of the protocol of packets on the link.
static u16 vrrp_adv_payload_len(vrrp_vr_t *vr)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
#define clib_mem_unaligned(pointer, type)
ip4_address_t group_address
static vlib_main_t * vlib_get_main(void)
int vrrp_garp_or_na_send(vrrp_vr_t *vr)
#define vec_elt(v, i)
Get vector value at index i.
#define IGMP4_MCAST_ADDR_AS_U8
static vrrp_intf_t * vrrp_intf_get(u32 sw_if_index)
static_always_inline u32 vrrp_adv_next_node(vrrp_vr_t *vr)
static void ip6_set_solicited_node_multicast_address(ip6_address_t *a, u32 id)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
const ip6_address_t * ip6_get_link_local_address(u32 sw_if_index)
bool fib_sas4_get(u32 sw_if_index, const ip4_address_t *dst, ip4_address_t *src)
Get an IPv4 Source address to use in a packet being sent out an interface.
static const ip46_address_t vrrp6_mcast_addr
static void vrrp6_na_pkt_build(vrrp_vr_t *vr, vlib_buffer_t *b, ip6_address_t *addr6)
#define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b)
VLIB buffer representation.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
u8 * ethernet_build_rewrite(vnet_main_t *vnm, u32 sw_if_index, vnet_link_t link_type, const void *dst_address)
build a rewrite string to use for sending packets of type 'link_type' to 'dst_address' ...
static void ip6_address_copy(ip6_address_t *dst, const ip6_address_t *src)
static const u8 vrrp4_dst_mac[6]
#define vec_foreach(var, vec)
Vector iterator.
ip46_address_t * vr_addrs
static void ip6_multicast_ethernet_address(u8 *ethernet_address, u32 group_id)
ip46_address_t * peer_addrs
u16 vrrp_adv_csum(void *l3_hdr, void *payload, u8 is_ipv6, u16 len)
static ip_csum_t ip_incremental_checksum(ip_csum_t sum, void *_data, uword n_bytes)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static u16 ip4_header_checksum(ip4_header_t *i)
static_always_inline const ip46_address_t * vrrp_adv_mcast_addr(vrrp_vr_t *vr)
static u16 ip_csum_fold(ip_csum_t c)
static void ip6_set_reserved_multicast_address(ip6_address_t *a, ip6_multicast_address_scope_t scope, u16 id)