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