diff options
| author | Russ White <russ@riw.us> | 2022-01-18 09:08:38 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-18 09:08:38 -0500 |
| commit | 05786ac7744a6077a7f5aff9d2bfe1c92e54e17c (patch) | |
| tree | 7b25f5cda483135e144e490d3e8ac970b5781d7f /ospf6d/ospf6_zebra.c | |
| parent | c748ab25673c118e7ae67a82348af5f54c2bec64 (diff) | |
| parent | 485e8b5662dbecdb9f2e1a3e0a88dbfaffd640b2 (diff) | |
Merge pull request #9644 from opensourcerouting/ospf-opaque-attrs
OSPF opaque route attributes
Diffstat (limited to 'ospf6d/ospf6_zebra.c')
| -rw-r--r-- | ospf6d/ospf6_zebra.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c index 5e50a6cc55..b818633518 100644 --- a/ospf6d/ospf6_zebra.c +++ b/ospf6d/ospf6_zebra.c @@ -27,6 +27,7 @@ #include "stream.h" #include "zclient.h" #include "memory.h" +#include "route_opaque.h" #include "lib/bfd.h" #include "lib_errors.h" @@ -371,6 +372,38 @@ DEFUN(show_zebra, return CMD_SUCCESS; } +static void ospf6_zebra_append_opaque_attr(struct ospf6_route *request, + struct zapi_route *api) +{ + struct ospf_zebra_opaque ospf_opaque = {}; + + /* OSPF path type */ + snprintf(ospf_opaque.path_type, sizeof(ospf_opaque.path_type), "%s", + OSPF6_PATH_TYPE_NAME(request->path.type)); + + switch (request->path.type) { + case OSPF6_PATH_TYPE_INTRA: + case OSPF6_PATH_TYPE_INTER: + /* OSPF area ID */ + (void)inet_ntop(AF_INET, &request->path.area_id, + ospf_opaque.area_id, + sizeof(ospf_opaque.area_id)); + break; + case OSPF6_PATH_TYPE_EXTERNAL1: + case OSPF6_PATH_TYPE_EXTERNAL2: + /* OSPF route tag */ + snprintf(ospf_opaque.tag, sizeof(ospf_opaque.tag), "%u", + request->path.tag); + break; + default: + break; + } + + SET_FLAG(api->message, ZAPI_MESSAGE_OPAQUE); + api->opaque.length = sizeof(struct ospf_zebra_opaque); + memcpy(api->opaque.data, &ospf_opaque, api->opaque.length); +} + #define ADD 0 #define REM 1 static void ospf6_zebra_route_update(int type, struct ospf6_route *request, @@ -455,6 +488,10 @@ static void ospf6_zebra_route_update(int type, struct ospf6_route *request, api.distance = ospf6_distance_apply((struct prefix_ipv6 *)dest, request, ospf6); + if (type == ADD + && CHECK_FLAG(ospf6->config_flags, OSPF6_SEND_EXTRA_DATA_TO_ZEBRA)) + ospf6_zebra_append_opaque_attr(request, &api); + if (type == REM) ret = zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api); else |
