FD.io VPP  v18.01.2-1-g9b554f3
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 
31 
32 /*
33  * This Routine gets called from IPv6 hop-by-hop option handling.
34  * Only if we are encap node, then add PPC data.
35  * On a Transit(MID) node we dont do anything with E2E headers.
36  * On decap node decap is handled by seperate function.
37  */
38 int
41 {
42  u32 opaque_index = vnet_buffer(b)->l2_classify.opaque_index;
43  ioam_e2e_option_t * e2e;
44  int rv = 0;
45  ioam_seqno_data *data;
46 
47  /* Bypass seqno processing */
48  if (PREDICT_FALSE(opaque_index == 0x7FFFFFFF))
49  return rv;
50 
51  data = ioam_e2ec_get_seqno_data_from_flow_ctx(opaque_index);
52  e2e = (ioam_e2e_option_t *) opt;
53  e2e->e2e_hdr.e2e_data = clib_host_to_net_u32(++data->seq_num);
54 
55  return (rv);
56 }
57 
58 /*
59  * This Routine gets called on POP/Decap node.
60  */
61 int
64 {
65  u32 opaque_index = vnet_buffer(b)->l2_classify.opaque_index;
66  ioam_e2e_option_t * e2e;
67  int rv = 0;
68  ioam_seqno_data *data;
69 
70  data = ioam_e2ec_get_seqno_data_from_flow_ctx(opaque_index);
71  e2e = (ioam_e2e_option_t *) opt;
73  (u64) clib_net_to_host_u32(e2e->e2e_hdr.e2e_data));
74 
75  return (rv);
76 }
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:44
seqno_rx_info seqno_rx
static void ioam_analyze_seqno(seqno_rx_info *seqno_rx, u64 seqno)
unsigned long u64
Definition: types.h:89
#define PREDICT_FALSE(x)
Definition: clib.h:105
The fine-grained event logger allows lightweight, thread-safe event logging at minimum cost...
unsigned int u32
Definition: types.h:88
#define vnet_buffer(b)
Definition: buffer.h:326