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