]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Fixed annoying undefined values with nexthops
authorMaria Matejka <mq@ucw.cz>
Wed, 3 Apr 2024 16:27:09 +0000 (18:27 +0200)
committerMaria Matejka <mq@ucw.cz>
Sat, 18 May 2024 13:46:53 +0000 (15:46 +0200)
proto/bgp/packets.c
proto/ospf/rt.c

index ce7226454a89133e60725af762ef65a259bfb5fd..aa7e187da89171ed91c51f0cda18123272774602 100644 (file)
@@ -1104,17 +1104,11 @@ bgp_apply_next_hop(struct bgp_parse_state *s, ea_list **to, ip_addr gw, ip_addr
 
     ea_set_attr_u32(to, &ea_gen_igp_metric, 0, c->cf->cost);
 
-    struct nexthop_adata_mpls nam = {
-      .nhad = {
-       .nh = {
-         .gw = nbr->addr,
-         .iface = nbr->iface,
-       },
-       .ad = {
-         .length = NEXTHOP_NEXT(&nam.nhad.nh) - (void *) nam.nhad.ad.data,
-       },
-      },
-    };
+    struct nexthop_adata_mpls nam;
+    memset(&nam, 0, sizeof nam);
+    nam.nhad.nh.gw = nbr->addr;
+    nam.nhad.nh.iface = nbr->iface;
+    nam.nhad.ad.length = NEXTHOP_NEXT(&nam.nhad.nh) - (void *) nam.nhad.ad.data;
     ea_set_attr_data(to, &ea_gen_nexthop, 0, nam.nhad.ad.data, nam.nhad.ad.length);
   }
   else /* GW_RECURSIVE */
index 59ae6cf043d6c103707a536c5fddc37c96b6bb76..6618c866581325f1fec2550d3a2bb11aa04a731a 100644 (file)
@@ -34,15 +34,11 @@ unresolved_vlink(ort *ort)
 static inline struct nexthop_adata *
 new_nexthop(struct ospf_proto *p, ip_addr gw, struct iface *iface, byte weight)
 {
-  struct nexthop_adata *nhad = lp_alloc(p->nhpool, sizeof(struct nexthop_adata));
-  *nhad = (struct nexthop_adata) {
-    .ad = { .length = sizeof *nhad - sizeof nhad->ad, },
-    .nh = {
-      .gw = gw,
-      .iface = iface,
-      .weight = weight,
-    },
-  };
+  struct nexthop_adata *nhad = lp_allocz(p->nhpool, sizeof(struct nexthop_adata));
+  nhad->ad.length = sizeof *nhad - sizeof nhad->ad;
+  nhad->nh.gw = gw;
+  nhad->nh.iface = iface;
+  nhad->nh.weight = weight;
 
   return nhad;
 }