Annotation of embedaddon/quagga/isisd/isis_events.c, revision 1.1.1.3

1.1       misho       1: /*
                      2:  * IS-IS Rout(e)ing protocol - isis_events.h   
                      3:  *
                      4:  * Copyright (C) 2001,2002   Sampo Saaristo
                      5:  *                           Tampere University of Technology      
                      6:  *                           Institute of Communications Engineering
                      7:  *
                      8:  * This program is free software; you can redistribute it and/or modify it 
                      9:  * under the terms of the GNU General Public Licenseas published by the Free 
                     10:  * Software Foundation; either version 2 of the License, or (at your option) 
                     11:  * any later version.
                     12:  *
                     13:  * This program is distributed in the hope that it will be useful,but WITHOUT 
                     14:  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
                     15:  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
                     16:  * more details.
                     17: 
                     18:  * You should have received a copy of the GNU General Public License along 
                     19:  * with this program; if not, write to the Free Software Foundation, Inc., 
                     20:  * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
                     21:  */
                     22: #include <zebra.h>
                     23: 
                     24: #include "log.h"
                     25: #include "memory.h"
                     26: #include "if.h"
                     27: #include "linklist.h"
                     28: #include "command.h"
                     29: #include "thread.h"
                     30: #include "hash.h"
                     31: #include "prefix.h"
                     32: #include "stream.h"
1.1.1.2   misho      33: #include "table.h"
1.1       misho      34: 
                     35: #include "isisd/dict.h"
                     36: #include "isisd/include-netbsd/iso.h"
                     37: #include "isisd/isis_constants.h"
                     38: #include "isisd/isis_common.h"
1.1.1.2   misho      39: #include "isisd/isis_flags.h"
1.1       misho      40: #include "isisd/isis_circuit.h"
                     41: #include "isisd/isis_tlv.h"
                     42: #include "isisd/isis_lsp.h"
                     43: #include "isisd/isis_pdu.h"
                     44: #include "isisd/isis_network.h"
                     45: #include "isisd/isis_misc.h"
                     46: #include "isisd/isis_constants.h"
                     47: #include "isisd/isis_adjacency.h"
                     48: #include "isisd/isis_dr.h"
                     49: #include "isisd/isisd.h"
                     50: #include "isisd/isis_csm.h"
                     51: #include "isisd/isis_events.h"
                     52: #include "isisd/isis_spf.h"
                     53: 
                     54: /* debug isis-spf spf-events 
                     55:  4w4d: ISIS-Spf (tlt): L2 SPF needed, new adjacency, from 0x609229F4
                     56:  4w4d: ISIS-Spf (tlt): L2, 0000.0000.0042.01-00 TLV contents changed, code 0x2
                     57:  4w4d: ISIS-Spf (tlt): L2, new LSP 0 DEAD.BEEF.0043.00-00
                     58:  4w5d: ISIS-Spf (tlt): L1 SPF needed, periodic SPF, from 0x6091C844
                     59:  4w5d: ISIS-Spf (tlt): L2 SPF needed, periodic SPF, from 0x6091C844
                     60: */
                     61: 
                     62: void
1.1.1.2   misho      63: isis_event_circuit_state_change (struct isis_circuit *circuit,
                     64:                                  struct isis_area *area, int up)
1.1       misho      65: {
                     66:   area->circuit_state_changes++;
                     67: 
                     68:   if (isis->debugs & DEBUG_EVENTS)
1.1.1.2   misho      69:     zlog_debug ("ISIS-Evt (%s) circuit %s", area->area_tag,
                     70:                 up ? "up" : "down");
1.1       misho      71: 
                     72:   /*
                     73:    * Regenerate LSPs this affects
                     74:    */
1.1.1.2   misho      75:   lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 0);
1.1       misho      76: 
                     77:   return;
                     78: }
                     79: 
1.1.1.2   misho      80: static void
                     81: area_resign_level (struct isis_area *area, int level)
                     82: {
                     83:   if (area->lspdb[level - 1])
                     84:     {
                     85:       lsp_db_destroy (area->lspdb[level - 1]);
                     86:       area->lspdb[level - 1] = NULL;
                     87:     }
                     88:   if (area->spftree[level - 1])
                     89:     {
                     90:       isis_spftree_del (area->spftree[level - 1]);
                     91:       area->spftree[level - 1] = NULL;
                     92:     }
                     93: #ifdef HAVE_IPV6
                     94:   if (area->spftree6[level - 1])
                     95:     {
                     96:       isis_spftree_del (area->spftree6[level - 1]);
                     97:       area->spftree6[level - 1] = NULL;
                     98:     }
                     99: #endif
                    100:   if (area->route_table[level - 1])
                    101:     {
                    102:       route_table_finish (area->route_table[level - 1]);
                    103:       area->route_table[level - 1] = NULL;
                    104:     }
                    105: #ifdef HAVE_IPV6
                    106:   if (area->route_table6[level - 1])
                    107:     {
                    108:       route_table_finish (area->route_table6[level - 1]);
                    109:       area->route_table6[level - 1] = NULL;
                    110:     }
                    111: #endif /* HAVE_IPV6 */
                    112: 
1.1.1.3 ! misho     113:   sched_debug("ISIS (%s): Resigned from L%d - canceling LSP regeneration timer.",
        !           114:               area->area_tag, level);
1.1.1.2   misho     115:   THREAD_TIMER_OFF (area->t_lsp_refresh[level - 1]);
1.1.1.3 ! misho     116:   area->lsp_regenerate_pending[level - 1] = 0;
1.1.1.2   misho     117: }
                    118: 
1.1       misho     119: void
                    120: isis_event_system_type_change (struct isis_area *area, int newtype)
                    121: {
                    122:   struct listnode *node;
                    123:   struct isis_circuit *circuit;
                    124: 
                    125:   if (isis->debugs & DEBUG_EVENTS)
                    126:     zlog_debug ("ISIS-Evt (%s) system type change %s -> %s", area->area_tag,
                    127:               circuit_t2string (area->is_type), circuit_t2string (newtype));
                    128: 
                    129:   if (area->is_type == newtype)
                    130:     return;                    /* No change */
                    131: 
                    132:   switch (area->is_type)
1.1.1.2   misho     133:   {
1.1       misho     134:     case IS_LEVEL_1:
1.1.1.2   misho     135:       if (newtype == IS_LEVEL_2)
                    136:         area_resign_level (area, IS_LEVEL_1);
                    137: 
1.1       misho     138:       if (area->lspdb[1] == NULL)
1.1.1.2   misho     139:         area->lspdb[1] = lsp_db_init ();
                    140:       if (area->route_table[1] == NULL)
                    141:         area->route_table[1] = route_table_init ();
                    142: #ifdef HAVE_IPV6
                    143:       if (area->route_table6[1] == NULL)
                    144:         area->route_table6[1] = route_table_init ();
                    145: #endif /* HAVE_IPV6 */
1.1       misho     146:       break;
1.1.1.2   misho     147: 
1.1       misho     148:     case IS_LEVEL_1_AND_2:
                    149:       if (newtype == IS_LEVEL_1)
1.1.1.2   misho     150:         area_resign_level (area, IS_LEVEL_2);
1.1       misho     151:       else
1.1.1.2   misho     152:         area_resign_level (area, IS_LEVEL_1);
1.1       misho     153:       break;
1.1.1.2   misho     154: 
1.1       misho     155:     case IS_LEVEL_2:
1.1.1.2   misho     156:       if (newtype == IS_LEVEL_1)
                    157:         area_resign_level (area, IS_LEVEL_2);
                    158: 
1.1       misho     159:       if (area->lspdb[0] == NULL)
1.1.1.2   misho     160:         area->lspdb[0] = lsp_db_init ();
                    161:       if (area->route_table[0] == NULL)
                    162:         area->route_table[0] = route_table_init ();
                    163: #ifdef HAVE_IPV6
                    164:       if (area->route_table6[0] == NULL)
                    165:         area->route_table6[0] = route_table_init ();
                    166: #endif /* HAVE_IPV6 */
1.1       misho     167:       break;
1.1.1.2   misho     168: 
1.1       misho     169:     default:
                    170:       break;
1.1.1.2   misho     171:   }
1.1       misho     172: 
                    173:   area->is_type = newtype;
                    174: 
1.1.1.2   misho     175:   /* override circuit's is_type */
                    176:   if (area->is_type != IS_LEVEL_1_AND_2)
                    177:   {
                    178:     for (ALL_LIST_ELEMENTS_RO (area->circuit_list, node, circuit))
                    179:       isis_event_circuit_type_change (circuit, newtype);
                    180:   }
1.1       misho     181: 
1.1.1.2   misho     182:   spftree_area_init (area);
1.1       misho     183: 
1.1.1.2   misho     184:   if (newtype & IS_LEVEL_1)
                    185:     lsp_generate (area, IS_LEVEL_1);
                    186:   if (newtype & IS_LEVEL_2)
                    187:     lsp_generate (area, IS_LEVEL_2);
                    188:   lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1);
1.1       misho     189: 
1.1.1.2   misho     190:   return;
1.1       misho     191: }
                    192: 
                    193: static void
                    194: circuit_commence_level (struct isis_circuit *circuit, int level)
                    195: {
                    196:   if (level == 1)
                    197:     {
1.1.1.2   misho     198:       if (! circuit->is_passive)
                    199:         THREAD_TIMER_ON (master, circuit->t_send_psnp[0], send_l1_psnp, circuit,
                    200:                         isis_jitter (circuit->psnp_interval[0], PSNP_JITTER));
1.1       misho     201: 
                    202:       if (circuit->circ_type == CIRCUIT_T_BROADCAST)
                    203:        {
                    204:          THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
1.1.1.2   misho     205:                           circuit, 2 * circuit->hello_interval[0]);
1.1       misho     206: 
                    207:          THREAD_TIMER_ON (master, circuit->u.bc.t_send_lan_hello[0],
                    208:                           send_lan_l1_hello, circuit,
                    209:                           isis_jitter (circuit->hello_interval[0],
                    210:                                        IIH_JITTER));
                    211: 
                    212:          circuit->u.bc.lan_neighs[0] = list_new ();
                    213:        }
                    214:     }
                    215:   else
                    216:     {
1.1.1.2   misho     217:       if (! circuit->is_passive)
                    218:         THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
                    219:                         isis_jitter (circuit->psnp_interval[1], PSNP_JITTER));
1.1       misho     220: 
                    221:       if (circuit->circ_type == CIRCUIT_T_BROADCAST)
                    222:        {
                    223:          THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
                    224:                           circuit, 2 * circuit->hello_interval[1]);
                    225: 
                    226:          THREAD_TIMER_ON (master, circuit->u.bc.t_send_lan_hello[1],
                    227:                           send_lan_l2_hello, circuit,
                    228:                           isis_jitter (circuit->hello_interval[1],
                    229:                                        IIH_JITTER));
                    230: 
                    231:          circuit->u.bc.lan_neighs[1] = list_new ();
                    232:        }
                    233:     }
                    234: 
                    235:   return;
                    236: }
                    237: 
                    238: static void
                    239: circuit_resign_level (struct isis_circuit *circuit, int level)
                    240: {
                    241:   int idx = level - 1;
                    242: 
                    243:   THREAD_TIMER_OFF (circuit->t_send_csnp[idx]);
                    244:   THREAD_TIMER_OFF (circuit->t_send_psnp[idx]);
                    245: 
                    246:   if (circuit->circ_type == CIRCUIT_T_BROADCAST)
                    247:     {
                    248:       THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[idx]);
                    249:       THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[idx]);
                    250:       THREAD_TIMER_OFF (circuit->u.bc.t_refresh_pseudo_lsp[idx]);
1.1.1.3 ! misho     251:       circuit->lsp_regenerate_pending[idx] = 0;
1.1       misho     252:       circuit->u.bc.run_dr_elect[idx] = 0;
1.1.1.2   misho     253:       list_delete (circuit->u.bc.lan_neighs[idx]);
                    254:       circuit->u.bc.lan_neighs[idx] = NULL;
