]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_zebra.c
*: Properly use memset() when zeroing
[mirror_frr.git] / bgpd / bgp_zebra.c
index 6691dc56ca40d7d81984e59842945f247701afb2..2c1d561721956c5f4942be8728e147b2b23b03f1 100644 (file)
@@ -882,6 +882,12 @@ bool bgp_zebra_nexthop_set(union sockunion *local, union sockunion *remote,
                         */
                        if (!v6_ll_avail && if_is_loopback(ifp))
                                v6_ll_avail = true;
+                       else {
+                               flog_warn(
+                                       EC_BGP_NO_LL_ADDRESS_AVAILABLE,
+                                       "Interface: %s does not have a v6 LL address associated with it, waiting until one is created for it",
+                                       ifp->name);
+                       }
                } else
                /* Link-local address. */
                {
@@ -1019,7 +1025,7 @@ static bool bgp_tm_chunk_obtained;
 static uint32_t bgp_tm_min, bgp_tm_max, bgp_tm_chunk_size;
 struct bgp *bgp_tm_bgp;
 
-static int bgp_zebra_tm_connect(struct thread *t)
+static void bgp_zebra_tm_connect(struct thread *t)
 {
        struct zclient *zclient;
        int delay = 10, ret = 0;
@@ -1050,7 +1056,6 @@ static int bgp_zebra_tm_connect(struct thread *t)
        }
        thread_add_timer(bm->master, bgp_zebra_tm_connect, zclient, delay,
                         &bgp_tm_thread_connect);
-       return 0;
 }
 
 bool bgp_zebra_tm_chunk_obtained(void)
@@ -1261,6 +1266,7 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
        struct bgp_path_info *mpinfo_cp = &local_info;
        route_tag_t tag;
        mpls_label_t label;
+       struct bgp_sid_info *sid_info;
        int nh_othervrf = 0;
        bool is_evpn;
        bool nh_updated = false;
@@ -1477,9 +1483,22 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
 
                if (mpinfo->extra && !sid_zero(&mpinfo->extra->sid[0].sid)
                    && !CHECK_FLAG(api.flags, ZEBRA_FLAG_EVPN_ROUTE)) {
-                       memcpy(&api_nh->seg6_segs, &mpinfo->extra->sid[0].sid,
+                       sid_info = &mpinfo->extra->sid[0];
+
+                       memcpy(&api_nh->seg6_segs, &sid_info->sid,
                               sizeof(api_nh->seg6_segs));
 
+                       if (sid_info->transposition_len != 0) {
+                               if (!bgp_is_valid_label(
+                                           &mpinfo->extra->label[0]))
+                                       continue;
+
+                               label = label_pton(&mpinfo->extra->label[0]);
+                               transpose_sid(&api_nh->seg6_segs, label,
+                                             sid_info->transposition_offset,
+                                             sid_info->transposition_len);
+                       }
+
                        SET_FLAG(api_nh->flags, ZAPI_NEXTHOP_FLAG_SEG6);
                }
 
@@ -1497,7 +1516,8 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
                        sizeof(bzo.aspath));
 
                if (info->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES))
