📄 ospf_mib_wrn_helper.c
字号:
mApiOspfPrintf(("mApi2Ospf_configRedistributeOpts:Invalid pointer\n")); return; } /* assume that the IP Routing Table doesn't have to be read for now */ readRtTable = FALSE; /* SPR#88389 - get the existing autonomous system border router status */ asStatus = ospf2Mapi_bool2TrueValueGet( ospf.autonomous_system_border_router ); /* changes to any of the following does not require immediate action. We simply * let the changes take their natural caurse. In the event that the routing table * has changed when the following objects have not been enabled, the routes * distribution will not occur until the next time the routing table is changed * again (this occurs during the next cycle when ospf needs to update the routing * table). There is a potential problem though. If there is no change to the * routing table after we have enabled the following objects, the routes for RIP, * BGP-4 and/or static route may never be updated. This needs to be fixed later... * * Notice that setting the following objects to "enabled" do not imply that the * routes will be redistributed. In order for those changes to take effect, the * router itself must be a AS Border Router (i.e. the ospfASBdrRtrStatus must also * be "enabled". */ ospfRedistrbuteOption = ospf2Mapi_bool2TrueValueGet( ospf.ospf_redistribution_configuration.redistribute_ip_default_route ); if ( pWrnGenGroup->wrnOspfRedistributeDefaultRoutes != ospfRedistrbuteOption ) { ospf.ospf_redistribution_configuration.redistribute_ip_default_route = (pWrnGenGroup->wrnOspfRedistributeDefaultRoutes == EmApiOspf_true ? TRUE : FALSE); /* SPR#88309: tell 'em to read the routing table only if the route * redistribution option is TRUE */ if ( pWrnGenGroup->wrnOspfRedistributeDefaultRoutes == EmApiOspf_true ) readRtTable = TRUE; else if ( asStatus == EmApiOspf_true ) { /* SPR#88389: the router was initially configured to redistribute * default route but it must now stop doing so. Flush the default * route that it has previously redistributed. Set the routeProtoId * to M2_ipRouteProto_default (an invalid M2 protocol ID that only * used locally) so that the wrnOspf_mApi_findExtRouteByProtoId() * can correctly determine if the default route exists in the * ospfExtLsdbTable. This is done this way because default route * that is added to the routing table also uses the M2 protocol ID * M2_ipRouteProto_other. */ routeProtoId = M2_ipRouteProto_default; rc = ospf_mApi_avlTreeWalk( &thisMapi->ospfExtLsdbAvl.pOspfAvlRoot, wrnOspf_mApi_findExtRouteByProtoId, (void *)routeProtoId ); if ( rc == EXTERNAL_ROUTE_FOUND ) { /* now set the routeProtoId to the correct type */ routeProtoId = M2_ipRouteProto_other; ospf_dynamic_flush_external_routes( routeProtoId, TRUE ); } return; } } ospfRedistrbuteOption = ospf2Mapi_bool2TrueValueGet( ospf.ospf_redistribution_configuration.redistribute_all_static ); if ( pWrnGenGroup->wrnOspfRedistributeStaticRoutes != ospfRedistrbuteOption ) { ospf.ospf_redistribution_configuration.redistribute_all_static = (pWrnGenGroup->wrnOspfRedistributeStaticRoutes == EmApiOspf_true ? TRUE : FALSE); /* SPR#88309: tell 'em to read the routing table only if the route * redistribution option is TRUE */ if ( pWrnGenGroup->wrnOspfRedistributeStaticRoutes == EmApiOspf_true ) readRtTable = TRUE; else if ( asStatus == EmApiOspf_true ) { /* SPR#88389: the router was initially configured to redistribute * static route but it must now stop doing so. Flush all the * static routes that it has previously redistributed. */ routeProtoId = M2_ipRouteProto_other; rc = ospf_mApi_avlTreeWalk( &thisMapi->ospfExtLsdbAvl.pOspfAvlRoot, wrnOspf_mApi_findExtRouteByProtoId, (void *)routeProtoId ); if ( rc == EXTERNAL_ROUTE_FOUND ) ospf_dynamic_flush_external_routes( routeProtoId, FALSE ); return; } } ospfRedistrbuteOption = ospf2Mapi_bool2TrueValueGet( ospf.ospf_redistribution_configuration.redistribute_all_rip ); if ( pWrnGenGroup->wrnOspfRedistributeRIPRoutes != ospfRedistrbuteOption ) { ospf.ospf_redistribution_configuration.redistribute_all_rip = (pWrnGenGroup->wrnOspfRedistributeRIPRoutes == EmApiOspf_true ? TRUE : FALSE); /* SPR#88309: tell 'em to read the routing table only if the route * redistribution option is TRUE */ if ( pWrnGenGroup->wrnOspfRedistributeRIPRoutes == EmApiOspf_true ) readRtTable = TRUE; else if ( asStatus == EmApiOspf_true ) { /* SPR#88389: the router was initially configured to redistribute * RIP route but it must now stop doing so. Flush all the RIP * routes that it has previously redistributed. */ routeProtoId = M2_ipRouteProto_rip; rc = ospf_mApi_avlTreeWalk( &thisMapi->ospfExtLsdbAvl.pOspfAvlRoot, wrnOspf_mApi_findExtRouteByProtoId, (void *)routeProtoId ); if ( rc == EXTERNAL_ROUTE_FOUND ) ospf_dynamic_flush_external_routes( routeProtoId, FALSE ); return; } } ospfRedistrbuteOption = ospf2Mapi_bool2TrueValueGet( ospf.ospf_redistribution_configuration.redistribute_all_bgp ); if ( pWrnGenGroup->wrnOspfRedistributeBGPRoutes != ospfRedistrbuteOption ) { ospf.ospf_redistribution_configuration.redistribute_all_bgp = (pWrnGenGroup->wrnOspfRedistributeBGPRoutes == EmApiOspf_true ? TRUE : FALSE); /* SPR#88309: tell 'em to read the routing table only if the route * redistribution option is TRUE */ if ( pWrnGenGroup->wrnOspfRedistributeBGPRoutes == EmApiOspf_true ) readRtTable = TRUE; else if ( asStatus == EmApiOspf_true ) { /* SPR#88389: the router was initially configured to redistribute * BGP route but it must now stop doing so. Flush all the BGP * routes that it has previously redistributed. */ routeProtoId = M2_ipRouteProto_bgp; rc = ospf_mApi_avlTreeWalk( &thisMapi->ospfExtLsdbAvl.pOspfAvlRoot, wrnOspf_mApi_findExtRouteByProtoId, (void *)routeProtoId ); if ( rc == EXTERNAL_ROUTE_FOUND ) ospf_dynamic_flush_external_routes( routeProtoId, FALSE ); return; } } /* SPR#88309 - examine the system routing table if any of the route * redistribution option or ospfASBdrRtrStatus has changed. */ if ( (readRtTable == TRUE) || (asBdrStatusChanged == TRUE) ) { mApiOspfGenGroup_t *pGenGroup; enum BOOLEAN asBdrRtrStatus; enum BOOLEAN redistributeStaticRoutes; enum BOOLEAN redistributeRIPRoutes; enum BOOLEAN redistributeBGPRoutes; enum BOOLEAN redistributeDefaultRoutes; pGenGroup = (mApiOspfGenGroup_t *)thisMapi->pMapiOspfGenGroup; asBdrRtrStatus = (pGenGroup->ospfASBdrRtrStatus == EmApiOspf_true ? TRUE : FALSE); if ( asBdrRtrStatus == FALSE ) return; redistributeStaticRoutes = (pWrnGenGroup->wrnOspfRedistributeStaticRoutes == EmApiOspf_true ? TRUE : FALSE); redistributeRIPRoutes = (pWrnGenGroup->wrnOspfRedistributeRIPRoutes == EmApiOspf_true ? TRUE : FALSE); redistributeBGPRoutes = (pWrnGenGroup->wrnOspfRedistributeBGPRoutes == EmApiOspf_true ? TRUE : FALSE); redistributeDefaultRoutes = (pWrnGenGroup->wrnOspfRedistributeDefaultRoutes == EmApiOspf_true ? TRUE : FALSE); /* SPR#88309 - it is only necessary to examine the routing table if * at least one of the route redistribution option is set */ if ( (redistributeStaticRoutes == TRUE) || (redistributeRIPRoutes == TRUE) || (redistributeBGPRoutes == TRUE) || (redistributeDefaultRoutes == TRUE) ) { ospf_sysctl_rtableWalk( asBdrRtrStatus, redistributeStaticRoutes, redistributeRIPRoutes, redistributeBGPRoutes, redistributeDefaultRoutes ); /* SPR#88309: force the timer task to export the external routes */ ospf_dynamic_export_external_routes(); } } return;}/**************************************************************************************** mApi2Ospf_configWrnGenGroup - dynamically configre WRN OSPF General Group Parameters** This routine dynamically configure the WRN OSPF Enterpise MIB General Group parameters.* These parameters apply globally to the OSPF protocol.** RETURNS: OK or ERROR*/STATUS mApi2Ospf_configWrnGenGroup( void *pGenParams ){ STATUS mutexAcquired; mApiOspfTrueValue_t ospf1583Option; mApiOspfTrueValue_t ospfOpaqueOption; mApiWrnOspfGenGroup_t *pGenGroup; pGenGroup = (mApiWrnOspfGenGroup_t *)pGenParams; if ( pGenGroup == NULL ) { mApiOspfPrintf(("mApi2Ospf_configWrnGenGroup:Invalid pointer\n")); return ERROR; } /* make sure OSPF Protocol is running. If not, return OK as no-op. This allow * ospf be configured at the MIB layer without the OSPF protocol running. */ if ( thisMapi->ospfProtoInit == FALSE ) return OK; /* lock the ospf mutex semaphore for exclusive access to ospf structure */ mutexAcquired = semTake (ospf_global_mutex , WAIT_FOREVER); if ( mutexAcquired == ERROR ) { mApiOspfPrintf(("mApi2Ospf_configGenGroup:failed to acquire ospf mutex!\n")); return ERROR; } /* convert ospf_rfc1583_compatibility boolean used by ospf to mApiOspfTrueValue_t */ ospf1583Option = ospf2Mapi_bool2TrueValueGet( ospf.ospf_rfc1583_compatibility ); if ( pGenGroup->wrnOspfRFC1583Compatibility != ospf1583Option ) { /* RFC1583Compatibility option only applies to RFC2178 and RFC2328 */ if ( thisMapi->ospfRfcProto == EospfProtoType_rfc1583 ) { /* don't allow this option to be set */ semGive (ospf_global_mutex ); mApiOspfPrintf(("mApi2Ospf_configWrnGenGroup:option not for rfc1583\n")); return ERROR; } /* regardless if the RFC1583Compatibility option is previously set, we know that * there is a change to this option. This option affects the choice of metrics * used among multiple AS external LSAs. To properly maintain synchronization * with the neighbors, force all OSPF interfaces to be reinitialize so that * all database can be relearned. */ ospf.ospf_rfc1583_compatibility = ( pGenGroup->wrnOspfRFC1583Compatibility == EmApiOspf_true ? TRUE : FALSE ); /* reinitialize all the interfaces. Tell 'em don't have to lock the ospf's mutex * since we are locking it now. Notice that it is not necessary to update the * management database operational status for the interfaces. This is because * ospf will turn around to send the update request to MIB API each time there * is a change to the interface operational state. */ mApi2Ospf_forceIfInit( EmApiOspf_false ); } /* convert opaque_capability boolean used by ospf to mApiOspfTrueValue_t */ ospfOpaqueOption = ospf2Mapi_bool2TrueValueGet( ospf.opaque_capability ); if ( pGenGroup->wrnOspfOpaqueLsaSupport != ospfOpaqueOption ) { /* if OSPF is not opaque lsa capable, do not allow this option to be set */ if ( thisMapi->ospfOpaqueEnable == FALSE ) { semGive (ospf_global_mutex ); mApiOspfPrintf(("mApi2Ospf_configWrnGenGroup:ospf not opaque capable\n")); return ERROR; } /* set the opaqque option */ ospf.opaque_capability = ( pGenGroup->wrnOspfOpaqueLsaSupport == EmApiOspf_true ? TRUE : FALSE ); /* if opaque capability is previously enabled and it is now disabled, flush all * Opaque LSAs in OSPF as well as MIB API Management Database. */ if ( ospfOpaqueOption == EmApiOspf_true ) { OSPF_AREA_ENTRY *pOspfArea; BOOL resetAllToDefault; /* we know the opaque option is now disabled (otherwise we will not get here), * tell OSPF to flush all Opaque LSAs. Loop through each area to remove any * opaque lsas in that area (if any) */ for ( pOspfArea = ospf.sptr_area_list; pOspfArea != NULL; pOspfArea = pOspfArea->sptr_forward_link ) { ospf_dynamic_flush_opaque_lsa( pOspfArea ); } /* flush all the opaque lsas from the MIB API Management Database. Tell 'em * to reset all general group counters for wrnOspfGeneralGroup to its * initial value */ resetAllToDefault = TRUE;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -