summaryrefslogtreecommitdiff
path: root/lib/srv6.h
diff options
context:
space:
mode:
authorDmytro Shytyi <dmytro.shytyi@6wind.com>2023-07-26 17:56:32 +0200
committerDmytro Shytyi <dmytro.shytyi@6wind.com>2023-09-20 15:07:15 +0200
commitf20cf1457d43c3d5f61845ea5db1c1743b29cfbf (patch)
tree933e0cc401c582be7b63878b1daea96b322a89a7 /lib/srv6.h
parentbc6d311d28b11af7533762a9e85f5dd8c7b5c525 (diff)
bgpd,lib,sharpd,zebra: srv6 introduce multiple segs/SIDs in nexthop
Append zebra and lib to use muliple SRv6 segs SIDs, and keep one seg SID for bgpd and sharpd. Note: bgpd and sharpd compilation relies on the lib and zebra files, i.e if we separate this: lib or zebra or bgpd or sharpd in different commits - this will not compile. Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
Diffstat (limited to 'lib/srv6.h')
-rw-r--r--lib/srv6.h29
1 files changed, 24 insertions, 5 deletions
diff --git a/lib/srv6.h b/lib/srv6.h
index 7c8c6b4a65..fb34f861c8 100644
--- a/lib/srv6.h
+++ b/lib/srv6.h
@@ -14,8 +14,11 @@
#include <arpa/inet.h>
#include <netinet/in.h>
-#define SRV6_MAX_SIDS 16
+#define SRV6_MAX_SIDS 16
+#define SRV6_MAX_SEGS 8
#define SRV6_LOCNAME_SIZE 256
+#define SRH_BASE_HEADER_LENGTH 8
+#define SRH_SEGMENT_LENGTH 16
#ifdef __cplusplus
extern "C" {
@@ -74,6 +77,8 @@ enum seg6local_flavor_op {
ZEBRA_SEG6_LOCAL_FLV_OP_NEXT_CSID = 4,
};
+#define SRV6_SEG_STRLEN 1024
+
struct seg6_segs {
size_t num_segs;
struct in6_addr segs[256];
@@ -89,6 +94,11 @@ struct seg6local_flavors_info {
uint8_t lcnode_func_len;
};
+struct seg6_seg_stack {
+ uint8_t num_segs;
+ struct in6_addr seg[0]; /* 1 or more segs */
+};
+
struct seg6local_context {
struct in_addr nh4;
struct in6_addr nh6;
@@ -170,7 +180,7 @@ struct nexthop_srv6 {
struct seg6local_context seg6local_ctx;
/* SRv6 Headend-behaviour */
- struct in6_addr seg6_segs;
+ struct seg6_seg_stack *seg6_segs;
};
static inline const char *seg6_mode2str(enum seg6_mode_t mode)
@@ -206,12 +216,21 @@ static inline bool sid_diff(
return !sid_same(a, b);
}
-static inline bool sid_zero(
- const struct in6_addr *a)
+
+static inline bool sid_zero(const struct seg6_seg_stack *a)
+{
+ struct in6_addr zero = {};
+
+ assert(a);
+
+ return sid_same(&a->seg[0], &zero);
+}
+
+static inline bool sid_zero_ipv6(const struct in6_addr *a)
{
struct in6_addr zero = {};
- return sid_same(a, &zero);
+ return sid_same(&a[0], &zero);
}
static inline void *sid_copy(struct in6_addr *dst,