Revision d6a7e2fb proto/ospf/ospf.c

View differences:

proto/ospf/ospf.c
175 175

  
176 176
  if(new->u.ospf.metric1=LSINFINITY) return 0;
177 177

  
178
  /* External paths are always longer that internal */
178 179
  if(((new->attrs->source==RTS_OSPF) || (new->attrs->source==RTS_OSPF_IA))
179 180
    && (old->attrs->source==RTS_OSPF_EXT)) return 1;
180

  
181 181
  if(((old->attrs->source==RTS_OSPF) || (old->attrs->source==RTS_OSPF_IA))
182 182
    && (new->attrs->source==RTS_OSPF_EXT)) return 0;
183 183

  
184
  if(new->u.ospf.metric2!=0)
184
  if(new->u.ospf.metric2<old->u.ospf.metric2)
185 185
  {
186
    if(old->u.ospf.metric2==0) return 0;
187
    if(new->u.ospf.metric2<old->u.ospf.metric2) return 1;
188
    return 0;
186
    if(old->u.ospf.metric2==LSINFINITY) return 0; /* Old is E1, new is E2 */
187
    return 1;	/* Both are E2 */
189 188
  }
190
  else
189
	
190
  if(new->u.ospf.metric2>old->u.ospf.metric2)
191 191
  {
192
    if(old->u.ospf.metric2!=0) return 1;
193
    if(new->u.ospf.metric1<old->u.ospf.metric1) return 1;
194
    return 0;
192
    if(new->u.ospf.metric2==LSINFINITY) return 1; /* New is E1, old is E2 */
193
    return 0;	/* Both are E2 */
195 194
  }
195

  
196
  /* 
197
   * E2 metrics are the same. It means that:
198
   * 1) Paths are E2 with same metric
199
   * 2) Paths are E1.
200
   */
201

  
202
  if(new->u.ospf.metric1<old->u.ospf.metric1) return 1;
203
  return 0;	/* Old is shorter or same */
196 204
}
197 205

  
198 206
static int
......
419 427
  if(rte->attrs->source==RTS_OSPF) type='I';
420 428
  buf += bsprintf(buf, " %c", type);
421 429
  if(met!=' ') buf += bsprintf(buf, "%c", met);
422
  buf += bsprintf(buf, " (%d/%d)", rte->pref,
423
    (rte->u.ospf.metric2==LSINFINITY) ? rte->u.ospf.metric1 :
424
    rte->u.ospf.metric2);
430
  buf += bsprintf(buf, " (%d/%d", rte->pref, rte->u.ospf.metric1);
431
  if(rte->u.ospf.metric2!=LSINFINITY) buf += bsprintf(buf, "/%d", rte->u.ospf.metric2);
432
  buf += bsprintf(buf, ")");
425 433
  if(rte->attrs->source==RTS_OSPF_EXT && rte->u.ospf.tag)
426 434
  {
427 435
    buf += bsprintf(buf, " [%x]", rte->u.ospf.tag);

Also available in: Unified diff