aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/tunnel/tunnel.h
diff options
context:
space:
mode:
authorNeale Ranns <neale@graphiant.com>2021-02-04 11:02:52 +0000
committerOle Tr�an <otroan@employees.org>2021-02-08 11:44:00 +0000
commita91cb45909642978592c7e21a8f6d2da2e44e506 (patch)
treeeab3c645e03cba2707555647cb61e83ffedef42f /src/vnet/tunnel/tunnel.h
parent7d527a2292bdabc84ff070f5b27f35c0e858cddd (diff)
tunnel: support copying TTL and flow label from inner to outer
Type: feature The added functionality is to support copying TTL and flow label from inner to outer. The .api was extened to support expressing this and also adding a common tunnel endpoint type. i find it best to make API changes in one patch so there are less versions of the API. Signed-off-by: Neale Ranns <neale@graphiant.com> Change-Id: I755c1e3f4c475058792af39c1abeda92129efb76
Diffstat (limited to 'src/vnet/tunnel/tunnel.h')
-rw-r--r--src/vnet/tunnel/tunnel.h89
1 files changed, 76 insertions, 13 deletions
diff --git a/src/vnet/tunnel/tunnel.h b/src/vnet/tunnel/tunnel.h
index de06b6002f5..acf0e4ca4e0 100644
--- a/src/vnet/tunnel/tunnel.h
+++ b/src/vnet/tunnel/tunnel.h
@@ -18,7 +18,8 @@
#ifndef __TUNNEL_H__
#define __TUNNEL_H__
-#include <vlib/vlib.h>
+#include <vnet/ip/ip_types.h>
+#include <vnet/fib/fib_node.h>
#define foreach_tunnel_mode \
_(P2P, "point-to-point") \
@@ -37,28 +38,90 @@ extern uword unformat_tunnel_mode (unformat_input_t * input, va_list * args);
/**
* Keep these idenitical to those in ipip.api
*/
-#define forech_tunnel_encap_decap_flag \
- _(NONE, "none", 0x0) \
- _(ENCAP_COPY_DF, "encap-copy-df", 0x1) \
- _(ENCAP_SET_DF, "encap-set-df", 0x2) \
- _(ENCAP_COPY_DSCP, "encap-copy-dscp", 0x4) \
- _(ENCAP_COPY_ECN, "encap-copy-ecn", 0x8) \
- _(DECAP_COPY_ECN, "decap-copy-ecn", 0x10) \
- _(ENCAP_INNER_HASH, "encap-inner-hash", 0x20)
+#define foreach_tunnel_encap_decap_flag \
+ _ (NONE, "none", 0x0) \
+ _ (ENCAP_COPY_DF, "encap-copy-df", 0x1) \
+ _ (ENCAP_SET_DF, "encap-set-df", 0x2) \
+ _ (ENCAP_COPY_DSCP, "encap-copy-dscp", 0x4) \
+ _ (ENCAP_COPY_ECN, "encap-copy-ecn", 0x8) \
+ _ (DECAP_COPY_ECN, "decap-copy-ecn", 0x10) \
+ _ (ENCAP_INNER_HASH, "encap-inner-hash", 0x20) \
+ _ (ENCAP_COPY_HOP_LIMIT, "encap-copy-hop-limit", 0x40) \
+ _ (ENCAP_COPY_FLOW_LABEL, "encap-copy-flow-label", 0x80)
typedef enum tunnel_encap_decap_flags_t_
{
#define _(a,b,c) TUNNEL_ENCAP_DECAP_FLAG_##a = c,
- forech_tunnel_encap_decap_flag
+ foreach_tunnel_encap_decap_flag
#undef _
} __clib_packed tunnel_encap_decap_flags_t;
-#define TUNNEL_FLAG_MASK (0x1f)
+extern const u8 TUNNEL_ENCAP_DECAP_FLAG_MASK;
extern u8 *format_tunnel_encap_decap_flags (u8 * s, va_list * args);
-extern uword
-unformat_tunnel_encap_decap_flags (unformat_input_t * input, va_list * args);
+extern uword unformat_tunnel_encap_decap_flags (unformat_input_t *input,
+ va_list *args);
+
+#define foreach_tunnel_flag \
+ _ (RESOLVED, 0, "resolved") \
+ _ (TRACK_MTU, 1, "track-mtu")
+
+typedef enum tunnel_flags_t_
+{
+ TUNNEL_FLAG_NONE = 0,
+#define _(n, b, s) TUNNEL_FLAG_##n = (1 << b),
+ foreach_tunnel_flag
+#undef _
+} __clib_packed tunnel_flags_t;
+
+extern const u8 TUNNEL_FLAG_MASK;
+
+extern u8 *format_tunnel_flags (u8 *s, va_list *args);
+extern uword unformat_tunnel_flags (unformat_input_t *input, va_list *args);
+
+/**
+ * A representation of an IP tunnel config
+ */
+typedef struct tunnel_t_
+{
+ ip_address_t t_src;
+ ip_address_t t_dst;
+ tunnel_encap_decap_flags_t t_encap_decap_flags;
+ tunnel_flags_t t_flags;
+ tunnel_mode_t t_mode;
+ u32 t_table_id;
+ ip_dscp_t t_dscp;
+ u8 t_hop_limit;
+
+ /**
+ * derived data
+ */
+ u32 t_fib_index;
+
+ fib_node_index_t t_fib_entry_index;
+ u32 t_sibling;
+
+} tunnel_t;
+
+extern u8 *format_tunnel (u8 *s, va_list *args);
+extern uword unformat_tunnel (unformat_input_t *input, va_list *args);
+
+extern void tunnel_copy (const tunnel_t *src, tunnel_t *dst);
+extern int tunnel_resolve (tunnel_t *t, fib_node_type_t child_type,
+ index_t child_index);
+extern void tunnel_unresolve (tunnel_t *t);
+
+extern ip_address_family_t tunnel_get_af (const tunnel_t *t);
+
+extern void tunnel_contribute_forwarding (const tunnel_t *t, dpo_id_t *dpo);
+
+extern void tunnel_build_v6_hdr (const tunnel_t *t, ip_protocol_t next_proto,
+ ip6_header_t *ip);
+extern void tunnel_build_v4_hdr (const tunnel_t *t, ip_protocol_t next_proto,
+ ip4_header_t *ip);
+
#endif
+
/*
* fd.io coding-style-patch-verification: ON
*