FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
gtp6_e.c
Go to the documentation of this file.
1 /*
2  * srv6_end_m_gtp6_e.c
3  *
4  * Copyright (c) 2019 Arrcus Inc and/or its affiliates.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #include <vnet/vnet.h>
19 #include <vnet/adj/adj.h>
20 #include <vnet/plugin/plugin.h>
21 #include <vpp/app/version.h>
22 #include <srv6-mobile/mobile.h>
23 
25 
26 static void
28 {
29 }
30 
31 static void
33 {
34 }
35 
36 static u8 *
37 clb_dpo_format_srv6_end_m_gtp6_e (u8 * s, va_list * args)
38 {
39  index_t index = va_arg (*args, index_t);
40  CLIB_UNUSED (u32 indent) = va_arg (*args, u32);
41 
42  return (format (s, "SR: dynamic_proxy_index:[%u]", index));
43 }
44 
45 const static dpo_vft_t dpo_vft = {
49 };
50 
51 const static char *const srv6_end_m_gtp6_e_nodes[] = {
52  "srv6-end-m-gtp6-e",
53  NULL,
54 };
55 
56 const static char *const *const dpo_nodes[DPO_PROTO_NUM] = {
58 };
59 
60 static u8 fn_name[] = "SRv6-End.M.GTP6.E-plugin";
61 static u8 keyword_str[] = "end.m.gtp6.e";
62 static u8 def_str[] =
63  "Endpoint function with encapsulation for IPv6/GTP tunnel";
64 static u8 param_str[] = "";
65 
66 static u8 *
67 clb_format_srv6_end_m_gtp6_e (u8 * s, va_list * args)
68 {
69  s = format (s, "SRv6 End format function unsupported.");
70  return s;
71 }
72 
73 static uword
75 {
76  if (!unformat (input, "end.m.gtp6.e"))
77  return 0;
78  return 1;
79 }
80 
81 static int
83 {
84  return 0;
85 }
86 
87 static int
89 {
90  return 0;
91 }
92 
93 static clib_error_t *
95 {
97  ip6_header_t *ip6 = &sm->cache_hdr.ip6;
98  udp_header_t *udp = &sm->cache_hdr.udp;
99  gtpu_header_t *gtpu = &sm->cache_hdr.gtpu;
100  dpo_type_t dpo_type;
101  vlib_node_t *node;
102  int rc;
103 
104  sm->vlib_main = vm;
105  sm->vnet_main = vnet_get_main ();
106 
107  node = vlib_get_node_by_name (vm, (u8 *) "srv6-end-m-gtp6-e");
108  sm->end_m_gtp6_e_node_index = node->index;
109 
110  node = vlib_get_node_by_name (vm, (u8 *) "error-drop");
111  sm->error_node_index = node->index;
112 
113  // clear the pre cached packet
114  clib_memset_u8 (ip6, 0, sizeof (ip6_gtpu_header_t));
115 
116  // set defaults
117  ip6->ip_version_traffic_class_and_flow_label = 0x60;
118  ip6->protocol = IP_PROTOCOL_UDP;
119  ip6->hop_limit = 64;
120 
121  udp->dst_port = clib_host_to_net_u16 (SRV6_GTP_UDP_DST_PORT);
122 
124  gtpu->type = GTPU_TYPE_GTPU;
125 
126  dpo_type = dpo_register_new_type (&dpo_vft, dpo_nodes);
127 
129  &dpo_type,
134  if (rc < 0)
135  clib_error_return (0, "SRv6 Endpoint GTP6.E LocalSID function"
136  "couldn't be registered");
137  return 0;
138 }
139 
140 /* *INDENT-OFF* */
142 {
143  .arc_name = "ip6-unicast",
144  .node_name = "srv6-end-m-gtp6-e",
145  .runs_before = 0,
146 };
147 
149 /* *INDENT-ON* */
150 
151 /*
152  * fd.io coding-style-patch-verification: ON
153  *
154  * Local Variables:
155  * eval: (c-set-style "gnu")
156  * End:
157  */
VNET_FEATURE_INIT
VNET_FEATURE_INIT(srv6_end_m_gtp6_e, static)
clb_unformat_srv6_end_m_gtp6_e
static uword clb_unformat_srv6_end_m_gtp6_e(unformat_input_t *input, va_list *args)
Definition: gtp6_e.c:74
adj.h
dpo_register_new_type
dpo_type_t dpo_register_new_type(const dpo_vft_t *vft, const char *const *const *nodes)
Create and register a new DPO type.
Definition: dpo.c:349
srv6_end_m_gtp6_e_init
static clib_error_t * srv6_end_m_gtp6_e_init(vlib_main_t *vm)
Definition: gtp6_e.c:94
param_str
static u8 param_str[]
Definition: gtp6_e.c:64
GTPU_PT_GTP
#define GTPU_PT_GTP
Definition: mobile.h:164
gtpu_header_t::ver_flags
u8 ver_flags
Definition: mobile.h:92
clb_format_srv6_end_m_gtp6_e
static u8 * clb_format_srv6_end_m_gtp6_e(u8 *s, va_list *args)
Definition: gtp6_e.c:67
SRV6_GTP_UDP_DST_PORT
#define SRV6_GTP_UDP_DST_PORT
Definition: mobile.h:29
ip6_sr_localsid_t
SR LocalSID.
Definition: sr.h:122
sr_localsid_register_function
int sr_localsid_register_function(vlib_main_t *vm, u8 *fn_name, u8 *keyword_str, u8 *def_str, u8 *params_str, u8 prefix_length, dpo_type_t *dpo, format_function_t *ls_format, unformat_function_t *ls_unformat, sr_plugin_callback_t *creation_fn, sr_plugin_callback_t *removal_fn)
SR LocalSID plugin registry.
Definition: sr_localsid.c:2347
srv6_end_m_gtp6_e
vlib_node_registration_t srv6_end_m_gtp6_e
(constructor) VLIB_REGISTER_NODE (srv6_end_m_gtp6_e)
Definition: node.c:2963
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
clib_error_return
#define clib_error_return(e, args...)
Definition: error.h:99
fn_name
static u8 fn_name[]
Definition: gtp6_e.c:60
def_str
static u8 def_str[]
Definition: gtp6_e.c:62
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
srv6_end_main_v6_s
Definition: mobile.h:246
unformat_input_t
struct _unformat_input_t unformat_input_t
udp_header_t
Definition: udp_packet.h:45
srv6_end_main_v6_s::vnet_main
vnet_main_t * vnet_main
Definition: mobile.h:249
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
clb_dpo_unlock_srv6_end_m_gtp6_e
static void clb_dpo_unlock_srv6_end_m_gtp6_e(dpo_id_t *dpo)
Definition: gtp6_e.c:32
srv6_end_main_v6
srv6_end_main_v6_t srv6_end_main_v6
Definition: gtp6_e.c:24
GTPU_V1_VER
#define GTPU_V1_VER
Definition: mobile.h:162
CLIB_UNUSED
#define CLIB_UNUSED(x)
Definition: clib.h:90
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
index_t
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
Definition: dpo.h:43
mobile.h
gtpu_header_t
Definition: mobile.h:90
uword
u64 uword
Definition: types.h:112
dpo_vft
const static dpo_vft_t dpo_vft
Definition: gtp6_e.c:45
dpo_nodes
const static char *const *const dpo_nodes[DPO_PROTO_NUM]
Definition: gtp6_e.c:56
srv6_end_main_v6_s::cache_hdr
ip6_gtpu_header_t cache_hdr
Definition: mobile.h:254
dpo_type_t
enum dpo_type_t_ dpo_type_t
Common types of data-path objects New types can be dynamically added using dpo_register_new_type()
ip6_gtpu_header_t::udp
udp_header_t udp
Definition: mobile.h:157
clb_dpo_format_srv6_end_m_gtp6_e
static u8 * clb_dpo_format_srv6_end_m_gtp6_e(u8 *s, va_list *args)
Definition: gtp6_e.c:37
clb_creation_srv6_end_m_gtp6_e
static int clb_creation_srv6_end_m_gtp6_e(ip6_sr_localsid_t *localsid)
Definition: gtp6_e.c:82
keyword_str
static u8 keyword_str[]
Definition: gtp6_e.c:61
dpo_vft_t_::dv_lock
dpo_lock_fn_t dv_lock
A reference counting lock function.
Definition: dpo.h:428
clb_dpo_lock_srv6_end_m_gtp6_e
static void clb_dpo_lock_srv6_end_m_gtp6_e(dpo_id_t *dpo)
Definition: gtp6_e.c:27
clib_memset_u8
static_always_inline void clib_memset_u8(void *p, u8 val, uword count)
Definition: string.h:441
ip6_gtpu_header_t::ip6
ip6_header_t ip6
Definition: mobile.h:156
srv6_end_main_v6_s::vlib_main
vlib_main_t * vlib_main
Definition: mobile.h:248
plugin.h
index
u32 index
Definition: flow_types.api:221
vlib_get_node_by_name
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
Definition: node.c:45
clb_removal_srv6_end_m_gtp6_e
static int clb_removal_srv6_end_m_gtp6_e(ip6_sr_localsid_t *localsid)
Definition: gtp6_e.c:88
format
description fragment has unexpected format
Definition: map.api:433
DPO_PROTO_IP6
@ DPO_PROTO_IP6
Definition: dpo.h:65
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
udp_header_t::dst_port
u16 dst_port
Definition: udp_packet.h:48
gtpu_header_t::type
u8 type
Definition: mobile.h:93
ip6
vl_api_ip6_address_t ip6
Definition: one.api:424
ip6_gtpu_header_t::gtpu
gtpu_header_t gtpu
Definition: mobile.h:158
srv6_end_main_v6_s::end_m_gtp6_e_node_index
u32 end_m_gtp6_e_node_index
Definition: mobile.h:251
srv6_end_m_gtp6_e_nodes
const static char *const srv6_end_m_gtp6_e_nodes[]
Definition: gtp6_e.c:51
ip6_header_t
Definition: ip6_packet.h:294
vlib_main_t
Definition: main.h:102
vlib_node_t
Definition: node.h:247
dpo_vft_t_
A virtual function table regisitered for a DPO type.
Definition: dpo.h:423
ip6_gtpu_header_t
Definition: mobile.h:154
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
srv6_end_main_v6_s::error_node_index
u32 error_node_index
Definition: mobile.h:252
dpo_id_t_
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:172
vnet.h
DPO_PROTO_NUM
#define DPO_PROTO_NUM
Definition: dpo.h:72
GTPU_TYPE_GTPU
#define GTPU_TYPE_GTPU
Definition: mobile.h:104