-                       strlcpy(bzo.community, info->attr->community->str,
+                       strlcpy(bzo.community,
+                               bgp_attr_get_community(info->attr)->str,
                                sizeof(bzo.community));
 
                if (info->attr->flag
@@ -2870,8 +2890,8 @@ static int bgp_zebra_process_local_l3vni(ZAPI_CALLBACK_ARGS)
        ifindex_t svi_ifindex;
        bool is_anycast_mac = false;
 
-       memset(&svi_rmac, 0, sizeof(struct ethaddr));
-       memset(&originator_ip, 0, sizeof(struct in_addr));
+       memset(&svi_rmac, 0, sizeof(svi_rmac));
+       memset(&originator_ip, 0, sizeof(originator_ip));
        s = zclient->ibuf;
        l3vni = stream_getl(s);
        if (cmd == ZEBRA_L3VNI_ADD) {
@@ -3028,7 +3048,7 @@ static int bgp_zebra_process_local_ip_prefix(ZAPI_CALLBACK_ARGS)
        struct bgp *bgp_vrf = NULL;
        struct prefix p;
 
-       memset(&p, 0, sizeof(struct prefix));
+       memset(&p, 0, sizeof(p));
        s = zclient->ibuf;
        stream_get(&p, s, sizeof(struct prefix));
 
@@ -3135,26 +3155,26 @@ static int bgp_zebra_process_srv6_locator_chunk(ZAPI_CALLBACK_ARGS)
        struct stream *s = NULL;
        struct bgp *bgp = bgp_get_default();
        struct listnode *node;
-       struct prefix_ipv6 *c;
-       struct srv6_locator_chunk s6c = {};
-       struct prefix_ipv6 *chunk = NULL;
+       struct srv6_locator_chunk *c;
+       struct srv6_locator_chunk *chunk = srv6_locator_chunk_alloc();
 
        s = zclient->ibuf;
-       zapi_srv6_locator_chunk_decode(s, &s6c);
+       zapi_srv6_locator_chunk_decode(s, chunk);
 
-       if (strcmp(bgp->srv6_locator_name, s6c.locator_name) != 0) {
+       if (strcmp(bgp->srv6_locator_name, chunk->locator_name) != 0) {
                zlog_err("%s: Locator name unmatch %s:%s", __func__,
-                        bgp->srv6_locator_name, s6c.locator_name);
+                        bgp->srv6_locator_name, chunk->locator_name);
+               srv6_locator_chunk_free(chunk);
                return 0;
        }
 
        for (ALL_LIST_ELEMENTS_RO(bgp->srv6_locator_chunks, node, c)) {
-               if (!prefix_cmp(c, &s6c.prefix))
+               if (!prefix_cmp(&c->prefix, &chunk->prefix)) {
+                       srv6_locator_chunk_free(chunk);
                        return 0;
+               }
        }
 
-       chunk = prefix_ipv6_new();
-       *chunk = s6c.prefix;
        listnode_add(bgp->srv6_locator_chunks, chunk);
        vpn_leak_postchange_all();
        return 0;
@@ -3183,7 +3203,7 @@ static int bgp_zebra_process_srv6_locator_delete(ZAPI_CALLBACK_ARGS)
        struct srv6_locator loc = {};
        struct bgp *bgp = bgp_get_default();
        struct listnode *node, *nnode;
-       struct prefix_ipv6 *chunk;
+       struct srv6_locator_chunk *chunk;
        struct bgp_srv6_function *func;
        struct bgp *bgp_vrf;
        struct in6_addr *tovpn_sid;
@@ -3195,7 +3215,7 @@ static int bgp_zebra_process_srv6_locator_delete(ZAPI_CALLBACK_ARGS)
        // refresh chunks
        for (ALL_LIST_ELEMENTS(bgp->srv6_locator_chunks, node, nnode, chunk))
                if (prefix_match((struct prefix *)&loc.prefix,
-                                (struct prefix *)chunk))
+                                (struct prefix *)&chunk->prefix))
                        listnode_delete(bgp->srv6_locator_chunks, chunk);
 
        // refresh functions
@@ -3499,7 +3519,7 @@ void bgp_zebra_announce_default(struct bgp *bgp, struct nexthop *nh,
        if (!vrf_is_backend_netns() && bgp->vrf_id != nh->vrf_id)
                return;
 
-       memset(&p, 0, sizeof(struct prefix));
+       memset(&p, 0, sizeof(p));
        if (afi != AFI_IP && afi != AFI_IP6)
                return;
        p.family = afi2family(afi);
@@ -3600,7 +3620,7 @@ int bgp_zebra_send_capabilities(struct bgp *bgp, bool disable)
        /* Check if capability is already sent. If the flag force is set
         * send the capability since this can be initial bgp configuration
         */
-       memset(&api, 0, sizeof(struct zapi_cap));
+       memset(&api, 0, sizeof(api));
        if (disable) {
                api.cap = ZEBRA_CLIENT_GR_DISABLE;
                api.vrf_id = bgp->vrf_id;
@@ -3680,7 +3700,7 @@ int bgp_zebra_stale_timer_update(struct bgp *bgp)
                return BGP_GR_FAILURE;
        }
 
-       memset(&api, 0, sizeof(struct zapi_cap));
+       memset(&api, 0, sizeof(api));
        api.cap = ZEBRA_CLIENT_RIB_STALE_TIME;
        api.stale_removal_time = bgp->rib_stale_time;
        api.vrf_id = bgp->vrf_id;