diff options
| -rw-r--r-- | lib/nexthop.h | 2 | ||||
| -rw-r--r-- | lib/zclient.c | 6 | ||||
| -rw-r--r-- | sharpd/sharp_vty.c | 4 | ||||
| -rw-r--r-- | sharpd/sharp_zebra.c | 19 | ||||
| -rw-r--r-- | sharpd/sharp_zebra.h | 6 | ||||
| -rw-r--r-- | zebra/rt_netlink.c | 13 | ||||
| -rw-r--r-- | zebra/zapi_msg.h | 3 | ||||
| -rw-r--r-- | zebra/zebra_srv6.c | 7 | ||||
| -rw-r--r-- | zebra/zebra_srv6.h | 3 | ||||
| -rw-r--r-- | zebra/zebra_srv6_vty.c | 54 |
10 files changed, 69 insertions, 48 deletions
diff --git a/lib/nexthop.h b/lib/nexthop.h index 8c52631af1..c9af1ff478 100644 --- a/lib/nexthop.h +++ b/lib/nexthop.h @@ -168,7 +168,7 @@ void nexthop_del_labels(struct nexthop *); void nexthop_add_seg6local(struct nexthop *nexthop, uint32_t action, const struct seg6local_context *ctx); void nexthop_del_seg6local(struct nexthop *nexthop); -void nexthop_add_seg6(struct nexthop *nexthop, const struct in6_addr* segs); +void nexthop_add_seg6(struct nexthop *nexthop, const struct in6_addr *segs); void nexthop_del_seg6(struct nexthop *nexthop); /* diff --git a/lib/zclient.c b/lib/zclient.c index 8520fd769d..7eb365c305 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -2774,7 +2774,8 @@ int srv6_manager_get_locator_chunk(struct zclient *zclient, /* send request */ s = zclient->obuf; stream_reset(s); - zclient_create_header(s, ZEBRA_SRV6_MANAGER_GET_LOCATOR_CHUNK, VRF_DEFAULT); + zclient_create_header(s, ZEBRA_SRV6_MANAGER_GET_LOCATOR_CHUNK, + VRF_DEFAULT); /* proto */ stream_putc(s, zclient->redist_default); @@ -3580,7 +3581,8 @@ enum zclient_send_status zclient_send_mlag_register(struct zclient *client, enum zclient_send_status zclient_send_mlag_deregister(struct zclient *client) { - return zebra_message_send(client, ZEBRA_MLAG_CLIENT_UNREGISTER, VRF_DEFAULT); + return zebra_message_send(client, ZEBRA_MLAG_CLIENT_UNREGISTER, + VRF_DEFAULT); } enum zclient_send_status zclient_send_mlag_data(struct zclient *client, diff --git a/sharpd/sharp_vty.c b/sharpd/sharp_vty.c index 5997e5e312..58f6e3fe95 100644 --- a/sharpd/sharp_vty.c +++ b/sharpd/sharp_vty.c @@ -318,6 +318,7 @@ DEFPY (install_routes, } else if (seg6l_oif) { struct seg6local_context ctx; enum seg6local_action_t action; + memset(&ctx, 0, sizeof(struct seg6local_context)); if (seg6l_enddx4) { action = ZEBRA_SEG6_LOCAL_ACTION_END_DX4; @@ -1047,7 +1048,8 @@ void sharp_vty_init(void) install_element(ENABLE_NODE, &show_sharp_ted_cmd); install_element(ENABLE_NODE, &sharp_srv6_manager_get_locator_chunk_cmd); - install_element(ENABLE_NODE, &sharp_srv6_manager_release_locator_chunk_cmd); + install_element(ENABLE_NODE, + &sharp_srv6_manager_release_locator_chunk_cmd); install_element(ENABLE_NODE, &show_sharp_segment_routing_srv6_cmd); return; diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c index 7c24ae380f..ae4add6a60 100644 --- a/sharpd/sharp_zebra.c +++ b/sharpd/sharp_zebra.c @@ -338,7 +338,8 @@ static void sharp_install_routes_restart(struct prefix *p, uint32_t count, uint32_t nhgid, const struct nexthop_group *nhg, const struct nexthop_group *backup_nhg, - uint32_t routes, uint32_t flags, char *opaque) + uint32_t routes, uint32_t flags, + char *opaque) { uint32_t temp, i; bool v4 = false; @@ -924,7 +925,7 @@ static int nhg_notify_owner(ZAPI_CALLBACK_ARGS) return 0; } -int sharp_zebra_srv6_manager_get_locator_chunk(const char* locator_name) +int sharp_zebra_srv6_manager_get_locator_chunk(const char *locator_name) { return srv6_manager_get_locator_chunk(zclient, locator_name); } @@ -942,6 +943,7 @@ static void sharp_zebra_process_srv6_locator_chunk(ZAPI_CALLBACK_ARGS) uint16_t len; char name[256] = {0}; struct prefix_ipv6 *chunk = NULL; + chunk = prefix_ipv6_new(); s = zclient->ibuf; @@ -965,16 +967,17 @@ static void sharp_zebra_process_srv6_locator_chunk(ZAPI_CALLBACK_ARGS) struct listnode *loc_node; struct sharp_srv6_locator *loc; + for (ALL_LIST_ELEMENTS_RO(sg.srv6_locators, loc_node, loc)) { + struct listnode *chunk_node; + struct prefix_ipv6 *c; + if (strcmp(loc->name, name)) continue; - struct listnode *chunk_node; - struct prefix_ipv6 *c; - for (ALL_LIST_ELEMENTS_RO(loc->chunks, chunk_node, c)) { + for (ALL_LIST_ELEMENTS_RO(loc->chunks, chunk_node, c)) if (!prefix_cmp(c, chunk)) return; - } listnode_add(loc->chunks, chunk); } return; @@ -983,7 +986,6 @@ stream_failure: free(chunk); zlog_err("%s: can't get locator_chunk!!", __func__); - return; } void sharp_zebra_init(void) @@ -1007,5 +1009,6 @@ void sharp_zebra_init(void) zclient->redistribute_route_add = sharp_redistribute_route; zclient->redistribute_route_del = sharp_redistribute_route; zclient->opaque_msg_handler = sharp_opaque_handler; - zclient->process_srv6_locator_chunk = sharp_zebra_process_srv6_locator_chunk; + zclient->process_srv6_locator_chunk = + sharp_zebra_process_srv6_locator_chunk; } diff --git a/sharpd/sharp_zebra.h b/sharpd/sharp_zebra.h index 043a7405c2..45e26a9b3d 100644 --- a/sharpd/sharp_zebra.h +++ b/sharpd/sharp_zebra.h @@ -39,7 +39,8 @@ extern void sharp_install_routes_helper(struct prefix *p, vrf_id_t vrf_id, uint8_t instance, uint32_t nhgid, const struct nexthop_group *nhg, const struct nexthop_group *backup_nhg, - uint32_t routes, uint32_t flags, char *opaque); + uint32_t routes, uint32_t flags, + char *opaque); extern void sharp_remove_routes_helper(struct prefix *p, vrf_id_t vrf_id, uint8_t instance, uint32_t routes); @@ -67,6 +68,9 @@ extern void sharp_redistribute_vrf(struct vrf *vrf, int source); extern int sharp_zebra_srv6_manager_get_locator_chunk(const char* locator_name); extern int sharp_zebra_srv6_manager_release_locator_chunk(const char *locator_name); +extern int sharp_zebra_srv6_manager_get_locator_chunk(const char *locator_name); +extern int sharp_zebra_srv6_manager_release_locator_chunk( + const char *locator_name); extern void sharp_install_seg6local_route_helper(struct prefix *p, uint8_t instance, enum seg6local_action_t act, diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 705a035de5..f5ce4e795b 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -474,7 +474,7 @@ parse_nexthop_unicast(ns_id_t ns_id, struct rtmsg *rtm, struct rtattr **tb, mpls_label_t labels[MPLS_MAX_LABELS] = {0}; int num_labels = 0; enum seg6local_action_t seg6l_act = SEG6_LOCAL_ACTION_UNSPEC; - struct seg6local_context seg6l_ctx = {{0}}; + struct seg6local_context seg6l_ctx = { {0} }; struct in6_addr seg6_segs = {0}; int num_segs = 0; @@ -556,7 +556,7 @@ static uint8_t parse_multipath_nexthops_unicast(ns_id_t ns_id, mpls_label_t labels[MPLS_MAX_LABELS] = {0}; int num_labels = 0; enum seg6local_action_t seg6l_act = SEG6_LOCAL_ACTION_UNSPEC; - struct seg6local_context seg6l_ctx = {{0}}; + struct seg6local_context seg6l_ctx = { {0} }; struct in6_addr seg6_segs = {0}; int num_segs = 0; struct rtattr *rtnh_tb[RTA_MAX + 1] = {}; @@ -1336,6 +1336,7 @@ static size_t fill_seg6ipt_encap(char *buffer, size_t buflen, struct seg6_iptunnel_encap *ipt; struct ipv6_sr_hdr *srh; const size_t srhlen = 24; + memset(buffer, 0, buflen); ipt = (struct seg6_iptunnel_encap *)buffer; @@ -2479,16 +2480,16 @@ ssize_t netlink_nexthop_msg_encode(uint16_t cmd, break; case SEG6_LOCAL_ACTION_END_DX4: nl_attr_put32(&req->n, buflen, - SEG6_LOCAL_ACTION, - SEG6_LOCAL_ACTION_END_DX4); + SEG6_LOCAL_ACTION, + SEG6_LOCAL_ACTION_END_DX4); nl_attr_put(&req->n, buflen, SEG6_LOCAL_NH4, &ctx->nh4, sizeof(struct in_addr)); break; case SEG6_LOCAL_ACTION_END_DT6: nl_attr_put32(&req->n, buflen, - SEG6_LOCAL_ACTION, - SEG6_LOCAL_ACTION_END_DT6); + SEG6_LOCAL_ACTION, + SEG6_LOCAL_ACTION_END_DT6); nl_attr_put32(&req->n, buflen, SEG6_LOCAL_TABLE, ctx->table); diff --git a/zebra/zapi_msg.h b/zebra/zapi_msg.h index 35bb554121..e991dca4f3 100644 --- a/zebra/zapi_msg.h +++ b/zebra/zapi_msg.h @@ -122,8 +122,7 @@ extern int zsend_zebra_srv6_locator_add(struct zserv *client, extern int zsend_zebra_srv6_locator_delete(struct zserv *client, struct srv6_locator *loc); extern int zsend_srv6_manager_get_locator_chunk_response(struct zserv *client, - vrf_id_t vrf_id, - struct srv6_locator *loc); + vrf_id_t vrf_id, struct srv6_locator *loc); #ifdef __cplusplus } diff --git a/zebra/zebra_srv6.c b/zebra/zebra_srv6.c index b4b691e8e0..1e12117ac4 100644 --- a/zebra/zebra_srv6.c +++ b/zebra/zebra_srv6.c @@ -115,6 +115,7 @@ void zebra_srv6_locator_add(struct srv6_locator *locator) void zebra_srv6_locator_delete(struct srv6_locator *locator) { struct zebra_srv6 *srv6 = zebra_srv6_get_default(); + listnode_delete(srv6->locators, locator); } @@ -206,6 +207,8 @@ static int zebra_srv6_manager_get_locator_chunk(struct srv6_locator **loc, const char *locator_name, vrf_id_t vrf_id) { + int ret = 0; + *loc = assign_srv6_locator_chunk(client->proto, client->instance, client->session_id, locator_name); @@ -217,7 +220,6 @@ static int zebra_srv6_manager_get_locator_chunk(struct srv6_locator **loc, (*loc)->name, zebra_route_string(client->proto), client->instance); - int ret = 0; if ((*loc)->status_up) ret = zsend_srv6_manager_get_locator_chunk_response(client, vrf_id, @@ -244,9 +246,8 @@ static int release_srv6_locator_chunk(uint8_t proto, uint16_t instance, struct srv6_locator *loc = NULL; loc = zebra_srv6_locator_lookup(locator_name); - if (!loc) { + if (!loc) return -1; - } if (IS_ZEBRA_DEBUG_PACKET) zlog_debug("%s: Releasing srv6-locator on %s", __func__, diff --git a/zebra/zebra_srv6.h b/zebra/zebra_srv6.h index 751cee6e70..84fcc305bc 100644 --- a/zebra/zebra_srv6.h +++ b/zebra/zebra_srv6.h @@ -65,7 +65,8 @@ extern void zebra_srv6_init(void); extern struct zebra_srv6 *zebra_srv6_get_default(void); extern bool zebra_srv6_is_enable(void); -extern void srv6_manager_client_connect_call(struct zserv *client, vrf_id_t vrf_id); +extern void srv6_manager_client_connect_call(struct zserv *client, + vrf_id_t vrf_id); extern void srv6_manager_get_locator_chunk_call(struct srv6_locator **loc, struct zserv *client, const char *locator_name, diff --git a/zebra/zebra_srv6_vty.c b/zebra/zebra_srv6_vty.c index 73038fad73..e2685141bb 100644 --- a/zebra/zebra_srv6_vty.c +++ b/zebra/zebra_srv6_vty.c @@ -147,30 +147,31 @@ DEFUN (show_srv6_locator_detail, if (uj) { vty_out(vty, "JSON format isn't supported\n"); return CMD_WARNING; - } else { - for (ALL_LIST_ELEMENTS_RO(srv6->locators, node, locator)) { - if (strcmp(locator->name, locator_name) != 0) { - continue; - } + } - prefix2str(&locator->prefix, str, sizeof(str)); - vty_out(vty, "Name: %s\n", locator->name); - vty_out(vty, "Prefix: %s\n", str); - vty_out(vty, "Function-Bit-Len: %u\n", - locator->function_bits_length); - - vty_out(vty, "Chunks:\n"); - struct listnode *node; - struct srv6_locator_chunk *chunk; - for (ALL_LIST_ELEMENTS_RO((struct list *)locator->chunks, node, chunk)) { - prefix2str(&chunk->prefix, str, sizeof(str)); - vty_out(vty, "- prefix: %s, owner: %s\n", str, - zebra_route_string(chunk->proto)); - } + for (ALL_LIST_ELEMENTS_RO(srv6->locators, node, locator)) { + struct listnode *node; + struct srv6_locator_chunk *chunk; + + if (strcmp(locator->name, locator_name) != 0) + continue; + + prefix2str(&locator->prefix, str, sizeof(str)); + vty_out(vty, "Name: %s\n", locator->name); + vty_out(vty, "Prefix: %s\n", str); + vty_out(vty, "Function-Bit-Len: %u\n", + locator->function_bits_length); + + vty_out(vty, "Chunks:\n"); + for (ALL_LIST_ELEMENTS_RO((struct list *)locator->chunks, node, + chunk)) { + prefix2str(&chunk->prefix, str, sizeof(str)); + vty_out(vty, "- prefix: %s, owner: %s\n", str, + zebra_route_string(chunk->proto)); } - } + return CMD_SUCCESS; } @@ -264,16 +265,23 @@ DEFUN (locator_prefix, } else { for (ALL_LIST_ELEMENTS_RO(locator->chunks, node, chunk)) { uint8_t zero[16] = {0}; + if (memcmp(&chunk->prefix.prefix, zero, 16) == 0) { struct zserv *client; struct listnode *client_node; + chunk->prefix = prefix; - for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, client_node, client)) { + for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, + client_node, + client)) { + struct srv6_locator *tmp; + if (client->proto != chunk->proto) continue; - struct srv6_locator *tmp; srv6_manager_get_locator_chunk_call( - &tmp, client, locator->name, VRF_DEFAULT); + &tmp, client, + locator->name, + VRF_DEFAULT); } } } |
