diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/if.c | 26 | ||||
| -rw-r--r-- | lib/if.h | 2 | ||||
| -rw-r--r-- | lib/srv6.c | 13 | ||||
| -rw-r--r-- | lib/srv6.h | 1 | ||||
| -rw-r--r-- | lib/zclient.c | 69 |
5 files changed, 84 insertions, 27 deletions
@@ -1095,13 +1095,15 @@ const char *if_link_type_str(enum zebra_link_type llt) struct if_link_params *if_link_params_get(struct interface *ifp) { - int i; + return ifp->link_params; +} - if (ifp->link_params != NULL) - return ifp->link_params; +struct if_link_params *if_link_params_enable(struct interface *ifp) +{ + struct if_link_params *iflp; + int i; - struct if_link_params *iflp = - XCALLOC(MTYPE_IF_LINK_PARAMS, sizeof(struct if_link_params)); + iflp = if_link_params_init(ifp); /* Compute default bandwidth based on interface */ iflp->default_bw = @@ -1129,6 +1131,20 @@ struct if_link_params *if_link_params_get(struct interface *ifp) return iflp; } +struct if_link_params *if_link_params_init(struct interface *ifp) +{ + struct if_link_params *iflp = if_link_params_get(ifp); + + if (iflp) + return iflp; + + iflp = XCALLOC(MTYPE_IF_LINK_PARAMS, sizeof(struct if_link_params)); + + ifp->link_params = iflp; + + return iflp; +} + void if_link_params_free(struct interface *ifp) { XFREE(MTYPE_IF_LINK_PARAMS, ifp->link_params); @@ -588,6 +588,8 @@ struct connected *connected_get_linklocal(struct interface *ifp); /* link parameters */ struct if_link_params *if_link_params_get(struct interface *); +struct if_link_params *if_link_params_enable(struct interface *ifp); +struct if_link_params *if_link_params_init(struct interface *ifp); void if_link_params_free(struct interface *); /* Northbound. */ diff --git a/lib/srv6.c b/lib/srv6.c index 6a658444c6..306d92ae30 100644 --- a/lib/srv6.c +++ b/lib/srv6.c @@ -57,6 +57,8 @@ const char *seg6local_action2str(uint32_t action) return "End.AS"; case ZEBRA_SEG6_LOCAL_ACTION_END_AM: return "End.AM"; + case ZEBRA_SEG6_LOCAL_ACTION_END_DT46: + return "End.DT46"; case ZEBRA_SEG6_LOCAL_ACTION_UNSPEC: return "unspec"; default: @@ -105,6 +107,7 @@ const char *seg6local_context2str(char *str, size_t size, case ZEBRA_SEG6_LOCAL_ACTION_END_T: case ZEBRA_SEG6_LOCAL_ACTION_END_DT6: case ZEBRA_SEG6_LOCAL_ACTION_END_DT4: + case ZEBRA_SEG6_LOCAL_ACTION_END_DT46: snprintf(str, size, "table %u", ctx->table); return str; @@ -228,10 +231,20 @@ json_object *srv6_locator_json(const struct srv6_locator *loc) /* set prefix */ json_object_string_addf(jo_root, "prefix", "%pFX", &loc->prefix); + /* set block_bits_length */ + json_object_int_add(jo_root, "blockBitsLength", loc->block_bits_length); + + /* set node_bits_length */ + json_object_int_add(jo_root, "nodeBitsLength", loc->node_bits_length); + /* set function_bits_length */ json_object_int_add(jo_root, "functionBitsLength", loc->function_bits_length); + /* set argument_bits_length */ + json_object_int_add(jo_root, "argumentBitsLength", + loc->argument_bits_length); + /* set status_up */ json_object_boolean_add(jo_root, "statusUp", loc->status_up); diff --git a/lib/srv6.h b/lib/srv6.h index e0db30cd13..6e0c3ce99d 100644 --- a/lib/srv6.h +++ b/lib/srv6.h @@ -60,6 +60,7 @@ enum seg6local_action_t { ZEBRA_SEG6_LOCAL_ACTION_END_AS = 13, ZEBRA_SEG6_LOCAL_ACTION_END_AM = 14, ZEBRA_SEG6_LOCAL_ACTION_END_BPF = 15, + ZEBRA_SEG6_LOCAL_ACTION_END_DT46 = 16, }; struct seg6_segs { diff --git a/lib/zclient.c b/lib/zclient.c index 8ec82ab7bb..f5d45b40ef 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -2299,13 +2299,22 @@ static int zclient_handle_error(ZAPI_CALLBACK_ARGS) return 0; } -static int link_params_set_value(struct stream *s, struct if_link_params *iflp) +static int link_params_set_value(struct stream *s, struct interface *ifp) { + uint8_t link_params_enabled; + struct if_link_params *iflp; + uint32_t bwclassnum; + + iflp = if_link_params_get(ifp); if (iflp == NULL) - return -1; + iflp = if_link_params_init(ifp); - uint32_t bwclassnum; + STREAM_GETC(s, link_params_enabled); + if (!link_params_enabled) { + if_link_params_free(ifp); + return 0; + } STREAM_GETL(s, iflp->lp_status); STREAM_GETL(s, iflp->te_metric); @@ -2346,9 +2355,9 @@ struct interface *zebra_interface_link_params_read(struct stream *s, bool *changed) { struct if_link_params *iflp; - struct if_link_params iflp_copy; + struct if_link_params iflp_prev; ifindex_t ifindex; - bool params_changed = false; + bool iflp_prev_set; STREAM_GETL(s, ifindex); @@ -2361,22 +2370,32 @@ struct interface *zebra_interface_link_params_read(struct stream *s, return NULL; } - if (ifp->link_params == NULL) - params_changed = true; - - if ((iflp = if_link_params_get(ifp)) == NULL) - return NULL; - - memcpy(&iflp_copy, iflp, sizeof(iflp_copy)); + iflp = if_link_params_get(ifp); + if (iflp) { + iflp_prev_set = true; + memcpy(&iflp_prev, ifp->link_params, sizeof(iflp_prev)); + } else + iflp_prev_set = false; - if (link_params_set_value(s, iflp) != 0) + /* read the link_params from stream + * Free ifp->link_params if the stream has no params + * to means that link-params are not enabled on links. + */ + if (link_params_set_value(s, ifp) != 0) goto stream_failure; - if (memcmp(&iflp_copy, iflp, sizeof(iflp_copy))) - params_changed = true; + if (changed == NULL) + return ifp; - if (changed) - *changed = params_changed; + if (iflp_prev_set && iflp) { + if (memcmp(&iflp_prev, iflp, sizeof(iflp_prev))) + *changed = true; + else + *changed = false; + } else if (!iflp_prev_set && !iflp) + *changed = false; + else + *changed = true; return ifp; @@ -2415,10 +2434,8 @@ static void zebra_interface_if_set_value(struct stream *s, /* Read Traffic Engineering status */ link_params_status = stream_getc(s); /* Then, Traffic Engineering parameters if any */ - if (link_params_status) { - struct if_link_params *iflp = if_link_params_get(ifp); - link_params_set_value(s, iflp); - } + if (link_params_status) + link_params_set_value(s, ifp); nexthop_group_interface_state_change(ifp, old_ifindex); @@ -2435,12 +2452,20 @@ size_t zebra_interface_link_params_write(struct stream *s, struct if_link_params *iflp; int i; - if (s == NULL || ifp == NULL || ifp->link_params == NULL) + if (s == NULL || ifp == NULL) return 0; iflp = ifp->link_params; w = 0; + /* encode if link_params is enabled */ + if (iflp) { + w += stream_putc(s, true); + } else { + w += stream_putc(s, false); + return w; + } + w += stream_putl(s, iflp->lp_status); w += stream_putl(s, iflp->te_metric); |
