blob: 89404552b928a22a2ad9360bae53747ab59b9b60 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/*
2 * Zebra connect library for OSPFd
3 * Copyright (C) 1997, 98, 99, 2000 Kunihiro Ishiguro, Toshiaki Takada
4 *
5 * This file is part of GNU Zebra.
6 *
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
21 */
22
23#include <zebra.h>
24
25#include "thread.h"
26#include "command.h"
27#include "network.h"
28#include "prefix.h"
29#include "routemap.h"
30#include "table.h"
31#include "stream.h"
32#include "memory.h"
33#include "zclient.h"
34#include "filter.h"
hassodd669bb2004-05-10 07:43:59 +000035#include "plist.h"
paul718e3742002-12-13 20:15:29 +000036#include "log.h"
37
38#include "ospfd/ospfd.h"
39#include "ospfd/ospf_interface.h"
40#include "ospfd/ospf_ism.h"
41#include "ospfd/ospf_asbr.h"
42#include "ospfd/ospf_asbr.h"
43#include "ospfd/ospf_abr.h"
44#include "ospfd/ospf_lsa.h"
45#include "ospfd/ospf_dump.h"
46#include "ospfd/ospf_route.h"
47#include "ospfd/ospf_zebra.h"
48#ifdef HAVE_SNMP
49#include "ospfd/ospf_snmp.h"
50#endif /* HAVE_SNMP */
51
52/* Zebra structure to hold current status. */
53struct zclient *zclient = NULL;
54
55/* For registering threads. */
56extern struct thread_master *master;
hasso18a6dce2004-10-03 18:18:34 +000057struct in_addr router_id_zebra;
58
59/* Router-id update message from zebra. */
paul4dadc292005-05-06 21:37:42 +000060static int
hasso18a6dce2004-10-03 18:18:34 +000061ospf_router_id_update_zebra (int command, struct zclient *zclient,
Feng Luc99f3482014-10-16 09:52:36 +080062 zebra_size_t length, vrf_id_t vrf_id)
hasso18a6dce2004-10-03 18:18:34 +000063{
64 struct ospf *ospf;
65 struct prefix router_id;
66 zebra_router_id_update_read(zclient->ibuf,&router_id);
67
Andrew J. Schorr7f643eb2006-11-30 16:17:02 +000068 if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
69 {
70 char buf[128];
71 prefix2str(&router_id, buf, sizeof(buf));
72 zlog_debug("Zebra rcvd: router id update %s", buf);
73 }
74
hasso18a6dce2004-10-03 18:18:34 +000075 router_id_zebra = router_id.u.prefix4;
76
77 ospf = ospf_lookup ();
paulb29800a2005-11-20 14:50:45 +000078
hasso18a6dce2004-10-03 18:18:34 +000079 if (ospf != NULL)
paulb29800a2005-11-20 14:50:45 +000080 ospf_router_id_update (ospf);
81
hasso18a6dce2004-10-03 18:18:34 +000082 return 0;
83}
paul718e3742002-12-13 20:15:29 +000084
85/* Inteface addition message from zebra. */
paul4dadc292005-05-06 21:37:42 +000086static int
Feng Luc99f3482014-10-16 09:52:36 +080087ospf_interface_add (int command, struct zclient *zclient, zebra_size_t length,
88 vrf_id_t vrf_id)
paul718e3742002-12-13 20:15:29 +000089{
90 struct interface *ifp;
91
Feng Luc99f3482014-10-16 09:52:36 +080092 ifp = zebra_interface_add_read (zclient->ibuf, vrf_id);
paul718e3742002-12-13 20:15:29 +000093
94 if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
Stephen Hemminger30d20592009-07-28 11:58:51 +010095 zlog_debug ("Zebra: interface add %s index %d flags %llx metric %d mtu %d",
96 ifp->name, ifp->ifindex, (unsigned long long)ifp->flags,
97 ifp->metric, ifp->mtu);
paul718e3742002-12-13 20:15:29 +000098
paulcf795c52003-06-19 02:13:25 +000099 assert (ifp->info);
paulf2c80652002-12-13 21:44:27 +0000100
paul718e3742002-12-13 20:15:29 +0000101 if (!OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), type))
102 {
103 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
ajsbc18d612004-12-15 15:07:19 +0000104 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +0000105 }
106
Joakim Tjernlunda49eb302008-09-02 19:06:31 +0100107 ospf_if_update (NULL, ifp);
paul718e3742002-12-13 20:15:29 +0000108
109#ifdef HAVE_SNMP
110 ospf_snmp_if_update (ifp);
111#endif /* HAVE_SNMP */
112
113 return 0;
114}
115
paul4dadc292005-05-06 21:37:42 +0000116static int
paul718e3742002-12-13 20:15:29 +0000117ospf_interface_delete (int command, struct zclient *zclient,
Feng Luc99f3482014-10-16 09:52:36 +0800118 zebra_size_t length, vrf_id_t vrf_id)
paul718e3742002-12-13 20:15:29 +0000119{
120 struct interface *ifp;
121 struct stream *s;
122 struct route_node *rn;
123
paulcf795c52003-06-19 02:13:25 +0000124 s = zclient->ibuf;
paul718e3742002-12-13 20:15:29 +0000125 /* zebra_interface_state_read() updates interface structure in iflist */
Feng Luc99f3482014-10-16 09:52:36 +0800126 ifp = zebra_interface_state_read (s, vrf_id);
paul718e3742002-12-13 20:15:29 +0000127
128 if (ifp == NULL)
129 return 0;
130
131 if (if_is_up (ifp))
132 zlog_warn ("Zebra: got delete of %s, but interface is still up",
paulcf795c52003-06-19 02:13:25 +0000133 ifp->name);
134
paul718e3742002-12-13 20:15:29 +0000135 if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
ajs9b0e25c2004-12-08 19:06:51 +0000136 zlog_debug
Andrew Certain0798cee2012-12-04 13:43:42 -0800137 ("Zebra: interface delete %s index %d flags %llx metric %d mtu %d",
138 ifp->name, ifp->ifindex, (unsigned long long)ifp->flags, ifp->metric, ifp->mtu);
paul718e3742002-12-13 20:15:29 +0000139
140#ifdef HAVE_SNMP
141 ospf_snmp_if_delete (ifp);
142#endif /* HAVE_SNMP */
143
144 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
145 if (rn->info)
146 ospf_if_free ((struct ospf_interface *) rn->info);
147
ajsd2fc8892005-04-02 18:38:43 +0000148 ifp->ifindex = IFINDEX_INTERNAL;
paul718e3742002-12-13 20:15:29 +0000149 return 0;
150}
151
ajsd2fc8892005-04-02 18:38:43 +0000152static struct interface *
Feng Luc99f3482014-10-16 09:52:36 +0800153zebra_interface_if_lookup (struct stream *s, vrf_id_t vrf_id)
paul718e3742002-12-13 20:15:29 +0000154{
ajs21fefa92005-04-02 23:16:41 +0000155 char ifname_tmp[INTERFACE_NAMSIZ];
paul718e3742002-12-13 20:15:29 +0000156
157 /* Read interface name. */
158 stream_get (ifname_tmp, s, INTERFACE_NAMSIZ);
159
ajsd2fc8892005-04-02 18:38:43 +0000160 /* And look it up. */
ajs21fefa92005-04-02 23:16:41 +0000161 return if_lookup_by_name_len(ifname_tmp,
162 strnlen(ifname_tmp, INTERFACE_NAMSIZ));
paul718e3742002-12-13 20:15:29 +0000163}
164
paul4dadc292005-05-06 21:37:42 +0000165static int
paul718e3742002-12-13 20:15:29 +0000166ospf_interface_state_up (int command, struct zclient *zclient,
Feng Luc99f3482014-10-16 09:52:36 +0800167 zebra_size_t length, vrf_id_t vrf_id)
paul718e3742002-12-13 20:15:29 +0000168{
169 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +0000170 struct ospf_interface *oi;
171 struct route_node *rn;
paulcf795c52003-06-19 02:13:25 +0000172
Feng Luc99f3482014-10-16 09:52:36 +0800173 ifp = zebra_interface_if_lookup (zclient->ibuf, vrf_id);
paul718e3742002-12-13 20:15:29 +0000174
175 if (ifp == NULL)
176 return 0;
177
178 /* Interface is already up. */
paul2e3b2e42002-12-13 21:03:13 +0000179 if (if_is_operative (ifp))
paul718e3742002-12-13 20:15:29 +0000180 {
181 /* Temporarily keep ifp values. */
ajsa608bbf2005-03-29 17:03:49 +0000182 struct interface if_tmp;
paul718e3742002-12-13 20:15:29 +0000183 memcpy (&if_tmp, ifp, sizeof (struct interface));
184
185 zebra_interface_if_set_value (zclient->ibuf, ifp);
186
187 if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
ajs9b0e25c2004-12-08 19:06:51 +0000188 zlog_debug ("Zebra: Interface[%s] state update.", ifp->name);
paul718e3742002-12-13 20:15:29 +0000189
190 if (if_tmp.bandwidth != ifp->bandwidth)
paulcf795c52003-06-19 02:13:25 +0000191 {
192 if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
ajs9b0e25c2004-12-08 19:06:51 +0000193 zlog_debug ("Zebra: Interface[%s] bandwidth change %d -> %d.",
paulcf795c52003-06-19 02:13:25 +0000194 ifp->name, if_tmp.bandwidth, ifp->bandwidth);
paul718e3742002-12-13 20:15:29 +0000195
paulcf795c52003-06-19 02:13:25 +0000196 ospf_if_recalculate_output_cost (ifp);
197 }
ajsa608bbf2005-03-29 17:03:49 +0000198
199 if (if_tmp.mtu != ifp->mtu)
200 {
201 if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
202 zlog_debug ("Zebra: Interface[%s] MTU change %u -> %u.",
203 ifp->name, if_tmp.mtu, ifp->mtu);
204
205 /* Must reset the interface (simulate down/up) when MTU changes. */
206 ospf_if_reset(ifp);
207 }
paul718e3742002-12-13 20:15:29 +0000208 return 0;
209 }
paulcf795c52003-06-19 02:13:25 +0000210
paul718e3742002-12-13 20:15:29 +0000211 zebra_interface_if_set_value (zclient->ibuf, ifp);
paulcf795c52003-06-19 02:13:25 +0000212
paul718e3742002-12-13 20:15:29 +0000213 if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
ajs9b0e25c2004-12-08 19:06:51 +0000214 zlog_debug ("Zebra: Interface[%s] state change to up.", ifp->name);
paulcf795c52003-06-19 02:13:25 +0000215
216 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +0000217 {
paulcf795c52003-06-19 02:13:25 +0000218 if ((oi = rn->info) == NULL)
219 continue;
220
paul718e3742002-12-13 20:15:29 +0000221 ospf_if_up (oi);
222 }
paulcf795c52003-06-19 02:13:25 +0000223
paul718e3742002-12-13 20:15:29 +0000224 return 0;
225}
226
paul4dadc292005-05-06 21:37:42 +0000227static int
paul718e3742002-12-13 20:15:29 +0000228ospf_interface_state_down (int command, struct zclient *zclient,
Feng Luc99f3482014-10-16 09:52:36 +0800229 zebra_size_t length, vrf_id_t vrf_id)
paul718e3742002-12-13 20:15:29 +0000230{
231 struct interface *ifp;
232 struct ospf_interface *oi;
233 struct route_node *node;
234
Feng Luc99f3482014-10-16 09:52:36 +0800235 ifp = zebra_interface_state_read (zclient->ibuf, vrf_id);
paul718e3742002-12-13 20:15:29 +0000236
237 if (ifp == NULL)
238 return 0;
239
240 if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
ajs9b0e25c2004-12-08 19:06:51 +0000241 zlog_debug ("Zebra: Interface[%s] state change to down.", ifp->name);
paul718e3742002-12-13 20:15:29 +0000242
paulcf795c52003-06-19 02:13:25 +0000243 for (node = route_top (IF_OIFS (ifp)); node; node = route_next (node))
paul718e3742002-12-13 20:15:29 +0000244 {
paulcf795c52003-06-19 02:13:25 +0000245 if ((oi = node->info) == NULL)
246 continue;
paul718e3742002-12-13 20:15:29 +0000247 ospf_if_down (oi);
248 }
249
250 return 0;
251}
252
paul4dadc292005-05-06 21:37:42 +0000253static int
paul718e3742002-12-13 20:15:29 +0000254ospf_interface_address_add (int command, struct zclient *zclient,
Feng Luc99f3482014-10-16 09:52:36 +0800255 zebra_size_t length, vrf_id_t vrf_id)
paul718e3742002-12-13 20:15:29 +0000256{
257 struct connected *c;
258
Feng Luc99f3482014-10-16 09:52:36 +0800259 c = zebra_interface_address_read (command, zclient->ibuf, vrf_id);
paul718e3742002-12-13 20:15:29 +0000260
261 if (c == NULL)
262 return 0;
263
Andrew J. Schorr7f643eb2006-11-30 16:17:02 +0000264 if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
265 {
266 char buf[128];
267 prefix2str(c->address, buf, sizeof(buf));
268 zlog_debug("Zebra: interface %s address add %s", c->ifp->name, buf);
269 }
270
Joakim Tjernlunda49eb302008-09-02 19:06:31 +0100271 ospf_if_update (NULL, c->ifp);
paul718e3742002-12-13 20:15:29 +0000272
273#ifdef HAVE_SNMP
274 ospf_snmp_if_update (c->ifp);
275#endif /* HAVE_SNMP */
276
277 return 0;
278}
279
paul4dadc292005-05-06 21:37:42 +0000280static int
paul718e3742002-12-13 20:15:29 +0000281ospf_interface_address_delete (int command, struct zclient *zclient,
Feng Luc99f3482014-10-16 09:52:36 +0800282 zebra_size_t length, vrf_id_t vrf_id)
paul718e3742002-12-13 20:15:29 +0000283{
284 struct connected *c;
285 struct interface *ifp;
286 struct ospf_interface *oi;
287 struct route_node *rn;
288 struct prefix p;
289
Feng Luc99f3482014-10-16 09:52:36 +0800290 c = zebra_interface_address_read (command, zclient->ibuf, vrf_id);
paul718e3742002-12-13 20:15:29 +0000291
292 if (c == NULL)
293 return 0;
294
Andrew J. Schorr7f643eb2006-11-30 16:17:02 +0000295 if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
296 {
297 char buf[128];
298 prefix2str(c->address, buf, sizeof(buf));
299 zlog_debug("Zebra: interface %s address delete %s", c->ifp->name, buf);
300 }
301
paul718e3742002-12-13 20:15:29 +0000302 ifp = c->ifp;
303 p = *c->address;
304 p.prefixlen = IPV4_MAX_PREFIXLEN;
305
306 rn = route_node_lookup (IF_OIFS (ifp), &p);
paulcf795c52003-06-19 02:13:25 +0000307 if (!rn)
paul98429f62006-01-10 22:11:54 +0000308 {
309 connected_free (c);
310 return 0;
311 }
paul718e3742002-12-13 20:15:29 +0000312
313 assert (rn->info);
314 oi = rn->info;
Joakim Tjernlundfbb6c862010-03-08 13:58:09 +0100315 route_unlock_node (rn);
paulcf795c52003-06-19 02:13:25 +0000316
paul718e3742002-12-13 20:15:29 +0000317 /* Call interface hook functions to clean up */
318 ospf_if_free (oi);
paulcf795c52003-06-19 02:13:25 +0000319
paul718e3742002-12-13 20:15:29 +0000320#ifdef HAVE_SNMP
321 ospf_snmp_if_update (c->ifp);
322#endif /* HAVE_SNMP */
323
324 connected_free (c);
325
paul718e3742002-12-13 20:15:29 +0000326 return 0;
327}
paul72357f22003-06-19 02:11:23 +0000328
paul718e3742002-12-13 20:15:29 +0000329void
330ospf_zebra_add (struct prefix_ipv4 *p, struct ospf_route *or)
331{
332 u_char message;
333 u_char distance;
334 u_char flags;
335 int psize;
336 struct stream *s;
337 struct ospf_path *path;
hasso52dc7ee2004-09-23 19:18:23 +0000338 struct listnode *node;
paul718e3742002-12-13 20:15:29 +0000339
Feng Luc99f3482014-10-16 09:52:36 +0800340 if (vrf_bitmap_check (zclient->redist[ZEBRA_ROUTE_OSPF], VRF_DEFAULT))
paul718e3742002-12-13 20:15:29 +0000341 {
342 message = 0;
343 flags = 0;
344
345 /* OSPF pass nexthop and metric */
346 SET_FLAG (message, ZAPI_MESSAGE_NEXTHOP);
347 SET_FLAG (message, ZAPI_MESSAGE_METRIC);
348
349 /* Distance value. */
350 distance = ospf_distance_apply (p, or);
351 if (distance)
paul72357f22003-06-19 02:11:23 +0000352 SET_FLAG (message, ZAPI_MESSAGE_DISTANCE);
paul718e3742002-12-13 20:15:29 +0000353
354 /* Make packet. */
355 s = zclient->obuf;
356 stream_reset (s);
357
paul718e3742002-12-13 20:15:29 +0000358 /* Put command, type, flags, message. */
Feng Luc99f3482014-10-16 09:52:36 +0800359 zclient_create_header (s, ZEBRA_IPV4_ROUTE_ADD, VRF_DEFAULT);
paul718e3742002-12-13 20:15:29 +0000360 stream_putc (s, ZEBRA_ROUTE_OSPF);
361 stream_putc (s, flags);
362 stream_putc (s, message);
Denis Ovsienkob4e45f62011-12-05 16:35:14 +0400363 stream_putw (s, SAFI_UNICAST);
paulcf795c52003-06-19 02:13:25 +0000364
paul718e3742002-12-13 20:15:29 +0000365 /* Put prefix information. */
366 psize = PSIZE (p->prefixlen);
367 stream_putc (s, p->prefixlen);
paulcf795c52003-06-19 02:13:25 +0000368 stream_write (s, (u_char *) & p->prefix, psize);
paul718e3742002-12-13 20:15:29 +0000369
370 /* Nexthop count. */
paul96735ee2003-08-10 02:51:22 +0000371 stream_putc (s, or->paths->count);
paul718e3742002-12-13 20:15:29 +0000372
373 /* Nexthop, ifindex, distance and metric information. */
paul1eb8ef22005-04-07 07:30:20 +0000374 for (ALL_LIST_ELEMENTS_RO (or->paths, node, path))
paul72357f22003-06-19 02:11:23 +0000375 {
Joakim Tjernlundba281d32012-07-07 17:06:13 +0200376 if (path->nexthop.s_addr != INADDR_ANY &&
377 path->ifindex != 0)
378 {
379 stream_putc (s, ZEBRA_NEXTHOP_IPV4_IFINDEX);
380 stream_put_in_addr (s, &path->nexthop);
381 stream_putl (s, path->ifindex);
382 }
383 else if (path->nexthop.s_addr != INADDR_ANY)
paulcf795c52003-06-19 02:13:25 +0000384 {
385 stream_putc (s, ZEBRA_NEXTHOP_IPV4);
386 stream_put_in_addr (s, &path->nexthop);
387 }
388 else
389 {
390 stream_putc (s, ZEBRA_NEXTHOP_IFINDEX);
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +0200391 if (path->ifindex)
392 stream_putl (s, path->ifindex);
paulcf795c52003-06-19 02:13:25 +0000393 else
394 stream_putl (s, 0);
395 }
paul72357f22003-06-19 02:11:23 +0000396
397 if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
398 {
Andrew J. Schorr56b3ea02007-03-14 20:21:43 +0000399 char buf[2][INET_ADDRSTRLEN];
400 zlog_debug("Zebra: Route add %s/%d nexthop %s",
401 inet_ntop(AF_INET, &p->prefix,
402 buf[0], sizeof(buf[0])),
403 p->prefixlen,
404 inet_ntop(AF_INET, &path->nexthop,
405 buf[1], sizeof(buf[1])));
paulcf795c52003-06-19 02:13:25 +0000406 }
407 }
paul718e3742002-12-13 20:15:29 +0000408
409 if (CHECK_FLAG (message, ZAPI_MESSAGE_DISTANCE))
paulcf795c52003-06-19 02:13:25 +0000410 stream_putc (s, distance);
paul718e3742002-12-13 20:15:29 +0000411 if (CHECK_FLAG (message, ZAPI_MESSAGE_METRIC))
paulcf795c52003-06-19 02:13:25 +0000412 {
413 if (or->path_type == OSPF_PATH_TYPE1_EXTERNAL)
414 stream_putl (s, or->cost + or->u.ext.type2_cost);
415 else if (or->path_type == OSPF_PATH_TYPE2_EXTERNAL)
416 stream_putl (s, or->u.ext.type2_cost);
417 else
418 stream_putl (s, or->cost);
419 }
paul718e3742002-12-13 20:15:29 +0000420
421 stream_putw_at (s, 0, stream_get_endp (s));
422
ajs634f9ea2005-04-11 15:51:40 +0000423 zclient_send_message(zclient);
paul718e3742002-12-13 20:15:29 +0000424 }
425}
426
427void
428ospf_zebra_delete (struct prefix_ipv4 *p, struct ospf_route *or)
429{
Joakim Tjernlundba281d32012-07-07 17:06:13 +0200430 u_char message;
431 u_char distance;
432 u_char flags;
433 int psize;
434 struct stream *s;
paul72357f22003-06-19 02:11:23 +0000435 struct ospf_path *path;
Joakim Tjernlundba281d32012-07-07 17:06:13 +0200436 struct listnode *node;
paul718e3742002-12-13 20:15:29 +0000437
Feng Luc99f3482014-10-16 09:52:36 +0800438 if (vrf_bitmap_check (zclient->redist[ZEBRA_ROUTE_OSPF], VRF_DEFAULT))
paul718e3742002-12-13 20:15:29 +0000439 {
Joakim Tjernlundba281d32012-07-07 17:06:13 +0200440 message = 0;
441 flags = 0;
442 /* Distance value. */
443 distance = ospf_distance_apply (p, or);
444 /* Make packet. */
445 s = zclient->obuf;
446 stream_reset (s);
paul718e3742002-12-13 20:15:29 +0000447
Joakim Tjernlundba281d32012-07-07 17:06:13 +0200448 /* Put command, type, flags, message. */
Feng Luc99f3482014-10-16 09:52:36 +0800449 zclient_create_header (s, ZEBRA_IPV4_ROUTE_DELETE, VRF_DEFAULT);
Joakim Tjernlundba281d32012-07-07 17:06:13 +0200450 stream_putc (s, ZEBRA_ROUTE_OSPF);
451 stream_putc (s, flags);
452 stream_putc (s, message);
453 stream_putw (s, SAFI_UNICAST);
paul72357f22003-06-19 02:11:23 +0000454
Joakim Tjernlundba281d32012-07-07 17:06:13 +0200455 /* Put prefix information. */
456 psize = PSIZE (p->prefixlen);
457 stream_putc (s, p->prefixlen);
458 stream_write (s, (u_char *) & p->prefix, psize);
paul72357f22003-06-19 02:11:23 +0000459
Joakim Tjernlundba281d32012-07-07 17:06:13 +0200460 /* Nexthop count. */
461 stream_putc (s, or->paths->count);
462
463 /* Nexthop, ifindex, distance and metric information. */
464 for (ALL_LIST_ELEMENTS_RO (or->paths, node, path))
465 {
466 if (path->nexthop.s_addr != INADDR_ANY &&
467 path->ifindex != 0)
468 {
469 stream_putc (s, ZEBRA_NEXTHOP_IPV4_IFINDEX);
470 stream_put_in_addr (s, &path->nexthop);
471 stream_putl (s, path->ifindex);
472 }
473 else if (path->nexthop.s_addr != INADDR_ANY)
474 {
475 stream_putc (s, ZEBRA_NEXTHOP_IPV4);
476 stream_put_in_addr (s, &path->nexthop);
477 }
478 else
479 {
480 stream_putc (s, ZEBRA_NEXTHOP_IFINDEX);
481 stream_putl (s, path->ifindex);
482 }
483
484 if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
485 {
Andrew J. Schorr56b3ea02007-03-14 20:21:43 +0000486 char buf[2][INET_ADDRSTRLEN];
Christian Frankea25a1262013-11-27 14:36:05 +0000487 zlog_debug("Zebra: Route delete %s/%d nexthop %s",
Joakim Tjernlundba281d32012-07-07 17:06:13 +0200488 inet_ntop(AF_INET, &p->prefix,
489 buf[0], sizeof(buf[0])),
Andrew J. Schorr56b3ea02007-03-14 20:21:43 +0000490 p->prefixlen,
Joakim Tjernlundba281d32012-07-07 17:06:13 +0200491 inet_ntop(AF_INET, &path->nexthop,
Andrew J. Schorr56b3ea02007-03-14 20:21:43 +0000492 buf[1], sizeof(buf[1])));
Joakim Tjernlundba281d32012-07-07 17:06:13 +0200493 }
494 }
495
496 if (CHECK_FLAG (message, ZAPI_MESSAGE_DISTANCE))
497 stream_putc (s, distance);
498 if (CHECK_FLAG (message, ZAPI_MESSAGE_METRIC))
499 {
500 if (or->path_type == OSPF_PATH_TYPE1_EXTERNAL)
501 stream_putl (s, or->cost + or->u.ext.type2_cost);
502 else if (or->path_type == OSPF_PATH_TYPE2_EXTERNAL)
503 stream_putl (s, or->u.ext.type2_cost);
504 else
505 stream_putl (s, or->cost);
506 }
507
508 stream_putw_at (s, 0, stream_get_endp (s));
509
510 zclient_send_message(zclient);
paul718e3742002-12-13 20:15:29 +0000511 }
512}
513
514void
515ospf_zebra_add_discard (struct prefix_ipv4 *p)
516{
517 struct zapi_ipv4 api;
518
Feng Luc99f3482014-10-16 09:52:36 +0800519 if (vrf_bitmap_check (zclient->redist[ZEBRA_ROUTE_OSPF], VRF_DEFAULT))
paul718e3742002-12-13 20:15:29 +0000520 {
Feng Luc99f3482014-10-16 09:52:36 +0800521 api.vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +0000522 api.type = ZEBRA_ROUTE_OSPF;
523 api.flags = ZEBRA_FLAG_BLACKHOLE;
524 api.message = 0;
Denis Ovsienkob4e45f62011-12-05 16:35:14 +0400525 api.safi = SAFI_UNICAST;
paul718e3742002-12-13 20:15:29 +0000526 SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
527 api.nexthop_num = 0;
528 api.ifindex_num = 0;
529
paul0a589352004-05-08 11:48:26 +0000530 zapi_ipv4_route (ZEBRA_IPV4_ROUTE_ADD, zclient, p, &api);
Andrew J. Schorr7f643eb2006-11-30 16:17:02 +0000531
532 if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
533 zlog_debug ("Zebra: Route add discard %s/%d",
534 inet_ntoa (p->prefix), p->prefixlen);
paul718e3742002-12-13 20:15:29 +0000535 }
536}
537
538void
539ospf_zebra_delete_discard (struct prefix_ipv4 *p)
540{
541 struct zapi_ipv4 api;
542
Feng Luc99f3482014-10-16 09:52:36 +0800543 if (vrf_bitmap_check (zclient->redist[ZEBRA_ROUTE_OSPF], VRF_DEFAULT))
paul718e3742002-12-13 20:15:29 +0000544 {
Feng Luc99f3482014-10-16 09:52:36 +0800545 api.vrf_id = VRF_DEFAULT;
paul718e3742002-12-13 20:15:29 +0000546 api.type = ZEBRA_ROUTE_OSPF;
547 api.flags = ZEBRA_FLAG_BLACKHOLE;
548 api.message = 0;
Denis Ovsienkob4e45f62011-12-05 16:35:14 +0400549 api.safi = SAFI_UNICAST;
paul718e3742002-12-13 20:15:29 +0000550 SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
551 api.nexthop_num = 0;
552 api.ifindex_num = 0;
553
paul0a589352004-05-08 11:48:26 +0000554 zapi_ipv4_route (ZEBRA_IPV4_ROUTE_DELETE, zclient, p, &api);
paul72357f22003-06-19 02:11:23 +0000555
556 if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
ajs9b0e25c2004-12-08 19:06:51 +0000557 zlog_debug ("Zebra: Route delete discard %s/%d",
paulcf795c52003-06-19 02:13:25 +0000558 inet_ntoa (p->prefix), p->prefixlen);
paul72357f22003-06-19 02:11:23 +0000559
paul718e3742002-12-13 20:15:29 +0000560 }
561}
562
563int
564ospf_is_type_redistributed (int type)
565{
566 return (DEFAULT_ROUTE_TYPE (type)) ?
Feng Luc99f3482014-10-16 09:52:36 +0800567 vrf_bitmap_check (zclient->default_information, VRF_DEFAULT) : \
568 vrf_bitmap_check (zclient->redist[type], VRF_DEFAULT);
paul718e3742002-12-13 20:15:29 +0000569}
570
571int
paul020709f2003-04-04 02:44:16 +0000572ospf_redistribute_set (struct ospf *ospf, int type, int mtype, int mvalue)
paul718e3742002-12-13 20:15:29 +0000573{
574 int force = 0;
paulcf795c52003-06-19 02:13:25 +0000575
paul718e3742002-12-13 20:15:29 +0000576 if (ospf_is_type_redistributed (type))
577 {
paul68980082003-03-25 05:07:42 +0000578 if (mtype != ospf->dmetric[type].type)
paulcf795c52003-06-19 02:13:25 +0000579 {
580 ospf->dmetric[type].type = mtype;
581 force = LSA_REFRESH_FORCE;
582 }
paul68980082003-03-25 05:07:42 +0000583 if (mvalue != ospf->dmetric[type].value)
paulcf795c52003-06-19 02:13:25 +0000584 {
585 ospf->dmetric[type].value = mvalue;
586 force = LSA_REFRESH_FORCE;
587 }
588
paul68980082003-03-25 05:07:42 +0000589 ospf_external_lsa_refresh_type (ospf, type, force);
paulcf795c52003-06-19 02:13:25 +0000590
paul718e3742002-12-13 20:15:29 +0000591 if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
ajs9b0e25c2004-12-08 19:06:51 +0000592 zlog_debug ("Redistribute[%s]: Refresh Type[%d], Metric[%d]",
ajsf52d13c2005-10-01 17:38:06 +0000593 ospf_redist_string(type),
paulcf795c52003-06-19 02:13:25 +0000594 metric_type (ospf, type), metric_value (ospf, type));
595
paul718e3742002-12-13 20:15:29 +0000596 return CMD_SUCCESS;
597 }
598
paul68980082003-03-25 05:07:42 +0000599 ospf->dmetric[type].type = mtype;
600 ospf->dmetric[type].value = mvalue;
paul718e3742002-12-13 20:15:29 +0000601
Feng Luc99f3482014-10-16 09:52:36 +0800602 zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type, VRF_DEFAULT);
paul718e3742002-12-13 20:15:29 +0000603
604 if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
ajs9b0e25c2004-12-08 19:06:51 +0000605 zlog_debug ("Redistribute[%s]: Start Type[%d], Metric[%d]",
ajsf52d13c2005-10-01 17:38:06 +0000606 ospf_redist_string(type),
paulcf795c52003-06-19 02:13:25 +0000607 metric_type (ospf, type), metric_value (ospf, type));
608
paul68980082003-03-25 05:07:42 +0000609 ospf_asbr_status_update (ospf, ++ospf->redistribute);
paul718e3742002-12-13 20:15:29 +0000610
611 return CMD_SUCCESS;
612}
613
614int
paul020709f2003-04-04 02:44:16 +0000615ospf_redistribute_unset (struct ospf *ospf, int type)
paul718e3742002-12-13 20:15:29 +0000616{
617 if (type == zclient->redist_default)
618 return CMD_SUCCESS;
619
paulcf795c52003-06-19 02:13:25 +0000620 if (!ospf_is_type_redistributed (type))
paul718e3742002-12-13 20:15:29 +0000621 return CMD_SUCCESS;
622
Feng Luc99f3482014-10-16 09:52:36 +0800623 zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, type, VRF_DEFAULT);
paulcf795c52003-06-19 02:13:25 +0000624
paul718e3742002-12-13 20:15:29 +0000625 if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
ajs9b0e25c2004-12-08 19:06:51 +0000626 zlog_debug ("Redistribute[%s]: Stop",
ajsf52d13c2005-10-01 17:38:06 +0000627 ospf_redist_string(type));
paul718e3742002-12-13 20:15:29 +0000628
paul68980082003-03-25 05:07:42 +0000629 ospf->dmetric[type].type = -1;
630 ospf->dmetric[type].value = -1;
paul718e3742002-12-13 20:15:29 +0000631
632 /* Remove the routes from OSPF table. */
Paul Jakma6db3a6f2006-05-12 23:02:46 +0000633 ospf_redistribute_withdraw (ospf, type);
paul718e3742002-12-13 20:15:29 +0000634
paul68980082003-03-25 05:07:42 +0000635 ospf_asbr_status_update (ospf, --ospf->redistribute);
paul718e3742002-12-13 20:15:29 +0000636
637 return CMD_SUCCESS;
638}
639
640int
paul020709f2003-04-04 02:44:16 +0000641ospf_redistribute_default_set (struct ospf *ospf, int originate,
paulcf795c52003-06-19 02:13:25 +0000642 int mtype, int mvalue)
paul718e3742002-12-13 20:15:29 +0000643{
Andrew J. Schorr8fb8a502006-10-24 19:04:26 +0000644 ospf->default_originate = originate;
645 ospf->dmetric[DEFAULT_ROUTE].type = mtype;
646 ospf->dmetric[DEFAULT_ROUTE].value = mvalue;
paul020709f2003-04-04 02:44:16 +0000647
paul718e3742002-12-13 20:15:29 +0000648 if (ospf_is_type_redistributed (DEFAULT_ROUTE))
649 {
Andrew J. Schorr8fb8a502006-10-24 19:04:26 +0000650 /* if ospf->default_originate changes value, is calling
651 ospf_external_lsa_refresh_default sufficient to implement
652 the change? */
paul68980082003-03-25 05:07:42 +0000653 ospf_external_lsa_refresh_default (ospf);
paulcf795c52003-06-19 02:13:25 +0000654
paul718e3742002-12-13 20:15:29 +0000655 if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
ajs9b0e25c2004-12-08 19:06:51 +0000656 zlog_debug ("Redistribute[%s]: Refresh Type[%d], Metric[%d]",
ajsf52d13c2005-10-01 17:38:06 +0000657 ospf_redist_string(DEFAULT_ROUTE),
paulcf795c52003-06-19 02:13:25 +0000658 metric_type (ospf, DEFAULT_ROUTE),
659 metric_value (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +0000660 return CMD_SUCCESS;
661 }
662
Feng Luc99f3482014-10-16 09:52:36 +0800663 zclient_redistribute_default (ZEBRA_REDISTRIBUTE_DEFAULT_ADD, zclient,
664 VRF_DEFAULT);
paulcf795c52003-06-19 02:13:25 +0000665
paul718e3742002-12-13 20:15:29 +0000666 if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
ajs9b0e25c2004-12-08 19:06:51 +0000667 zlog_debug ("Redistribute[DEFAULT]: Start Type[%d], Metric[%d]",
paulcf795c52003-06-19 02:13:25 +0000668 metric_type (ospf, DEFAULT_ROUTE),
669 metric_value (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +0000670
paul68980082003-03-25 05:07:42 +0000671 if (ospf->router_id.s_addr == 0)
672 ospf->external_origin |= (1 << DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +0000673 else
Paul Jakma4021b602006-05-12 22:55:41 +0000674 thread_add_timer (master, ospf_default_originate_timer, ospf, 1);
paul718e3742002-12-13 20:15:29 +0000675
paul68980082003-03-25 05:07:42 +0000676 ospf_asbr_status_update (ospf, ++ospf->redistribute);
paul718e3742002-12-13 20:15:29 +0000677
678 return CMD_SUCCESS;
679}
680
681int
paul020709f2003-04-04 02:44:16 +0000682ospf_redistribute_default_unset (struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +0000683{
684 if (!ospf_is_type_redistributed (DEFAULT_ROUTE))
685 return CMD_SUCCESS;
686
paul68980082003-03-25 05:07:42 +0000687 ospf->default_originate = DEFAULT_ORIGINATE_NONE;
688 ospf->dmetric[DEFAULT_ROUTE].type = -1;
689 ospf->dmetric[DEFAULT_ROUTE].value = -1;
paul718e3742002-12-13 20:15:29 +0000690
Feng Luc99f3482014-10-16 09:52:36 +0800691 zclient_redistribute_default (ZEBRA_REDISTRIBUTE_DEFAULT_DELETE, zclient,
692 VRF_DEFAULT);
paul718e3742002-12-13 20:15:29 +0000693
694 if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
ajs9b0e25c2004-12-08 19:06:51 +0000695 zlog_debug ("Redistribute[DEFAULT]: Stop");
paulcf795c52003-06-19 02:13:25 +0000696
paul68980082003-03-25 05:07:42 +0000697 ospf_asbr_status_update (ospf, --ospf->redistribute);
paul718e3742002-12-13 20:15:29 +0000698
699 return CMD_SUCCESS;
700}
701
paul4dadc292005-05-06 21:37:42 +0000702static int
paul020709f2003-04-04 02:44:16 +0000703ospf_external_lsa_originate_check (struct ospf *ospf,
paulcf795c52003-06-19 02:13:25 +0000704 struct external_info *ei)
paul718e3742002-12-13 20:15:29 +0000705{
706 /* If prefix is multicast, then do not originate LSA. */
707 if (IN_MULTICAST (htonl (ei->p.prefix.s_addr)))
708 {
709 zlog_info ("LSA[Type5:%s]: Not originate AS-external-LSA, "
paulcf795c52003-06-19 02:13:25 +0000710 "Prefix belongs multicast", inet_ntoa (ei->p.prefix));
paul718e3742002-12-13 20:15:29 +0000711 return 0;
712 }
713
714 /* Take care of default-originate. */
715 if (is_prefix_default (&ei->p))
paul68980082003-03-25 05:07:42 +0000716 if (ospf->default_originate == DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +0000717 {
Denis Ovsienkobcc6c592011-09-10 23:29:19 +0400718 zlog_info ("LSA[Type5:0.0.0.0]: Not originate AS-external-LSA "
paulcf795c52003-06-19 02:13:25 +0000719 "for default");
720 return 0;
paul718e3742002-12-13 20:15:29 +0000721 }
722
723 return 1;
724}
725
726/* If connected prefix is OSPF enable interface, then do not announce. */
727int
paulcf795c52003-06-19 02:13:25 +0000728ospf_distribute_check_connected (struct ospf *ospf, struct external_info *ei)
paul718e3742002-12-13 20:15:29 +0000729{
Joakim Tjernlund5d8de932009-08-07 13:48:15 +0200730 struct listnode *node;
731 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +0000732
Joakim Tjernlund5d8de932009-08-07 13:48:15 +0200733
734 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
735 if (prefix_match (oi->address, (struct prefix *) &ei->p))
paulcf795c52003-06-19 02:13:25 +0000736 return 0;
paul718e3742002-12-13 20:15:29 +0000737 return 1;
738}
739
740/* return 1 if external LSA must be originated, 0 otherwise */
741int
paul68980082003-03-25 05:07:42 +0000742ospf_redistribute_check (struct ospf *ospf,
paulcf795c52003-06-19 02:13:25 +0000743 struct external_info *ei, int *changed)
paul718e3742002-12-13 20:15:29 +0000744{
745 struct route_map_set_values save_values;
746 struct prefix_ipv4 *p = &ei->p;
747 u_char type = is_prefix_default (&ei->p) ? DEFAULT_ROUTE : ei->type;
paulcf795c52003-06-19 02:13:25 +0000748
paul718e3742002-12-13 20:15:29 +0000749 if (changed)
750 *changed = 0;
751
paul020709f2003-04-04 02:44:16 +0000752 if (!ospf_external_lsa_originate_check (ospf, ei))
paul718e3742002-12-13 20:15:29 +0000753 return 0;
754
755 /* Take care connected route. */
paul68980082003-03-25 05:07:42 +0000756 if (type == ZEBRA_ROUTE_CONNECT &&
757 !ospf_distribute_check_connected (ospf, ei))
paul718e3742002-12-13 20:15:29 +0000758 return 0;
759
paul020709f2003-04-04 02:44:16 +0000760 if (!DEFAULT_ROUTE_TYPE (type) && DISTRIBUTE_NAME (ospf, type))
paul718e3742002-12-13 20:15:29 +0000761 /* distirbute-list exists, but access-list may not? */
paul020709f2003-04-04 02:44:16 +0000762 if (DISTRIBUTE_LIST (ospf, type))
763 if (access_list_apply (DISTRIBUTE_LIST (ospf, type), p) == FILTER_DENY)
paulcf795c52003-06-19 02:13:25 +0000764 {
765 if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
ajs9b0e25c2004-12-08 19:06:51 +0000766 zlog_debug ("Redistribute[%s]: %s/%d filtered by ditribute-list.",
ajsf52d13c2005-10-01 17:38:06 +0000767 ospf_redist_string(type),
paulcf795c52003-06-19 02:13:25 +0000768 inet_ntoa (p->prefix), p->prefixlen);
769 return 0;
770 }
paul718e3742002-12-13 20:15:29 +0000771
772 save_values = ei->route_map_set;
773 ospf_reset_route_map_set_values (&ei->route_map_set);
paulcf795c52003-06-19 02:13:25 +0000774
paul718e3742002-12-13 20:15:29 +0000775 /* apply route-map if needed */
paul020709f2003-04-04 02:44:16 +0000776 if (ROUTEMAP_NAME (ospf, type))
paul718e3742002-12-13 20:15:29 +0000777 {
778 int ret;
779
paulcf795c52003-06-19 02:13:25 +0000780 ret = route_map_apply (ROUTEMAP (ospf, type), (struct prefix *) p,
781 RMAP_OSPF, ei);
paul718e3742002-12-13 20:15:29 +0000782
783 if (ret == RMAP_DENYMATCH)
paulcf795c52003-06-19 02:13:25 +0000784 {
785 ei->route_map_set = save_values;
786 if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
ajs9b0e25c2004-12-08 19:06:51 +0000787 zlog_debug ("Redistribute[%s]: %s/%d filtered by route-map.",
ajsf52d13c2005-10-01 17:38:06 +0000788 ospf_redist_string(type),
paulcf795c52003-06-19 02:13:25 +0000789 inet_ntoa (p->prefix), p->prefixlen);
790 return 0;
791 }
792
paul718e3742002-12-13 20:15:29 +0000793 /* check if 'route-map set' changed something */
794 if (changed)
paulcf795c52003-06-19 02:13:25 +0000795 *changed = !ospf_route_map_set_compare (&ei->route_map_set,
796 &save_values);
paul718e3742002-12-13 20:15:29 +0000797 }
798
799 return 1;
800}
801
802/* OSPF route-map set for redistribution */
803void
paul6c835672004-10-11 11:00:30 +0000804ospf_routemap_set (struct ospf *ospf, int type, const char *name)
paul718e3742002-12-13 20:15:29 +0000805{
paul020709f2003-04-04 02:44:16 +0000806 if (ROUTEMAP_NAME (ospf, type))
807 free (ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +0000808
paul020709f2003-04-04 02:44:16 +0000809 ROUTEMAP_NAME (ospf, type) = strdup (name);
810 ROUTEMAP (ospf, type) = route_map_lookup_by_name (name);
paul718e3742002-12-13 20:15:29 +0000811}
812
813void
paul020709f2003-04-04 02:44:16 +0000814ospf_routemap_unset (struct ospf *ospf, int type)
paul718e3742002-12-13 20:15:29 +0000815{
paul020709f2003-04-04 02:44:16 +0000816 if (ROUTEMAP_NAME (ospf, type))
817 free (ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +0000818
paul020709f2003-04-04 02:44:16 +0000819 ROUTEMAP_NAME (ospf, type) = NULL;
820 ROUTEMAP (ospf, type) = NULL;
paul718e3742002-12-13 20:15:29 +0000821}
822
823/* Zebra route add and delete treatment. */
paul4dadc292005-05-06 21:37:42 +0000824static int
paul718e3742002-12-13 20:15:29 +0000825ospf_zebra_read_ipv4 (int command, struct zclient *zclient,
Feng Luc99f3482014-10-16 09:52:36 +0800826 zebra_size_t length, vrf_id_t vrf_id)
paul718e3742002-12-13 20:15:29 +0000827{
828 struct stream *s;
829 struct zapi_ipv4 api;
830 unsigned long ifindex;
831 struct in_addr nexthop;
832 struct prefix_ipv4 p;
833 struct external_info *ei;
paul020709f2003-04-04 02:44:16 +0000834 struct ospf *ospf;
Donald Sharp5e57b5f2016-03-11 16:28:34 -0500835 unsigned char plength = 0;
paul718e3742002-12-13 20:15:29 +0000836
837 s = zclient->ibuf;
838 ifindex = 0;
839 nexthop.s_addr = 0;
840
841 /* Type, flags, message. */
842 api.type = stream_getc (s);
843 api.flags = stream_getc (s);
844 api.message = stream_getc (s);
845
846 /* IPv4 prefix. */
847 memset (&p, 0, sizeof (struct prefix_ipv4));
848 p.family = AF_INET;
Donald Sharp5e57b5f2016-03-11 16:28:34 -0500849 plength = stream_getc (s);
850 p.prefixlen = MIN(IPV4_MAX_PREFIXLEN, plength);
paul718e3742002-12-13 20:15:29 +0000851 stream_get (&p.prefix, s, PSIZE (p.prefixlen));
852
hasso8585d4e2004-04-20 17:25:12 +0000853 if (IPV4_NET127(ntohl(p.prefix.s_addr)))
854 return 0;
855
paul718e3742002-12-13 20:15:29 +0000856 /* Nexthop, ifindex, distance, metric. */
857 if (CHECK_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP))
858 {
859 api.nexthop_num = stream_getc (s);
860 nexthop.s_addr = stream_get_ipv4 (s);
861 }
862 if (CHECK_FLAG (api.message, ZAPI_MESSAGE_IFINDEX))
863 {
864 api.ifindex_num = stream_getc (s);
gdt6a8da852004-02-13 17:40:51 +0000865 /* XXX assert(api.ifindex_num == 1); */
paul718e3742002-12-13 20:15:29 +0000866 ifindex = stream_getl (s);
867 }
868 if (CHECK_FLAG (api.message, ZAPI_MESSAGE_DISTANCE))
869 api.distance = stream_getc (s);
870 if (CHECK_FLAG (api.message, ZAPI_MESSAGE_METRIC))
871 api.metric = stream_getl (s);
872
paul020709f2003-04-04 02:44:16 +0000873 ospf = ospf_lookup ();
874 if (ospf == NULL)
875 return 0;
876
paul718e3742002-12-13 20:15:29 +0000877 if (command == ZEBRA_IPV4_ROUTE_ADD)
878 {
paul7021c422003-07-15 12:52:22 +0000879 /* XXX|HACK|TODO|FIXME:
hassoa0a39762004-04-23 08:51:10 +0000880 * Maybe we should ignore reject/blackhole routes? Testing shows that
881 * there is no problems though and this is only way to "summarize"
882 * routes in ASBR at the moment. Maybe we need just a better generalised
883 * solution for these types?
884 *
885 * if ( CHECK_FLAG (api.flags, ZEBRA_FLAG_BLACKHOLE)
886 * || CHECK_FLAG (api.flags, ZEBRA_FLAG_REJECT))
887 * return 0;
paul7021c422003-07-15 12:52:22 +0000888 */
paul7021c422003-07-15 12:52:22 +0000889
paul718e3742002-12-13 20:15:29 +0000890 ei = ospf_external_info_add (api.type, p, ifindex, nexthop);
891
paul68980082003-03-25 05:07:42 +0000892 if (ospf->router_id.s_addr == 0)
paulcf795c52003-06-19 02:13:25 +0000893 /* Set flags to generate AS-external-LSA originate event
894 for each redistributed protocols later. */
895 ospf->external_origin |= (1 << api.type);
paul718e3742002-12-13 20:15:29 +0000896 else
paulcf795c52003-06-19 02:13:25 +0000897 {
898 if (ei)
899 {
900 if (is_prefix_default (&p))
901 ospf_external_lsa_refresh_default (ospf);
902 else
903 {
904 struct ospf_lsa *current;
paul718e3742002-12-13 20:15:29 +0000905
paulcf795c52003-06-19 02:13:25 +0000906 current = ospf_external_info_find_lsa (ospf, &ei->p);
907 if (!current)
908 ospf_external_lsa_originate (ospf, ei);
909 else if (IS_LSA_MAXAGE (current))
910 ospf_external_lsa_refresh (ospf, current,
911 ei, LSA_REFRESH_FORCE);
912 else
913 zlog_warn ("ospf_zebra_read_ipv4() : %s already exists",
914 inet_ntoa (p.prefix));
915 }
916 }
917 }
paul718e3742002-12-13 20:15:29 +0000918 }
paulcf795c52003-06-19 02:13:25 +0000919 else /* if (command == ZEBRA_IPV4_ROUTE_DELETE) */
paul718e3742002-12-13 20:15:29 +0000920 {
921 ospf_external_info_delete (api.type, p);
paul7021c422003-07-15 12:52:22 +0000922 if (is_prefix_default (&p))
paulcf795c52003-06-19 02:13:25 +0000923 ospf_external_lsa_refresh_default (ospf);
paul7021c422003-07-15 12:52:22 +0000924 else
ajs5339cfd2005-09-19 13:28:05 +0000925 ospf_external_lsa_flush (ospf, api.type, &p, ifindex /*, nexthop */);
paul718e3742002-12-13 20:15:29 +0000926 }
927
928 return 0;
929}
David Lamparter6b0655a2014-06-04 06:53:35 +0200930
paulcf795c52003-06-19 02:13:25 +0000931
paul718e3742002-12-13 20:15:29 +0000932int
paul6c835672004-10-11 11:00:30 +0000933ospf_distribute_list_out_set (struct ospf *ospf, int type, const char *name)
paul718e3742002-12-13 20:15:29 +0000934{
935 /* Lookup access-list for distribute-list. */
paul020709f2003-04-04 02:44:16 +0000936 DISTRIBUTE_LIST (ospf, type) = access_list_lookup (AFI_IP, name);
paul718e3742002-12-13 20:15:29 +0000937
938 /* Clear previous distribute-name. */
paul020709f2003-04-04 02:44:16 +0000939 if (DISTRIBUTE_NAME (ospf, type))
940 free (DISTRIBUTE_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +0000941
942 /* Set distribute-name. */
paul020709f2003-04-04 02:44:16 +0000943 DISTRIBUTE_NAME (ospf, type) = strdup (name);
paul718e3742002-12-13 20:15:29 +0000944
945 /* If access-list have been set, schedule update timer. */
paul020709f2003-04-04 02:44:16 +0000946 if (DISTRIBUTE_LIST (ospf, type))
paul68980082003-03-25 05:07:42 +0000947 ospf_distribute_list_update (ospf, type);
paul718e3742002-12-13 20:15:29 +0000948
949 return CMD_SUCCESS;
950}
951
952int
paul6c835672004-10-11 11:00:30 +0000953ospf_distribute_list_out_unset (struct ospf *ospf, int type, const char *name)
paul718e3742002-12-13 20:15:29 +0000954{
955 /* Schedule update timer. */
paul020709f2003-04-04 02:44:16 +0000956 if (DISTRIBUTE_LIST (ospf, type))
paul68980082003-03-25 05:07:42 +0000957 ospf_distribute_list_update (ospf, type);
paul718e3742002-12-13 20:15:29 +0000958
959 /* Unset distribute-list. */
paul020709f2003-04-04 02:44:16 +0000960 DISTRIBUTE_LIST (ospf, type) = NULL;
paul718e3742002-12-13 20:15:29 +0000961
962 /* Clear distribute-name. */
paul020709f2003-04-04 02:44:16 +0000963 if (DISTRIBUTE_NAME (ospf, type))
964 free (DISTRIBUTE_NAME (ospf, type));
paulcf795c52003-06-19 02:13:25 +0000965
paul020709f2003-04-04 02:44:16 +0000966 DISTRIBUTE_NAME (ospf, type) = NULL;
paul718e3742002-12-13 20:15:29 +0000967
968 return CMD_SUCCESS;
969}
970
971/* distribute-list update timer. */
paul4dadc292005-05-06 21:37:42 +0000972static int
paul718e3742002-12-13 20:15:29 +0000973ospf_distribute_list_update_timer (struct thread *thread)
974{
975 struct route_node *rn;
976 struct external_info *ei;
977 struct route_table *rt;
978 struct ospf_lsa *lsa;
Joakim Tjernlund46154fe2010-04-14 16:01:25 +0200979 int type, default_refresh = 0;
paul020709f2003-04-04 02:44:16 +0000980 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +0000981
paul020709f2003-04-04 02:44:16 +0000982 ospf = ospf_lookup ();
983 if (ospf == NULL)
984 return 0;
985
paul68980082003-03-25 05:07:42 +0000986 ospf->t_distribute_update = NULL;
paul718e3742002-12-13 20:15:29 +0000987
988 zlog_info ("Zebra[Redistribute]: distribute-list update timer fired!");
989
990 /* foreach all external info. */
Joakim Tjernlund274d3f02010-04-14 11:05:27 +0200991 for (type = 0; type <= ZEBRA_ROUTE_MAX; type++)
992 {
993 rt = EXTERNAL_INFO (type);
994 if (!rt)
995 continue;
996 for (rn = route_top (rt); rn; rn = route_next (rn))
997 if ((ei = rn->info) != NULL)
998 {
999 if (is_prefix_default (&ei->p))
Joakim Tjernlund46154fe2010-04-14 16:01:25 +02001000 default_refresh = 1;
Joakim Tjernlund274d3f02010-04-14 11:05:27 +02001001 else if ((lsa = ospf_external_info_find_lsa (ospf, &ei->p)))
1002 ospf_external_lsa_refresh (ospf, lsa, ei, LSA_REFRESH_IF_CHANGED);
1003 else
1004 ospf_external_lsa_originate (ospf, ei);
1005 }
1006 }
Joakim Tjernlund46154fe2010-04-14 16:01:25 +02001007 if (default_refresh)
1008 ospf_external_lsa_refresh_default (ospf);
paul718e3742002-12-13 20:15:29 +00001009 return 0;
1010}
1011
paul718e3742002-12-13 20:15:29 +00001012/* Update distribute-list and set timer to apply access-list. */
1013void
Andrew Certain0798cee2012-12-04 13:43:42 -08001014ospf_distribute_list_update (struct ospf *ospf, uintptr_t type)
paul718e3742002-12-13 20:15:29 +00001015{
1016 struct route_table *rt;
paulcf795c52003-06-19 02:13:25 +00001017
paul718e3742002-12-13 20:15:29 +00001018 /* External info does not exist. */
1019 if (!(rt = EXTERNAL_INFO (type)))
1020 return;
1021
Joakim Tjernlund45acaa02010-04-14 11:05:28 +02001022 /* If exists previously invoked thread, then let it continue. */
paul68980082003-03-25 05:07:42 +00001023 if (ospf->t_distribute_update)
Joakim Tjernlund45acaa02010-04-14 11:05:28 +02001024 return;
paul718e3742002-12-13 20:15:29 +00001025
1026 /* Set timer. */
paul68980082003-03-25 05:07:42 +00001027 ospf->t_distribute_update =
Michael Rossberg2ef762e2015-07-27 07:56:25 +02001028 thread_add_timer_msec (master, ospf_distribute_list_update_timer,
1029 (void *) type, ospf->min_ls_interval);
paul718e3742002-12-13 20:15:29 +00001030}
1031
1032/* If access-list is updated, apply some check. */
paul4dadc292005-05-06 21:37:42 +00001033static void
paul718e3742002-12-13 20:15:29 +00001034ospf_filter_update (struct access_list *access)
1035{
paul020709f2003-04-04 02:44:16 +00001036 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00001037 int type;
1038 int abr_inv = 0;
1039 struct ospf_area *area;
hasso52dc7ee2004-09-23 19:18:23 +00001040 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00001041
1042 /* If OSPF instatnce does not exist, return right now. */
paul020709f2003-04-04 02:44:16 +00001043 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00001044 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00001045 return;
1046
paul718e3742002-12-13 20:15:29 +00001047 /* Update distribute-list, and apply filter. */
hasso01018ce2005-08-05 07:40:15 +00001048 for (type = 0; type <= ZEBRA_ROUTE_MAX; type++)
paul718e3742002-12-13 20:15:29 +00001049 {
paul020709f2003-04-04 02:44:16 +00001050 if (ROUTEMAP (ospf, type) != NULL)
paulcf795c52003-06-19 02:13:25 +00001051 {
1052 /* if route-map is not NULL it may be using this access list */
1053 ospf_distribute_list_update (ospf, type);
1054 continue;
1055 }
1056
hasso01018ce2005-08-05 07:40:15 +00001057 /* There is place for route-map for default-information (ZEBRA_ROUTE_MAX),
1058 * but no distribute list. */
1059 if (type == ZEBRA_ROUTE_MAX)
1060 break;
paul718e3742002-12-13 20:15:29 +00001061
paul020709f2003-04-04 02:44:16 +00001062 if (DISTRIBUTE_NAME (ospf, type))
paulcf795c52003-06-19 02:13:25 +00001063 {
1064 /* Keep old access-list for distribute-list. */
1065 struct access_list *old = DISTRIBUTE_LIST (ospf, type);
1066
1067 /* Update access-list for distribute-list. */
1068 DISTRIBUTE_LIST (ospf, type) =
1069 access_list_lookup (AFI_IP, DISTRIBUTE_NAME (ospf, type));
1070
1071 /* No update for this distribute type. */
1072 if (old == NULL && DISTRIBUTE_LIST (ospf, type) == NULL)
1073 continue;
1074
1075 /* Schedule distribute-list update timer. */
1076 if (DISTRIBUTE_LIST (ospf, type) == NULL ||
1077 strcmp (DISTRIBUTE_NAME (ospf, type), access->name) == 0)
1078 ospf_distribute_list_update (ospf, type);
1079 }
paul718e3742002-12-13 20:15:29 +00001080 }
1081
1082 /* Update Area access-list. */
paul1eb8ef22005-04-07 07:30:20 +00001083 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
1084 {
1085 if (EXPORT_NAME (area))
1086 {
1087 EXPORT_LIST (area) = NULL;
1088 abr_inv++;
1089 }
paul718e3742002-12-13 20:15:29 +00001090
paul1eb8ef22005-04-07 07:30:20 +00001091 if (IMPORT_NAME (area))
1092 {
1093 IMPORT_LIST (area) = NULL;
1094 abr_inv++;
1095 }
1096 }
paul718e3742002-12-13 20:15:29 +00001097
1098 /* Schedule ABR tasks -- this will be changed -- takada. */
paul020709f2003-04-04 02:44:16 +00001099 if (IS_OSPF_ABR (ospf) && abr_inv)
paul68980082003-03-25 05:07:42 +00001100 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001101}
hassodd669bb2004-05-10 07:43:59 +00001102
1103/* If prefix-list is updated, do some updates. */
1104void
1105ospf_prefix_list_update (struct prefix_list *plist)
1106{
1107 struct ospf *ospf;
1108 int type;
1109 int abr_inv = 0;
1110 struct ospf_area *area;
hasso52dc7ee2004-09-23 19:18:23 +00001111 struct listnode *node;
hassodd669bb2004-05-10 07:43:59 +00001112
1113 /* If OSPF instatnce does not exist, return right now. */
1114 ospf = ospf_lookup ();
1115 if (ospf == NULL)
1116 return;
1117
1118 /* Update all route-maps which are used as redistribution filters.
1119 * They might use prefix-list.
1120 */
hasso01018ce2005-08-05 07:40:15 +00001121 for (type = 0; type <= ZEBRA_ROUTE_MAX; type++)
hassodd669bb2004-05-10 07:43:59 +00001122 {
1123 if (ROUTEMAP (ospf, type) != NULL)
1124 {
1125 /* If route-map is not NULL it may be using this prefix list */
1126 ospf_distribute_list_update (ospf, type);
1127 continue;
1128 }
1129 }
1130
1131 /* Update area filter-lists. */
paul1eb8ef22005-04-07 07:30:20 +00001132 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
1133 {
1134 /* Update filter-list in. */
1135 if (PREFIX_NAME_IN (area))
David Lampartere66cbd12015-04-13 10:21:34 +02001136 if (strcmp (PREFIX_NAME_IN (area), prefix_list_name (plist)) == 0)
paul1eb8ef22005-04-07 07:30:20 +00001137 {
1138 PREFIX_LIST_IN (area) =
1139 prefix_list_lookup (AFI_IP, PREFIX_NAME_IN (area));
1140 abr_inv++;
1141 }
hassodd669bb2004-05-10 07:43:59 +00001142
paul1eb8ef22005-04-07 07:30:20 +00001143 /* Update filter-list out. */
1144 if (PREFIX_NAME_OUT (area))
David Lampartere66cbd12015-04-13 10:21:34 +02001145 if (strcmp (PREFIX_NAME_OUT (area), prefix_list_name (plist)) == 0)
paul1eb8ef22005-04-07 07:30:20 +00001146 {
1147 PREFIX_LIST_IN (area) =
1148 prefix_list_lookup (AFI_IP, PREFIX_NAME_OUT (area));
1149 abr_inv++;
1150 }
1151 }
hassodd669bb2004-05-10 07:43:59 +00001152
1153 /* Schedule ABR task. */
1154 if (IS_OSPF_ABR (ospf) && abr_inv)
1155 ospf_schedule_abr_task (ospf);
1156}
paulcf795c52003-06-19 02:13:25 +00001157
paul4dadc292005-05-06 21:37:42 +00001158static struct ospf_distance *
1159ospf_distance_new (void)
paul718e3742002-12-13 20:15:29 +00001160{
Stephen Hemminger393deb92008-08-18 14:13:29 -07001161 return XCALLOC (MTYPE_OSPF_DISTANCE, sizeof (struct ospf_distance));
paul718e3742002-12-13 20:15:29 +00001162}
1163
paul4dadc292005-05-06 21:37:42 +00001164static void
paul718e3742002-12-13 20:15:29 +00001165ospf_distance_free (struct ospf_distance *odistance)
1166{
1167 XFREE (MTYPE_OSPF_DISTANCE, odistance);
1168}
1169
1170int
paul6c835672004-10-11 11:00:30 +00001171ospf_distance_set (struct vty *vty, struct ospf *ospf,
1172 const char *distance_str,
1173 const char *ip_str,
1174 const char *access_list_str)
paul718e3742002-12-13 20:15:29 +00001175{
1176 int ret;
1177 struct prefix_ipv4 p;
1178 u_char distance;
1179 struct route_node *rn;
1180 struct ospf_distance *odistance;
1181
1182 ret = str2prefix_ipv4 (ip_str, &p);
1183 if (ret == 0)
1184 {
1185 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
1186 return CMD_WARNING;
1187 }
1188
1189 distance = atoi (distance_str);
1190
1191 /* Get OSPF distance node. */
paul68980082003-03-25 05:07:42 +00001192 rn = route_node_get (ospf->distance_table, (struct prefix *) &p);
paul718e3742002-12-13 20:15:29 +00001193 if (rn->info)
1194 {
1195 odistance = rn->info;
1196 route_unlock_node (rn);
1197 }
1198 else
1199 {
1200 odistance = ospf_distance_new ();
1201 rn->info = odistance;
1202 }
1203
1204 /* Set distance value. */
1205 odistance->distance = distance;
1206
1207 /* Reset access-list configuration. */
1208 if (odistance->access_list)
1209 {
1210 free (odistance->access_list);
1211 odistance->access_list = NULL;
1212 }
1213 if (access_list_str)
1214 odistance->access_list = strdup (access_list_str);
1215
1216 return CMD_SUCCESS;
1217}
1218
1219int
paul6c835672004-10-11 11:00:30 +00001220ospf_distance_unset (struct vty *vty, struct ospf *ospf,
1221 const char *distance_str,
1222 const char *ip_str, char
1223 const *access_list_str)
paul718e3742002-12-13 20:15:29 +00001224{
1225 int ret;
1226 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00001227 struct route_node *rn;
1228 struct ospf_distance *odistance;
1229
1230 ret = str2prefix_ipv4 (ip_str, &p);
1231 if (ret == 0)
1232 {
1233 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
1234 return CMD_WARNING;
1235 }
1236
paulcf795c52003-06-19 02:13:25 +00001237 rn = route_node_lookup (ospf->distance_table, (struct prefix *) &p);
1238 if (!rn)
paul718e3742002-12-13 20:15:29 +00001239 {
1240 vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE);
1241 return CMD_WARNING;
1242 }
1243
1244 odistance = rn->info;
1245
1246 if (odistance->access_list)
1247 free (odistance->access_list);
1248 ospf_distance_free (odistance);
1249
1250 rn->info = NULL;
1251 route_unlock_node (rn);
1252 route_unlock_node (rn);
1253
1254 return CMD_SUCCESS;
1255}
1256
1257void
paul68980082003-03-25 05:07:42 +00001258ospf_distance_reset (struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00001259{
1260 struct route_node *rn;
1261 struct ospf_distance *odistance;
1262
paul68980082003-03-25 05:07:42 +00001263 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00001264 if ((odistance = rn->info) != NULL)
1265 {
paulcf795c52003-06-19 02:13:25 +00001266 if (odistance->access_list)
1267 free (odistance->access_list);
1268 ospf_distance_free (odistance);
1269 rn->info = NULL;
1270 route_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00001271 }
1272}
1273
1274u_char
1275ospf_distance_apply (struct prefix_ipv4 *p, struct ospf_route *or)
1276{
paul020709f2003-04-04 02:44:16 +00001277 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00001278
paul020709f2003-04-04 02:44:16 +00001279 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00001280 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00001281 return 0;
1282
paul68980082003-03-25 05:07:42 +00001283 if (ospf->distance_intra)
paul718e3742002-12-13 20:15:29 +00001284 if (or->path_type == OSPF_PATH_INTRA_AREA)
paul68980082003-03-25 05:07:42 +00001285 return ospf->distance_intra;
paul718e3742002-12-13 20:15:29 +00001286
paul68980082003-03-25 05:07:42 +00001287 if (ospf->distance_inter)
paul718e3742002-12-13 20:15:29 +00001288 if (or->path_type == OSPF_PATH_INTER_AREA)
paul68980082003-03-25 05:07:42 +00001289 return ospf->distance_inter;
paul718e3742002-12-13 20:15:29 +00001290
paul68980082003-03-25 05:07:42 +00001291 if (ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00001292 if (or->path_type == OSPF_PATH_TYPE1_EXTERNAL
paulcf795c52003-06-19 02:13:25 +00001293 || or->path_type == OSPF_PATH_TYPE2_EXTERNAL)
paul68980082003-03-25 05:07:42 +00001294 return ospf->distance_external;
paulcf795c52003-06-19 02:13:25 +00001295
paul68980082003-03-25 05:07:42 +00001296 if (ospf->distance_all)
1297 return ospf->distance_all;
paul718e3742002-12-13 20:15:29 +00001298
1299 return 0;
1300}
1301
Feng Luc99f3482014-10-16 09:52:36 +08001302static void
1303ospf_zebra_connected (struct zclient *zclient)
1304{
1305 zclient_send_requests (zclient, VRF_DEFAULT);
1306}
1307
paul718e3742002-12-13 20:15:29 +00001308void
Donald Sharp71252932015-09-24 09:25:19 -04001309ospf_zebra_init (struct thread_master *master)
paul718e3742002-12-13 20:15:29 +00001310{
1311 /* Allocate zebra structure. */
Donald Sharp71252932015-09-24 09:25:19 -04001312 zclient = zclient_new (master);
paul718e3742002-12-13 20:15:29 +00001313 zclient_init (zclient, ZEBRA_ROUTE_OSPF);
Feng Luc99f3482014-10-16 09:52:36 +08001314 zclient->zebra_connected = ospf_zebra_connected;
hasso18a6dce2004-10-03 18:18:34 +00001315 zclient->router_id_update = ospf_router_id_update_zebra;
paul718e3742002-12-13 20:15:29 +00001316 zclient->interface_add = ospf_interface_add;
1317 zclient->interface_delete = ospf_interface_delete;
1318 zclient->interface_up = ospf_interface_state_up;
1319 zclient->interface_down = ospf_interface_state_down;
1320 zclient->interface_address_add = ospf_interface_address_add;
1321 zclient->interface_address_delete = ospf_interface_address_delete;
1322 zclient->ipv4_route_add = ospf_zebra_read_ipv4;
1323 zclient->ipv4_route_delete = ospf_zebra_read_ipv4;
1324
1325 access_list_add_hook (ospf_filter_update);
1326 access_list_delete_hook (ospf_filter_update);
hassodd669bb2004-05-10 07:43:59 +00001327 prefix_list_add_hook (ospf_prefix_list_update);
1328 prefix_list_delete_hook (ospf_prefix_list_update);
paul718e3742002-12-13 20:15:29 +00001329}