]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* |
508e53e2 | 2 | * Copyright (C) 2003 Yasuhiro Ohara |
718e3744 | 3 | * |
4 | * This file is part of GNU Zebra. | |
5 | * | |
6 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; either version 2, or (at your option) any | |
9 | * later version. | |
10 | * | |
11 | * GNU Zebra is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with GNU Zebra; see the file COPYING. If not, write to the | |
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
19 | * Boston, MA 02111-1307, USA. | |
20 | */ | |
21 | ||
508e53e2 | 22 | #include <zebra.h> |
718e3744 | 23 | |
508e53e2 | 24 | #include "memory.h" |
718e3744 | 25 | #include "if.h" |
26 | #include "log.h" | |
27 | #include "command.h" | |
508e53e2 | 28 | #include "thread.h" |
29 | #include "prefix.h" | |
30 | #include "plist.h" | |
718e3744 | 31 | |
508e53e2 | 32 | #include "ospf6_lsa.h" |
718e3744 | 33 | #include "ospf6_lsdb.h" |
508e53e2 | 34 | #include "ospf6_network.h" |
35 | #include "ospf6_message.h" | |
36 | #include "ospf6_route.h" | |
718e3744 | 37 | #include "ospf6_top.h" |
38 | #include "ospf6_area.h" | |
39 | #include "ospf6_interface.h" | |
508e53e2 | 40 | #include "ospf6_neighbor.h" |
41 | #include "ospf6_intra.h" | |
42 | #include "ospf6_spf.h" | |
049207c3 | 43 | #include "ospf6d.h" |
718e3744 | 44 | |
508e53e2 | 45 | unsigned char conf_debug_ospf6_interface = 0; |
46 | ||
0c083ee9 | 47 | const char *ospf6_interface_state_str[] = |
718e3744 | 48 | { |
508e53e2 | 49 | "None", |
50 | "Down", | |
51 | "Loopback", | |
52 | "Waiting", | |
53 | "PointToPoint", | |
54 | "DROther", | |
55 | "BDR", | |
56 | "DR", | |
57 | NULL | |
718e3744 | 58 | }; |
59 | ||
508e53e2 | 60 | struct ospf6_interface * |
61 | ospf6_interface_lookup_by_ifindex (int ifindex) | |
718e3744 | 62 | { |
508e53e2 | 63 | struct ospf6_interface *oi; |
64 | struct interface *ifp; | |
718e3744 | 65 | |
508e53e2 | 66 | ifp = if_lookup_by_index (ifindex); |
67 | if (ifp == NULL) | |
68 | return (struct ospf6_interface *) NULL; | |
69 | ||
70 | oi = (struct ospf6_interface *) ifp->info; | |
71 | return oi; | |
718e3744 | 72 | } |
73 | ||
508e53e2 | 74 | /* schedule routing table recalculation */ |
6ac29a51 | 75 | static void |
508e53e2 | 76 | ospf6_interface_lsdb_hook (struct ospf6_lsa *lsa) |
718e3744 | 77 | { |
508e53e2 | 78 | switch (ntohs (lsa->header->type)) |
79 | { | |
80 | case OSPF6_LSTYPE_LINK: | |
6452df09 | 81 | if (OSPF6_INTERFACE (lsa->lsdb->data)->state == OSPF6_INTERFACE_DR) |
82 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (OSPF6_INTERFACE (lsa->lsdb->data)); | |
83 | ospf6_spf_schedule (OSPF6_INTERFACE (lsa->lsdb->data)->area); | |
508e53e2 | 84 | break; |
85 | ||
86 | default: | |
508e53e2 | 87 | break; |
88 | } | |
718e3744 | 89 | } |
90 | ||
91 | /* Create new ospf6 interface structure */ | |
92 | struct ospf6_interface * | |
93 | ospf6_interface_create (struct interface *ifp) | |
94 | { | |
508e53e2 | 95 | struct ospf6_interface *oi; |
0c083ee9 | 96 | unsigned int iobuflen; |
718e3744 | 97 | |
508e53e2 | 98 | oi = (struct ospf6_interface *) |
393deb9b | 99 | XCALLOC (MTYPE_OSPF6_IF, sizeof (struct ospf6_interface)); |
718e3744 | 100 | |
393deb9b | 101 | if (!oi) |
718e3744 | 102 | { |
103 | zlog_err ("Can't malloc ospf6_interface for ifindex %d", ifp->ifindex); | |
104 | return (struct ospf6_interface *) NULL; | |
105 | } | |
106 | ||
508e53e2 | 107 | oi->area = (struct ospf6_area *) NULL; |
108 | oi->neighbor_list = list_new (); | |
109 | oi->neighbor_list->cmp = ospf6_neighbor_cmp; | |
110 | oi->linklocal_addr = (struct in6_addr *) NULL; | |
b51a3a31 VT |
111 | oi->instance_id = OSPF6_INTERFACE_INSTANCE_ID; |
112 | oi->transdelay = OSPF6_INTERFACE_TRANSDELAY; | |
113 | oi->priority = OSPF6_INTERFACE_PRIORITY; | |
114 | ||
115 | oi->hello_interval = OSPF6_INTERFACE_HELLO_INTERVAL; | |
116 | oi->dead_interval = OSPF6_INTERFACE_DEAD_INTERVAL; | |
117 | oi->rxmt_interval = OSPF6_INTERFACE_RXMT_INTERVAL; | |
118 | oi->cost = OSPF6_INTERFACE_COST; | |
508e53e2 | 119 | oi->state = OSPF6_INTERFACE_DOWN; |
120 | oi->flag = 0; | |
d42306d9 | 121 | oi->mtu_ignore = 0; |
508e53e2 | 122 | |
b596c71e | 123 | /* Try to adjust I/O buffer size with IfMtu */ |
1203e1c0 | 124 | oi->ifmtu = ifp->mtu6; |
125 | iobuflen = ospf6_iobuf_size (ifp->mtu6); | |
b596c71e | 126 | if (oi->ifmtu > iobuflen) |
3b4cd3a9 | 127 | { |
1e05838a | 128 | if (IS_OSPF6_DEBUG_INTERFACE) |
c6487d61 | 129 | zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.", |
130 | ifp->name, iobuflen); | |
3b4cd3a9 | 131 | oi->ifmtu = iobuflen; |
132 | } | |
3b4cd3a9 | 133 | |
6452df09 | 134 | oi->lsupdate_list = ospf6_lsdb_create (oi); |
135 | oi->lsack_list = ospf6_lsdb_create (oi); | |
136 | oi->lsdb = ospf6_lsdb_create (oi); | |
508e53e2 | 137 | oi->lsdb->hook_add = ospf6_interface_lsdb_hook; |
138 | oi->lsdb->hook_remove = ospf6_interface_lsdb_hook; | |
6452df09 | 139 | oi->lsdb_self = ospf6_lsdb_create (oi); |
508e53e2 | 140 | |
cf1ce250 PJ |
141 | oi->route_connected = OSPF6_ROUTE_TABLE_CREATE (INTERFACE, CONNECTED_ROUTES); |
142 | oi->route_connected->scope = oi; | |
718e3744 | 143 | |
144 | /* link both */ | |
508e53e2 | 145 | oi->interface = ifp; |
146 | ifp->info = oi; | |
718e3744 | 147 | |
508e53e2 | 148 | return oi; |
718e3744 | 149 | } |
150 | ||
151 | void | |
508e53e2 | 152 | ospf6_interface_delete (struct ospf6_interface *oi) |
718e3744 | 153 | { |
1eb8ef25 | 154 | struct listnode *node, *nnode; |
508e53e2 | 155 | struct ospf6_neighbor *on; |
718e3744 | 156 | |
1eb8ef25 | 157 | for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on)) |
508e53e2 | 158 | ospf6_neighbor_delete (on); |
1eb8ef25 | 159 | |
508e53e2 | 160 | list_delete (oi->neighbor_list); |
718e3744 | 161 | |
508e53e2 | 162 | THREAD_OFF (oi->thread_send_hello); |
163 | THREAD_OFF (oi->thread_send_lsupdate); | |
164 | THREAD_OFF (oi->thread_send_lsack); | |
165 | ||
166 | ospf6_lsdb_remove_all (oi->lsdb); | |
167 | ospf6_lsdb_remove_all (oi->lsupdate_list); | |
168 | ospf6_lsdb_remove_all (oi->lsack_list); | |
169 | ||
170 | ospf6_lsdb_delete (oi->lsdb); | |
6452df09 | 171 | ospf6_lsdb_delete (oi->lsdb_self); |
172 | ||
508e53e2 | 173 | ospf6_lsdb_delete (oi->lsupdate_list); |
174 | ospf6_lsdb_delete (oi->lsack_list); | |
718e3744 | 175 | |
508e53e2 | 176 | ospf6_route_table_delete (oi->route_connected); |
718e3744 | 177 | |
178 | /* cut link */ | |
508e53e2 | 179 | oi->interface->info = NULL; |
718e3744 | 180 | |
181 | /* plist_name */ | |
508e53e2 | 182 | if (oi->plist_name) |
183 | XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name); | |
184 | ||
185 | XFREE (MTYPE_OSPF6_IF, oi); | |
186 | } | |
187 | ||
188 | void | |
189 | ospf6_interface_enable (struct ospf6_interface *oi) | |
190 | { | |
191 | UNSET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE); | |
718e3744 | 192 | |
508e53e2 | 193 | oi->thread_send_hello = |
194 | thread_add_event (master, ospf6_hello_send, oi, 0); | |
195 | } | |
196 | ||
197 | void | |
198 | ospf6_interface_disable (struct ospf6_interface *oi) | |
199 | { | |
1eb8ef25 | 200 | struct listnode *node, *nnode; |
508e53e2 | 201 | struct ospf6_neighbor *on; |
202 | ||
203 | SET_FLAG (oi->flag, OSPF6_INTERFACE_DISABLE); | |
204 | ||
1eb8ef25 | 205 | for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on)) |
508e53e2 | 206 | ospf6_neighbor_delete (on); |
1eb8ef25 | 207 | |
508e53e2 | 208 | list_delete_all_node (oi->neighbor_list); |
209 | ||
210 | ospf6_lsdb_remove_all (oi->lsdb); | |
211 | ospf6_lsdb_remove_all (oi->lsupdate_list); | |
212 | ospf6_lsdb_remove_all (oi->lsack_list); | |
213 | ||
214 | THREAD_OFF (oi->thread_send_hello); | |
215 | THREAD_OFF (oi->thread_send_lsupdate); | |
216 | THREAD_OFF (oi->thread_send_lsack); | |
718e3744 | 217 | } |
218 | ||
219 | static struct in6_addr * | |
508e53e2 | 220 | ospf6_interface_get_linklocal_address (struct interface *ifp) |
718e3744 | 221 | { |
52dc7ee6 | 222 | struct listnode *n; |
718e3744 | 223 | struct connected *c; |
224 | struct in6_addr *l = (struct in6_addr *) NULL; | |
225 | ||
226 | /* for each connected address */ | |
1eb8ef25 | 227 | for (ALL_LIST_ELEMENTS_RO (ifp->connected, n, c)) |
718e3744 | 228 | { |
718e3744 | 229 | /* if family not AF_INET6, ignore */ |
230 | if (c->address->family != AF_INET6) | |
231 | continue; | |
232 | ||
233 | /* linklocal scope check */ | |
234 | if (IN6_IS_ADDR_LINKLOCAL (&c->address->u.prefix6)) | |
235 | l = &c->address->u.prefix6; | |
236 | } | |
237 | return l; | |
238 | } | |
239 | ||
240 | void | |
241 | ospf6_interface_if_add (struct interface *ifp) | |
242 | { | |
508e53e2 | 243 | struct ospf6_interface *oi; |
0c083ee9 | 244 | unsigned int iobuflen; |
718e3744 | 245 | |
508e53e2 | 246 | oi = (struct ospf6_interface *) ifp->info; |
247 | if (oi == NULL) | |
718e3744 | 248 | return; |
249 | ||
b596c71e | 250 | /* Try to adjust I/O buffer size with IfMtu */ |
251 | if (oi->ifmtu == 0) | |
1203e1c0 | 252 | oi->ifmtu = ifp->mtu6; |
253 | iobuflen = ospf6_iobuf_size (ifp->mtu6); | |
b596c71e | 254 | if (oi->ifmtu > iobuflen) |
3b4cd3a9 | 255 | { |
1e05838a | 256 | if (IS_OSPF6_DEBUG_INTERFACE) |
c6487d61 | 257 | zlog_debug ("Interface %s: IfMtu is adjusted to I/O buffer size: %d.", |
258 | ifp->name, iobuflen); | |
3b4cd3a9 | 259 | oi->ifmtu = iobuflen; |
260 | } | |
718e3744 | 261 | |
262 | /* interface start */ | |
508e53e2 | 263 | if (oi->area) |
264 | thread_add_event (master, interface_up, oi, 0); | |
718e3744 | 265 | } |
266 | ||
267 | void | |
268 | ospf6_interface_if_del (struct interface *ifp) | |
269 | { | |
508e53e2 | 270 | struct ospf6_interface *oi; |
718e3744 | 271 | |
508e53e2 | 272 | oi = (struct ospf6_interface *) ifp->info; |
273 | if (oi == NULL) | |
718e3744 | 274 | return; |
275 | ||
276 | /* interface stop */ | |
508e53e2 | 277 | if (oi->area) |
278 | thread_execute (master, interface_down, oi, 0); | |
718e3744 | 279 | |
508e53e2 | 280 | listnode_delete (oi->area->if_list, oi); |
281 | oi->area = (struct ospf6_area *) NULL; | |
718e3744 | 282 | |
283 | /* cut link */ | |
508e53e2 | 284 | oi->interface = NULL; |
718e3744 | 285 | ifp->info = NULL; |
286 | ||
508e53e2 | 287 | ospf6_interface_delete (oi); |
718e3744 | 288 | } |
289 | ||
290 | void | |
291 | ospf6_interface_state_update (struct interface *ifp) | |
292 | { | |
508e53e2 | 293 | struct ospf6_interface *oi; |
718e3744 | 294 | |
508e53e2 | 295 | oi = (struct ospf6_interface *) ifp->info; |
296 | if (oi == NULL) | |
718e3744 | 297 | return; |
508e53e2 | 298 | if (oi->area == NULL) |
718e3744 | 299 | return; |
300 | ||
301 | if (if_is_up (ifp)) | |
508e53e2 | 302 | thread_add_event (master, interface_up, oi, 0); |
718e3744 | 303 | else |
508e53e2 | 304 | thread_add_event (master, interface_down, oi, 0); |
718e3744 | 305 | |
306 | return; | |
307 | } | |
308 | ||
309 | void | |
508e53e2 | 310 | ospf6_interface_connected_route_update (struct interface *ifp) |
718e3744 | 311 | { |
508e53e2 | 312 | struct ospf6_interface *oi; |
313 | struct ospf6_route *route; | |
314 | struct connected *c; | |
1eb8ef25 | 315 | struct listnode *node, *nnode; |
718e3744 | 316 | |
508e53e2 | 317 | oi = (struct ospf6_interface *) ifp->info; |
318 | if (oi == NULL) | |
718e3744 | 319 | return; |
320 | ||
321 | /* reset linklocal pointer */ | |
508e53e2 | 322 | oi->linklocal_addr = ospf6_interface_get_linklocal_address (ifp); |
718e3744 | 323 | |
508e53e2 | 324 | /* if area is null, do not make connected-route list */ |
325 | if (oi->area == NULL) | |
718e3744 | 326 | return; |
327 | ||
508e53e2 | 328 | /* update "route to advertise" interface route table */ |
329 | ospf6_route_remove_all (oi->route_connected); | |
508e53e2 | 330 | |
1eb8ef25 | 331 | for (ALL_LIST_ELEMENTS (oi->interface->connected, node, nnode, c)) |
332 | { | |
508e53e2 | 333 | if (c->address->family != AF_INET6) |
334 | continue; | |
335 | ||
1e05838a | 336 | CONTINUE_IF_ADDRESS_LINKLOCAL (IS_OSPF6_DEBUG_INTERFACE, c->address); |
337 | CONTINUE_IF_ADDRESS_UNSPECIFIED (IS_OSPF6_DEBUG_INTERFACE, c->address); | |
338 | CONTINUE_IF_ADDRESS_LOOPBACK (IS_OSPF6_DEBUG_INTERFACE, c->address); | |
339 | CONTINUE_IF_ADDRESS_V4COMPAT (IS_OSPF6_DEBUG_INTERFACE, c->address); | |
340 | CONTINUE_IF_ADDRESS_V4MAPPED (IS_OSPF6_DEBUG_INTERFACE, c->address); | |
718e3744 | 341 | |
508e53e2 | 342 | /* apply filter */ |
343 | if (oi->plist_name) | |
344 | { | |
345 | struct prefix_list *plist; | |
346 | enum prefix_list_type ret; | |
347 | char buf[128]; | |
348 | ||
349 | prefix2str (c->address, buf, sizeof (buf)); | |
350 | plist = prefix_list_lookup (AFI_IP6, oi->plist_name); | |
351 | ret = prefix_list_apply (plist, (void *) c->address); | |
352 | if (ret == PREFIX_DENY) | |
353 | { | |
1e05838a | 354 | if (IS_OSPF6_DEBUG_INTERFACE) |
c6487d61 | 355 | zlog_debug ("%s on %s filtered by prefix-list %s ", |
356 | buf, oi->interface->name, oi->plist_name); | |
508e53e2 | 357 | continue; |
358 | } | |
359 | } | |
360 | ||
361 | route = ospf6_route_create (); | |
362 | memcpy (&route->prefix, c->address, sizeof (struct prefix)); | |
363 | apply_mask (&route->prefix); | |
364 | route->type = OSPF6_DEST_TYPE_NETWORK; | |
365 | route->path.area_id = oi->area->area_id; | |
366 | route->path.type = OSPF6_PATH_TYPE_INTRA; | |
367 | route->path.cost = oi->cost; | |
368 | route->nexthop[0].ifindex = oi->interface->ifindex; | |
369 | inet_pton (AF_INET6, "::1", &route->nexthop[0].address); | |
370 | ospf6_route_add (route, oi->route_connected); | |
371 | } | |
372 | ||
373 | /* create new Link-LSA */ | |
374 | OSPF6_LINK_LSA_SCHEDULE (oi); | |
375 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi); | |
376 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area); | |
718e3744 | 377 | } |
378 | ||
508e53e2 | 379 | static void |
380 | ospf6_interface_state_change (u_char next_state, struct ospf6_interface *oi) | |
718e3744 | 381 | { |
508e53e2 | 382 | u_char prev_state; |
718e3744 | 383 | |
508e53e2 | 384 | prev_state = oi->state; |
385 | oi->state = next_state; | |
718e3744 | 386 | |
508e53e2 | 387 | if (prev_state == next_state) |
388 | return; | |
389 | ||
390 | /* log */ | |
391 | if (IS_OSPF6_DEBUG_INTERFACE) | |
392 | { | |
c6487d61 | 393 | zlog_debug ("Interface state change %s: %s -> %s", oi->interface->name, |
394 | ospf6_interface_state_str[prev_state], | |
395 | ospf6_interface_state_str[next_state]); | |
508e53e2 | 396 | } |
3bc4f84e | 397 | oi->state_change++; |
718e3744 | 398 | |
508e53e2 | 399 | if ((prev_state == OSPF6_INTERFACE_DR || |
400 | prev_state == OSPF6_INTERFACE_BDR) && | |
401 | (next_state != OSPF6_INTERFACE_DR && | |
402 | next_state != OSPF6_INTERFACE_BDR)) | |
9a9446ea | 403 | ospf6_sso (oi->interface->ifindex, &alldrouters6, IPV6_LEAVE_GROUP); |
508e53e2 | 404 | if ((prev_state != OSPF6_INTERFACE_DR && |
405 | prev_state != OSPF6_INTERFACE_BDR) && | |
406 | (next_state == OSPF6_INTERFACE_DR || | |
407 | next_state == OSPF6_INTERFACE_BDR)) | |
9a9446ea | 408 | ospf6_sso (oi->interface->ifindex, &alldrouters6, IPV6_JOIN_GROUP); |
508e53e2 | 409 | |
410 | OSPF6_ROUTER_LSA_SCHEDULE (oi->area); | |
6452df09 | 411 | if (next_state == OSPF6_INTERFACE_DOWN) |
412 | { | |
413 | OSPF6_NETWORK_LSA_EXECUTE (oi); | |
414 | OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT (oi); | |
415 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area); | |
416 | } | |
417 | else if (prev_state == OSPF6_INTERFACE_DR || | |
418 | next_state == OSPF6_INTERFACE_DR) | |
508e53e2 | 419 | { |
420 | OSPF6_NETWORK_LSA_SCHEDULE (oi); | |
421 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi); | |
422 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area); | |
423 | } | |
718e3744 | 424 | } |
425 | ||
508e53e2 | 426 | \f |
427 | /* DR Election, RFC2328 section 9.4 */ | |
718e3744 | 428 | |
508e53e2 | 429 | #define IS_ELIGIBLE(n) \ |
430 | ((n)->state >= OSPF6_NEIGHBOR_TWOWAY && (n)->priority != 0) | |
718e3744 | 431 | |
508e53e2 | 432 | static struct ospf6_neighbor * |
433 | better_bdrouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b) | |
434 | { | |
435 | if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id) && | |
436 | (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id)) | |
437 | return NULL; | |
438 | else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter == a->router_id) | |
439 | return b; | |
440 | else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter == b->router_id) | |
441 | return a; | |
442 | ||
443 | if (a->bdrouter == a->router_id && b->bdrouter != b->router_id) | |
444 | return a; | |
445 | if (a->bdrouter != a->router_id && b->bdrouter == b->router_id) | |
446 | return b; | |
447 | ||
448 | if (a->priority > b->priority) | |
449 | return a; | |
450 | if (a->priority < b->priority) | |
451 | return b; | |
452 | ||
453 | if (ntohl (a->router_id) > ntohl (b->router_id)) | |
454 | return a; | |
455 | if (ntohl (a->router_id) < ntohl (b->router_id)) | |
456 | return b; | |
457 | ||
458 | zlog_warn ("Router-ID duplicate ?"); | |
459 | return a; | |
460 | } | |
718e3744 | 461 | |
508e53e2 | 462 | static struct ospf6_neighbor * |
463 | better_drouter (struct ospf6_neighbor *a, struct ospf6_neighbor *b) | |
464 | { | |
465 | if ((a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id) && | |
466 | (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id)) | |
467 | return NULL; | |
468 | else if (a == NULL || ! IS_ELIGIBLE (a) || a->drouter != a->router_id) | |
469 | return b; | |
470 | else if (b == NULL || ! IS_ELIGIBLE (b) || b->drouter != b->router_id) | |
471 | return a; | |
472 | ||
473 | if (a->drouter == a->router_id && b->drouter != b->router_id) | |
474 | return a; | |
475 | if (a->drouter != a->router_id && b->drouter == b->router_id) | |
476 | return b; | |
477 | ||
478 | if (a->priority > b->priority) | |
479 | return a; | |
480 | if (a->priority < b->priority) | |
481 | return b; | |
482 | ||
483 | if (ntohl (a->router_id) > ntohl (b->router_id)) | |
484 | return a; | |
485 | if (ntohl (a->router_id) < ntohl (b->router_id)) | |
486 | return b; | |
487 | ||
488 | zlog_warn ("Router-ID duplicate ?"); | |
489 | return a; | |
718e3744 | 490 | } |
491 | ||
508e53e2 | 492 | static u_char |
493 | dr_election (struct ospf6_interface *oi) | |
718e3744 | 494 | { |
1eb8ef25 | 495 | struct listnode *node, *nnode; |
508e53e2 | 496 | struct ospf6_neighbor *on, *drouter, *bdrouter, myself; |
497 | struct ospf6_neighbor *best_drouter, *best_bdrouter; | |
498 | u_char next_state = 0; | |
499 | ||
500 | drouter = bdrouter = NULL; | |
501 | best_drouter = best_bdrouter = NULL; | |
502 | ||
503 | /* pseudo neighbor myself, including noting current DR/BDR (1) */ | |
504 | memset (&myself, 0, sizeof (myself)); | |
505 | inet_ntop (AF_INET, &oi->area->ospf6->router_id, myself.name, | |
506 | sizeof (myself.name)); | |
507 | myself.state = OSPF6_NEIGHBOR_TWOWAY; | |
508 | myself.drouter = oi->drouter; | |
509 | myself.bdrouter = oi->bdrouter; | |
510 | myself.priority = oi->priority; | |
511 | myself.router_id = oi->area->ospf6->router_id; | |
512 | ||
513 | /* Electing BDR (2) */ | |
1eb8ef25 | 514 | for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on)) |
515 | bdrouter = better_bdrouter (bdrouter, on); | |
516 | ||
508e53e2 | 517 | best_bdrouter = bdrouter; |
518 | bdrouter = better_bdrouter (best_bdrouter, &myself); | |
519 | ||
520 | /* Electing DR (3) */ | |
1eb8ef25 | 521 | for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on)) |
522 | drouter = better_drouter (drouter, on); | |
523 | ||
508e53e2 | 524 | best_drouter = drouter; |
525 | drouter = better_drouter (best_drouter, &myself); | |
526 | if (drouter == NULL) | |
527 | drouter = bdrouter; | |
528 | ||
529 | /* the router itself is newly/no longer DR/BDR (4) */ | |
530 | if ((drouter == &myself && myself.drouter != myself.router_id) || | |
531 | (drouter != &myself && myself.drouter == myself.router_id) || | |
532 | (bdrouter == &myself && myself.bdrouter != myself.router_id) || | |
533 | (bdrouter != &myself && myself.bdrouter == myself.router_id)) | |
534 | { | |
535 | myself.drouter = (drouter ? drouter->router_id : htonl (0)); | |
536 | myself.bdrouter = (bdrouter ? bdrouter->router_id : htonl (0)); | |
537 | ||
538 | /* compatible to Electing BDR (2) */ | |
539 | bdrouter = better_bdrouter (best_bdrouter, &myself); | |
540 | ||
541 | /* compatible to Electing DR (3) */ | |
542 | drouter = better_drouter (best_drouter, &myself); | |
543 | if (drouter == NULL) | |
544 | drouter = bdrouter; | |
545 | } | |
546 | ||
547 | /* Set interface state accordingly (5) */ | |
548 | if (drouter && drouter == &myself) | |
549 | next_state = OSPF6_INTERFACE_DR; | |
550 | else if (bdrouter && bdrouter == &myself) | |
551 | next_state = OSPF6_INTERFACE_BDR; | |
552 | else | |
553 | next_state = OSPF6_INTERFACE_DROTHER; | |
718e3744 | 554 | |
508e53e2 | 555 | /* If NBMA, schedule Start for each neighbor having priority of 0 (6) */ |
556 | /* XXX */ | |
557 | ||
558 | /* If DR or BDR change, invoke AdjOK? for each neighbor (7) */ | |
559 | /* RFC 2328 section 12.4. Originating LSAs (3) will be handled | |
560 | accordingly after AdjOK */ | |
561 | if (oi->drouter != (drouter ? drouter->router_id : htonl (0)) || | |
562 | oi->bdrouter != (bdrouter ? bdrouter->router_id : htonl (0))) | |
718e3744 | 563 | { |
508e53e2 | 564 | if (IS_OSPF6_DEBUG_INTERFACE) |
c6487d61 | 565 | zlog_debug ("DR Election on %s: DR: %s BDR: %s", oi->interface->name, |
566 | (drouter ? drouter->name : "0.0.0.0"), | |
567 | (bdrouter ? bdrouter->name : "0.0.0.0")); | |
508e53e2 | 568 | |
1eb8ef25 | 569 | for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, node, on)) |
508e53e2 | 570 | { |
508e53e2 | 571 | if (on->state < OSPF6_NEIGHBOR_TWOWAY) |
572 | continue; | |
573 | /* Schedule AdjOK. */ | |
574 | thread_add_event (master, adj_ok, on, 0); | |
575 | } | |
718e3744 | 576 | } |
508e53e2 | 577 | |
578 | oi->drouter = (drouter ? drouter->router_id : htonl (0)); | |
579 | oi->bdrouter = (bdrouter ? bdrouter->router_id : htonl (0)); | |
580 | return next_state; | |
718e3744 | 581 | } |
582 | ||
508e53e2 | 583 | \f |
584 | /* Interface State Machine */ | |
718e3744 | 585 | int |
508e53e2 | 586 | interface_up (struct thread *thread) |
718e3744 | 587 | { |
508e53e2 | 588 | struct ospf6_interface *oi; |
589 | ||
590 | oi = (struct ospf6_interface *) THREAD_ARG (thread); | |
591 | assert (oi && oi->interface); | |
592 | ||
593 | if (IS_OSPF6_DEBUG_INTERFACE) | |
c6487d61 | 594 | zlog_debug ("Interface Event %s: [InterfaceUp]", |
595 | oi->interface->name); | |
508e53e2 | 596 | |
597 | /* check physical interface is up */ | |
598 | if (! if_is_up (oi->interface)) | |
599 | { | |
600 | if (IS_OSPF6_DEBUG_INTERFACE) | |
c6487d61 | 601 | zlog_debug ("Interface %s is down, can't execute [InterfaceUp]", |
602 | oi->interface->name); | |
508e53e2 | 603 | return 0; |
604 | } | |
605 | ||
606 | /* if already enabled, do nothing */ | |
607 | if (oi->state > OSPF6_INTERFACE_DOWN) | |
608 | { | |
609 | if (IS_OSPF6_DEBUG_INTERFACE) | |
c6487d61 | 610 | zlog_debug ("Interface %s already enabled", |
611 | oi->interface->name); | |
508e53e2 | 612 | return 0; |
613 | } | |
614 | ||
615 | /* Join AllSPFRouters */ | |
9a9446ea | 616 | ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_JOIN_GROUP); |
508e53e2 | 617 | |
618 | /* Update interface route */ | |
619 | ospf6_interface_connected_route_update (oi->interface); | |
718e3744 | 620 | |
508e53e2 | 621 | /* Schedule Hello */ |
622 | if (! CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE)) | |
623 | thread_add_event (master, ospf6_hello_send, oi, 0); | |
624 | ||
625 | /* decide next interface state */ | |
626 | if (if_is_pointopoint (oi->interface)) | |
627 | ospf6_interface_state_change (OSPF6_INTERFACE_POINTTOPOINT, oi); | |
628 | else if (oi->priority == 0) | |
629 | ospf6_interface_state_change (OSPF6_INTERFACE_DROTHER, oi); | |
630 | else | |
718e3744 | 631 | { |
508e53e2 | 632 | ospf6_interface_state_change (OSPF6_INTERFACE_WAITING, oi); |
633 | thread_add_timer (master, wait_timer, oi, oi->dead_interval); | |
718e3744 | 634 | } |
508e53e2 | 635 | |
636 | return 0; | |
718e3744 | 637 | } |
638 | ||
639 | int | |
508e53e2 | 640 | wait_timer (struct thread *thread) |
718e3744 | 641 | { |
508e53e2 | 642 | struct ospf6_interface *oi; |
718e3744 | 643 | |
508e53e2 | 644 | oi = (struct ospf6_interface *) THREAD_ARG (thread); |
645 | assert (oi && oi->interface); | |
718e3744 | 646 | |
508e53e2 | 647 | if (IS_OSPF6_DEBUG_INTERFACE) |
c6487d61 | 648 | zlog_debug ("Interface Event %s: [WaitTimer]", |
649 | oi->interface->name); | |
718e3744 | 650 | |
508e53e2 | 651 | if (oi->state == OSPF6_INTERFACE_WAITING) |
652 | ospf6_interface_state_change (dr_election (oi), oi); | |
718e3744 | 653 | |
508e53e2 | 654 | return 0; |
718e3744 | 655 | } |
656 | ||
508e53e2 | 657 | int |
658 | backup_seen (struct thread *thread) | |
659 | { | |
660 | struct ospf6_interface *oi; | |
661 | ||
662 | oi = (struct ospf6_interface *) THREAD_ARG (thread); | |
663 | assert (oi && oi->interface); | |
664 | ||
665 | if (IS_OSPF6_DEBUG_INTERFACE) | |
c6487d61 | 666 | zlog_debug ("Interface Event %s: [BackupSeen]", |
667 | oi->interface->name); | |
508e53e2 | 668 | |
669 | if (oi->state == OSPF6_INTERFACE_WAITING) | |
670 | ospf6_interface_state_change (dr_election (oi), oi); | |
671 | ||
672 | return 0; | |
673 | } | |
674 | ||
675 | int | |
676 | neighbor_change (struct thread *thread) | |
718e3744 | 677 | { |
508e53e2 | 678 | struct ospf6_interface *oi; |
679 | ||
680 | oi = (struct ospf6_interface *) THREAD_ARG (thread); | |
681 | assert (oi && oi->interface); | |
682 | ||
683 | if (IS_OSPF6_DEBUG_INTERFACE) | |
c6487d61 | 684 | zlog_debug ("Interface Event %s: [NeighborChange]", |
685 | oi->interface->name); | |
508e53e2 | 686 | |
687 | if (oi->state == OSPF6_INTERFACE_DROTHER || | |
688 | oi->state == OSPF6_INTERFACE_BDR || | |
689 | oi->state == OSPF6_INTERFACE_DR) | |
690 | ospf6_interface_state_change (dr_election (oi), oi); | |
691 | ||
692 | return 0; | |
718e3744 | 693 | } |
694 | ||
508e53e2 | 695 | int |
696 | interface_down (struct thread *thread) | |
718e3744 | 697 | { |
508e53e2 | 698 | struct ospf6_interface *oi; |
1eb8ef25 | 699 | struct listnode *node, *nnode; |
508e53e2 | 700 | struct ospf6_neighbor *on; |
701 | ||
702 | oi = (struct ospf6_interface *) THREAD_ARG (thread); | |
703 | assert (oi && oi->interface); | |
704 | ||
705 | if (IS_OSPF6_DEBUG_INTERFACE) | |
c6487d61 | 706 | zlog_debug ("Interface Event %s: [InterfaceDown]", |
707 | oi->interface->name); | |
508e53e2 | 708 | |
709 | /* Leave AllSPFRouters */ | |
710 | if (oi->state > OSPF6_INTERFACE_DOWN) | |
9a9446ea | 711 | ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_LEAVE_GROUP); |
508e53e2 | 712 | |
713 | ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi); | |
714 | ||
1eb8ef25 | 715 | for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on)) |
716 | ospf6_neighbor_delete (on); | |
717 | ||
508e53e2 | 718 | list_delete_all_node (oi->neighbor_list); |
719 | ||
720 | return 0; | |
718e3744 | 721 | } |
722 | ||
508e53e2 | 723 | \f |
718e3744 | 724 | /* show specified interface structure */ |
6ac29a51 | 725 | static int |
508e53e2 | 726 | ospf6_interface_show (struct vty *vty, struct interface *ifp) |
718e3744 | 727 | { |
508e53e2 | 728 | struct ospf6_interface *oi; |
718e3744 | 729 | struct connected *c; |
730 | struct prefix *p; | |
52dc7ee6 | 731 | struct listnode *i; |
508e53e2 | 732 | char strbuf[64], drouter[32], bdrouter[32]; |
0c083ee9 | 733 | const char *updown[3] = {"down", "up", NULL}; |
734 | const char *type; | |
508e53e2 | 735 | struct timeval res, now; |
736 | char duration[32]; | |
737 | struct ospf6_lsa *lsa; | |
718e3744 | 738 | |
739 | /* check physical interface type */ | |
508e53e2 | 740 | if (if_is_loopback (ifp)) |
718e3744 | 741 | type = "LOOPBACK"; |
508e53e2 | 742 | else if (if_is_broadcast (ifp)) |
718e3744 | 743 | type = "BROADCAST"; |
508e53e2 | 744 | else if (if_is_pointopoint (ifp)) |
718e3744 | 745 | type = "POINTOPOINT"; |
746 | else | |
747 | type = "UNKNOWN"; | |
748 | ||
749 | vty_out (vty, "%s is %s, type %s%s", | |
508e53e2 | 750 | ifp->name, updown[if_is_up (ifp)], type, |
049207c3 | 751 | VNL); |
752 | vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VNL); | |
718e3744 | 753 | |
508e53e2 | 754 | if (ifp->info == NULL) |
718e3744 | 755 | { |
049207c3 | 756 | vty_out (vty, " OSPF not enabled on this interface%s", VNL); |
718e3744 | 757 | return 0; |
758 | } | |
759 | else | |
508e53e2 | 760 | oi = (struct ospf6_interface *) ifp->info; |
718e3744 | 761 | |
049207c3 | 762 | vty_out (vty, " Internet Address:%s", VNL); |
1eb8ef25 | 763 | |
764 | for (ALL_LIST_ELEMENTS_RO (ifp->connected, i, c)) | |
718e3744 | 765 | { |
718e3744 | 766 | p = c->address; |
767 | prefix2str (p, strbuf, sizeof (strbuf)); | |
768 | switch (p->family) | |
769 | { | |
770 | case AF_INET: | |
508e53e2 | 771 | vty_out (vty, " inet : %s%s", strbuf, |
049207c3 | 772 | VNL); |
718e3744 | 773 | break; |
774 | case AF_INET6: | |
508e53e2 | 775 | vty_out (vty, " inet6: %s%s", strbuf, |
049207c3 | 776 | VNL); |
718e3744 | 777 | break; |
778 | default: | |
508e53e2 | 779 | vty_out (vty, " ??? : %s%s", strbuf, |
049207c3 | 780 | VNL); |
718e3744 | 781 | break; |
782 | } | |
783 | } | |
784 | ||
508e53e2 | 785 | if (oi->area) |
718e3744 | 786 | { |
508e53e2 | 787 | vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s", |
049207c3 | 788 | oi->instance_id, oi->ifmtu, ifp->mtu6, VNL); |
d42306d9 DT |
789 | vty_out (vty, " MTU mismatch detection: %s%s", oi->mtu_ignore ? |
790 | "disabled" : "enabled", VNL); | |
508e53e2 | 791 | inet_ntop (AF_INET, &oi->area->area_id, |
718e3744 | 792 | strbuf, sizeof (strbuf)); |
508e53e2 | 793 | vty_out (vty, " Area ID %s, Cost %hu%s", strbuf, oi->cost, |
049207c3 | 794 | VNL); |
718e3744 | 795 | } |
796 | else | |
049207c3 | 797 | vty_out (vty, " Not Attached to Area%s", VNL); |
718e3744 | 798 | |
799 | vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s", | |
508e53e2 | 800 | ospf6_interface_state_str[oi->state], |
801 | oi->transdelay, oi->priority, | |
049207c3 | 802 | VNL); |
803 | vty_out (vty, " Timer intervals configured:%s", VNL); | |
718e3744 | 804 | vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s", |
508e53e2 | 805 | oi->hello_interval, oi->dead_interval, oi->rxmt_interval, |
049207c3 | 806 | VNL); |
718e3744 | 807 | |
508e53e2 | 808 | inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter)); |
809 | inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter)); | |
049207c3 | 810 | vty_out (vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL); |
718e3744 | 811 | |
812 | vty_out (vty, " Number of I/F scoped LSAs is %u%s", | |
049207c3 | 813 | oi->lsdb->count, VNL); |
718e3744 | 814 | |
86f72dcb | 815 | quagga_gettime (QUAGGA_CLK_MONOTONIC, &now); |
718e3744 | 816 | |
508e53e2 | 817 | timerclear (&res); |
818 | if (oi->thread_send_lsupdate) | |
819 | timersub (&oi->thread_send_lsupdate->u.sands, &now, &res); | |
820 | timerstring (&res, duration, sizeof (duration)); | |
821 | vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s", | |
822 | oi->lsupdate_list->count, duration, | |
823 | (oi->thread_send_lsupdate ? "on" : "off"), | |
049207c3 | 824 | VNL); |
508e53e2 | 825 | for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa; |
826 | lsa = ospf6_lsdb_next (lsa)) | |
049207c3 | 827 | vty_out (vty, " %s%s", lsa->name, VNL); |
508e53e2 | 828 | |
829 | timerclear (&res); | |
830 | if (oi->thread_send_lsack) | |
831 | timersub (&oi->thread_send_lsack->u.sands, &now, &res); | |
832 | timerstring (&res, duration, sizeof (duration)); | |
833 | vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s", | |
834 | oi->lsack_list->count, duration, | |
835 | (oi->thread_send_lsack ? "on" : "off"), | |
049207c3 | 836 | VNL); |
508e53e2 | 837 | for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa; |
838 | lsa = ospf6_lsdb_next (lsa)) | |
049207c3 | 839 | vty_out (vty, " %s%s", lsa->name, VNL); |
718e3744 | 840 | |
508e53e2 | 841 | return 0; |
718e3744 | 842 | } |
843 | ||
844 | /* show interface */ | |
845 | DEFUN (show_ipv6_ospf6_interface, | |
846 | show_ipv6_ospf6_interface_ifname_cmd, | |
847 | "show ipv6 ospf6 interface IFNAME", | |
848 | SHOW_STR | |
849 | IP6_STR | |
850 | OSPF6_STR | |
851 | INTERFACE_STR | |
852 | IFNAME_STR | |
853 | ) | |
854 | { | |
855 | struct interface *ifp; | |
52dc7ee6 | 856 | struct listnode *i; |
718e3744 | 857 | |
858 | if (argc) | |
859 | { | |
860 | ifp = if_lookup_by_name (argv[0]); | |
508e53e2 | 861 | if (ifp == NULL) |
718e3744 | 862 | { |
863 | vty_out (vty, "No such Interface: %s%s", argv[0], | |
049207c3 | 864 | VNL); |
718e3744 | 865 | return CMD_WARNING; |
866 | } | |
867 | ospf6_interface_show (vty, ifp); | |
868 | } | |
869 | else | |
870 | { | |
1eb8ef25 | 871 | for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp)) |
872 | ospf6_interface_show (vty, ifp); | |
718e3744 | 873 | } |
508e53e2 | 874 | |
718e3744 | 875 | return CMD_SUCCESS; |
876 | } | |
877 | ||
878 | ALIAS (show_ipv6_ospf6_interface, | |
879 | show_ipv6_ospf6_interface_cmd, | |
880 | "show ipv6 ospf6 interface", | |
881 | SHOW_STR | |
882 | IP6_STR | |
883 | OSPF6_STR | |
884 | INTERFACE_STR | |
6ac29a51 | 885 | ) |
508e53e2 | 886 | |
887 | DEFUN (show_ipv6_ospf6_interface_ifname_prefix, | |
888 | show_ipv6_ospf6_interface_ifname_prefix_cmd, | |
889 | "show ipv6 ospf6 interface IFNAME prefix", | |
890 | SHOW_STR | |
891 | IP6_STR | |
892 | OSPF6_STR | |
893 | INTERFACE_STR | |
894 | IFNAME_STR | |
895 | "Display connected prefixes to advertise\n" | |
718e3744 | 896 | ) |
508e53e2 | 897 | { |
898 | struct interface *ifp; | |
899 | struct ospf6_interface *oi; | |
900 | ||
901 | ifp = if_lookup_by_name (argv[0]); | |
902 | if (ifp == NULL) | |
903 | { | |
049207c3 | 904 | vty_out (vty, "No such Interface: %s%s", argv[0], VNL); |
508e53e2 | 905 | return CMD_WARNING; |
906 | } | |
907 | ||
908 | oi = ifp->info; | |
909 | if (oi == NULL) | |
910 | { | |
049207c3 | 911 | vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[0], VNL); |
508e53e2 | 912 | return CMD_WARNING; |
913 | } | |
914 | ||
915 | argc--; | |
916 | argv++; | |
917 | ospf6_route_table_show (vty, argc, argv, oi->route_connected); | |
918 | ||
919 | return CMD_SUCCESS; | |
920 | } | |
921 | ||
922 | ALIAS (show_ipv6_ospf6_interface_ifname_prefix, | |
923 | show_ipv6_ospf6_interface_ifname_prefix_detail_cmd, | |
924 | "show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)", | |
925 | SHOW_STR | |
926 | IP6_STR | |
927 | OSPF6_STR | |
928 | INTERFACE_STR | |
929 | IFNAME_STR | |
930 | "Display connected prefixes to advertise\n" | |
931 | OSPF6_ROUTE_ADDRESS_STR | |
932 | OSPF6_ROUTE_PREFIX_STR | |
ea402198 | 933 | "Display details of the prefixes\n" |
6ac29a51 | 934 | ) |
508e53e2 | 935 | |
936 | ALIAS (show_ipv6_ospf6_interface_ifname_prefix, | |
937 | show_ipv6_ospf6_interface_ifname_prefix_match_cmd, | |
938 | "show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)", | |
939 | SHOW_STR | |
940 | IP6_STR | |
941 | OSPF6_STR | |
942 | INTERFACE_STR | |
943 | IFNAME_STR | |
944 | "Display connected prefixes to advertise\n" | |
945 | OSPF6_ROUTE_PREFIX_STR | |
946 | OSPF6_ROUTE_MATCH_STR | |
ea402198 | 947 | "Display details of the prefixes\n" |
6ac29a51 | 948 | ) |
508e53e2 | 949 | |
950 | DEFUN (show_ipv6_ospf6_interface_prefix, | |
951 | show_ipv6_ospf6_interface_prefix_cmd, | |
952 | "show ipv6 ospf6 interface prefix", | |
953 | SHOW_STR | |
954 | IP6_STR | |
955 | OSPF6_STR | |
956 | INTERFACE_STR | |
957 | "Display connected prefixes to advertise\n" | |
958 | ) | |
959 | { | |
52dc7ee6 | 960 | struct listnode *i; |
508e53e2 | 961 | struct ospf6_interface *oi; |
962 | struct interface *ifp; | |
963 | ||
1eb8ef25 | 964 | for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp)) |
508e53e2 | 965 | { |
508e53e2 | 966 | oi = (struct ospf6_interface *) ifp->info; |
967 | if (oi == NULL) | |
968 | continue; | |
969 | ||
970 | ospf6_route_table_show (vty, argc, argv, oi->route_connected); | |
971 | } | |
972 | ||
973 | return CMD_SUCCESS; | |
974 | } | |
975 | ||
976 | ALIAS (show_ipv6_ospf6_interface_prefix, | |
977 | show_ipv6_ospf6_interface_prefix_detail_cmd, | |
978 | "show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)", | |
979 | SHOW_STR | |
980 | IP6_STR | |
981 | OSPF6_STR | |
982 | INTERFACE_STR | |
983 | "Display connected prefixes to advertise\n" | |
984 | OSPF6_ROUTE_ADDRESS_STR | |
985 | OSPF6_ROUTE_PREFIX_STR | |
ea402198 | 986 | "Display details of the prefixes\n" |
6ac29a51 | 987 | ) |
508e53e2 | 988 | |
989 | ALIAS (show_ipv6_ospf6_interface_prefix, | |
990 | show_ipv6_ospf6_interface_prefix_match_cmd, | |
991 | "show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)", | |
992 | SHOW_STR | |
993 | IP6_STR | |
994 | OSPF6_STR | |
995 | INTERFACE_STR | |
996 | "Display connected prefixes to advertise\n" | |
997 | OSPF6_ROUTE_PREFIX_STR | |
998 | OSPF6_ROUTE_MATCH_STR | |
ea402198 | 999 | "Display details of the prefixes\n" |
6ac29a51 | 1000 | ) |
508e53e2 | 1001 | |
718e3744 | 1002 | |
1003 | /* interface variable set command */ | |
b596c71e | 1004 | DEFUN (ipv6_ospf6_ifmtu, |
1005 | ipv6_ospf6_ifmtu_cmd, | |
1006 | "ipv6 ospf6 ifmtu <1-65535>", | |
1007 | IP6_STR | |
1008 | OSPF6_STR | |
1009 | "Interface MTU\n" | |
1010 | "OSPFv3 Interface MTU\n" | |
1011 | ) | |
1012 | { | |
1013 | struct ospf6_interface *oi; | |
1014 | struct interface *ifp; | |
0c083ee9 | 1015 | unsigned int ifmtu, iobuflen; |
1eb8ef25 | 1016 | struct listnode *node, *nnode; |
b596c71e | 1017 | struct ospf6_neighbor *on; |
1018 | ||
1019 | ifp = (struct interface *) vty->index; | |
1020 | assert (ifp); | |
1021 | ||
1022 | oi = (struct ospf6_interface *) ifp->info; | |
1023 | if (oi == NULL) | |
1024 | oi = ospf6_interface_create (ifp); | |
1025 | assert (oi); | |
1026 | ||
1027 | ifmtu = strtol (argv[0], NULL, 10); | |
1028 | ||
1029 | if (oi->ifmtu == ifmtu) | |
1030 | return CMD_SUCCESS; | |
1031 | ||
1203e1c0 | 1032 | if (ifp->mtu6 != 0 && ifp->mtu6 < ifmtu) |
b596c71e | 1033 | { |
1034 | vty_out (vty, "%s's ospf6 ifmtu cannot go beyond physical mtu (%d)%s", | |
049207c3 | 1035 | ifp->name, ifp->mtu6, VNL); |
b596c71e | 1036 | return CMD_WARNING; |
1037 | } | |
1038 | ||
1039 | if (oi->ifmtu < ifmtu) | |
1040 | { | |
1041 | iobuflen = ospf6_iobuf_size (ifmtu); | |
1042 | if (iobuflen < ifmtu) | |
1043 | { | |
1044 | vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s", | |
049207c3 | 1045 | ifp->name, iobuflen, VNL); |
b596c71e | 1046 | oi->ifmtu = iobuflen; |
1047 | } | |
1048 | else | |
1049 | oi->ifmtu = ifmtu; | |
1050 | } | |
1051 | else | |
1052 | oi->ifmtu = ifmtu; | |
1053 | ||
1054 | /* re-establish adjacencies */ | |
1eb8ef25 | 1055 | for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on)) |
b596c71e | 1056 | { |
b596c71e | 1057 | THREAD_OFF (on->inactivity_timer); |
3e834b12 | 1058 | thread_add_event (master, inactivity_timer, on, 0); |
b596c71e | 1059 | } |
1060 | ||
1061 | return CMD_SUCCESS; | |
1062 | } | |
1063 | ||
049207c3 | 1064 | DEFUN (no_ipv6_ospf6_ifmtu, |
1065 | no_ipv6_ospf6_ifmtu_cmd, | |
1066 | "no ipv6 ospf6 ifmtu", | |
1067 | NO_STR | |
1068 | IP6_STR | |
1069 | OSPF6_STR | |
1070 | "Interface MTU\n" | |
1071 | ) | |
1072 | { | |
1073 | struct ospf6_interface *oi; | |
1074 | struct interface *ifp; | |
0c083ee9 | 1075 | unsigned int iobuflen; |
1eb8ef25 | 1076 | struct listnode *node, *nnode; |
049207c3 | 1077 | struct ospf6_neighbor *on; |
1078 | ||
1079 | ifp = (struct interface *) vty->index; | |
1080 | assert (ifp); | |
1081 | ||
1082 | oi = (struct ospf6_interface *) ifp->info; | |
1083 | if (oi == NULL) | |
1084 | oi = ospf6_interface_create (ifp); | |
1085 | assert (oi); | |
1086 | ||
1087 | if (oi->ifmtu < ifp->mtu) | |
1088 | { | |
1089 | iobuflen = ospf6_iobuf_size (ifp->mtu); | |
1090 | if (iobuflen < ifp->mtu) | |
1091 | { | |
1092 | vty_out (vty, "%s's ifmtu is adjusted to I/O buffer size (%d).%s", | |
1093 | ifp->name, iobuflen, VNL); | |
1094 | oi->ifmtu = iobuflen; | |
1095 | } | |
1096 | else | |
1097 | oi->ifmtu = ifp->mtu; | |
1098 | } | |
1099 | else | |
1100 | oi->ifmtu = ifp->mtu; | |
1101 | ||
1102 | /* re-establish adjacencies */ | |
1eb8ef25 | 1103 | for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on)) |
049207c3 | 1104 | { |
049207c3 | 1105 | THREAD_OFF (on->inactivity_timer); |
3e834b12 | 1106 | thread_add_event (master, inactivity_timer, on, 0); |
049207c3 | 1107 | } |
1108 | ||
1109 | return CMD_SUCCESS; | |
1110 | } | |
1111 | ||
718e3744 | 1112 | DEFUN (ipv6_ospf6_cost, |
1113 | ipv6_ospf6_cost_cmd, | |
508e53e2 | 1114 | "ipv6 ospf6 cost <1-65535>", |
718e3744 | 1115 | IP6_STR |
1116 | OSPF6_STR | |
1117 | "Interface cost\n" | |
508e53e2 | 1118 | "Outgoing metric of this interface\n" |
718e3744 | 1119 | ) |
1120 | { | |
508e53e2 | 1121 | struct ospf6_interface *oi; |
718e3744 | 1122 | struct interface *ifp; |
0c083ee9 | 1123 | unsigned long int lcost; |
718e3744 | 1124 | |
508e53e2 | 1125 | ifp = (struct interface *) vty->index; |
718e3744 | 1126 | assert (ifp); |
1127 | ||
508e53e2 | 1128 | oi = (struct ospf6_interface *) ifp->info; |
1129 | if (oi == NULL) | |
1130 | oi = ospf6_interface_create (ifp); | |
1131 | assert (oi); | |
718e3744 | 1132 | |
0c083ee9 | 1133 | lcost = strtol (argv[0], NULL, 10); |
718e3744 | 1134 | |
0c083ee9 | 1135 | if (lcost > UINT32_MAX) |
1136 | { | |
1137 | vty_out (vty, "Cost %ld is out of range%s", lcost, VNL); | |
1138 | return CMD_WARNING; | |
1139 | } | |
1140 | ||
1141 | if (oi->cost == lcost) | |
1142 | return CMD_SUCCESS; | |
1143 | ||
1144 | oi->cost = lcost; | |
1145 | ||
508e53e2 | 1146 | /* update cost held in route_connected list in ospf6_interface */ |
1147 | ospf6_interface_connected_route_update (oi->interface); | |
718e3744 | 1148 | |
508e53e2 | 1149 | /* execute LSA hooks */ |
1150 | if (oi->area) | |
1151 | { | |
1152 | OSPF6_LINK_LSA_SCHEDULE (oi); | |
1153 | OSPF6_ROUTER_LSA_SCHEDULE (oi->area); | |
1154 | OSPF6_NETWORK_LSA_SCHEDULE (oi); | |
1155 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi); | |
1156 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area); | |
1157 | } | |
718e3744 | 1158 | |
1159 | return CMD_SUCCESS; | |
1160 | } | |
1161 | ||
718e3744 | 1162 | DEFUN (ipv6_ospf6_hellointerval, |
1163 | ipv6_ospf6_hellointerval_cmd, | |
508e53e2 | 1164 | "ipv6 ospf6 hello-interval <1-65535>", |
718e3744 | 1165 | IP6_STR |
1166 | OSPF6_STR | |
508e53e2 | 1167 | "Interval time of Hello packets\n" |
718e3744 | 1168 | SECONDS_STR |
1169 | ) | |
1170 | { | |
508e53e2 | 1171 | struct ospf6_interface *oi; |
718e3744 | 1172 | struct interface *ifp; |
1173 | ||
1174 | ifp = (struct interface *) vty->index; | |
1175 | assert (ifp); | |
718e3744 | 1176 | |
508e53e2 | 1177 | oi = (struct ospf6_interface *) ifp->info; |
1178 | if (oi == NULL) | |
1179 | oi = ospf6_interface_create (ifp); | |
1180 | assert (oi); | |
1181 | ||
1182 | oi->hello_interval = strtol (argv[0], NULL, 10); | |
718e3744 | 1183 | return CMD_SUCCESS; |
1184 | } | |
1185 | ||
1186 | /* interface variable set command */ | |
1187 | DEFUN (ipv6_ospf6_deadinterval, | |
1188 | ipv6_ospf6_deadinterval_cmd, | |
508e53e2 | 1189 | "ipv6 ospf6 dead-interval <1-65535>", |
718e3744 | 1190 | IP6_STR |
1191 | OSPF6_STR | |
508e53e2 | 1192 | "Interval time after which a neighbor is declared down\n" |
718e3744 | 1193 | SECONDS_STR |
1194 | ) | |
1195 | { | |
508e53e2 | 1196 | struct ospf6_interface *oi; |
718e3744 | 1197 | struct interface *ifp; |
1198 | ||
1199 | ifp = (struct interface *) vty->index; | |
1200 | assert (ifp); | |
718e3744 | 1201 | |
508e53e2 | 1202 | oi = (struct ospf6_interface *) ifp->info; |
1203 | if (oi == NULL) | |
1204 | oi = ospf6_interface_create (ifp); | |
1205 | assert (oi); | |
1206 | ||
1207 | oi->dead_interval = strtol (argv[0], NULL, 10); | |
718e3744 | 1208 | return CMD_SUCCESS; |
1209 | } | |
1210 | ||
1211 | /* interface variable set command */ | |
1212 | DEFUN (ipv6_ospf6_transmitdelay, | |
1213 | ipv6_ospf6_transmitdelay_cmd, | |
508e53e2 | 1214 | "ipv6 ospf6 transmit-delay <1-3600>", |
718e3744 | 1215 | IP6_STR |
1216 | OSPF6_STR | |
508e53e2 | 1217 | "Transmit delay of this interface\n" |
718e3744 | 1218 | SECONDS_STR |
1219 | ) | |
1220 | { | |
508e53e2 | 1221 | struct ospf6_interface *oi; |
718e3744 | 1222 | struct interface *ifp; |
1223 | ||
1224 | ifp = (struct interface *) vty->index; | |
1225 | assert (ifp); | |
718e3744 | 1226 | |
508e53e2 | 1227 | oi = (struct ospf6_interface *) ifp->info; |
1228 | if (oi == NULL) | |
1229 | oi = ospf6_interface_create (ifp); | |
1230 | assert (oi); | |
1231 | ||
1232 | oi->transdelay = strtol (argv[0], NULL, 10); | |
718e3744 | 1233 | return CMD_SUCCESS; |
1234 | } | |
1235 | ||
1236 | /* interface variable set command */ | |
1237 | DEFUN (ipv6_ospf6_retransmitinterval, | |
1238 | ipv6_ospf6_retransmitinterval_cmd, | |
508e53e2 | 1239 | "ipv6 ospf6 retransmit-interval <1-65535>", |
718e3744 | 1240 | IP6_STR |
1241 | OSPF6_STR | |
1242 | "Time between retransmitting lost link state advertisements\n" | |
1243 | SECONDS_STR | |
1244 | ) | |
1245 | { | |
508e53e2 | 1246 | struct ospf6_interface *oi; |
718e3744 | 1247 | struct interface *ifp; |
1248 | ||
1249 | ifp = (struct interface *) vty->index; | |
1250 | assert (ifp); | |
718e3744 | 1251 | |
508e53e2 | 1252 | oi = (struct ospf6_interface *) ifp->info; |
1253 | if (oi == NULL) | |
1254 | oi = ospf6_interface_create (ifp); | |
1255 | assert (oi); | |
1256 | ||
1257 | oi->rxmt_interval = strtol (argv[0], NULL, 10); | |
718e3744 | 1258 | return CMD_SUCCESS; |
1259 | } | |
1260 | ||
1261 | /* interface variable set command */ | |
1262 | DEFUN (ipv6_ospf6_priority, | |
1263 | ipv6_ospf6_priority_cmd, | |
508e53e2 | 1264 | "ipv6 ospf6 priority <0-255>", |
718e3744 | 1265 | IP6_STR |
1266 | OSPF6_STR | |
1267 | "Router priority\n" | |
508e53e2 | 1268 | "Priority value\n" |
718e3744 | 1269 | ) |
1270 | { | |
508e53e2 | 1271 | struct ospf6_interface *oi; |
718e3744 | 1272 | struct interface *ifp; |
1273 | ||
1274 | ifp = (struct interface *) vty->index; | |
1275 | assert (ifp); | |
718e3744 | 1276 | |
508e53e2 | 1277 | oi = (struct ospf6_interface *) ifp->info; |
1278 | if (oi == NULL) | |
1279 | oi = ospf6_interface_create (ifp); | |
1280 | assert (oi); | |
1281 | ||
1282 | oi->priority = strtol (argv[0], NULL, 10); | |
718e3744 | 1283 | |
508e53e2 | 1284 | if (oi->area) |
1285 | ospf6_interface_state_change (dr_election (oi), oi); | |
718e3744 | 1286 | |
1287 | return CMD_SUCCESS; | |
1288 | } | |
1289 | ||
1290 | DEFUN (ipv6_ospf6_instance, | |
1291 | ipv6_ospf6_instance_cmd, | |
508e53e2 | 1292 | "ipv6 ospf6 instance-id <0-255>", |
718e3744 | 1293 | IP6_STR |
1294 | OSPF6_STR | |
508e53e2 | 1295 | "Instance ID for this interface\n" |
1296 | "Instance ID value\n" | |
718e3744 | 1297 | ) |
1298 | { | |
508e53e2 | 1299 | struct ospf6_interface *oi; |
718e3744 | 1300 | struct interface *ifp; |
1301 | ||
1302 | ifp = (struct interface *)vty->index; | |
1303 | assert (ifp); | |
1304 | ||
508e53e2 | 1305 | oi = (struct ospf6_interface *)ifp->info; |
1306 | if (oi == NULL) | |
1307 | oi = ospf6_interface_create (ifp); | |
1308 | assert (oi); | |
718e3744 | 1309 | |
508e53e2 | 1310 | oi->instance_id = strtol (argv[0], NULL, 10); |
718e3744 | 1311 | return CMD_SUCCESS; |
1312 | } | |
1313 | ||
1314 | DEFUN (ipv6_ospf6_passive, | |
1315 | ipv6_ospf6_passive_cmd, | |
1316 | "ipv6 ospf6 passive", | |
1317 | IP6_STR | |
1318 | OSPF6_STR | |
508e53e2 | 1319 | "passive interface, No adjacency will be formed on this interface\n" |
718e3744 | 1320 | ) |
1321 | { | |
508e53e2 | 1322 | struct ospf6_interface *oi; |
718e3744 | 1323 | struct interface *ifp; |
1eb8ef25 | 1324 | struct listnode *node, *nnode; |
508e53e2 | 1325 | struct ospf6_neighbor *on; |
718e3744 | 1326 | |
1327 | ifp = (struct interface *) vty->index; | |
1328 | assert (ifp); | |
718e3744 | 1329 | |
508e53e2 | 1330 | oi = (struct ospf6_interface *) ifp->info; |
1331 | if (oi == NULL) | |
1332 | oi = ospf6_interface_create (ifp); | |
1333 | assert (oi); | |
718e3744 | 1334 | |
508e53e2 | 1335 | SET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE); |
1336 | THREAD_OFF (oi->thread_send_hello); | |
1337 | ||
1eb8ef25 | 1338 | for (ALL_LIST_ELEMENTS (oi->neighbor_list, node, nnode, on)) |
718e3744 | 1339 | { |
508e53e2 | 1340 | THREAD_OFF (on->inactivity_timer); |
3e834b12 | 1341 | thread_add_event (master, inactivity_timer, on, 0); |
718e3744 | 1342 | } |
1343 | ||
1344 | return CMD_SUCCESS; | |
1345 | } | |
1346 | ||
1347 | DEFUN (no_ipv6_ospf6_passive, | |
1348 | no_ipv6_ospf6_passive_cmd, | |
1349 | "no ipv6 ospf6 passive", | |
1350 | NO_STR | |
1351 | IP6_STR | |
1352 | OSPF6_STR | |
1353 | "passive interface: No Adjacency will be formed on this I/F\n" | |
1354 | ) | |
1355 | { | |
508e53e2 | 1356 | struct ospf6_interface *oi; |
718e3744 | 1357 | struct interface *ifp; |
1358 | ||
1359 | ifp = (struct interface *) vty->index; | |
1360 | assert (ifp); | |
718e3744 | 1361 | |
508e53e2 | 1362 | oi = (struct ospf6_interface *) ifp->info; |
1363 | if (oi == NULL) | |
1364 | oi = ospf6_interface_create (ifp); | |
1365 | assert (oi); | |
718e3744 | 1366 | |
508e53e2 | 1367 | UNSET_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE); |
1368 | THREAD_OFF (oi->thread_send_hello); | |
1369 | oi->thread_send_hello = | |
1370 | thread_add_event (master, ospf6_hello_send, oi, 0); | |
718e3744 | 1371 | |
1372 | return CMD_SUCCESS; | |
1373 | } | |
1374 | ||
d42306d9 DT |
1375 | DEFUN (ipv6_ospf6_mtu_ignore, |
1376 | ipv6_ospf6_mtu_ignore_cmd, | |
1377 | "ipv6 ospf6 mtu-ignore", | |
1378 | IP6_STR | |
1379 | OSPF6_STR | |
1380 | "Ignore MTU mismatch on this interface\n" | |
1381 | ) | |
1382 | { | |
1383 | struct ospf6_interface *oi; | |
1384 | struct interface *ifp; | |
1385 | ||
1386 | ifp = (struct interface *) vty->index; | |
1387 | assert (ifp); | |
1388 | ||
1389 | oi = (struct ospf6_interface *) ifp->info; | |
1390 | if (oi == NULL) | |
1391 | oi = ospf6_interface_create (ifp); | |
1392 | assert (oi); | |
1393 | ||
1394 | oi->mtu_ignore = 1; | |
1395 | ||
1396 | return CMD_SUCCESS; | |
1397 | } | |
1398 | ||
1399 | DEFUN (no_ipv6_ospf6_mtu_ignore, | |
1400 | no_ipv6_ospf6_mtu_ignore_cmd, | |
1401 | "no ipv6 ospf6 mtu-ignore", | |
1402 | NO_STR | |
1403 | IP6_STR | |
1404 | OSPF6_STR | |
1405 | "Ignore MTU mismatch on this interface\n" | |
1406 | ) | |
1407 | { | |
1408 | struct ospf6_interface *oi; | |
1409 | struct interface *ifp; | |
1410 | ||
1411 | ifp = (struct interface *) vty->index; | |
1412 | assert (ifp); | |
1413 | ||
1414 | oi = (struct ospf6_interface *) ifp->info; | |
1415 | if (oi == NULL) | |
1416 | oi = ospf6_interface_create (ifp); | |
1417 | assert (oi); | |
1418 | ||
1419 | oi->mtu_ignore = 0; | |
1420 | ||
1421 | return CMD_SUCCESS; | |
1422 | } | |
1423 | ||
718e3744 | 1424 | DEFUN (ipv6_ospf6_advertise_prefix_list, |
1425 | ipv6_ospf6_advertise_prefix_list_cmd, | |
1426 | "ipv6 ospf6 advertise prefix-list WORD", | |
1427 | IP6_STR | |
1428 | OSPF6_STR | |
1429 | "Advertising options\n" | |
1430 | "Filter prefix using prefix-list\n" | |
1431 | "Prefix list name\n" | |
1432 | ) | |
1433 | { | |
508e53e2 | 1434 | struct ospf6_interface *oi; |
718e3744 | 1435 | struct interface *ifp; |
1436 | ||
1437 | ifp = (struct interface *) vty->index; | |
1438 | assert (ifp); | |
718e3744 | 1439 | |
508e53e2 | 1440 | oi = (struct ospf6_interface *) ifp->info; |
1441 | if (oi == NULL) | |
1442 | oi = ospf6_interface_create (ifp); | |
1443 | assert (oi); | |
718e3744 | 1444 | |
508e53e2 | 1445 | if (oi->plist_name) |
1446 | XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name); | |
1447 | oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]); | |
718e3744 | 1448 | |
508e53e2 | 1449 | ospf6_interface_connected_route_update (oi->interface); |
2470e99e DW |
1450 | |
1451 | if (oi->area) | |
508e53e2 | 1452 | { |
2470e99e DW |
1453 | OSPF6_LINK_LSA_SCHEDULE (oi); |
1454 | if (oi->state == OSPF6_INTERFACE_DR) | |
1455 | { | |
1456 | OSPF6_NETWORK_LSA_SCHEDULE (oi); | |
1457 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi); | |
1458 | } | |
1459 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area); | |
508e53e2 | 1460 | } |
718e3744 | 1461 | |
1462 | return CMD_SUCCESS; | |
1463 | } | |
1464 | ||
1465 | DEFUN (no_ipv6_ospf6_advertise_prefix_list, | |
1466 | no_ipv6_ospf6_advertise_prefix_list_cmd, | |
1467 | "no ipv6 ospf6 advertise prefix-list", | |
1468 | NO_STR | |
1469 | IP6_STR | |
1470 | OSPF6_STR | |
1471 | "Advertising options\n" | |
1472 | "Filter prefix using prefix-list\n" | |
1473 | ) | |
1474 | { | |
508e53e2 | 1475 | struct ospf6_interface *oi; |
718e3744 | 1476 | struct interface *ifp; |
1477 | ||
1478 | ifp = (struct interface *) vty->index; | |
1479 | assert (ifp); | |
718e3744 | 1480 | |
508e53e2 | 1481 | oi = (struct ospf6_interface *) ifp->info; |
1482 | if (oi == NULL) | |
1483 | oi = ospf6_interface_create (ifp); | |
1484 | assert (oi); | |
1485 | ||
1486 | if (oi->plist_name) | |
718e3744 | 1487 | { |
508e53e2 | 1488 | XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name); |
1489 | oi->plist_name = NULL; | |
718e3744 | 1490 | } |
1491 | ||
508e53e2 | 1492 | ospf6_interface_connected_route_update (oi->interface); |
2470e99e DW |
1493 | |
1494 | if (oi->area) | |
508e53e2 | 1495 | { |
2470e99e DW |
1496 | OSPF6_LINK_LSA_SCHEDULE (oi); |
1497 | if (oi->state == OSPF6_INTERFACE_DR) | |
1498 | { | |
1499 | OSPF6_NETWORK_LSA_SCHEDULE (oi); | |
1500 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT (oi); | |
1501 | } | |
1502 | OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB (oi->area); | |
508e53e2 | 1503 | } |
718e3744 | 1504 | |
1505 | return CMD_SUCCESS; | |
1506 | } | |
1507 | ||
6ac29a51 | 1508 | static int |
508e53e2 | 1509 | config_write_ospf6_interface (struct vty *vty) |
718e3744 | 1510 | { |
52dc7ee6 | 1511 | struct listnode *i; |
508e53e2 | 1512 | struct ospf6_interface *oi; |
718e3744 | 1513 | struct interface *ifp; |
1514 | ||
1eb8ef25 | 1515 | for (ALL_LIST_ELEMENTS_RO (iflist, i, ifp)) |
718e3744 | 1516 | { |
508e53e2 | 1517 | oi = (struct ospf6_interface *) ifp->info; |
1518 | if (oi == NULL) | |
718e3744 | 1519 | continue; |
1520 | ||
1521 | vty_out (vty, "interface %s%s", | |
049207c3 | 1522 | oi->interface->name, VNL); |
508e53e2 | 1523 | |
1524 | if (ifp->desc) | |
049207c3 | 1525 | vty_out (vty, " description %s%s", ifp->desc, VNL); |
1203e1c0 | 1526 | if (ifp->mtu6 != oi->ifmtu) |
049207c3 | 1527 | vty_out (vty, " ipv6 ospf6 ifmtu %d%s", oi->ifmtu, VNL); |
b51a3a31 VT |
1528 | |
1529 | if (oi->cost != OSPF6_INTERFACE_COST) | |
1530 | vty_out (vty, " ipv6 ospf6 cost %d%s", | |
1531 | oi->cost, VNL); | |
1532 | ||
1533 | if (oi->hello_interval != OSPF6_INTERFACE_HELLO_INTERVAL) | |
1534 | vty_out (vty, " ipv6 ospf6 hello-interval %d%s", | |
1535 | oi->hello_interval, VNL); | |
1536 | ||
1537 | if (oi->dead_interval != OSPF6_INTERFACE_DEAD_INTERVAL) | |
1538 | vty_out (vty, " ipv6 ospf6 dead-interval %d%s", | |
1539 | oi->dead_interval, VNL); | |
1540 | ||
1541 | if (oi->rxmt_interval != OSPF6_INTERFACE_RXMT_INTERVAL) | |
1542 | vty_out (vty, " ipv6 ospf6 retransmit-interval %d%s", | |
1543 | oi->rxmt_interval, VNL); | |
1544 | ||
1545 | if (oi->priority != OSPF6_INTERFACE_PRIORITY) | |
1546 | vty_out (vty, " ipv6 ospf6 priority %d%s", | |
1547 | oi->priority, VNL); | |
1548 | ||
1549 | if (oi->transdelay != OSPF6_INTERFACE_TRANSDELAY) | |
1550 | vty_out (vty, " ipv6 ospf6 transmit-delay %d%s", | |
1551 | oi->transdelay, VNL); | |
1552 | ||
1553 | if (oi->instance_id != OSPF6_INTERFACE_INSTANCE_ID) | |
1554 | vty_out (vty, " ipv6 ospf6 instance-id %d%s", | |
1555 | oi->instance_id, VNL); | |
718e3744 | 1556 | |
508e53e2 | 1557 | if (oi->plist_name) |
718e3744 | 1558 | vty_out (vty, " ipv6 ospf6 advertise prefix-list %s%s", |
049207c3 | 1559 | oi->plist_name, VNL); |
718e3744 | 1560 | |
508e53e2 | 1561 | if (CHECK_FLAG (oi->flag, OSPF6_INTERFACE_PASSIVE)) |
049207c3 | 1562 | vty_out (vty, " ipv6 ospf6 passive%s", VNL); |
718e3744 | 1563 | |
d42306d9 DT |
1564 | if (oi->mtu_ignore) |
1565 | vty_out (vty, " ipv6 ospf6 mtu-ignore%s", VNL); | |
1566 | ||
049207c3 | 1567 | vty_out (vty, "!%s", VNL); |
718e3744 | 1568 | } |
1569 | return 0; | |
1570 | } | |
1571 | ||
7fc626de | 1572 | static struct cmd_node interface_node = |
718e3744 | 1573 | { |
1574 | INTERFACE_NODE, | |
1575 | "%s(config-if)# ", | |
69b4a810 | 1576 | 1 /* VTYSH */ |
718e3744 | 1577 | }; |
1578 | ||
1579 | void | |
6ac29a51 | 1580 | ospf6_interface_init (void) |
718e3744 | 1581 | { |
1582 | /* Install interface node. */ | |
508e53e2 | 1583 | install_node (&interface_node, config_write_ospf6_interface); |
718e3744 | 1584 | |
1585 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd); | |
508e53e2 | 1586 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd); |
1587 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd); | |
1588 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd); | |
718e3744 | 1589 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd); |
508e53e2 | 1590 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd); |
1591 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd); | |
1592 | install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd); | |
718e3744 | 1593 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_cmd); |
508e53e2 | 1594 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_cmd); |
1595 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd); | |
1596 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd); | |
718e3744 | 1597 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_cmd); |
508e53e2 | 1598 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd); |
1599 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd); | |
1600 | install_element (ENABLE_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd); | |
718e3744 | 1601 | |
508e53e2 | 1602 | install_element (CONFIG_NODE, &interface_cmd); |
718e3744 | 1603 | install_default (INTERFACE_NODE); |
1604 | install_element (INTERFACE_NODE, &interface_desc_cmd); | |
1605 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); | |
1606 | install_element (INTERFACE_NODE, &ipv6_ospf6_cost_cmd); | |
b596c71e | 1607 | install_element (INTERFACE_NODE, &ipv6_ospf6_ifmtu_cmd); |
049207c3 | 1608 | install_element (INTERFACE_NODE, &no_ipv6_ospf6_ifmtu_cmd); |
718e3744 | 1609 | install_element (INTERFACE_NODE, &ipv6_ospf6_deadinterval_cmd); |
1610 | install_element (INTERFACE_NODE, &ipv6_ospf6_hellointerval_cmd); | |
1611 | install_element (INTERFACE_NODE, &ipv6_ospf6_priority_cmd); | |
1612 | install_element (INTERFACE_NODE, &ipv6_ospf6_retransmitinterval_cmd); | |
1613 | install_element (INTERFACE_NODE, &ipv6_ospf6_transmitdelay_cmd); | |
1614 | install_element (INTERFACE_NODE, &ipv6_ospf6_instance_cmd); | |
508e53e2 | 1615 | |
718e3744 | 1616 | install_element (INTERFACE_NODE, &ipv6_ospf6_passive_cmd); |
1617 | install_element (INTERFACE_NODE, &no_ipv6_ospf6_passive_cmd); | |
508e53e2 | 1618 | |
d42306d9 DT |
1619 | install_element (INTERFACE_NODE, &ipv6_ospf6_mtu_ignore_cmd); |
1620 | install_element (INTERFACE_NODE, &no_ipv6_ospf6_mtu_ignore_cmd); | |
1621 | ||
508e53e2 | 1622 | install_element (INTERFACE_NODE, &ipv6_ospf6_advertise_prefix_list_cmd); |
1623 | install_element (INTERFACE_NODE, &no_ipv6_ospf6_advertise_prefix_list_cmd); | |
1624 | } | |
1625 | ||
1626 | DEFUN (debug_ospf6_interface, | |
1627 | debug_ospf6_interface_cmd, | |
1628 | "debug ospf6 interface", | |
1629 | DEBUG_STR | |
1630 | OSPF6_STR | |
1631 | "Debug OSPFv3 Interface\n" | |
1632 | ) | |
1633 | { | |
1634 | OSPF6_DEBUG_INTERFACE_ON (); | |
1635 | return CMD_SUCCESS; | |
1636 | } | |
1637 | ||
1638 | DEFUN (no_debug_ospf6_interface, | |
1639 | no_debug_ospf6_interface_cmd, | |
1640 | "no debug ospf6 interface", | |
1641 | NO_STR | |
1642 | DEBUG_STR | |
1643 | OSPF6_STR | |
1644 | "Debug OSPFv3 Interface\n" | |
1645 | ) | |
1646 | { | |
3b68735f | 1647 | OSPF6_DEBUG_INTERFACE_OFF (); |
508e53e2 | 1648 | return CMD_SUCCESS; |
1649 | } | |
1650 | ||
1651 | int | |
1652 | config_write_ospf6_debug_interface (struct vty *vty) | |
1653 | { | |
1654 | if (IS_OSPF6_DEBUG_INTERFACE) | |
049207c3 | 1655 | vty_out (vty, "debug ospf6 interface%s", VNL); |
508e53e2 | 1656 | return 0; |
1657 | } | |
1658 | ||
1659 | void | |
6ac29a51 | 1660 | install_element_ospf6_debug_interface (void) |
508e53e2 | 1661 | { |
1662 | install_element (ENABLE_NODE, &debug_ospf6_interface_cmd); | |
1663 | install_element (ENABLE_NODE, &no_debug_ospf6_interface_cmd); | |
1664 | install_element (CONFIG_NODE, &debug_ospf6_interface_cmd); | |
1665 | install_element (CONFIG_NODE, &no_debug_ospf6_interface_cmd); | |
718e3744 | 1666 | } |
1667 | ||
1668 |