Revision ce1da96e nest/rt-table.c

View differences:

nest/rt-table.c
683 683
}
684 684

  
685 685
static void
686
rt_show_rte(struct cli *c, byte *ia, rte *e, struct rt_show_data *d)
686
rt_show_rte(struct cli *c, byte *ia, rte *e, struct rt_show_data *d, ea_list *tmpa)
687 687
{
688 688
  byte via[STD_ADDRESS_P_LENGTH+32], from[STD_ADDRESS_P_LENGTH+6];
689 689
  byte tm[TM_RELTIME_BUFFER_SIZE], info[256];
......
695 695
    bsprintf(from, " from %I", a->from);
696 696
  else
697 697
    from[0] = 0;
698
  if (a->proto->proto->get_route_info || d->verbose)
699
    {
700
      /* Need to normalize the extended attributes */
701
      ea_list *t = tmpa;
702
      t = ea_append(t, a->eattrs);
703
      tmpa = alloca(ea_scan(t));
704
      ea_merge(t, tmpa);
705
    }
698 706
  if (a->proto->proto->get_route_info)
699
    a->proto->proto->get_route_info(e, info);
707
    a->proto->proto->get_route_info(e, info, tmpa);
700 708
  else
701 709
    bsprintf(info, " (%d)", e->pref);
702 710
  cli_printf(c, -1007, "%-18s %s [%s %s%s]%s", ia, via, a->proto->name, tm, from, info);
703 711
  if (d->verbose)
704
    rta_show(c, a);
712
    rta_show(c, a, tmpa);
705 713
}
706 714

  
707 715
static void
......
709 717
{
710 718
  rte *e, *ee;
711 719
  byte ia[STD_ADDRESS_P_LENGTH+8];
720
  int ok;
712 721

  
713 722
  bsprintf(ia, "%I/%d", n->n.prefix, n->n.pxlen);
714 723
  for(e=n->routes; e; e=e->next)
715 724
    {
716
      struct ea_list *tmpa = NULL;
725
      struct ea_list *tmpa, *old_tmpa;
726
      struct proto *p0 = e->attrs->proto;
727
      struct proto *p1 = d->import_protocol;
717 728
      ee = e;
718 729
      rte_update_lock();		/* We use the update buffer for filtering */
719
      if (d->filter == FILTER_ACCEPT || f_run(d->filter, &ee, &tmpa, rte_update_pool, 0) <= F_ACCEPT)
730
      old_tmpa = tmpa = p0->make_tmp_attrs ? p0->make_tmp_attrs(e, rte_update_pool) : NULL;
731
      ok = (d->filter == FILTER_ACCEPT || f_run(d->filter, &e, &tmpa, rte_update_pool, FF_FORCE_TMPATTR) <= F_ACCEPT);
732
      if (ok && d->import_mode)
733
	{
734
	  int ic = (p1->import_control ? p1->import_control(p1, &e, &tmpa, rte_update_pool) : 0);
735
	  if (ic < 0)
736
	    ok = 0;
737
	  else if (!ic && d->import_mode > 1)
738
	    {
739
	      if (p1->out_filter == FILTER_REJECT ||
740
		  p1->out_filter && f_run(p1->out_filter, &e, &tmpa, rte_update_pool, FF_FORCE_TMPATTR) > F_ACCEPT)
741
		ok = 0;
742
	    }
743
	}
744
      if (ok)
720 745
	{
721
	  rt_show_rte(c, ia, e, d);
746
	  rt_show_rte(c, ia, e, d, tmpa);
722 747
	  ia[0] = 0;
723 748
	}
724 749
      if (e != ee)
725 750
	rte_free(ee);
726 751
      rte_update_unlock();
752
      if (d->import_mode)		/* In import mode, accept only the primary route */
753
	break;
727 754
    }
728 755
}
729 756

  
......
742 769
  FIB_ITERATE_START(fib, it, f)
743 770
    {
744 771
      net *n = (net *) f;
772
      if (d->running_on_config && d->running_on_config != config)
773
	{
774
	  cli_printf(c, 8004, "Stopped due to reconfiguration");
775
	  goto done;
776
	}
777
      if (d->import_protocol &&
778
	  d->import_protocol->core_state != FS_HAPPY &&
779
	  d->import_protocol->core_state != FS_FEEDING)
780
	{
781
	  cli_printf(c, 8005, "Protocol is down");
782
	  goto done;
783
	}
745 784
      if (!max--)
746 785
	{
747 786
	  FIB_ITERATE_PUT(it, f);
......
751 790
    }
752 791
  FIB_ITERATE_END(f);
753 792
  cli_printf(c, 0, "");
793
done:
754 794
  c->cont = c->cleanup = NULL;
755 795
}
756 796

  

Also available in: Unified diff