Revision 62e64905 proto/static/config.Y

View differences:

proto/static/config.Y
13 13
CF_DEFINES
14 14

  
15 15
#define STATIC_CFG ((struct static_config *) this_proto)
16
static struct static_route *this_srt, *last_srt;
16
static struct static_route *this_srt, *this_snh;
17 17
static struct f_inst **this_srt_last_cmd;
18 18

  
19
static struct static_route *
20
static_nexthop_new(void)
21
{
22
  struct static_route *nh;
23

  
24
  if (!this_snh)
25
  {
26
    /* First next hop */
27
    nh = this_srt;
28
    rem_node(&this_srt->n);
29
  }
30
  else
31
  {
32
    /* Additional next hop */
33
    nh = cfg_allocz(sizeof(struct static_route));
34
    nh->net = this_srt->net;
35
    this_snh->mp_next = nh;
36
  }
37

  
38
  nh->dest = RTD_UNICAST;
39
  nh->mp_head = this_srt;
40
  return nh;
41
};
42

  
19 43
static void
20 44
static_route_finish(void)
21 45
{ }
......
45 69
 | static_proto stat_route stat_route_opt_list ';' { static_route_finish(); }
46 70
 ;
47 71

  
48
stat_nexthop_via: VIA
49
{
50
  if (last_srt)
51
  {
52
    last_srt = (last_srt->mp_next = cfg_allocz(sizeof(struct static_route)));
53
    last_srt->net = this_srt->net;
54
  }
55
  else
56
  {
57
    last_srt = this_srt;
58
    rem_node(&this_srt->n);
59
  }
60

  
61
  last_srt->mp_head = this_srt;
62
  last_srt->dest = RTD_UNICAST;
63
};
64

  
65
stat_nexthop_ident:
66
    stat_nexthop_via ipa ipa_scope {
67
      last_srt->via = $2;
68
      last_srt->iface = $3;
69
      add_tail(&STATIC_CFG->neigh_routes, &last_srt->n);
72
stat_nexthop:
73
    VIA ipa ipa_scope {
74
      this_snh = static_nexthop_new();
75
      this_snh->via = $2;
76
      this_snh->iface = $3;
77
      add_tail(&STATIC_CFG->neigh_routes, &this_snh->n);
70 78
    }
71
  | stat_nexthop_via TEXT {
72
      last_srt->via = IPA_NONE;
73
      last_srt->if_name = $2;
74
      add_tail(&STATIC_CFG->iface_routes, &last_srt->n);
79
  | VIA TEXT {
80
      this_snh = static_nexthop_new();
81
      this_snh->via = IPA_NONE;
82
      this_snh->if_name = $2;
83
      add_tail(&STATIC_CFG->iface_routes, &this_snh->n);
75 84
    }
76
  | stat_nexthop_ident MPLS label_stack {
77
    last_srt->label_count = $3[0];
78
    last_srt->label_stack = &($3[1]);
85
  | stat_nexthop MPLS label_stack {
86
    this_snh->label_count = $3[0];
87
    this_snh->label_stack = &($3[1]);
79 88
  }
80
  | stat_nexthop_ident WEIGHT expr {
81
    last_srt->weight = $3 - 1;
89
  | stat_nexthop WEIGHT expr {
90
    this_snh->weight = $3 - 1;
82 91
    if (($3<1) || ($3>256)) cf_error("Weight must be in range 1-256");
83 92
  }
84
  | stat_nexthop_ident BFD bool { last_srt->use_bfd = $3; cf_check_bfd($3); }
93
  | stat_nexthop BFD bool {
94
    this_snh->use_bfd = $3; cf_check_bfd($3);
95
  }
85 96
;
86 97

  
87
stat_nexthop:
88
    stat_nexthop_ident
89
  | stat_nexthop stat_nexthop_ident
98
stat_nexthops:
99
    stat_nexthop
100
  | stat_nexthops stat_nexthop
90 101
;
91 102

  
92 103
stat_route0: ROUTE net_any {
......
95 106
     this_srt->net = $2;
96 107
     this_srt_last_cmd = &(this_srt->cmds);
97 108
     this_srt->mp_next = NULL;
98
     last_srt = NULL;
109
     this_snh = NULL;
99 110
  }
100 111
 ;
101 112

  
102 113
stat_route:
103
   stat_route0 stat_nexthop
114
   stat_route0 stat_nexthops
104 115
 | stat_route0 RECURSIVE ipa {
105 116
      this_srt->dest = RTDX_RECURSIVE;
106 117
      this_srt->via = $3;

Also available in: Unified diff