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