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