Revision a7a7372a proto/ospf/topology.h

View differences:

proto/ospf/topology.h
18 18
				   in intra-area routing table calculation */
19 19
  struct top_hash_entry *next;	/* Next in hash chain */
20 20
  struct ospf_lsa_header lsa;
21
  u16 lsa_type;			/* lsa.type processed and converted to common values */	
21
  u16 lsa_type;			/* lsa.type processed and converted to common values (LSA_T_*) */	
22 22
  u16 init_age;			/* Initial value for lsa.age during inst_time */
23 23
  u32 domain;			/* Area ID for area-wide LSAs, Iface ID for link-wide LSAs */
24 24
  //  struct ospf_area *oa;
......
37 37
#define OUTSPF 0
38 38
#define CANDIDATE 1
39 39
#define INSPF 2
40
  u8 rtcalc;			/* LSA generated during RT calculation (LSA_RTCALC or LSA_STALE)*/
40
  u8 mode;			/* LSA generated during RT calculation (LSA_RTCALC or LSA_STALE)*/
41 41
  u8 nhs_reuse;			/* Whether nhs nodes can be reused during merging.
42 42
				   See a note in rt.c:merge_nexthops() */
43 43
};
44 44

  
45
#define LSA_RTCALC	1
46
#define LSA_STALE	2
45

  
46
/* Prevents ospf_hash_find() to ignore the entry, for p->lsrqh and p->lsrth */
47
#define LSA_BODY_DUMMY ((void *) 1)
48

  
49
/*
50
 * LSA entry life cycle
51
 *
52
 * LSA entries are created by ospf_originate_lsa() (for locally originated LSAs)
53
 * or ospf_install_lsa() (for LSAs received from neighbors). A regular (like
54
 * newly originated) LSA entry has defined lsa_body nad lsa.age < %LSA_MAXAGE.
55
 * When the LSA is requested to be flushed by ospf_flush_lsa(), the lsa.age is
56
 * set to %LSA_MAXAGE and flooded. Flush process is finished asynchronously,
57
 * when (at least) flooding is acknowledged by neighbors. This is detected in
58
 * ospf_update_lsadb(), then ospf_clear_lsa() is called to free the LSA body but
59
 * the LSA entry is kept. Such LSA does not formally exist, we keep an empty
60
 * entry (until regular timeout) to know inst_time and lsa.sn in the case of
61
 * later reorigination. After the timeout, LSA is removed by ospf_remove_lsa().
62
 *
63
 * When LSA origination is requested (by ospf_originate_lsa()). but it is not
64
 * possible to do that immediately (because of MinLSInterval or because the
65
 * sequence number is wrapping), The new LSA is scheduled for later origination
66
 * in next_lsa_* fields of the LSA entry. The later origination is handled by
67
 * ospf_originate_next_lsa() called from ospf_update_lsadb(). We can see that
68
 * both real origination and final flush is asynchronous to ospf_originate_lsa()
69
 * and ospf_flush_lsa().
70
 *
71
 * LSA entry therefore could be in three basic states:
72
 * R - regular (lsa.age < %LSA_MAXAGE, lsa_body != NULL)
73
 * F - flushing (lsa.age == %LSA_MAXAGE, lsa_body != NULL)
74
 * E - empty (lsa.age == %LSA_MAXAGE, lsa_body == NULL)
75
 *
76
 * And these states are doubled based on whether the next LSA is scheduled
77
 * (next_lsa_body != NULL, -n suffix) or not (next_lsa_body == NULL). We also
78
 * use X for a state of non-existentce. We have this basic state graph
79
 * (transitions from any state to R are omitted for clarity):
80
 *
81
 *  X --> R ---> F ---> E --> X
82
 *        | \  / |      |
83
 *        |  \/  |      |
84
 *        |  /\  |      |
85
 *        | /  \ |      |
86
 *        Rn --> Fn --> En
87
 *
88
 * The transitions are:
89
 *
90
 * any state -> R		- new LSA origination requested and executed
91
 * R -> Rn, F -> Fn, E -> En	- new LSA origination requested and postponed
92
 * R -> Fn			- new LSA origination requested, seqnum wrapping
93
 * Rn,Fn,En -> R		- postponed LSA finally originated
94
 * R -> R			- LSA refresh done
95
 * R -> Fn			- LSA refresh with seqnum wrapping
96
 * R -> F, Rn -> Fn		- LSA age timeout
97
 * R,Rn,Fn -> F, En -> E	- LSA flush requested
98
 * F -> E, Fn -> En		- LSA flush done (acknowledged)
99
 * E -> X			- LSA real age timeout (or immediate for received LSA)
100
 *
101
 * The 'origination requested' and 'flush requested' transitions are triggered
102
 * and done by ospf_originate_lsa() and ospf_flush_lsa(), the rest is handled
103
 * asynchronously by ospf_update_lsadb().
104
 *
105
 * The situation is significantly simpler for non-local (received) LSAs - there
106
 * is no postponed origination and after flushing is done, LSAs are immediately
107
 * removed, so it is just X -> R -> F -> X, or X -> F -> X (when MaxAge LSA is
108
 * received).
109
 *
110
 * There are also some special cases related to handling of received unknown
111
 * self-originated LSAs in ospf_advance_lsa():
112
 * X -> F		- LSA is received and immediately flushed
113
 * R,Rn -> Fn		- LSA with MaxSeqNo received and flushed, current LSA scheduled
114
 */
115

  
116

  
117
#define LSA_M_BASIC	0
118
#define LSA_M_EXPORT	1
119
#define LSA_M_RTCALC	2
120
#define LSA_M_STALE	3
121

  
122
/*
123
 * LSA entry modes:
124
 *
125
 * LSA_M_BASIC - The LSA is explicitly originated using ospf_originate_lsa() and
126
 * explicitly flushed using ospf_flush_lsa(). When the LSA is changed, the
127
 * routing table calculation is scheduled. This is also the mode used for LSAs
128
 * received from neighbors. Example: Router-LSAs, Network-LSAs.
129
 *
130
 * LSA_M_EXPORT - like LSA_M_BASIC, but the routing table calculation does not
131
 * depend on the LSA. Therefore, the calculation is not scheduled when the LSA
132
 * is changed. Example: AS-external-LSAs for exported routes.
133
 *
134
 * LSA_M_RTCALC - The LSA has to be requested using ospf_originate_lsa() during
135
 * each routing table calculation, otherwise it is flushed automatically at the
136
 * end of the calculation. The LSA is a result of the calculation and not a
137
 * source for it. Therefore, the calculation is not scheduled when the LSA is
138
 * changed. Example: Summary-LSAs.
139
 *
140
 * LSA_M_STALE - Temporary state for LSA_M_RTCALC that is not requested during
141
 * the current routing table calculation.
142
 *
143
 *
144
 * Note that we do not schedule the routing table calculation when the age of
145
 * LSA_M_BASIC LSA is changed to MaxAge because of the sequence number wrapping,
146
 * As it will be switched back to a regular one ASAP.
147
 */
148

  
47 149

  
48 150
struct top_graph
49 151
{
......
61 163
struct ospf_new_lsa
62 164
{
63 165
  u16 type;
166
  u8  mode;
64 167
  u32 dom;
65 168
  u32 id;
66 169
  u16 opts;
......
69 172
  struct ort *nf;
70 173
};
71 174

  
72
struct top_graph *ospf_top_new(pool *);
73
void ospf_top_free(struct top_graph *);
74
void ospf_top_dump(struct top_graph *, struct proto *);
175
struct top_graph *ospf_top_new(struct ospf_proto *p, pool *pool);
176
void ospf_top_free(struct top_graph *f);
75 177

  
76 178
struct top_hash_entry * ospf_install_lsa(struct ospf_proto *p, struct ospf_lsa_header *lsa, u32 type, u32 domain, void *body);
77 179
struct top_hash_entry * ospf_originate_lsa(struct ospf_proto *p, struct ospf_new_lsa *lsa);
......
84 186

  
85 187
void ospf_originate_sum_net_lsa(struct ospf_proto *p, struct ospf_area *oa, ort *nf, int metric);
86 188
void ospf_originate_sum_rt_lsa(struct ospf_proto *p, struct ospf_area *oa, ort *nf, int metric, u32 options);
87
void ospf_originate_ext_lsa(struct ospf_proto *p, struct ospf_area *oa, ort *nf, u8 rtcalc, u32 metric, u32 ebit, ip_addr fwaddr, u32 tag, int pbit);
189
void ospf_originate_ext_lsa(struct ospf_proto *p, struct ospf_area *oa, ort *nf, u8 mode, u32 metric, u32 ebit, ip_addr fwaddr, u32 tag, int pbit);
88 190

  
89 191
void ospf_rt_notify(struct proto *P, rtable *tbl, net *n, rte *new, rte *old, ea_list *attrs);
90 192
void ospf_update_topology(struct ospf_proto *p);

Also available in: Unified diff