📄 labelreq.c
字号:
/* huyonghong 2003.4.3 策略处理去掉 */
/* 2003.4.23 wengqing 增加保护,如果ldpcb的链表乱掉,将该链表加入到待删除链中 */
/* 2003.5.29 huyonghong 在增加保护的地方,如果链表乱掉处理后直接返回,否则都要执行
UPSTREAM_LOST操作
/*2003.12.30 MPLS_INSERT_INTO_DOWN_LSP_LIST作链表插入时,处理有误,用函数
MplsInsertIntodownGlobalList替代*/
/* 2004-1-6 lixia add for debug mpls */
#include "ldpvars.h"
/*****************************************************************************/
/* global variable
*/
/*****************************************************************************/
/* 1: aggregate, MPLS_POLICY_AGGREGATE
0: deaggregate, MPLS_POLICY_DEAGGREGATE
*/
unsigned char policy_aggregate;
/* 1: independent, MPLS_POLICY_INDEPENDENT
0: ordered, MPLS_POLICY_ORDERED
*/
unsigned char policy_control_mode;
/****************************************************************************/
/* Product Name: MPLS PACK1.0
* Module Name: LDP/CR_LDP
* File Name: ldppdu.h
* Author Name: weng.qing shi.zhaohui hu.yonghong
* Creat Date: 2002-6-18
* Version : 1.0
* Input : mplsLdpSession_t *, inbound seesion pointer;
* void * , input message;
* Output : void
* Function : Label request process function
* Note :
* wengqing 2002/12/16 if receive the label request for the same lspid,
* directly send notify to upstream
* Hongyonghong 2003.2.24 if receive the label request for the same lspid,process it as up lost
*/
/****************************************************************************/
void FuncLblRequest(mplsLdpSession_t * session, void * inputEvent)
{
mplsLdpLblReqMsg_t * lblReqMsg = MPLS_NULL;
mplsLdpFecEntry * fecEntry = MPLS_NULL;
mplsLdpCrLsp * crLspEntry = MPLS_NULL;
mplsLdpLspCB * lspCb = MPLS_NULL;
mplsLdpLspCB * lspCb_t = MPLS_NULL;
mplsLdpSession_t * downSession = MPLS_NULL;
unsigned short preLen;
int i = 0;
lblmsgTlvExists tlvExist;
tlvExist.mark = 0;
MPLS_MEMSET(&fec_msg,0,sizeof(FecMsg));
lblReqMsg = (mplsLdpLblReqMsg_t *)inputEvent;
if(lblReqMsg->fecTlvExists == 0)
{
MPLS_SEND_NOTIFY(session,MISSPARAMETER,lblReqMsg->baseMsg.msgId, \
lblReqMsg->baseMsg.flags.flags.msgType);
return;
}
/* 当存在FEC聚合时,同一FEC可能使用同一标记,Label Release无法区分,此处为了防止这种情况,
加以防止;当还没有删除完时,不接纳新的Label Request*/
if(g_up_lsp_list.first != MPLS_NULL || g_down_lsp_list.first != MPLS_NULL || fec_lspcb_scan.timer != 0)
{
MPLS_SEND_NOTIFY(session,INTERNALERROR,lblReqMsg->baseMsg.msgId, \
lblReqMsg->baseMsg.flags.flags.msgType);
return;
}
if(loopdetcetpro(MPLS_LBLREQ_MSGTYPE,lblReqMsg,session) == LDP_FALSE)
return;
if(lblReqMsg->fecTlv.wcElemExists == 1)
{
/***************************************************/
/* send notification message, unsupported fec family
*/
/***************************************************/
MPLS_SEND_NOTIFY(session,NOROUTE,lblReqMsg->baseMsg.msgId, \
lblReqMsg->baseMsg.flags.flags.msgType);
return;
}
/*********************************************************************/
/* label request message must have lspid tlv for crlsp
*/
/*********************************************************************/
if(lblReqMsg->lspidTlvExists == 1)
{
MPLS_CRFECCB_SEARCH(lblReqMsg->lspidTlv.routerId, \
lblReqMsg->lspidTlv.localCrlspId,crLspEntry);
if(crLspEntry == MPLS_NULL)
{
MPLS_CRFECCB_CREATE(lblReqMsg->lspidTlv.routerId, \
lblReqMsg->lspidTlv.localCrlspId,crLspEntry)
}
/*
if I receive the label request for the same lspid, directly send notify to upstream
*/
else
{
/***************************************************/
/* send notification message, Internal Error
*/
/***************************************************/
MPLS_SEND_NOTIFY(session,LOOPDETECT,lblReqMsg->baseMsg.msgId, \
lblReqMsg->baseMsg.flags.flags.msgType);
if(!(crLspEntry->crlspCb.waitflag & 0x1))
{
/* if receive the label request for the same lspid,process it as up lost */
#if 0
MPLS_MEMSET(&(ldp_snd_msg.notifMsg), 0, sizeof(mplsLdpNotifMsg_t));
ldp_snd_msg.notifMsg.status.flags.flags.status = LOOPDETECT;
LspCBFsm(MPLS_NULL,LDP_DOWNSTREAM_NAK,\
&(ldp_snd_msg.notifMsg),LDP_CR_LSP,crLspEntry,&(crLspEntry->crlspCb));
#endif
#if 1
/* 2003.4.23 wengqing 增加保护,如果ldpcb的链表乱掉,将该链表加入到待删除链中 */
#if MPLS_PROTECT
if(crLspEntry->crlspCb.up_lsp_session_list.prev)
{
if((crLspEntry->crlspCb.up_lsp_session_list.prev)->up_lsp_session_list.next != &(crLspEntry->crlspCb))
{
// crLspEntry->crlspCb.up_lsp_session_list.prev = MPLS_NULL;
lspCb_t = &(crLspEntry->crlspCb);
while(lspCb_t->up_lsp_session_list.next)
{
lspCb_t = lspCb_t->up_lsp_session_list.next;
}
lspcb_scan ++;
/*MPLS_INSERT_INTO_UP_LSP_LIST(g_up_lsp_list,
&(crLspEntry->crlspCb), \
lspCb_t);*/
MplsInsertIntoupGlobalList(g_up_lsp_list,crLspEntry->crlspCb.upSessionIndex,&(crLspEntry->crlspCb),lspCb_t);
return ;
}
}
else if(crLspEntry->crlspCb.down_lsp_session_list.prev)
{
if((crLspEntry->crlspCb.down_lsp_session_list.prev)->down_lsp_session_list.next != &(crLspEntry->crlspCb))
{
// crLspEntry->crlspCb.down_lsp_session_list.prev = MPLS_NULL;
lspCb_t = &(crLspEntry->crlspCb);
while(lspCb_t->down_lsp_session_list.next)
{
lspCb_t = lspCb_t->down_lsp_session_list.next;
}
lspcb_scan ++;
/*MPLS_INSERT_INTO_DOWN_LSP_LIST(g_down_lsp_list,
&(crLspEntry->crlspCb), \
lspCb_t);*/
MplsInsertIntodownGlobalList(g_down_lsp_list,crLspEntry->crlspCb.downSessionIndex,&(crLspEntry->crlspCb),lspCb_t);
return;
}
}
#endif
LspCBFsm(MPLS_NULL,UPSTREAM_LOST,\
MPLS_NULL,LDP_CR_LSP,crLspEntry,&(crLspEntry->crlspCb));
#endif
}
return;
}
if(crLspEntry == MPLS_NULL)
{
/***************************************************/
/* send notification message, Internal Error
*/
/***************************************************/
MPLS_SEND_NOTIFY(session,INTERNALERROR,lblReqMsg->baseMsg.msgId, \
lblReqMsg->baseMsg.flags.flags.msgType);
DEBUG_OUT(DEBUG_OWNER_MPLS, DEBUG_LEVEL_MPLS_CR,"FuncLblRequest,creat crfec fail\n");
return;
}
crLspEntry->crlspCb.lspIndex = MPLS_GET_CRLSP_INDEX;
rec_lblreq_tlvpro(session,lblReqMsg,crLspEntry, \
&(crLspEntry->crlspCb),LDP_CR_LSP);
/********************************************************/
/* build the Fec Inquire message, update fec
*/
/********************************************************/
crLspEntry->mplsLdpFecType = lblReqMsg->fecTlv.fecElemTypes[0];
if(crLspEntry->mplsLdpFecType != MPLS_CRLSP_FEC)
{
crLspEntry->mplsFecAddr = \
lblReqMsg->fecTlv.fecElArray[0].addressEl.address;
crLspEntry->mplsLdpFecAddrLen = \
lblReqMsg->fecTlv.fecElArray[0].addressEl.preLen;
}
crLspEntry->crlspCb.lspType = LDP_CR_LSP;
crLspEntry->crlspCb.upifIndex = session->ifIndex;
crLspEntry->crlspCb.upPeerLdpid.lsrAddress = session->peerLdpId.lsrAddress;
crLspEntry->crlspCb.upPeerLdpid.labelSpace = session->peerLdpId.labelSpace;
if(session->labelAdvertisement == DOWNSTREAMONDEMAND)
{
ifindex2mod_req.ifIndex = crLspEntry->crlspCb.upifIndex;
ifindex2mod_req.mpls_protocol_type = MPLS_LABEL_SWITCH_PROTOCOL_ATM;
ifindex2mod_req.mpls_platform = local_platform;
mpls_ifindex2module(&ifindex2mod_req,&ifindex2mod_ack,MPLS_INTERFACE);
if(ifindex2mod_ack.ack == MPLS_SUCCESS)
{
crLspEntry->crlspCb.upAtmLabel.module = ifindex2mod_ack.mod;
crLspEntry->crlspCb.upAtmLabel.port = ifindex2mod_ack.port;
}
crLspEntry->crlspCb.status = IDLE;
crLspEntry->crlspCb.subStatus = FEC_INDEX_REQ_AWAITED;
}
fec_msg.Fec.fecElemNum = 1;
fec_msg.Fec.fecElemTypes[0] = crLspEntry->mplsLdpFecType;
MPLS_MEMCPY(&(fec_msg.Fec.fecElArray[0]),&(lblReqMsg->fecTlv.fecElArray[0]),\
sizeof(mplsFecElement_t));
tlvExist.mark = crLspEntry->tlvExists;
if(tlvExist.flags.fecTlvExists == 1)
{
fec_msg.Fec.TlvExists.flags.fecTlvExists = 1;
}
if(tlvExist.flags.lspidTlvExists == 1)
{
fec_msg.Fec.TlvExists.flags.lspidTlvExists = 1;
MPLS_MEMCPY(&(fec_msg.Fec.lspidTlv),&(lblReqMsg->lspidTlv),sizeof(mplsLdpLspIdTlv_t));
}
if(tlvExist.flags.erTlvExists == 1)
{
MPLS_MEMCPY(&(fec_msg.Fec.erTlv),&(crLspEntry->erTlv), \
sizeof(mplsLdpErTlv_t));
fec_msg.Fec.TlvExists.flags.erTlvExists = 1;
}
if(tlvExist.flags.trafficTlvExists == 1)
{
MPLS_MEMCPY(&(fec_msg.Fec.Traffic),&(crLspEntry->trafficTlv), \
sizeof(mplsLdpTrafficTlv_t));
fec_msg.Fec.TlvExists.flags.trafficTlvExists = 1;
}
if(tlvExist.flags.pinningTlvExists == 1)
{
MPLS_MEMCPY(&(fec_msg.Fec.pinningTlv),&(crLspEntry->pinningTlv), \
sizeof(mplsLdpPinningTlv_t));
fec_msg.Fec.TlvExists.flags.pinningTlvExists = 1;
}
if(tlvExist.flags.recClassTlvExists == 1)
{
MPLS_MEMCPY(&(fec_msg.Fec.resClassTlv),&(crLspEntry->resClassTlv), \
sizeof(mplsLdpResClsTlv_t));
fec_msg.Fec.TlvExists.flags.recClassTlvExists = 1;
}
if(tlvExist.flags.preemptTlvExists == 1)
{
MPLS_MEMCPY(&(fec_msg.Fec.preemptTlv),&(crLspEntry->preemptTlv), \
sizeof(mplsLdpPreemptTlv_t));
fec_msg.Fec.TlvExists.flags.preemptTlvExists = 1;
}
#if 0
MPLS_INSERT_INTO_DOWN_LSP_LIST(session->lsp_up_cb_list,\
&(crLspEntry->crlspCb),&(crLspEntry->crlspCb));
fec_msg.OperateType = INQUIRE_TYPE;
fec_msg.Fec.statusCode = INTERNALERROR;
fecPid.module = selfLdpPid.module;
ASEND(MPLS_FEC_STUDY,&fec_msg,sizeof(FecMsg),fecPid);
#endif
#if 1
MPLS_INSERT_INTO_UP_LSP_LIST(session->lsp_up_cb_list,\
&(crLspEntry->crlspCb),&(crLspEntry->crlspCb));
ldp_inquirertepro(&fec_msg, session->ifIndex);
/* 2002.10.30 for crlsp ErTlv Study, update er tlv */
if(tlvExist.flags.erTlvExists == 1)
{
MPLS_MEMCPY(&(crLspEntry->erTlv), &(fec_msg.Fec.erTlv),\
sizeof(mplsLdpErTlv_t));
}
ProcFecInquire(&fec_msg);
#endif
}
else
{
/*************************************************************/
/* in label request message, only support one fec element,
* but, we don't preasume this
*/
/*************************************************************/
for(i = 0; i <lblReqMsg->fecTlv.numberFecElements; i++)
{
fecEntry = MPLS_NULL;
if(lblReqMsg->fecTlv.fecElArray[i].addressEl.addressFam != MPLS_IPV4)
{
MPLS_SEND_NOTIFY(session,UNSUPADDRFAM,lblReqMsg->baseMsg.msgId, \
lblReqMsg->baseMsg.flags.flags.msgType);
}
preLen = lblReqMsg->fecTlv.fecElemTypes[i] == MPLS_HOSTADR_FEC ? \
32: lblReqMsg->fecTlv.fecElArray[i].addressEl.preLen;
/*
if(mpls_policy_filter( \
lblReqMsg->fecTlv.fecElArray[i].addressEl.address, \
preLen) != \
MPLS_TRUE)
{
MPLS_SEND_NOTIFY(session,NOROUTE,lblReqMsg->baseMsg.msgId, \
lblReqMsg->baseMsg.flags.flags.msgType);
}
*/
MPLS_FEC_SEARCH(lblReqMsg->fecTlv.fecElArray[i].addressEl.address,preLen,fecEntry);
if(fecEntry == MPLS_NULL)
{
/**********************************************/
/* send notification message, NO ROUTE
*/
/**********************************************/
MPLS_SEND_NOTIFY(session,NOROUTE,lblReqMsg->baseMsg.msgId, \
lblReqMsg->baseMsg.flags.flags.msgType);
return;
}
else if(!(fecEntry->owner & MPLS_OWNER_ROUTE))
{
/**********************************************/
/* send notification message, NO ROUTE
*/
/**********************************************/
MPLS_SEND_NOTIFY(session,NOROUTE,lblReqMsg->baseMsg.msgId, \
lblReqMsg->baseMsg.flags.flags.msgType);
return;
}
else if((fecEntry->pRes & MPLS_DENY_POLICY)&&(fecEntry->nodeType != MPLS_NODE_EGRESS)) //2003-11-10 lixia add for deny
{
/**********************************************/
/* send notification message, NO ROUTE
*/
/**********************************************/
MPLS_SEND_NOTIFY(session,NOROUTE,lblReqMsg->baseMsg.msgId, \
lblReqMsg->baseMsg.flags.flags.msgType);
printf("Deny this fec %x\n",fecEntry->fec_key.mplsFecAddr);
return;
}
else
{
/* by hyh */
/*
if((fecEntry->nodeType && MPLS_NODE_EGRESS)||
(fecEntry->nodeType && MPLS_NODE_PROXY_EGRESS))
*/
if((fecEntry->nodeType == MPLS_NODE_EGRESS)||
(fecEntry->nodeType == MPLS_NODE_PROXY_EGRESS))
{
lbl_req_fec_proc(session,MPLS_NULL,fecEntry,lblReqMsg);
return;
}
MPLS_NEXTHOP_SESSION_SEARCH(fecEntry->nexthopAddr,\
downSession);
if(downSession == MPLS_NULL)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -