📄 lec.c
字号:
entry->recv_vcc->push = entry->old_recv_push;#if 0 set_bit(ATM_VF_RELEASED,&entry->recv_vcc->flags); clear_bit(ATM_VF_READY,&entry->recv_vcc->flags); entry->recv_vcc->push(entry->recv_vcc, NULL);#endif atm_async_release_vcc(entry->recv_vcc, -EPIPE); entry->recv_vcc = NULL; } }/* * Insert entry to lec_arp_table * LANE2: Add to the end of the list to satisfy 8.1.13 */static __inline__ void lec_arp_put(struct lec_arp_table **lec_arp_tables, struct lec_arp_table *to_put){ unsigned short place; unsigned long flags; struct lec_arp_table *tmp; save_flags(flags); cli(); place = HASH(to_put->mac_addr[ETH_ALEN-1]); tmp = lec_arp_tables[place]; to_put->next = NULL; if (tmp == NULL) lec_arp_tables[place] = to_put; else { /* add to the end */ while (tmp->next) tmp = tmp->next; tmp->next = to_put; } restore_flags(flags); DPRINTK("LEC_ARP: Added entry:%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n", 0xff&to_put->mac_addr[0], 0xff&to_put->mac_addr[1], 0xff&to_put->mac_addr[2], 0xff&to_put->mac_addr[3], 0xff&to_put->mac_addr[4], 0xff&to_put->mac_addr[5]);}/* * Remove entry from lec_arp_table */static __inline__ int lec_arp_remove(struct lec_arp_table **lec_arp_tables, struct lec_arp_table *to_remove){ unsigned short place; struct lec_arp_table *tmp; unsigned long flags; int remove_vcc=1; save_flags(flags); cli(); if (!to_remove) { restore_flags(flags); return -1; } place = HASH(to_remove->mac_addr[ETH_ALEN-1]); tmp = lec_arp_tables[place]; if (tmp == to_remove) { lec_arp_tables[place] = tmp->next; } else { while(tmp && tmp->next != to_remove) { tmp = tmp->next; } if (!tmp) {/* Entry was not found */ restore_flags(flags); return -1; } } tmp->next = to_remove->next; del_timer(&to_remove->timer); /* If this is the only MAC connected to this VCC, also tear down the VCC */ if (to_remove->status >= ESI_FLUSH_PENDING) { /* * ESI_FLUSH_PENDING, ESI_FORWARD_DIRECT */ for(place=0;place<LEC_ARP_TABLE_SIZE;place++) { for(tmp=lec_arp_tables[place];tmp!=NULL;tmp=tmp->next){ if (memcmp(tmp->atm_addr, to_remove->atm_addr, ATM_ESA_LEN)==0) { remove_vcc=0; break; } } } if (remove_vcc) lec_arp_clear_vccs(to_remove); } skb_queue_purge(&to_remove->tx_wait); /* FIXME: good place for this? */ restore_flags(flags); DPRINTK("LEC_ARP: Removed entry:%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n", 0xff&to_remove->mac_addr[0], 0xff&to_remove->mac_addr[1], 0xff&to_remove->mac_addr[2], 0xff&to_remove->mac_addr[3], 0xff&to_remove->mac_addr[4], 0xff&to_remove->mac_addr[5]); return 0;}#if DEBUG_ARP_TABLEstatic char*get_status_string(unsigned char st){ switch(st) { case ESI_UNKNOWN: return "ESI_UNKNOWN"; case ESI_ARP_PENDING: return "ESI_ARP_PENDING"; case ESI_VC_PENDING: return "ESI_VC_PENDING"; case ESI_FLUSH_PENDING: return "ESI_FLUSH_PENDING"; case ESI_FORWARD_DIRECT: return "ESI_FORWARD_DIRECT"; default: return "<UNKNOWN>"; }}#endifvoiddump_arp_table(struct lec_priv *priv){#if DEBUG_ARP_TABLE int i,j, offset; struct lec_arp_table *rulla; char buf[1024]; struct lec_arp_table **lec_arp_tables = (struct lec_arp_table **)priv->lec_arp_tables; struct lec_arp_table *lec_arp_empty_ones = (struct lec_arp_table *)priv->lec_arp_empty_ones; struct lec_arp_table *lec_no_forward = (struct lec_arp_table *)priv->lec_no_forward; struct lec_arp_table *mcast_fwds = priv->mcast_fwds; printk("Dump %p:\n",priv); for (i=0;i<LEC_ARP_TABLE_SIZE;i++) { rulla = lec_arp_tables[i]; offset = 0; offset += sprintf(buf,"%d: %p\n",i, rulla); while (rulla) { offset += sprintf(buf+offset,"Mac:"); for(j=0;j<ETH_ALEN;j++) { offset+=sprintf(buf+offset, "%2.2x ", rulla->mac_addr[j]&0xff); } offset +=sprintf(buf+offset,"Atm:"); for(j=0;j<ATM_ESA_LEN;j++) { offset+=sprintf(buf+offset, "%2.2x ", rulla->atm_addr[j]&0xff); } offset+=sprintf(buf+offset, "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ", rulla->vcc?rulla->vcc->vpi:0, rulla->vcc?rulla->vcc->vci:0, rulla->recv_vcc?rulla->recv_vcc->vpi:0, rulla->recv_vcc?rulla->recv_vcc->vci:0, rulla->last_used, rulla->timestamp, rulla->no_tries); offset+=sprintf(buf+offset, "Flags:%x, Packets_flooded:%x, Status: %s ", rulla->flags, rulla->packets_flooded, get_status_string(rulla->status)); offset+=sprintf(buf+offset,"->%p\n",rulla->next); rulla = rulla->next; } printk("%s",buf); } rulla = lec_no_forward; if (rulla) printk("No forward\n"); while(rulla) { offset=0; offset += sprintf(buf+offset,"Mac:"); for(j=0;j<ETH_ALEN;j++) { offset+=sprintf(buf+offset,"%2.2x ", rulla->mac_addr[j]&0xff); } offset +=sprintf(buf+offset,"Atm:"); for(j=0;j<ATM_ESA_LEN;j++) { offset+=sprintf(buf+offset,"%2.2x ", rulla->atm_addr[j]&0xff); } offset+=sprintf(buf+offset, "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ", rulla->vcc?rulla->vcc->vpi:0, rulla->vcc?rulla->vcc->vci:0, rulla->recv_vcc?rulla->recv_vcc->vpi:0, rulla->recv_vcc?rulla->recv_vcc->vci:0, rulla->last_used, rulla->timestamp, rulla->no_tries); offset+=sprintf(buf+offset, "Flags:%x, Packets_flooded:%x, Status: %s ", rulla->flags, rulla->packets_flooded, get_status_string(rulla->status)); offset+=sprintf(buf+offset,"->%lx\n",(long)rulla->next); rulla = rulla->next; printk("%s",buf); } rulla = lec_arp_empty_ones; if (rulla) printk("Empty ones\n"); while(rulla) { offset=0; offset += sprintf(buf+offset,"Mac:"); for(j=0;j<ETH_ALEN;j++) { offset+=sprintf(buf+offset,"%2.2x ", rulla->mac_addr[j]&0xff); } offset +=sprintf(buf+offset,"Atm:"); for(j=0;j<ATM_ESA_LEN;j++) { offset+=sprintf(buf+offset,"%2.2x ", rulla->atm_addr[j]&0xff); } offset+=sprintf(buf+offset, "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ", rulla->vcc?rulla->vcc->vpi:0, rulla->vcc?rulla->vcc->vci:0, rulla->recv_vcc?rulla->recv_vcc->vpi:0, rulla->recv_vcc?rulla->recv_vcc->vci:0, rulla->last_used, rulla->timestamp, rulla->no_tries); offset+=sprintf(buf+offset, "Flags:%x, Packets_flooded:%x, Status: %s ", rulla->flags, rulla->packets_flooded, get_status_string(rulla->status)); offset+=sprintf(buf+offset,"->%lx\n",(long)rulla->next); rulla = rulla->next; printk("%s",buf); } rulla = mcast_fwds; if (rulla) printk("Multicast Forward VCCs\n"); while(rulla) { offset=0; offset += sprintf(buf+offset,"Mac:"); for(j=0;j<ETH_ALEN;j++) { offset+=sprintf(buf+offset,"%2.2x ", rulla->mac_addr[j]&0xff); } offset +=sprintf(buf+offset,"Atm:"); for(j=0;j<ATM_ESA_LEN;j++) { offset+=sprintf(buf+offset,"%2.2x ", rulla->atm_addr[j]&0xff); } offset+=sprintf(buf+offset, "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ", rulla->vcc?rulla->vcc->vpi:0, rulla->vcc?rulla->vcc->vci:0, rulla->recv_vcc?rulla->recv_vcc->vpi:0, rulla->recv_vcc?rulla->recv_vcc->vci:0, rulla->last_used, rulla->timestamp, rulla->no_tries); offset+=sprintf(buf+offset, "Flags:%x, Packets_flooded:%x, Status: %s ", rulla->flags, rulla->packets_flooded, get_status_string(rulla->status)); offset+=sprintf(buf+offset,"->%lx\n",(long)rulla->next); rulla = rulla->next; printk("%s",buf); }#endif}/* * Destruction of arp-cache */voidlec_arp_destroy(struct lec_priv *priv){ struct lec_arp_table *entry, *next; unsigned long flags; int i; save_flags(flags); cli(); del_timer(&priv->lec_arp_timer); /* * Remove all entries */ for (i=0;i<LEC_ARP_TABLE_SIZE;i++) { for(entry =priv->lec_arp_tables[i];entry != NULL; entry=next) { next = entry->next; lec_arp_remove(priv->lec_arp_tables, entry); kfree(entry); } } entry = priv->lec_arp_empty_ones; while(entry) { next = entry->next; del_timer(&entry->timer); lec_arp_clear_vccs(entry); kfree(entry); entry = next; } priv->lec_arp_empty_ones = NULL; entry = priv->lec_no_forward; while(entry) { next = entry->next; del_timer(&entry->timer); lec_arp_clear_vccs(entry); kfree(entry); entry = next; } priv->lec_no_forward = NULL; entry = priv->mcast_fwds; while(entry) { next = entry->next; del_timer(&entry->timer); lec_arp_clear_vccs(entry); kfree(entry); entry = next; } priv->mcast_fwds = NULL; priv->mcast_vcc = NULL; memset(priv->lec_arp_tables, 0, sizeof(struct lec_arp_table*)*LEC_ARP_TABLE_SIZE); restore_flags(flags);}/* * Find entry by mac_address */static __inline__ struct lec_arp_table*lec_arp_find(struct lec_priv *priv, unsigned char *mac_addr){ unsigned short place; struct lec_arp_table *to_return; DPRINTK("LEC_ARP: lec_arp_find :%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n", mac_addr[0]&0xff, mac_addr[1]&0xff, mac_addr[2]&0xff, mac_addr[3]&0xff, mac_addr[4]&0xff, mac_addr[5]&0xff); lec_arp_lock(priv); place = HASH(mac_addr[ETH_ALEN-1]); to_return = priv->lec_arp_tables[place]; while(to_return) { if (memcmp(mac_addr, to_return->mac_addr, ETH_ALEN) == 0) { lec_arp_unlock(priv); return to_return; } to_return = to_return->next; } lec_arp_unlock(priv); return NULL;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -