A kind of method of refreshing hardware table item
Technical field
The present invention relates to ethernet technology, refer to a kind of method of refreshing hardware table item especially.
Background technology
Along with development of Ethernet technology, Ethernet switch shared ratio in forwarding unit is increasing.Forwarding unit described here is: Ethernet switch, router, three-tier switch etc. have the network equipment of forwarding capability.Ethernet switch is compared with router, and maximum difference is: Ethernet switch is to E-Packet by hardware chip, and router then is to realize message forwarding by software.
In software is transmitted, transmit to software and transmit, comprise software fib table and software ARP table, specifically as shown in Figure 1; In hardware is transmitted, transmit and be hardware forwarding table, comprise hardware fib table and hardware ARP table, specifically as shown in Figure 2.What store in the list item of hardware fib table is: route prefix and with the index of this hardware fib table item corresponding hardware ARP list item; And in hardware ARP list item, store be: next-hop ip address, outbound port and target MAC (Media Access Control) address.Hardware is transmitted and the maximum difference of software forwarding is: need to carry out twice search procedure in software is transmitted, at first search the software fib table, search software ARP table again, E-Packet according to the content that finds; And in the hardware forwarding, owing to stored the index of corresponding hardware ARP list item in the hardware fib table item, therefore only need carry out one time search procedure, when searching the hardware fib table and obtain relevant hardware fib table item, just can directly obtain relevant hardware ARP list item according to the index of the hardware ARP list item of hardware fib table item storage.
This shows that hardware is transmitted the process avoided software to search once more in transmitting, has improved forward efficiency effectively.In actual applications, for the middle and high end forwarding unit, might point to same hardware ARP list item by up to ten million hardware fib table items, therefore, the variation of a hardware ARP list item may cause refreshing again of up to ten million hardware fib table items.But in real process, be not that each hardware ARP list item changes, hardware fib table item all can change.Here the hardware ARP list item of the indication finger that changes: outbound port changes or target MAC (Media Access Control) address changes or outbound port and target MAC (Media Access Control) address all change.For example: change at outbound port and cause under the situation that hardware ARP list item is refreshed, the hardware ARP table item index that returns after refreshing does not change, because storage is route prefix and corresponding hardware ARP table item index in the hardware fib table item, therefore, any variation does not take place with respect to the hardware fib table item before refreshing in the hardware fib table item after refreshing.Therefore,, all to refresh relevant hardware fib table item, then can cause the storm and stress of transmitting, influence the stability of system, waste system resource if each hardware ARP list item refreshes.
Summary of the invention
In view of this, main purpose of the present invention is to provide a kind of method of refreshing hardware table item, uses this method and can refresh the interior hardware table item of forwarding unit accurately.
For achieving the above object, technical scheme of the present invention is achieved in that
A kind of method of refreshing hardware table item, carry out following steps:
A, software address analysis protocol ARP list item obtain to change;
B, the variation that takes place according to software ARP list item, software ARP list item refreshes relevant hardware ARP list item, and obtain the hardware ARP table item index that returns after hardware ARP list item refreshes, the hardware ARP table item index that software ARP list item judge to obtain whether with refresh before hardware ARP table item index identical, if identical, process ends then; Otherwise,, refresh relevant hardware forwarding information table fib table item according to the hardware ARP table item index that returns.
Wherein, the described relevant hardware fib table item that refreshes is: software ARP list item triggers the hardware ARP table item index in the software fib table item refreshing hardware fib table item according to the hardware ARP table item index that returns.
Wherein, hardware ARP table is made up of hardware Media Access Control address MAC table and hardware outbound port table, and described step B comprises:
B11, only judge whether to change and software ARP list item is changed by target MAC (Media Access Control) address, when software ARP list item being changed when only changing by target MAC (Media Access Control) address, execution in step B12;
B12, according to the variation that software ARP list item takes place, software ARP list item refreshes relevant hardware MAC Address list item, and obtains the hardware mac address table item index that returns after the hardware mac address list item refreshes;
B13, software ARP list item judge the hardware mac address table item index that obtains whether with refresh before the hardware mac address table item index identical, if identical, process ends then; Otherwise, execution in step B14;
B14, according to the hardware mac address table item index that returns, software ARP list item refreshes relevant hardware outbound port list item, and obtains the hardware outbound port table item index that returns after hardware outbound port list item refreshes;
B15, software ARP list item judge the hardware outbound port table item index that obtains whether with refresh before hardware outbound port table item index identical, if identical, process ends then; Otherwise, refresh corresponding hardware fib table item according to the hardware outbound port table item index that returns.
Wherein, hardware ARP table is made up of hardware MAC table and hardware outbound port table; Described step B may further comprise the steps:
B21, according to the variation that software ARP list item takes place, software ARP list item refreshes relevant hardware MAC Address list item, and obtains the hardware mac address table item index that returns after the hardware mac address list item refreshes;
B22, the variation that takes place according to software ARP list item and the hardware mac address table item index that returns, software ARP list item refreshes relevant hardware outbound port list item, and obtains the hardware outbound port table item index that returns behind the refreshing hardware outbound port list item;
B23, software ARP list item judge the hardware outbound port table item index that obtains whether with refresh before hardware outbound port table item index identical, if identical, process ends then; Otherwise, refresh relevant hardware fib table item according to the hardware outbound port table item index that returns.
Wherein, the list item of software ARP described in the step B21 changes and changes and target MAC (Media Access Control) address changes for: outbound port.
Wherein, the described relevant hardware fib table item that refreshes is: software ARP list item triggers the hardware outbound port table item index in the software fib table item refreshing hardware fib table item according to the hardware outbound port table item index that returns.
Wherein, described hardware ARP table item index is hardware ARP list item address.
The method of a kind of refreshing hardware table item provided by the present invention, when software ARP list item changes, after refreshing hardware ARP list item, obtain hardware ARP list item and refresh the index that returns afterwards, and whether the hardware ARP table item index that judge to obtain is with to refresh hardware ARP table item index before identical, under situation inequality, according to the hardware ARP table item index refreshing hardware fib table item that returns; Otherwise, do not carry out the operation of refreshing hardware fib table item.By using method provided by the present invention, when refreshing hardware fib table item, not can owing to refresh behind the list item with refresh list item before, content in the list item does not change, and carried out invalid refresh process, caused the upheaval of transmitting, the method that the present invention proposes has been saved system resource effectively, has safeguarded the stability of system.
Description of drawings
Fig. 1 transmits schematic diagram for software;
Fig. 2 is the hardware forwarding table schematic diagram;
Fig. 3 is the schematic diagram of transmitting of hardware forwarding;
Fig. 4 is the flow chart of the present invention's first preferred embodiment;
The another schematic diagram of transmitting that Fig. 5 transmits for hardware;
Fig. 6 is the flow chart of the present invention's second preferred embodiment.
Embodiment
Core concept of the present invention is: after refreshing hardware ARP list item, obtain hardware ARP list item and refresh the hardware ARP table item index that returns afterwards, and whether the hardware ARP table item index that judge to obtain is with to refresh hardware ARP table item index before identical, if identical, then do not carry out the operation of refreshing hardware fib table item; Otherwise, according to the hardware ARP table item index refreshing hardware fib table item that returns.
Here, hardware table item index can be the hardware table item address, and promptly hardware ARP table item index can be hardware ARP list item address.
For making purpose of the present invention, technical scheme and advantage clearer, below with reference to accompanying drawing two preferred embodiments that develop simultaneously, the present invention is described in more detail.
In the hardware repeating process, be the foundation and the maintenance of support hardware list item, in software, also preserve a cover software fib table item and a software ARP list item simultaneously, wherein, further stored the index of corresponding hardware ARP list item at software ARP list item, software transmit with hardware forwarding table specifically as shown in Figure 3.Here, acting as of software ARP list item: since the content in the software ARP list item of Ethernet switch in real time and the determined outbound port of software control agreement and target MAC (Media Access Control) address be consistent, therefore when outbound port and/or target MAC (Media Access Control) address change, software ARP list item also can obtain the variation that outbound port or target MAC (Media Access Control) address take place, and produces accordingly to change.Wherein, described software control agreement is as Routing Protocol, ARP agreement etc.
In the present invention, described software ARP list item changes and is: software ARP list item by in real time and the determined outbound port of software protocol and target MAC (Media Access Control) address be consistent, and outbound port is changed or target MAC (Media Access Control) address changes or outbound port and target MAC (Media Access Control) address all change situation.
What the present invention's first preferred embodiment was described is: under the environment that hardware is transmitted, hardware forwarding table comprises hardware ARP table, hardware fib table, and for setting up and safeguard software ARP table and the software fib table that hardware table item is provided with.Detailed process is as shown in Figure 4:
Step 401~402: when software ARP list item acquisition variation, software ARP list item refreshes relevant hardware ARP list item according to the variation that takes place; After having refreshed hardware ARP list item, the hardware ARP table item index that returns after software ARP list item acquisition hardware ARP list item refreshes.
Step 403: whether the hardware ARP table item index that software ARP list item judge to obtain identical with the former hardware ARP table item index of self current storage, promptly with refreshing hardware ARP list item before hardware ARP table item index compare, if identical, then execution in step 404; Otherwise, upgrade the hardware ARP table item index of self storing, execution in step 405 according to the hardware ARP table item index that obtains.
Step 404: process ends, do not carry out the operation of refreshing hardware fib table item.
Step 405: software ARP list item is according to the hardware ARP table item index in the hardware ARP table item index triggering software fib table item refreshing hardware fib table item that returns.
The flow process of the present invention's first preferred embodiment finishes.
What the present invention's second preferred embodiment was described is: the another kind of pattern that hardware is transmitted, constitute jointly hardware ARP table by hardware outbound port table and hardware mac address table, be that hardware forwarding table comprises hardware mac address table, hardware outbound port table and hardware fib table, and for setting up and safeguard software ARP table and the software fib table that hardware table item is provided with, specifically as shown in Figure 5.
In the list item of hardware fib table, storage be route prefix and with the index of this hardware fib table item corresponding hardware outbound port list item, in hardware outbound port list item, store be next-hop ip address and outbound port and with the index of this hardware outbound port list item corresponding hardware MAC Address list item, what store in the hardware mac address list item is outbound port and target MAC (Media Access Control) address.The index of corresponding hardware outbound port list item and the index of corresponding hardware MAC Address list item in software ARP list item, have further been stored.
Under this hardware forward mode, the refresh process of particular hardware list item as shown in Figure 6:
Step 601~602: after software ARP list item obtains to change, target MAC (Media Access Control) address after at first software ARP list item being changed and outbound port information compare with the preceding software ARP list item that changes, judge whether only software ARP contents in table to be changed owing to target MAC (Media Access Control) address changes, if then execution in step 603; Otherwise, execution in step 606.
At this, execution only judges whether: since in hardware outbound port list item, store be outbound port, next-hop ip address, and and the index of this hardware outbound port list item corresponding hardware MAC Address list item, and what store in the hardware mac address list item is outbound port and target MAC (Media Access Control) address, therefore as long as when outbound port changes, all to carry out refreshing of hardware outbound port list item and hardware mac address list item; And only when target MAC (Media Access Control) address changes, the hardware mac address table item index after refreshing does not take place, and then only needs refreshing hardware mac address table entry index, and does not need to carry out the operation that other list item refreshes.
Step 603: the variation that software ARP list item takes place according to self, refresh relevant hardware MAC Address list item, and obtain the hardware mac address table item index that returns after the hardware mac address list item refreshes.
Step 604: the hardware mac address table item index that software ARP list item judge to obtain the whether former hardware mac address table item index with self current storage is identical, promptly with refreshing hardware MAC Address list item before the hardware mac address table item index compare, if identical, then execution in step 609; Otherwise, according to upgrading the hardware mac address table item index of self storing, execution in step 605.
Step 605: software ARP list item refreshes relevant hardware outbound port list item according to the hardware mac address table item index that returns, and the hardware outbound port table item index that returns behind the acquisition refreshing hardware outbound port list item, execution in step 608.
Step 606: according to the variation of software ARP list item generation, software ARP list item refreshes relevant hardware MAC Address list item, and the hardware mac address table item index that returns after refreshing according to the hardware mac address list item, upgrade the hardware mac address table item index of self storage.
Step 607: software ARP list item refreshes relevant hardware outbound port list item according to variation that self takes place and the hardware mac address table item index that returns, and the hardware outbound port table item index that returns behind the acquisition refreshing hardware outbound port list item.
Step 608: the former hardware outbound port table item index with self current storage is identical to judge the hardware outbound port table item index return, promptly compare with the hardware outbound port table item index that refreshes preceding hardware outbound port list item, if identical, then execution in step 609; Otherwise software ARP list item upgrades the hardware outbound port table item index of self storing, execution in step 610 according to the hardware outbound port table item index that obtains.
Step 609: process ends, do not carry out the operation of refreshing hardware fib table item.
Step 610: the hardware outbound port table item index that software ARP list item returns according to refreshing hardware outbound port list item, triggering software fib table item refreshes the hardware outbound port table item index in the relevant hardware fib table item.
The flow process of the present invention's second preferred embodiment finishes.
The above is preferred embodiment of the present invention only, is not to be used to limit protection scope of the present invention.