1.1       misho     255:     }
                    256: 
                    257:   return;
                    258: }
                    259: 
                    260: void
                    261: isis_event_circuit_type_change (struct isis_circuit *circuit, int newtype)
                    262: {
1.1.1.2   misho     263:   if (circuit->state != C_STATE_UP)
                    264:   {
                    265:     circuit->is_type = newtype;
                    266:     return;
                    267:   }
1.1       misho     268: 
                    269:   if (isis->debugs & DEBUG_EVENTS)
                    270:     zlog_debug ("ISIS-Evt (%s) circuit type change %s -> %s",
                    271:               circuit->area->area_tag,
1.1.1.2   misho     272:               circuit_t2string (circuit->is_type),
1.1       misho     273:               circuit_t2string (newtype));
                    274: 
1.1.1.2   misho     275:   if (circuit->is_type == newtype)
1.1       misho     276:     return;                    /* No change */
                    277: 
                    278:   if (!(newtype & circuit->area->is_type))
                    279:     {
                    280:       zlog_err ("ISIS-Evt (%s) circuit type change - invalid level %s because"
                    281:                " area is %s", circuit->area->area_tag,
                    282:                circuit_t2string (newtype),
                    283:                circuit_t2string (circuit->area->is_type));
                    284:       return;
                    285:     }
                    286: 
1.1.1.3 ! misho     287:   if (! circuit->is_passive)
1.1       misho     288:     {
1.1.1.3 ! misho     289:       switch (circuit->is_type)
        !           290:         {
        !           291:         case IS_LEVEL_1:
        !           292:           if (newtype == IS_LEVEL_2)
        !           293:             circuit_resign_level (circuit, 1);
        !           294:           circuit_commence_level (circuit, 2);
        !           295:           break;
        !           296:         case IS_LEVEL_1_AND_2:
        !           297:           if (newtype == IS_LEVEL_1)
        !           298:             circuit_resign_level (circuit, 2);
        !           299:           else
        !           300:             circuit_resign_level (circuit, 1);
        !           301:           break;
        !           302:         case IS_LEVEL_2:
        !           303:           if (newtype == IS_LEVEL_1)
        !           304:             circuit_resign_level (circuit, 2);
        !           305:           circuit_commence_level (circuit, 1);
        !           306:           break;
        !           307:         default:
        !           308:           break;
        !           309:         }
1.1       misho     310:     }
                    311: 
1.1.1.2   misho     312:   circuit->is_type = newtype;
                    313:   lsp_regenerate_schedule (circuit->area, IS_LEVEL_1 | IS_LEVEL_2, 0);
1.1       misho     314: 
                    315:   return;
                    316: }
                    317: 
                    318:  /* 04/18/2002 by Gwak. */
                    319:  /**************************************************************************
                    320:   *
                    321:   * EVENTS for LSP generation
                    322:   *
                    323:   * 1) an Adajacency or Circuit Up/Down event
                    324:   * 2) a chnage in Circuit metric
                    325:   * 3) a change in Reachable Address metric
                    326:   * 4) a change in manualAreaAddresses
                    327:   * 5) a change in systemID
                    328:   * 6) a change in DIS status
                    329:   * 7) a chnage in the waiting status
                    330:   *
                    331:   * ***********************************************************************
                    332:   *
                    333:   * current support event
                    334:   *
                    335:   * 1) Adjacency Up/Down event
                    336:   * 6) a change in DIS status
                    337:   *
                    338:   * ***********************************************************************/
                    339: 
                    340: void
                    341: isis_event_adjacency_state_change (struct isis_adjacency *adj, int newstate)
                    342: {
                    343:   /* adjacency state change event. 
                    344:    * - the only proto-type was supported */
                    345: 
                    346:   /* invalid arguments */
                    347:   if (!adj || !adj->circuit || !adj->circuit->area)
                    348:     return;
                    349: 
                    350:   if (isis->debugs & DEBUG_EVENTS)
                    351:     zlog_debug ("ISIS-Evt (%s) Adjacency State change",
                    352:                adj->circuit->area->area_tag);
                    353: 
                    354:   /* LSP generation again */
1.1.1.2   misho     355:   lsp_regenerate_schedule (adj->circuit->area, IS_LEVEL_1 | IS_LEVEL_2, 0);
1.1       misho     356: 
                    357:   return;
                    358: }
                    359: 
                    360: /* events supporting code */
                    361: 
                    362: int
                    363: isis_event_dis_status_change (struct thread *thread)
                    364: {
                    365:   struct isis_circuit *circuit;
                    366: 
                    367:   circuit = THREAD_ARG (thread);
                    368: 
                    369:   /* invalid arguments */
                    370:   if (!circuit || !circuit->area)
                    371:     return 0;
                    372:   if (isis->debugs & DEBUG_EVENTS)
                    373:     zlog_debug ("ISIS-Evt (%s) DIS status change", circuit->area->area_tag);
                    374: 
                    375:   /* LSP generation again */
1.1.1.2   misho     376:   lsp_regenerate_schedule (circuit->area, IS_LEVEL_1 | IS_LEVEL_2, 0);
1.1       misho     377: 
                    378:   return 0;
                    379: }
                    380: 
                    381: void
                    382: isis_event_auth_failure (char *area_tag, const char *error_string, u_char *sysid)
                    383: {
                    384:   if (isis->debugs & DEBUG_EVENTS)
                    385:     zlog_debug ("ISIS-Evt (%s) Authentication failure %s from %s",
                    386:                area_tag, error_string, sysid_print (sysid));
                    387: 
                    388:   return;
                    389: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>