FD.io VPP  v17.01.1-3-gc6833f8
Vector Packet Processing
ip6_ioam_seqno.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 
17 #include <vlib/vlib.h>
18 #include <vnet/vnet.h>
19 #include <vnet/pg/pg.h>
20 #include <vppinfra/error.h>
21 
22 #include <vnet/ip/ip.h>
23 
24 #include <vppinfra/hash.h>
25 #include <vppinfra/error.h>
26 #include <vppinfra/elog.h>
27 
28 #include "ip6_ioam_seqno.h"
29 #include "ip6_ioam_e2e.h"
30 
32 
34 {
35  seqno_bitmap *bitmap = &data->seqno_rx.bitmap;
38  bitmap->mask = 32 * SEQNO_WINDOW_ARRAY_SIZE - 1;
39  bitmap->array[0] = 0x00000000;/* pretend we haven seen sequence numbers 0*/
40  bitmap->highest = 0;
41 
42  data->seq_num = 0;
43  return ;
44 }
45 
46 /*
47  * This Routine gets called from IPv6 hop-by-hop option handling.
48  * Only if we are encap node, then add PPC data.
49  * On a Transit(MID) node we dont do anything with E2E headers.
50  * On decap node decap is handled by seperate function.
51  */
52 int
55 {
56  u32 opaque_index = vnet_buffer(b)->l2_classify.opaque_index;
57  ioam_e2e_option_t * e2e;
58  int rv = 0;
59  ioam_seqno_data *data;
60 
61  data = ioam_e2ec_get_seqno_data_from_flow_ctx(opaque_index);
62  e2e = (ioam_e2e_option_t *) opt;
63  e2e->e2e_data = clib_host_to_net_u32(++data->seq_num);
64 
65  return (rv);
66 }
67 
68 /*
69  * This Routine gets called on POP/Decap node.
70  */
71 int
74 {
75  u32 opaque_index = vnet_buffer(b)->l2_classify.opaque_index;
76  ioam_e2e_option_t * e2e;
77  int rv = 0;
78  ioam_seqno_data *data;
79 
80  data = ioam_e2ec_get_seqno_data_from_flow_ctx(opaque_index);
81  e2e = (ioam_e2e_option_t *) opt;
82  ioam_analyze_seqno(&data->seqno_rx, (u64) clib_net_to_host_u32(e2e->e2e_data));
83 
84  return (rv);
85 }
86 
87 u8 *
89 {
90  seqno_rx_info *rx;
91 
92  s = format(s, "SeqNo Data:\n");
93  if (enc)
94  {
95  s = format(s, " Current Seq. Number : %llu\n", seqno_data->seq_num);
96  }
97  else
98  {
99  rx = &seqno_data->seqno_rx;
100  s = format(s, " Highest Seq. Number : %llu\n", rx->bitmap.highest);
101  s = format(s, " Packets received : %llu\n", rx->rx_packets);
102  s = format(s, " Lost packets : %llu\n", rx->lost_packets);
103  s = format(s, " Reordered packets : %llu\n", rx->reordered_packets);
104  s = format(s, " Duplicate packets : %llu\n", rx->dup_packets);
105  }
106 
107  format(s, "\n");
108  return s;
109 }
void ioam_analyze_seqno(seqno_rx_info *ppc_rx, u64 seqno)
int ioam_seqno_encap_handler(vlib_buffer_t *b, ip6_header_t *ip, ip6_hop_by_hop_option_t *opt)
int ioam_seqno_decap_handler(vlib_buffer_t *b, ip6_header_t *ip, ip6_hop_by_hop_option_t *opt)
static ioam_seqno_data * ioam_e2ec_get_seqno_data_from_flow_ctx(u32 flow_ctx)
Definition: ip6_ioam_e2e.h:36
seqno_rx_info seqno_rx
unsigned long u64
Definition: types.h:89
#define SEQNO_WINDOW_ARRAY_SIZE
u8 * show_ioam_seqno_cmd_fn(u8 *s, ioam_seqno_data *seqno_data, u8 enc)
unsigned int u32
Definition: types.h:88
#define vnet_buffer(b)
Definition: buffer.h:361
unsigned char u8
Definition: types.h:56
#define SEQNO_WINDOW_SIZE
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:418
seqno_bitmap bitmap
void ioam_seqno_init_bitmap(ioam_seqno_data *data)
u64 array[SEQNO_WINDOW_ARRAY_SIZE]
ioam_seqno_data_main_t ioam_seqno_main