2 * Zebra connect library for OSPFd
3 * Copyright (C) 1997, 98, 99, 2000 Kunihiro Ishiguro, Toshiaki Takada
5 * This file is part of GNU Zebra.
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
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.
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.
40 #include "ospfd/ospfd.h"
41 #include "ospfd/ospf_interface.h"
42 #include "ospfd/ospf_ism.h"
43 #include "ospfd/ospf_asbr.h"
44 #include "ospfd/ospf_asbr.h"
45 #include "ospfd/ospf_abr.h"
46 #include "ospfd/ospf_lsa.h"
47 #include "ospfd/ospf_dump.h"
48 #include "ospfd/ospf_route.h"
49 #include "ospfd/ospf_lsdb.h"
50 #include "ospfd/ospf_neighbor.h"
51 #include "ospfd/ospf_nsm.h"
52 #include "ospfd/ospf_zebra.h"
54 #include "ospfd/ospf_snmp.h"
55 #endif /* HAVE_SNMP */
56 #include "ospfd/ospf_te.h"
58 /* Zebra structure to hold current status. */
59 struct zclient
*zclient
= NULL
;
61 /* For registering threads. */
62 extern struct thread_master
*master
;
63 struct in_addr router_id_zebra
;
65 /* Router-id update message from zebra. */
67 ospf_router_id_update_zebra (int command
, struct zclient
*zclient
,
68 zebra_size_t length
, vrf_id_t vrf_id
)
71 struct prefix router_id
;
72 zebra_router_id_update_read(zclient
->ibuf
,&router_id
);
74 if (IS_DEBUG_OSPF (zebra
, ZEBRA_INTERFACE
))
76 char buf
[PREFIX2STR_BUFFER
];
77 prefix2str(&router_id
, buf
, sizeof(buf
));
78 zlog_debug("Zebra rcvd: router id update %s", buf
);
81 router_id_zebra
= router_id
.u
.prefix4
;
83 ospf
= ospf_lookup ();
86 ospf_router_id_update (ospf
);
91 /* Inteface addition message from zebra. */
93 ospf_interface_add (int command
, struct zclient
*zclient
, zebra_size_t length
,
96 struct interface
*ifp
;
98 ifp
= zebra_interface_add_read (zclient
->ibuf
, vrf_id
);
100 if (IS_DEBUG_OSPF (zebra
, ZEBRA_INTERFACE
))
101 zlog_debug ("Zebra: interface add %s[%u] index %d flags %llx metric %d mtu %d",
102 ifp
->name
, ifp
->vrf_id
, ifp
->ifindex
, (unsigned long long)ifp
->flags
,
103 ifp
->metric
, ifp
->mtu
);
107 if (!OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), type
))
109 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), type
);
110 IF_DEF_PARAMS (ifp
)->type
= ospf_default_iftype(ifp
);
113 ospf_if_update (NULL
, ifp
);
116 ospf_snmp_if_update (ifp
);
117 #endif /* HAVE_SNMP */
123 ospf_interface_delete (int command
, struct zclient
*zclient
,
124 zebra_size_t length
, vrf_id_t vrf_id
)
126 struct interface
*ifp
;
128 struct route_node
*rn
;
131 /* zebra_interface_state_read() updates interface structure in iflist */
132 ifp
= zebra_interface_state_read (s
, vrf_id
);
138 zlog_warn ("Zebra: got delete of %s, but interface is still up",
141 if (IS_DEBUG_OSPF (zebra
, ZEBRA_INTERFACE
))
143 ("Zebra: interface delete %s[%u] index %d flags %llx metric %d mtu %d",
144 ifp
->name
, ifp
->vrf_id
, ifp
->ifindex
, (unsigned long long)ifp
->flags
, ifp
->metric
, ifp
->mtu
);
147 ospf_snmp_if_delete (ifp
);
148 #endif /* HAVE_SNMP */
150 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
152 ospf_if_free ((struct ospf_interface
*) rn
->info
);
154 ifp
->ifindex
= IFINDEX_DELETED
;
158 static struct interface
*
159 zebra_interface_if_lookup (struct stream
*s
, vrf_id_t vrf_id
)
161 char ifname_tmp
[INTERFACE_NAMSIZ
];
163 /* Read interface name. */
164 stream_get (ifname_tmp
, s
, INTERFACE_NAMSIZ
);
166 /* And look it up. */
167 return if_lookup_by_name_len(ifname_tmp
,
168 strnlen(ifname_tmp
, INTERFACE_NAMSIZ
));
172 ospf_interface_state_up (int command
, struct zclient
*zclient
,
173 zebra_size_t length
, vrf_id_t vrf_id
)
175 struct interface
*ifp
;
176 struct ospf_interface
*oi
;
177 struct route_node
*rn
;
179 ifp
= zebra_interface_if_lookup (zclient
->ibuf
, vrf_id
);
184 /* Interface is already up. */
185 if (if_is_operative (ifp
))
187 /* Temporarily keep ifp values. */
188 struct interface if_tmp
;
189 memcpy (&if_tmp
, ifp
, sizeof (struct interface
));
191 zebra_interface_if_set_value (zclient
->ibuf
, ifp
);
193 if (IS_DEBUG_OSPF (zebra
, ZEBRA_INTERFACE
))
194 zlog_debug ("Zebra: Interface[%s] state update.", ifp
->name
);
196 if (if_tmp
.bandwidth
!= ifp
->bandwidth
)
198 if (IS_DEBUG_OSPF (zebra
, ZEBRA_INTERFACE
))
199 zlog_debug ("Zebra: Interface[%s] bandwidth change %d -> %d.",
200 ifp
->name
, if_tmp
.bandwidth
, ifp
->bandwidth
);
202 ospf_if_recalculate_output_cost (ifp
);
205 if (if_tmp
.mtu
!= ifp
->mtu
)
207 if (IS_DEBUG_OSPF (zebra
, ZEBRA_INTERFACE
))
208 zlog_debug ("Zebra: Interface[%s] MTU change %u -> %u.",
209 ifp
->name
, if_tmp
.mtu
, ifp
->mtu
);
211 /* Must reset the interface (simulate down/up) when MTU changes. */
217 zebra_interface_if_set_value (zclient
->ibuf
, ifp
);
219 if (IS_DEBUG_OSPF (zebra
, ZEBRA_INTERFACE
))
220 zlog_debug ("Zebra: Interface[%s] state change to up.", ifp
->name
);
222 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
224 if ((oi
= rn
->info
) == NULL
)
234 ospf_interface_state_down (int command
, struct zclient
*zclient
,
235 zebra_size_t length
, vrf_id_t vrf_id
)
237 struct interface
*ifp
;
238 struct ospf_interface
*oi
;
239 struct route_node
*node
;
241 ifp
= zebra_interface_state_read (zclient
->ibuf
, vrf_id
);
246 if (IS_DEBUG_OSPF (zebra
, ZEBRA_INTERFACE
))
247 zlog_debug ("Zebra: Interface[%s] state change to down.", ifp
->name
);
249 for (node
= route_top (IF_OIFS (ifp
)); node
; node
= route_next (node
))
251 if ((oi
= node
->info
) == NULL
)
260 ospf_interface_address_add (int command
, struct zclient
*zclient
,
261 zebra_size_t length
, vrf_id_t vrf_id
)
265 c
= zebra_interface_address_read (command
, zclient
->ibuf
, vrf_id
);
270 if (IS_DEBUG_OSPF (zebra
, ZEBRA_INTERFACE
))
272 char buf
[PREFIX2STR_BUFFER
];
273 prefix2str(c
->address
, buf
, sizeof(buf
));
274 zlog_debug("Zebra: interface %s address add %s", c
->ifp
->name
, buf
);
277 ospf_if_update (NULL
, c
->ifp
);
280 ospf_snmp_if_update (c
->ifp
);
281 #endif /* HAVE_SNMP */
287 ospf_interface_address_delete (int command
, struct zclient
*zclient
,
288 zebra_size_t length
, vrf_id_t vrf_id
)
291 struct interface
*ifp
;
292 struct ospf_interface
*oi
;
293 struct route_node
*rn
;
296 c
= zebra_interface_address_read (command
, zclient
->ibuf
, vrf_id
);
301 if (IS_DEBUG_OSPF (zebra
, ZEBRA_INTERFACE
))
303 char buf
[PREFIX2STR_BUFFER
];
304 prefix2str(c
->address
, buf
, sizeof(buf
));
305 zlog_debug("Zebra: interface %s address delete %s", c
->ifp
->name
, buf
);
310 p
.prefixlen
= IPV4_MAX_PREFIXLEN
;
312 rn
= route_node_lookup (IF_OIFS (ifp
), &p
);
321 route_unlock_node (rn
);
323 /* Call interface hook functions to clean up */
327 ospf_snmp_if_update (c
->ifp
);
328 #endif /* HAVE_SNMP */
336 ospf_interface_link_params (int command
, struct zclient
*zclient
,
339 struct interface
*ifp
;
341 ifp
= zebra_interface_link_params_read (zclient
->ibuf
);
347 ospf_mpls_te_update_if (ifp
);
354 ospf_zebra_add (struct prefix_ipv4
*p
, struct ospf_route
*or)
361 struct ospf_path
*path
;
362 struct listnode
*node
;
363 struct ospf
*ospf
= ospf_lookup ();
365 if ((ospf
->instance
&&
366 redist_check_instance(&zclient
->mi_redist
[AFI_IP
][ZEBRA_ROUTE_OSPF
], ospf
->instance
))
368 vrf_bitmap_check (zclient
->redist
[AFI_IP
][ZEBRA_ROUTE_OSPF
], VRF_DEFAULT
))
373 /* OSPF pass nexthop and metric */
374 SET_FLAG (message
, ZAPI_MESSAGE_NEXTHOP
);
375 SET_FLAG (message
, ZAPI_MESSAGE_METRIC
);
377 /* Distance value. */
378 distance
= ospf_distance_apply (p
, or);
380 SET_FLAG (message
, ZAPI_MESSAGE_DISTANCE
);
382 /* Check if path type is ASE */
383 if (((or->path_type
== OSPF_PATH_TYPE1_EXTERNAL
) ||
384 (or->path_type
== OSPF_PATH_TYPE2_EXTERNAL
)) &&
385 (or->u
.ext
.tag
> 0) && (or->u
.ext
.tag
<= ROUTE_TAG_MAX
))
386 SET_FLAG (message
, ZAPI_MESSAGE_TAG
);
392 /* Put command, type, flags, message. */
393 zclient_create_header (s
, ZEBRA_IPV4_ROUTE_ADD
, VRF_DEFAULT
);
394 stream_putc (s
, ZEBRA_ROUTE_OSPF
);
395 stream_putw (s
, ospf
->instance
);
396 stream_putl (s
, flags
);
397 stream_putc (s
, message
);
398 stream_putw (s
, SAFI_UNICAST
);
400 /* Put prefix information. */
401 psize
= PSIZE (p
->prefixlen
);
402 stream_putc (s
, p
->prefixlen
);
403 stream_write (s
, (u_char
*) & p
->prefix
, psize
);
406 stream_putc (s
, or->paths
->count
);
408 /* Nexthop, ifindex, distance and metric information. */
409 for (ALL_LIST_ELEMENTS_RO (or->paths
, node
, path
))
412 if (path
->unnumbered
||
413 (path
->nexthop
.s_addr
!= INADDR_ANY
&&
416 stream_putc (s
, NEXTHOP_TYPE_IPV4_IFINDEX
);
417 stream_put_in_addr (s
, &path
->nexthop
);
418 stream_putl (s
, path
->ifindex
);
420 else if (path
->nexthop
.s_addr
!= INADDR_ANY
)
422 stream_putc (s
, NEXTHOP_TYPE_IPV4
);
423 stream_put_in_addr (s
, &path
->nexthop
);
427 stream_putc (s
, NEXTHOP_TYPE_IFINDEX
);
429 stream_putl (s
, path
->ifindex
);
433 #else /* HAVE_NETLINK */
434 if (path
->nexthop
.s_addr
!= INADDR_ANY
&&
437 stream_putc (s
, NEXTHOP_TYPE_IPV4_IFINDEX
);
438 stream_put_in_addr (s
, &path
->nexthop
);
439 stream_putl (s
, path
->ifindex
);
441 else if (path
->nexthop
.s_addr
!= INADDR_ANY
)
443 stream_putc (s
, NEXTHOP_TYPE_IPV4
);
444 stream_put_in_addr (s
, &path
->nexthop
);
448 stream_putc (s
, NEXTHOP_TYPE_IFINDEX
);
450 stream_putl (s
, path
->ifindex
);
454 #endif /* HAVE_NETLINK */
456 if (IS_DEBUG_OSPF (zebra
, ZEBRA_REDISTRIBUTE
))
458 char buf
[2][INET_ADDRSTRLEN
];
459 zlog_debug("Zebra: Route add %s/%d nexthop %s, ifindex=%d",
460 inet_ntop(AF_INET
, &p
->prefix
,
461 buf
[0], sizeof(buf
[0])),
463 inet_ntop(AF_INET
, &path
->nexthop
,
464 buf
[1], sizeof(buf
[1])),
469 if (CHECK_FLAG (message
, ZAPI_MESSAGE_DISTANCE
))
470 stream_putc (s
, distance
);
471 if (CHECK_FLAG (message
, ZAPI_MESSAGE_METRIC
))
473 if (or->path_type
== OSPF_PATH_TYPE1_EXTERNAL
)
474 stream_putl (s
, or->cost
+ or->u
.ext
.type2_cost
);
475 else if (or->path_type
== OSPF_PATH_TYPE2_EXTERNAL
)
476 stream_putl (s
, or->u
.ext
.type2_cost
);
478 stream_putl (s
, or->cost
);
481 if (CHECK_FLAG (message
, ZAPI_MESSAGE_TAG
))
482 stream_putl (s
, or->u
.ext
.tag
);
484 stream_putw_at (s
, 0, stream_get_endp (s
));
486 zclient_send_message(zclient
);
491 ospf_zebra_delete (struct prefix_ipv4
*p
, struct ospf_route
*or)
498 struct ospf_path
*path
;
499 struct listnode
*node
;
500 struct ospf
*ospf
= ospf_lookup ();
502 if ((ospf
->instance
&&
503 redist_check_instance(&zclient
->mi_redist
[AFI_IP
][ZEBRA_ROUTE_OSPF
], ospf
->instance
))
505 vrf_bitmap_check (zclient
->redist
[AFI_IP
][ZEBRA_ROUTE_OSPF
], VRF_DEFAULT
))
509 /* Distance value. */
510 distance
= ospf_distance_apply (p
, or);
515 /* Put command, type, flags, message. */
516 zclient_create_header (s
, ZEBRA_IPV4_ROUTE_DELETE
, VRF_DEFAULT
);
517 stream_putc (s
, ZEBRA_ROUTE_OSPF
);
518 stream_putw (s
, ospf
->instance
);
519 stream_putl (s
, flags
);
520 stream_putc (s
, message
);
521 stream_putw (s
, SAFI_UNICAST
);
523 /* Put prefix information. */
524 psize
= PSIZE (p
->prefixlen
);
525 stream_putc (s
, p
->prefixlen
);
526 stream_write (s
, (u_char
*) & p
->prefix
, psize
);
529 stream_putc (s
, or->paths
->count
);
531 /* Nexthop, ifindex, distance and metric information. */
532 for (ALL_LIST_ELEMENTS_RO (or->paths
, node
, path
))
534 if (path
->nexthop
.s_addr
!= INADDR_ANY
&&
537 stream_putc (s
, NEXTHOP_TYPE_IPV4_IFINDEX
);
538 stream_put_in_addr (s
, &path
->nexthop
);
539 stream_putl (s
, path
->ifindex
);
541 else if (path
->nexthop
.s_addr
!= INADDR_ANY
)
543 stream_putc (s
, NEXTHOP_TYPE_IPV4
);
544 stream_put_in_addr (s
, &path
->nexthop
);
548 stream_putc (s
, NEXTHOP_TYPE_IFINDEX
);
549 stream_putl (s
, path
->ifindex
);
552 if (IS_DEBUG_OSPF (zebra
, ZEBRA_REDISTRIBUTE
))
554 char buf
[2][INET_ADDRSTRLEN
];
555 zlog_debug("Zebra: Route delete %s/%d nexthop %s",
556 inet_ntop(AF_INET
, &p
->prefix
,
557 buf
[0], sizeof(buf
[0])),
559 inet_ntop(AF_INET
, &path
->nexthop
,
560 buf
[1], sizeof(buf
[1])));
564 if (CHECK_FLAG (message
, ZAPI_MESSAGE_DISTANCE
))
565 stream_putc (s
, distance
);
566 if (CHECK_FLAG (message
, ZAPI_MESSAGE_METRIC
))
568 if (or->path_type
== OSPF_PATH_TYPE1_EXTERNAL
)
569 stream_putl (s
, or->cost
+ or->u
.ext
.type2_cost
);
570 else if (or->path_type
== OSPF_PATH_TYPE2_EXTERNAL
)
571 stream_putl (s
, or->u
.ext
.type2_cost
);
573 stream_putl (s
, or->cost
);
576 stream_putw_at (s
, 0, stream_get_endp (s
));
578 zclient_send_message(zclient
);
583 ospf_zebra_add_discard (struct prefix_ipv4
*p
)
585 struct zapi_ipv4 api
;
586 struct ospf
*ospf
= ospf_lookup ();
588 if ((ospf
->instance
&&
589 redist_check_instance(&zclient
->mi_redist
[AFI_IP
][ZEBRA_ROUTE_OSPF
], ospf
->instance
))
591 vrf_bitmap_check (zclient
->redist
[AFI_IP
][ZEBRA_ROUTE_OSPF
], VRF_DEFAULT
))
593 api
.vrf_id
= VRF_DEFAULT
;
594 api
.type
= ZEBRA_ROUTE_OSPF
;
595 api
.instance
= ospf
->instance
;
596 api
.flags
= ZEBRA_FLAG_BLACKHOLE
;
598 api
.safi
= SAFI_UNICAST
;
599 SET_FLAG (api
.message
, ZAPI_MESSAGE_NEXTHOP
);
604 zapi_ipv4_route (ZEBRA_IPV4_ROUTE_ADD
, zclient
, p
, &api
);
606 if (IS_DEBUG_OSPF (zebra
, ZEBRA_REDISTRIBUTE
))
607 zlog_debug ("Zebra: Route add discard %s/%d",
608 inet_ntoa (p
->prefix
), p
->prefixlen
);
613 ospf_zebra_delete_discard (struct prefix_ipv4
*p
)
615 struct zapi_ipv4 api
;
616 struct ospf
*ospf
= ospf_lookup ();
618 if ((ospf
->instance
&&
619 redist_check_instance(&zclient
->mi_redist
[AFI_IP
][ZEBRA_ROUTE_OSPF
], ospf
->instance
))
621 vrf_bitmap_check (zclient
->redist
[AFI_IP
][ZEBRA_ROUTE_OSPF
], VRF_DEFAULT
))
623 api
.vrf_id
= VRF_DEFAULT
;
624 api
.type
= ZEBRA_ROUTE_OSPF
;
625 api
.instance
= ospf
->instance
;
626 api
.flags
= ZEBRA_FLAG_BLACKHOLE
;
628 api
.safi
= SAFI_UNICAST
;
629 SET_FLAG (api
.message
, ZAPI_MESSAGE_NEXTHOP
);
634 zapi_ipv4_route (ZEBRA_IPV4_ROUTE_DELETE
, zclient
, p
, &api
);
636 if (IS_DEBUG_OSPF (zebra
, ZEBRA_REDISTRIBUTE
))
637 zlog_debug ("Zebra: Route delete discard %s/%d",
638 inet_ntoa (p
->prefix
), p
->prefixlen
);
643 struct ospf_external
*
644 ospf_external_lookup (u_char type
, u_short instance
)
646 struct list
*ext_list
;
647 struct listnode
*node
;
648 struct ospf_external
*ext
;
650 ext_list
= om
->external
[type
];
654 for (ALL_LIST_ELEMENTS_RO(ext_list
, node
, ext
))
655 if (ext
->instance
== instance
)
661 struct ospf_external
*
662 ospf_external_add (u_char type
, u_short instance
)
664 struct list
*ext_list
;
665 struct ospf_external
*ext
;
667 ext
= ospf_external_lookup(type
, instance
);
671 if (!om
->external
[type
])
672 om
->external
[type
] = list_new();
674 ext_list
= om
->external
[type
];
675 ext
= (struct ospf_external
*)calloc (1, sizeof(struct ospf_external
));
676 ext
->instance
= instance
;
677 EXTERNAL_INFO (ext
) = route_table_init ();
679 listnode_add(ext_list
, ext
);
685 ospf_external_del (u_char type
, u_short instance
)
687 struct ospf_external
*ext
;
689 ext
= ospf_external_lookup(type
, instance
);
693 if (EXTERNAL_INFO (ext
))
694 route_table_finish(EXTERNAL_INFO (ext
));
696 listnode_delete(om
->external
[type
], ext
);
697 if (!om
->external
[type
]->count
)
699 list_free(om
->external
[type
]);
700 om
->external
[type
] = NULL
;
706 ospf_redist_lookup (struct ospf
*ospf
, u_char type
, u_short instance
)
708 struct list
*red_list
;
709 struct listnode
*node
;
710 struct ospf_redist
*red
;
712 red_list
= ospf
->redist
[type
];
716 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
))
717 if (red
->instance
== instance
)
724 ospf_redist_add (struct ospf
*ospf
, u_char type
, u_short instance
)
726 struct list
*red_list
;
727 struct ospf_redist
*red
;
729 red
= ospf_redist_lookup(ospf
, type
, instance
);
733 if (!ospf
->redist
[type
])
734 ospf
->redist
[type
] = list_new();
736 red_list
= ospf
->redist
[type
];
737 red
= (struct ospf_redist
*)calloc (1, sizeof(struct ospf_redist
));
738 red
->instance
= instance
;
739 red
->dmetric
.type
= -1;
740 red
->dmetric
.value
= -1;
742 listnode_add(red_list
, red
);
748 ospf_redist_del (struct ospf
*ospf
, u_char type
, u_short instance
)
750 struct ospf_redist
*red
;
752 red
= ospf_redist_lookup(ospf
, type
, instance
);
756 listnode_delete(ospf
->redist
[type
], red
);
757 if (!ospf
->redist
[type
]->count
)
759 list_free(ospf
->redist
[type
]);
760 ospf
->redist
[type
] = NULL
;
767 ospf_is_type_redistributed (int type
, u_short instance
)
769 return (DEFAULT_ROUTE_TYPE (type
) ?
770 vrf_bitmap_check (zclient
->default_information
, VRF_DEFAULT
) :
771 ((instance
&& redist_check_instance(&zclient
->mi_redist
[AFI_IP
][type
], instance
))
772 || (!instance
&& vrf_bitmap_check (zclient
->redist
[AFI_IP
][type
], VRF_DEFAULT
))));
776 ospf_redistribute_set (struct ospf
*ospf
, int type
, u_short instance
, int mtype
,
780 struct ospf_redist
*red
;
782 red
= ospf_redist_lookup(ospf
, type
, instance
);
783 if (ospf_is_type_redistributed (type
, instance
))
785 if (mtype
!= red
->dmetric
.type
)
787 red
->dmetric
.type
= mtype
;
788 force
= LSA_REFRESH_FORCE
;
790 if (mvalue
!= red
->dmetric
.value
)
792 red
->dmetric
.value
= mvalue
;
793 force
= LSA_REFRESH_FORCE
;
796 ospf_external_lsa_refresh_type (ospf
, type
, instance
, force
);
798 if (IS_DEBUG_OSPF (zebra
, ZEBRA_REDISTRIBUTE
))
799 zlog_debug ("Redistribute[%s][%d]: Refresh Type[%d], Metric[%d]",
800 ospf_redist_string(type
), instance
,
801 metric_type (ospf
, type
, instance
),
802 metric_value (ospf
, type
, instance
));
807 red
->dmetric
.type
= mtype
;
808 red
->dmetric
.value
= mvalue
;
810 ospf_external_add(type
, instance
);
812 zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD
, zclient
, AFI_IP
, type
,
813 instance
, VRF_DEFAULT
);
815 if (IS_DEBUG_OSPF (zebra
, ZEBRA_REDISTRIBUTE
))
816 zlog_debug ("Redistribute[%s][%d]: Start Type[%d], Metric[%d]",
817 ospf_redist_string(type
), instance
,
818 metric_type (ospf
, type
, instance
), metric_value (ospf
, type
, instance
));
820 ospf_asbr_status_update (ospf
, ++ospf
->redistribute
);
826 ospf_redistribute_unset (struct ospf
*ospf
, int type
, u_short instance
)
828 if (type
== zclient
->redist_default
&& instance
== zclient
->instance
)
831 if (!ospf_is_type_redistributed (type
, instance
))
834 zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE
, zclient
, AFI_IP
, type
,
835 instance
, VRF_DEFAULT
);
837 if (IS_DEBUG_OSPF (zebra
, ZEBRA_REDISTRIBUTE
))
838 zlog_debug ("Redistribute[%s][%d]: Stop",
839 ospf_redist_string(type
), instance
);
841 ospf_redist_del (ospf
, type
, instance
);
843 /* Remove the routes from OSPF table. */
844 ospf_redistribute_withdraw (ospf
, type
, instance
);
846 ospf_external_del(type
, instance
);
848 ospf_asbr_status_update (ospf
, --ospf
->redistribute
);
854 ospf_redistribute_default_set (struct ospf
*ospf
, int originate
,
855 int mtype
, int mvalue
)
857 struct ospf_redist
*red
;
859 ospf
->default_originate
= originate
;
861 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
862 red
->dmetric
.type
= mtype
;
863 red
->dmetric
.value
= mvalue
;
865 ospf_external_add(DEFAULT_ROUTE
, 0);
867 if (ospf_is_type_redistributed (DEFAULT_ROUTE
, 0))
869 /* if ospf->default_originate changes value, is calling
870 ospf_external_lsa_refresh_default sufficient to implement
872 ospf_external_lsa_refresh_default (ospf
);
874 if (IS_DEBUG_OSPF (zebra
, ZEBRA_REDISTRIBUTE
))
875 zlog_debug ("Redistribute[%s]: Refresh Type[%d], Metric[%d]",
876 ospf_redist_string(DEFAULT_ROUTE
),
877 metric_type (ospf
, DEFAULT_ROUTE
, 0),
878 metric_value (ospf
, DEFAULT_ROUTE
, 0));
882 zclient_redistribute_default (ZEBRA_REDISTRIBUTE_DEFAULT_ADD
, zclient
,
885 if (IS_DEBUG_OSPF (zebra
, ZEBRA_REDISTRIBUTE
))
886 zlog_debug ("Redistribute[DEFAULT]: Start Type[%d], Metric[%d]",
887 metric_type (ospf
, DEFAULT_ROUTE
, 0),
888 metric_value (ospf
, DEFAULT_ROUTE
, 0));
890 if (ospf
->router_id
.s_addr
== 0)
891 ospf
->external_origin
|= (1 << DEFAULT_ROUTE
);
893 thread_add_timer (master
, ospf_default_originate_timer
, ospf
, 1);
895 ospf_asbr_status_update (ospf
, ++ospf
->redistribute
);
901 ospf_redistribute_default_unset (struct ospf
*ospf
)
903 if (!ospf_is_type_redistributed (DEFAULT_ROUTE
, 0))
906 ospf
->default_originate
= DEFAULT_ORIGINATE_NONE
;
907 ospf_redist_del(ospf
, DEFAULT_ROUTE
, 0);
909 zclient_redistribute_default (ZEBRA_REDISTRIBUTE_DEFAULT_DELETE
, zclient
,
912 if (IS_DEBUG_OSPF (zebra
, ZEBRA_REDISTRIBUTE
))
913 zlog_debug ("Redistribute[DEFAULT]: Stop");
915 //Pending: how does the external_info cleanup work in this case?
917 ospf_asbr_status_update (ospf
, --ospf
->redistribute
);
923 ospf_external_lsa_originate_check (struct ospf
*ospf
,
924 struct external_info
*ei
)
926 /* If prefix is multicast, then do not originate LSA. */
927 if (IN_MULTICAST (htonl (ei
->p
.prefix
.s_addr
)))
929 zlog_info ("LSA[Type5:%s]: Not originate AS-external-LSA, "
930 "Prefix belongs multicast", inet_ntoa (ei
->p
.prefix
));
934 /* Take care of default-originate. */
935 if (is_prefix_default (&ei
->p
))
936 if (ospf
->default_originate
== DEFAULT_ORIGINATE_NONE
)
938 zlog_info ("LSA[Type5:0.0.0.0]: Not originate AS-external-LSA "
946 /* If connected prefix is OSPF enable interface, then do not announce. */
948 ospf_distribute_check_connected (struct ospf
*ospf
, struct external_info
*ei
)
950 struct listnode
*node
;
951 struct ospf_interface
*oi
;
954 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
955 if (prefix_match (oi
->address
, (struct prefix
*) &ei
->p
))
960 /* return 1 if external LSA must be originated, 0 otherwise */
962 ospf_redistribute_check (struct ospf
*ospf
,
963 struct external_info
*ei
, int *changed
)
965 struct route_map_set_values save_values
;
966 struct prefix_ipv4
*p
= &ei
->p
;
967 struct ospf_redist
*red
;
968 u_char type
= is_prefix_default (&ei
->p
) ? DEFAULT_ROUTE
: ei
->type
;
969 u_short instance
= is_prefix_default (&ei
->p
) ? 0 : ei
->instance
;
974 if (!ospf_external_lsa_originate_check (ospf
, ei
))
977 /* Take care connected route. */
978 if (type
== ZEBRA_ROUTE_CONNECT
&&
979 !ospf_distribute_check_connected (ospf
, ei
))
982 if (!DEFAULT_ROUTE_TYPE (type
) && DISTRIBUTE_NAME (ospf
, type
))
983 /* distirbute-list exists, but access-list may not? */
984 if (DISTRIBUTE_LIST (ospf
, type
))
985 if (access_list_apply (DISTRIBUTE_LIST (ospf
, type
), p
) == FILTER_DENY
)
987 if (IS_DEBUG_OSPF (zebra
, ZEBRA_REDISTRIBUTE
))
988 zlog_debug ("Redistribute[%s]: %s/%d filtered by ditribute-list.",
989 ospf_redist_string(type
),
990 inet_ntoa (p
->prefix
), p
->prefixlen
);
994 save_values
= ei
->route_map_set
;
995 ospf_reset_route_map_set_values (&ei
->route_map_set
);
997 /* apply route-map if needed */
998 red
= ospf_redist_lookup (ospf
, type
, instance
);
999 if (red
&& ROUTEMAP_NAME(red
))
1003 ret
= route_map_apply (ROUTEMAP (red
), (struct prefix
*) p
,
1006 if (ret
== RMAP_DENYMATCH
)
1008 ei
->route_map_set
= save_values
;
1009 if (IS_DEBUG_OSPF (zebra
, ZEBRA_REDISTRIBUTE
))
1010 zlog_debug ("Redistribute[%s]: %s/%d filtered by route-map.",
1011 ospf_redist_string(type
),
1012 inet_ntoa (p
->prefix
), p
->prefixlen
);
1016 /* check if 'route-map set' changed something */
1018 *changed
= !ospf_route_map_set_compare (&ei
->route_map_set
,
1025 /* OSPF route-map set for redistribution */
1027 ospf_routemap_set (struct ospf_redist
*red
, const char *name
)
1029 if (ROUTEMAP_NAME (red
))
1030 free (ROUTEMAP_NAME (red
));
1032 ROUTEMAP_NAME (red
) = strdup (name
);
1033 ROUTEMAP (red
) = route_map_lookup_by_name (name
);
1037 ospf_routemap_unset (struct ospf_redist
*red
)
1039 if (ROUTEMAP_NAME (red
))
1040 free (ROUTEMAP_NAME (red
));
1042 ROUTEMAP_NAME (red
) = NULL
;
1043 ROUTEMAP (red
) = NULL
;
1046 /* Zebra route add and delete treatment. */
1048 ospf_zebra_read_ipv4 (int command
, struct zclient
*zclient
,
1049 zebra_size_t length
, vrf_id_t vrf_id
)
1052 struct zapi_ipv4 api
;
1053 unsigned long ifindex
;
1054 struct in_addr nexthop
;
1055 struct prefix_ipv4 p
;
1056 struct external_info
*ei
;
1064 /* Type, flags, message. */
1065 api
.type
= stream_getc (s
);
1066 api
.instance
= stream_getw (s
);
1067 api
.flags
= stream_getl (s
);
1068 api
.message
= stream_getc (s
);
1071 memset (&p
, 0, sizeof (struct prefix_ipv4
));
1073 p
.prefixlen
= MIN(IPV4_MAX_PREFIXLEN
, stream_getc (s
));
1074 stream_get (&p
.prefix
, s
, PSIZE (p
.prefixlen
));
1076 if (IPV4_NET127(ntohl(p
.prefix
.s_addr
)))
1079 /* Nexthop, ifindex, distance, metric. */
1080 if (CHECK_FLAG (api
.message
, ZAPI_MESSAGE_NEXTHOP
))
1082 api
.nexthop_num
= stream_getc (s
);
1083 nexthop
.s_addr
= stream_get_ipv4 (s
);
1085 if (CHECK_FLAG (api
.message
, ZAPI_MESSAGE_IFINDEX
))
1087 api
.ifindex_num
= stream_getc (s
);
1088 /* XXX assert(api.ifindex_num == 1); */
1089 ifindex
= stream_getl (s
);
1091 if (CHECK_FLAG (api
.message
, ZAPI_MESSAGE_DISTANCE
))
1092 api
.distance
= stream_getc (s
);
1093 if (CHECK_FLAG (api
.message
, ZAPI_MESSAGE_METRIC
))
1094 api
.metric
= stream_getl (s
);
1095 if (CHECK_FLAG (api
.message
, ZAPI_MESSAGE_TAG
))
1096 api
.tag
= stream_getl (s
);
1100 ospf
= ospf_lookup ();
1104 if (command
== ZEBRA_REDISTRIBUTE_IPV4_ADD
)
1106 /* XXX|HACK|TODO|FIXME:
1107 * Maybe we should ignore reject/blackhole routes? Testing shows that
1108 * there is no problems though and this is only way to "summarize"
1109 * routes in ASBR at the moment. Maybe we need just a better generalised
1110 * solution for these types?
1112 * if ( CHECK_FLAG (api.flags, ZEBRA_FLAG_BLACKHOLE)
1113 * || CHECK_FLAG (api.flags, ZEBRA_FLAG_REJECT))
1117 /* Protocol tag overwrites all other tag value send by zebra */
1118 if (ospf
->dtag
[api
.type
] > 0)
1119 api
.tag
= ospf
->dtag
[api
.type
];
1122 * Given zebra sends update for a prefix via ADD message, it should
1123 * be considered as an implicit DEL for that prefix with other source
1126 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++)
1128 ospf_external_info_delete(i
, api
.instance
, p
);
1130 ei
= ospf_external_info_add (api
.type
, api
.instance
, p
, ifindex
,
1134 /* Nothing has changed, so nothing to do; return */
1137 if (ospf
->router_id
.s_addr
== 0)
1138 /* Set flags to generate AS-external-LSA originate event
1139 for each redistributed protocols later. */
1140 ospf
->external_origin
|= (1 << api
.type
);
1145 if (is_prefix_default (&p
))
1146 ospf_external_lsa_refresh_default (ospf
);
1149 struct ospf_lsa
*current
;
1151 current
= ospf_external_info_find_lsa (ospf
, &ei
->p
);
1153 ospf_external_lsa_originate (ospf
, ei
);
1156 if (IS_DEBUG_OSPF (zebra
, ZEBRA_REDISTRIBUTE
))
1157 zlog_debug ("ospf_zebra_read_ipv4() : %s refreshing LSA",
1158 inet_ntoa (p
.prefix
));
1159 ospf_external_lsa_refresh (ospf
, current
,
1160 ei
, LSA_REFRESH_FORCE
);
1166 else /* if (command == ZEBRA_REDISTRIBUTE_IPV4_DEL) */
1168 ospf_external_info_delete (api
.type
, api
.instance
, p
);
1169 if (is_prefix_default (&p
))
1170 ospf_external_lsa_refresh_default (ospf
);
1172 ospf_external_lsa_flush (ospf
, api
.type
, &p
, ifindex
/*, nexthop */);
1180 ospf_distribute_list_out_set (struct ospf
*ospf
, int type
, const char *name
)
1182 /* Lookup access-list for distribute-list. */
1183 DISTRIBUTE_LIST (ospf
, type
) = access_list_lookup (AFI_IP
, name
);
1185 /* Clear previous distribute-name. */
1186 if (DISTRIBUTE_NAME (ospf
, type
))
1187 free (DISTRIBUTE_NAME (ospf
, type
));
1189 /* Set distribute-name. */
1190 DISTRIBUTE_NAME (ospf
, type
) = strdup (name
);
1192 /* If access-list have been set, schedule update timer. */
1193 if (DISTRIBUTE_LIST (ospf
, type
))
1194 ospf_distribute_list_update (ospf
, type
, 0);
1200 ospf_distribute_list_out_unset (struct ospf
*ospf
, int type
, const char *name
)
1202 /* Schedule update timer. */
1203 if (DISTRIBUTE_LIST (ospf
, type
))
1204 ospf_distribute_list_update (ospf
, type
, 0);
1206 /* Unset distribute-list. */
1207 DISTRIBUTE_LIST (ospf
, type
) = NULL
;
1209 /* Clear distribute-name. */
1210 if (DISTRIBUTE_NAME (ospf
, type
))
1211 free (DISTRIBUTE_NAME (ospf
, type
));
1213 DISTRIBUTE_NAME (ospf
, type
) = NULL
;
1218 /* distribute-list update timer. */
1220 ospf_distribute_list_update_timer (struct thread
*thread
)
1222 struct route_node
*rn
;
1223 struct external_info
*ei
;
1224 struct route_table
*rt
;
1225 struct ospf_lsa
*lsa
;
1226 int type
, default_refresh
= 0;
1229 ospf
= ospf_lookup ();
1233 ospf
->t_distribute_update
= NULL
;
1235 zlog_info ("Zebra[Redistribute]: distribute-list update timer fired!");
1237 /* foreach all external info. */
1238 for (type
= 0; type
<= ZEBRA_ROUTE_MAX
; type
++)
1240 struct list
*ext_list
;
1241 struct listnode
*node
;
1242 struct ospf_external
*ext
;
1244 ext_list
= om
->external
[type
];
1248 for (ALL_LIST_ELEMENTS_RO(ext_list
, node
, ext
))
1250 rt
= ext
->external_info
;
1253 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
1254 if ((ei
= rn
->info
) != NULL
)
1256 if (is_prefix_default (&ei
->p
))
1257 default_refresh
= 1;
1258 else if ((lsa
= ospf_external_info_find_lsa (ospf
, &ei
->p
)))
1259 ospf_external_lsa_refresh (ospf
, lsa
, ei
, LSA_REFRESH_IF_CHANGED
);
1261 ospf_external_lsa_originate (ospf
, ei
);
1265 if (default_refresh
)
1266 ospf_external_lsa_refresh_default (ospf
);
1270 /* Update distribute-list and set timer to apply access-list. */
1272 ospf_distribute_list_update (struct ospf
*ospf
, uintptr_t type
,
1275 struct route_table
*rt
;
1276 struct ospf_external
*ext
;
1278 /* External info does not exist. */
1279 ext
= ospf_external_lookup(type
, instance
);
1280 if (!ext
|| !(rt
= EXTERNAL_INFO (ext
)))
1283 /* If exists previously invoked thread, then let it continue. */
1284 if (ospf
->t_distribute_update
)
1288 ospf
->t_distribute_update
=
1289 thread_add_timer_msec (master
, ospf_distribute_list_update_timer
,
1290 (void *) type
, ospf
->min_ls_interval
);
1293 /* If access-list is updated, apply some check. */
1295 ospf_filter_update (struct access_list
*access
)
1300 struct ospf_area
*area
;
1301 struct listnode
*node
;
1303 /* If OSPF instance does not exist, return right now. */
1304 ospf
= ospf_lookup ();
1308 /* Update distribute-list, and apply filter. */
1309 for (type
= 0; type
<= ZEBRA_ROUTE_MAX
; type
++)
1311 struct list
*red_list
;
1312 struct listnode
*node
;
1313 struct ospf_redist
*red
;
1315 red_list
= ospf
->redist
[type
];
1317 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
))
1321 /* if route-map is not NULL it may be using this access list */
1322 ospf_distribute_list_update (ospf
, type
, red
->instance
);
1326 /* There is place for route-map for default-information (ZEBRA_ROUTE_MAX),
1327 * but no distribute list. */
1328 if (type
== ZEBRA_ROUTE_MAX
)
1331 if (DISTRIBUTE_NAME (ospf
, type
))
1333 /* Keep old access-list for distribute-list. */
1334 struct access_list
*old
= DISTRIBUTE_LIST (ospf
, type
);
1336 /* Update access-list for distribute-list. */
1337 DISTRIBUTE_LIST (ospf
, type
) =
1338 access_list_lookup (AFI_IP
, DISTRIBUTE_NAME (ospf
, type
));
1340 /* No update for this distribute type. */
1341 if (old
== NULL
&& DISTRIBUTE_LIST (ospf
, type
) == NULL
)
1344 /* Schedule distribute-list update timer. */
1345 if (DISTRIBUTE_LIST (ospf
, type
) == NULL
||
1346 strcmp (DISTRIBUTE_NAME (ospf
, type
), access
->name
) == 0)
1347 ospf_distribute_list_update (ospf
, type
, 0);
1351 /* Update Area access-list. */
1352 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
1354 if (EXPORT_NAME (area
))
1356 EXPORT_LIST (area
) = NULL
;
1360 if (IMPORT_NAME (area
))
1362 IMPORT_LIST (area
) = NULL
;
1367 /* Schedule ABR tasks -- this will be changed -- takada. */
1368 if (IS_OSPF_ABR (ospf
) && abr_inv
)
1369 ospf_schedule_abr_task (ospf
);
1372 /* If prefix-list is updated, do some updates. */
1374 ospf_prefix_list_update (struct prefix_list
*plist
)
1379 struct ospf_area
*area
;
1380 struct listnode
*node
;
1382 /* If OSPF instatnce does not exist, return right now. */
1383 ospf
= ospf_lookup ();
1387 /* Update all route-maps which are used as redistribution filters.
1388 * They might use prefix-list.
1390 for (type
= 0; type
<= ZEBRA_ROUTE_MAX
; type
++)
1392 struct list
*red_list
;
1393 struct listnode
*node
;
1394 struct ospf_redist
*red
;
1396 red_list
= ospf
->redist
[type
];
1398 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
))
1402 /* if route-map is not NULL it may be using this prefix list */
1403 ospf_distribute_list_update (ospf
, type
, red
->instance
);
1408 /* Update area filter-lists. */
1409 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
1411 /* Update filter-list in. */
1412 if (PREFIX_NAME_IN (area
))
1413 if (strcmp (PREFIX_NAME_IN (area
), prefix_list_name (plist
)) == 0)
1415 PREFIX_LIST_IN (area
) =
1416 prefix_list_lookup (AFI_IP
, PREFIX_NAME_IN (area
));
1420 /* Update filter-list out. */
1421 if (PREFIX_NAME_OUT (area
))
1422 if (strcmp (PREFIX_NAME_OUT (area
), prefix_list_name (plist
)) == 0)
1424 PREFIX_LIST_IN (area
) =
1425 prefix_list_lookup (AFI_IP
, PREFIX_NAME_OUT (area
));
1430 /* Schedule ABR task. */
1431 if (IS_OSPF_ABR (ospf
) && abr_inv
)
1432 ospf_schedule_abr_task (ospf
);
1435 static struct ospf_distance
*
1436 ospf_distance_new (void)
1438 return XCALLOC (MTYPE_OSPF_DISTANCE
, sizeof (struct ospf_distance
));
1442 ospf_distance_free (struct ospf_distance
*odistance
)
1444 XFREE (MTYPE_OSPF_DISTANCE
, odistance
);
1448 ospf_distance_set (struct vty
*vty
, struct ospf
*ospf
,
1449 const char *distance_str
,
1451 const char *access_list_str
)
1454 struct prefix_ipv4 p
;
1456 struct route_node
*rn
;
1457 struct ospf_distance
*odistance
;
1459 ret
= str2prefix_ipv4 (ip_str
, &p
);
1462 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
1466 distance
= atoi (distance_str
);
1468 /* Get OSPF distance node. */
1469 rn
= route_node_get (ospf
->distance_table
, (struct prefix
*) &p
);
1472 odistance
= rn
->info
;
1473 route_unlock_node (rn
);
1477 odistance
= ospf_distance_new ();
1478 rn
->info
= odistance
;
1481 /* Set distance value. */
1482 odistance
->distance
= distance
;
1484 /* Reset access-list configuration. */
1485 if (odistance
->access_list
)
1487 free (odistance
->access_list
);
1488 odistance
->access_list
= NULL
;
1490 if (access_list_str
)
1491 odistance
->access_list
= strdup (access_list_str
);
1497 ospf_distance_unset (struct vty
*vty
, struct ospf
*ospf
,
1498 const char *distance_str
,
1499 const char *ip_str
, char
1500 const *access_list_str
)
1503 struct prefix_ipv4 p
;
1504 struct route_node
*rn
;
1505 struct ospf_distance
*odistance
;
1507 ret
= str2prefix_ipv4 (ip_str
, &p
);
1510 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
1514 rn
= route_node_lookup (ospf
->distance_table
, (struct prefix
*) &p
);
1517 vty_out (vty
, "Can't find specified prefix%s", VTY_NEWLINE
);
1521 odistance
= rn
->info
;
1523 if (odistance
->access_list
)
1524 free (odistance
->access_list
);
1525 ospf_distance_free (odistance
);
1528 route_unlock_node (rn
);
1529 route_unlock_node (rn
);
1535 ospf_distance_reset (struct ospf
*ospf
)
1537 struct route_node
*rn
;
1538 struct ospf_distance
*odistance
;
1540 for (rn
= route_top (ospf
->distance_table
); rn
; rn
= route_next (rn
))
1541 if ((odistance
= rn
->info
) != NULL
)
1543 if (odistance
->access_list
)
1544 free (odistance
->access_list
);
1545 ospf_distance_free (odistance
);
1547 route_unlock_node (rn
);
1552 ospf_distance_apply (struct prefix_ipv4
*p
, struct ospf_route
*or)
1556 ospf
= ospf_lookup ();
1560 if (ospf
->distance_intra
)
1561 if (or->path_type
== OSPF_PATH_INTRA_AREA
)
1562 return ospf
->distance_intra
;
1564 if (ospf
->distance_inter
)
1565 if (or->path_type
== OSPF_PATH_INTER_AREA
)
1566 return ospf
->distance_inter
;
1568 if (ospf
->distance_external
)
1569 if (or->path_type
== OSPF_PATH_TYPE1_EXTERNAL
1570 || or->path_type
== OSPF_PATH_TYPE2_EXTERNAL
)
1571 return ospf
->distance_external
;
1573 if (ospf
->distance_all
)
1574 return ospf
->distance_all
;
1580 ospf_zebra_connected (struct zclient
*zclient
)
1582 /* Send the client registration */
1583 bfd_client_sendmsg(zclient
, ZEBRA_BFD_CLIENT_REGISTER
);
1585 zclient_send_reg_requests (zclient
, VRF_DEFAULT
);
1589 ospf_zebra_init (struct thread_master
*master
, u_short instance
)
1591 /* Allocate zebra structure. */
1592 zclient
= zclient_new(master
);
1593 zclient_init (zclient
, ZEBRA_ROUTE_OSPF
, instance
);
1594 zclient
->zebra_connected
= ospf_zebra_connected
;
1595 zclient
->router_id_update
= ospf_router_id_update_zebra
;
1596 zclient
->interface_add
= ospf_interface_add
;
1597 zclient
->interface_delete
= ospf_interface_delete
;
1598 zclient
->interface_up
= ospf_interface_state_up
;
1599 zclient
->interface_down
= ospf_interface_state_down
;
1600 zclient
->interface_address_add
= ospf_interface_address_add
;
1601 zclient
->interface_address_delete
= ospf_interface_address_delete
;
1602 zclient
->interface_link_params
= ospf_interface_link_params
;
1604 zclient
->redistribute_route_ipv4_add
= ospf_zebra_read_ipv4
;
1605 zclient
->redistribute_route_ipv4_del
= ospf_zebra_read_ipv4
;
1607 access_list_add_hook (ospf_filter_update
);
1608 access_list_delete_hook (ospf_filter_update
);
1609 prefix_list_add_hook (ospf_prefix_list_update
);
1610 prefix_list_delete_hook (ospf_prefix_list_update
);