- mac老化机制 :硬件老化,删除硬件mac,通告上层软件
1.mac超时老化删除本地mac,保留mlag同步过来的mac
case MACSYN_MSG_RECVMACDEL:
ret = macSynLocalNotifier(&message);
if(message.pData != NULL)
netMblkClChainFree((M_BLK_ID)message.pData);
break;
/*本地网管和地址学习的处理函数*/
STATUS macSynLocalNotifier(tMacSynMsg *pMacSynMsg)
{
tPhyIfInfo phyinfo;
int32_t i =0, size = 0, msgType = 0, ret = OK;
tHwMacAddrEntry *pHwMac =NULL, macAddr;
M_BLK_ID pMblk = NULL;
size = sizeof(tHwMacAddrEntry);
pMblk = pMacSynMsg->pData;
msgType = pMacSynMsg->pktHead.msgType;
for(i=0; i<(pMacSynMsg->pktHead.dataLen/size); i++) /*解析所有mac地址表项, 对于静态表项来说,只有一条*/
{
if((msgType== MACSYN_MSG_RECVMACADD)||(msgType== MACSYN_MSG_RECVMACDEL))
{
if(pMblk->mBlkHdr.mLen < size)
{
pHwMac = &macAddr;
if(netMblkOffsetToBufCopy(pMblk, 0, (char *)pHwMac, size,(FUNCPTR) bcopy) < size)
{
macSynPrintf(MACSYN_DBG_ERR,("\r\n macSynLocalNotifier: Failed to copy entry %d.", i));
return ERROR;
}
pMblk = pMblk->mBlkHdr.mNext;
}
else
{
pHwMac = (tHwMacAddrEntry *)((char *)pMblk->mBlkHdr.mData);
pMblk->mBlkHdr.mLen -= size;
pMblk->mBlkHdr.mData += size;
}
}
else
pHwMac = &pMacSynMsg->pktHead.l2entry;
bzero((void *)&phyinfo, sizeof(tPhyIfInfo));
logical_to_phyical(&phyinfo, pHwMac->port[0]);
pHwMac->sys = phyinfo.unit;
if((pHwMac->mac[0] == 0x00)&&(pHwMac->mac[1] == 0x04)&&(pHwMac->mac[2] == 0x67))
gMacFhnLocal = 1;
if((gMacSynDebug & MACSYN_DBG_PKT)&&(gMacFhnLocal == 0))
macSynEntryPrint(pHwMac);
switch(pHwMac->keyType)
{
case HW_MACKEYTYPE_BRIDGE:
case HW_MACKEYTYPE_VP:
if((pHwMac->vlanId < 1)||(pHwMac->vlanId > 4094))
{
macSynPrintf(MACSYN_DBG_ERR,("\r\n macSynLocalNotifier: Bad vlan id %d.", pHwMac->vlanId));
if((msgType == MACSYN_MSG_RECVMACADD)||(msgType == MACSYN_MSG_RECVMACDEL))
gSysMacSynStatis.macLocalNotifyVidErr++;
continue;
}
break;
default:
break;
}
switch(msgType)
{
case MACSYN_MSG_RECVMACADD:
/*macSynPrintf(MACSYN_DBG_ADD,("\r\n macSynLocalNotifier,mac:0x%02x%02x%02x%02x%02x%02x.",pHwMac->mac[0],
pHwMac->mac[1],pHwMac->mac[2],pHwMac->mac[3],pHwMac->mac[4],pHwMac->mac[5]));*/
if(macSynMacLocalAdd(pHwMac) != OK)
break;
gSysMacSynStatis.macLocalAddSuccess++;
macSynStackEncode(pHwMac, MACSYN_SYNC_TYPEADD);
macSynMlagEncode(pHwMac, MACSYN_SYNC_TYPEADD);
break;
case MACSYN_MSG_RECVMACDEL:
if(macSynMacLocalDel(pHwMac) != OK)
break;
gSysMacSynStatis.macLocalDelSuccess++;
macSynStackEncode(pHwMac, MACSYN_SYNC_TYPEDEL);
macSynMlagEncode(pHwMac, MACSYN_SYNC_TYPEDEL);
break;
case MACSYN_MSG_ADDL2FDB:
gSysMacSynStatis.macLocalL3AddCnt02++;
if(macSynMacLocalAdd(pHwMac) != OK)
return ERROR;
gSysMacSynStatis.macLocalStaticAdd++;
macSynStackEncode(pHwMac, MACSYN_SYNC_TYPEADD);
macSynMlagEncode(pHwMac, MACSYN_SYNC_TYPEADD);
break;
case MACSYN_MSG_DELL2FDB:
gSysMacSynStatis.macLocalL3DelCnt02++;
if(macSynMacLocalDel(pHwMac) != OK)
return ERROR;
gSysMacSynStatis.macLocalStaticDel++;
macSynStackEncode(pHwMac, MACSYN_SYNC_TYPEDEL);
macSynMlagEncode(pHwMac, MACSYN_SYNC_TYPEDEL);
break;
default:
break;
}
gMacFhnLocal = 0;
}
return OK;
}
case MACSYN_MSG_RECVMACDEL:
if(macSynMacLocalDel(pHwMac) != OK)
break;
gSysMacSynStatis.macLocalDelSuccess++;
macSynStackEncode(pHwMac, MACSYN_SYNC_TYPEDEL);
macSynMlagEncode(pHwMac, MACSYN_SYNC_TYPEDEL);
break;
STATUS macSynMacLocalDel(tHwMacAddrEntry *pHwMac)
{
tPhyIfInfo phyInfo;
uint8_t ifName[64] = {0};
int32_t ret = OK, value = USP_IF_ENABLE;
tMacSynVlan *pMacSynVl