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