]> 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>
Mon, 13 May 2024 06:52:48 +0000 (08:52 +0200)
proto/bgp/packets.c
proto/ospf/rt.c

index 52c082893f2da9475418f6805e8d1dd70b0476ff..77f106e228301a418f352ba72998d2a0d33de505 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 8f28eeb1b57b2728449a3f5025ebc88499e3deff..a435119d3e05ae0a6928e99f44dd638a9492c938 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;
 }