Revision 62e64905 proto/rip/rip.c

View differences:

proto/rip/rip.c
147 147
      .src = p->p.main_source,
148 148
      .source = RTS_RIP,
149 149
      .scope = SCOPE_UNIVERSE,
150
      .dest = RTD_UNICAST,
150 151
    };
151 152

  
152 153
    u8 rt_metric = rt->metric;
153 154
    u16 rt_tag = rt->tag;
154
    struct rip_rte *rt2 = rt->next;
155 155

  
156
    /* Find second valid rte */
157
    while (rt2 && !rip_valid_rte(rt2))
158
      rt2 = rt2->next;
159

  
160
    a0.dest = RTD_UNICAST;
161
    if (p->ecmp && rt2)
156
    if (p->ecmp)
162 157
    {
163 158
      /* ECMP route */
159
      struct nexthop *nhs = NULL;
164 160
      int num = 0;
165 161

  
166 162
      for (rt = en->routes; rt && (num < p->ecmp); rt = rt->next)
......
168 164
	if (!rip_valid_rte(rt))
169 165
	    continue;
170 166

  
171
	struct nexthop *nh = (a0.nh.next ? &(a0.nh) : alloca(sizeof(struct nexthop)));
167
	struct nexthop *nh = allocz(sizeof(struct nexthop));
172 168

  
173 169
	nh->gw = rt->next_hop;
174 170
	nh->iface = rt->from->nbr->iface;
175 171
	nh->weight = rt->from->ifa->cf->ecmp_weight;
176 172

  
177
	if (a0.nh.next)
178
	  nexthop_insert(&(a0.nh), nh);
179

  
173
	nexthop_insert(&nhs, nh);
180 174
	num++;
181 175

  
182 176
	if (rt->tag != rt_tag)
183 177
	  rt_tag = 0;
184 178
      }
179

  
180
      a0.nh = *nhs;
185 181
    }
186 182
    else
187 183
    {
188 184
      /* Unipath route */
189
      a0.nh.next = NULL;
185
      a0.from = rt->from->nbr->addr;
190 186
      a0.nh.gw = rt->next_hop;
191 187
      a0.nh.iface = rt->from->nbr->iface;
192
      a0.from = rt->from->nbr->addr;
193 188
    }
194 189

  
195 190
    rta *a = rta_lookup(&a0);

Also available in: Unified diff