MAC address learning method, device, equipment and readable storage medium

文档序号:1941447 发布日期:2021-12-07 浏览:28次 中文

阅读说明:本技术 Mac地址学习方法、装置、设备及可读存储介质 (MAC address learning method, device, equipment and readable storage medium ) 是由 孙小军 周坤 于 2021-09-02 设计创作,主要内容包括:本发明提供一种MAC地址学习方法、装置、设备及可读存储介质。该方法包括:当从报文入口接收到为学习报文的以太网报文时,通过学习报文回调函数将其存入消息队列,并将其重组打包发送至控制面;通过MAC学习线程将消息队列中的以太网报文转化为MAC表项并写入TCAM,在内存中保存MAC表项的镜像;控制面通过经过重组打包的以太网报文学到本地MAC后,通告给远端,同时将本地MAC表项发给转发面,转发面适配层将本地MAC表项写入TCAM,设置匹配动作为转发态;老化线程周期性遍历MAC表项的镜像缓存,将为伪存在态的MAC表项的设置为学习态,并将其写入TCAM。通过本发明,提升了EVPN业务MAC地址学习的速率,且增强了EVPN业务MAC地址学习的可靠性。(The invention provides a method, a device and equipment for learning an MAC address and a readable storage medium. The method comprises the following steps: when an Ethernet message which is a learning message is received from a message inlet, the Ethernet message is stored in a message queue through a learning message callback function, and is recombined, packaged and sent to a control plane; converting the Ethernet message in the message queue into an MAC table entry through an MAC learning thread, writing the MAC table entry into a TCAM (ternary content addressable memory), and storing a mirror image of the MAC table entry in a memory; the control plane learns local MAC through the recombined and packaged Ethernet message, informs the remote end of the local MAC, simultaneously sends a local MAC table entry to a forwarding plane, and a forwarding plane adaptation layer writes the local MAC table entry into TCAM and sets matching action as a forwarding state; the aging thread periodically traverses the mirror cache of the MAC table entry, sets the MAC table entry in a pseudo-existing state to be in a learning state, and writes the MAC table entry into the TCAM. By the method and the device, the learning rate of the EVPN service MAC address is improved, and the learning reliability of the EVPN service MAC address is enhanced.)

1. A MAC address learning method is characterized in that the MAC address learning method comprises the following steps:

receiving an Ethernet message from a message inlet, wherein the attribute of the message inlet is a two-layer interface and is associated with EVPN service;

detecting whether the Ethernet message is a learning message;

if the Ethernet message is a learning message, storing the Ethernet message into a message queue through a learning message callback function in a packet receiving thread, and then recombining and packaging the Ethernet message to be sent to a control plane;

newly building an MAC learning thread on the forwarding surface, converting the Ethernet message in the message queue into an MAC table entry through the MAC learning thread, writing the MAC table entry into a TCAM (ternary content addressable memory), and storing a mirror image of the MAC table entry in a memory;

the control plane learns local MAC through the uploaded Ethernet messages which are recombined and packaged, notifies the local MAC to a remote end through BGP, simultaneously issues local MAC table entries to a forwarding plane, the forwarding plane adaptation layer writes the local MAC table entries into TCAM, and sets matching action as a forwarding state;

and newly building an aging thread on the forwarding surface, periodically traversing the mirror cache of the MAC table entry by the aging thread, modifying the matching action field of the MAC table entry of which the matching action field is the value corresponding to the pseudo-existence state into the value corresponding to the learning state, and writing the MAC table entry of which the matching action field is modified into the value corresponding to the learning state into the TCAM.

2. The MAC address learning method according to claim 1, wherein the step of detecting whether the ethernet packet is a learning packet comprises:

acquiring a source MAC and a destination MAC of the Ethernet message;

using the BD associated with the message inlet and the source MAC of the Ethernet message as key values to query an MAC table in the TCAM;

and if the matching action field of the query result is a value corresponding to the default state or the learning state, determining the Ethernet message as the learning message.

3. The MAC address learning method of claim 2, wherein a format of the MAC table is defined as: the key value part consists of a BD field, a MAC field and a PAD filling field, the length of the mask part is consistent with that of the key value part, all bits of the mask take the value of 1, and the data part consists of a matching action field, a destination port field and a mirror image index field.

4. The MAC address learning method according to claim 1, wherein the step of re-packetizing the ethernet packet to send to a control plane comprises:

and taking out the effective field in the private header of the Ethernet message and storing the effective field in a packet cache, wherein the first byte of the packet cache is defined as a counter which represents the number of the effective fields, the effective field is of a fixed length, the counter is added with 1 after being stored in the packet cache, the offset of the packet cache is of a fixed length, and after the counter reaches a threshold value, a component packet sending callback interface is called to send the recombined Ethernet message to a control plane.

5. The MAC address learning method according to claim 1, wherein the forwarding plane creates an MAC learning thread, converts the ethernet packet in the message queue into an MAC entry and writes the MAC entry into the TCAM through the MAC learning thread, and the step of storing the mirror image of the MAC entry in the memory includes:

newly building an MAC learning thread on the forwarding surface;

the MAC learning thread reads the Ethernet message from the message queue, analyzes the private head of the Ethernet message to obtain a BD field, a source MAC field and a destination port field, uses the BD field and the source MAC field as key values of an MAC table, sets the length of a mask to be consistent with the length of the key values, values of all bits of the mask to be 1, uses the destination port field as a data part of the MAC table, sets a matching action field of the data part to be in a false existence state to obtain an MAC table item corresponding to the Ethernet message, refreshes the MAC table item to TCAM, and stores a mirror image of the MAC table item in an internal memory.

6. An MAC address learning apparatus, comprising:

a receiving module, configured to receive an ethernet packet from a packet entry, where an attribute of the packet entry is a two-layer interface and is associated with an EVPN service;

the detection module is used for detecting whether the Ethernet message is a learning message;

the forwarding module is used for storing the Ethernet message into a message queue through a learning message callback function in a packet receiving thread if the Ethernet message is a learning message, and then recombining and packaging the Ethernet message to be sent to a control plane;

the forwarding surface is used for creating an MAC learning thread, converting the Ethernet message in the message queue into an MAC table entry through the MAC learning thread, writing the MAC table entry into the TCAM, and storing a mirror image of the MAC table entry in the memory;

the control plane is used for informing the remote end through BGP after learning the local MAC through the uploaded Ethernet messages which are recombined and packaged, simultaneously issuing the local MAC table entry to the forwarding plane, writing the local MAC table entry into TCAM by the forwarding plane adaptation layer, and setting the matching action as a forwarding state;

the forwarding surface is further used for newly building an aging thread, the aging thread periodically traverses the mirror cache of the MAC table entry, modifies the matching action field of the MAC table entry of which the matching action field is the value corresponding to the pseudo-existence state into the value corresponding to the learning state, and writes the MAC table entry of which the matching action field is modified into the value corresponding to the learning state into the TCAM.

7. The MAC address learning apparatus of claim 6, wherein the detection module is to:

acquiring a source MAC and a destination MAC of the Ethernet message;

using the BD associated with the message inlet and the source MAC of the Ethernet message as key values to query an MAC table in the TCAM;

and if the matching action field of the query result is a value corresponding to the default state or the learning state, determining the Ethernet message as the learning message.

8. The MAC address learning apparatus of claim 7, wherein a format of the MAC table is defined as: the key value part consists of a BD field, a MAC field and a PAD filling field, the length of the mask part is consistent with that of the key value part, all bits of the mask take the value of 1, and the data part consists of a matching action field, a destination port field and a mirror image index field.

9. A MAC address learning device comprising a processor, a memory, and a MAC address learning program stored on the memory and executable by the processor, wherein the MAC address learning program when executed by the processor implements the steps of the MAC address learning method of any one of claims 1 to 5.

10. A readable storage medium, having a MAC address learning program stored thereon, wherein the MAC address learning program, when executed by a processor, implements the steps of the MAC address learning method according to any one of claims 1 to 5.

Technical Field

The present invention relates to the field of communications technologies, and in particular, to a method, an apparatus, a device, and a readable storage medium for MAC address learning.

Background

Currently, there are two main ways to learn a local source MAC address:

in the first mode, the forwarding chip sends the local Ethernet message to be learned to the control plane learning source MAC, and the control plane learns and then sends the message to the forwarding plane; and in the second mode, the forwarding chip learns the source MAC, and the forwarding plane adaptation layer polls the source MAC learned by the forwarding chip and uploads the source MAC to the control plane.

Among them, the first method has the following disadvantages:

the repeated uploading causes congestion of a signaling channel, part of the uploaded messages are discarded, and the control plane processes the repeated messages or cannot receive the uploaded messages, so that the learning rate is slowed down; the HASH table needs HASH calculation, the read-write performance is not high, and HASH conflict exists.

The second method has the following disadvantages:

time consumed by forwarding adaptation layer polling; the forwarding adaptation layer is complex in logic, and needs to perform polling, duplicate checking, reporting and retransmission, so that the performance problem exists.

Disclosure of Invention

In order to solve at least one technical problem in the prior art, the invention provides a MAC address learning method, device, equipment and readable storage medium.

In a first aspect, the present invention provides a MAC address learning method, where the MAC address learning method includes:

receiving an Ethernet message from a message inlet, wherein the attribute of the message inlet is a two-layer interface and is associated with EVPN service;

detecting whether the Ethernet message is a learning message;

if the Ethernet message is a learning message, storing the Ethernet message into a message queue through a learning message callback function in a packet receiving thread, and then recombining and packaging the Ethernet message to be sent to a control plane;

newly building an MAC learning thread on the forwarding surface, converting the Ethernet message in the message queue into an MAC table entry through the MAC learning thread, writing the MAC table entry into a TCAM (ternary content addressable memory), and storing a mirror image of the MAC table entry in a memory;

the control plane learns local MAC through the uploaded Ethernet messages which are recombined and packaged, notifies the local MAC to a remote end through BGP, simultaneously issues local MAC table entries to a forwarding plane, the forwarding plane adaptation layer writes the local MAC table entries into TCAM, and sets matching action as a forwarding state;

and newly building an aging thread on the forwarding surface, periodically traversing the mirror cache of the MAC table entry by the aging thread, modifying the matching action field of the MAC table entry of which the matching action field is the value corresponding to the pseudo-existence state into the value corresponding to the learning state, and writing the MAC table entry of which the matching action field is modified into the value corresponding to the learning state into the TCAM.

Optionally, the step of detecting whether the ethernet packet is a learning packet includes:

acquiring a source MAC and a destination MAC of the Ethernet message;

using the BD associated with the message inlet and the source MAC of the Ethernet message as key values to query an MAC table in the TCAM;

and if the matching action field of the query result is a value corresponding to the default state or the learning state, determining the Ethernet message as the learning message.

Optionally, the format of the MAC table is defined as: the key value part consists of a BD field, a MAC field and a PAD filling field, the length of the mask part is consistent with that of the key value part, all bits of the mask take the value of 1, and the data part consists of a matching action field, a destination port field and a mirror image index field.

Optionally, the step of re-assembling, packaging and sending the ethernet packet to the control plane includes:

and taking out the effective field in the private header of the Ethernet message and storing the effective field in a packet cache, wherein the first byte of the packet cache is defined as a counter which represents the number of the effective fields, the effective field is of a fixed length, the counter is added with 1 after being stored in the packet cache, the offset of the packet cache is of a fixed length, and after the counter reaches a threshold value, a component packet sending callback interface is called to send the recombined Ethernet message to a control plane.

Optionally, the step of creating an MAC learning thread on the forwarding plane, converting the ethernet packet in the message queue into an MAC entry and writing the MAC entry into the TCAM through the MAC learning thread, and storing the mirror image of the MAC entry in the memory includes:

newly building an MAC learning thread on the forwarding surface;

the MAC learning thread reads the Ethernet message from the message queue, analyzes the private head of the Ethernet message to obtain a BD field, a source MAC field and a destination port field, takes the BD field and the source MAC field as key values of an MAC table, sets the length of a mask to be consistent with the length of the key values, sets all bits of the mask to take a value of 1, sets the destination port field as a data part of the MAC table, sets a matching action field of the data part to be in a false existence state, and obtains an MAC table item corresponding to the Ethernet message;

and the MAC learning thread refreshes the MAC table entry to the TCAM and stores the mirror image of the MAC table entry in the memory.

In a second aspect, the present invention further provides a MAC address learning apparatus, including:

a receiving module, configured to receive an ethernet packet from a packet entry, where an attribute of the packet entry is a two-layer interface and is associated with an EVPN service;

the detection module is used for detecting whether the Ethernet message is a learning message;

the forwarding module is used for storing the Ethernet message into a message queue through a learning message callback function in a packet receiving thread if the Ethernet message is a learning message, and then recombining and packaging the Ethernet message to be sent to a control plane;

the forwarding surface is used for creating an MAC learning thread, converting the Ethernet message in the message queue into an MAC table entry through the MAC learning thread, writing the MAC table entry into the TCAM, and storing a mirror image of the MAC table entry in the memory;

the control plane is used for informing the remote end through BGP after learning the local MAC through the uploaded Ethernet messages which are recombined and packaged, simultaneously issuing the local MAC table entry to the forwarding plane, writing the local MAC table entry into TCAM by the forwarding plane adaptation layer, and setting the matching action as a forwarding state;

the forwarding surface is further used for newly building an aging thread, the aging thread periodically traverses the mirror cache of the MAC table entry, modifies the matching action field of the MAC table entry of which the matching action field is the value corresponding to the pseudo-existence state into the value corresponding to the learning state, and writes the MAC table entry of which the matching action field is modified into the value corresponding to the learning state into the TCAM.

Optionally, the detection module is configured to:

acquiring a source MAC and a destination MAC of the Ethernet message;

using the BD associated with the message inlet and the source MAC of the Ethernet message as key values to query an MAC table in the TCAM;

and if the matching action field of the query result is a value corresponding to the default state or the learning state, determining the Ethernet message as the learning message.

Optionally, the format of the MAC table is defined as: the key value part consists of a BD field, a MAC field and a PAD filling field, the length of the mask part is consistent with that of the key value part, all bits of the mask take the value of 1, and the data part consists of a matching action field, a destination port field and a mirror image index field.

Optionally, the forwarding module is configured to take out an effective field in the private header of the ethernet packet and store the effective field in a packet cache, where a first byte of the packet cache is defined as a counter, the number of the effective field is represented, the effective field is of a fixed length, after the effective field is stored in the packet cache, the counter is self-incremented by 1, the packet cache is offset by a fixed length, and after the counter reaches a threshold value, the component packet sending callback interface is called to send the reassembled ethernet packet to the control plane.

Optionally, a forwarding plane, configured to:

newly building an MAC learning thread;

the MAC learning thread reads the Ethernet message from the message queue, analyzes the private head of the Ethernet message to obtain a BD field, a source MAC field and a destination port field, takes the BD field and the source MAC field as key values of an MAC table, sets the length of a mask to be consistent with the length of the key values, sets all bits of the mask to take a value of 1, sets the destination port field as a data part of the MAC table, sets a matching action field of the data part to be in a false existence state, and obtains an MAC table item corresponding to the Ethernet message;

and the MAC learning thread refreshes the MAC table entry to the TCAM and stores the mirror image of the MAC table entry in the memory.

In a third aspect, the present invention further provides a MAC address learning device, which includes a processor, a memory, and a MAC address learning program stored on the memory and executable by the processor, wherein when the MAC address learning program is executed by the processor, the steps of the MAC address learning method as described above are implemented.

In a fourth aspect, the present invention further provides a readable storage medium, which stores a MAC address learning program, wherein the MAC address learning program, when executed by a processor, implements the steps of the MAC address learning method as described above.

In the invention, an Ethernet message is received from a message inlet, the attribute of the message inlet is a two-layer interface, and the EVPN service is associated; detecting whether the Ethernet message is a learning message; if the Ethernet message is a learning message, storing the Ethernet message into a message queue through a learning message callback function in a packet receiving thread, and then recombining and packaging the Ethernet message to be sent to a control plane; newly building an MAC learning thread on the forwarding surface, converting the Ethernet message in the message queue into an MAC table entry through the MAC learning thread, writing the MAC table entry into a TCAM (ternary content addressable memory), and storing a mirror image of the MAC table entry in a memory; the control plane learns local MAC through the uploaded Ethernet messages which are recombined and packaged, notifies the local MAC to a remote end through BGP, simultaneously issues local MAC table entries to a forwarding plane, the forwarding plane adaptation layer writes the local MAC table entries into TCAM, and sets matching action as a forwarding state; and newly building an aging thread on the forwarding surface, periodically traversing the mirror cache of the MAC table entry by the aging thread, modifying the matching action field of the MAC table entry of which the matching action field is the value corresponding to the pseudo-existence state into the value corresponding to the learning state, and writing the MAC table entry of which the matching action field is modified into the value corresponding to the learning state into the TCAM. By the method and the device, the learning rate of the EVPN service MAC address is improved, and the learning reliability of the EVPN service MAC address is enhanced.

Drawings

Fig. 1 is a schematic diagram of a hardware structure of a MAC address learning device according to an embodiment of the present invention;

FIG. 2 is a flowchart illustrating a MAC address learning method according to an embodiment of the present invention;

fig. 3 is a schematic diagram of a MAC table format in an embodiment of the MAC address learning method of the present invention.

The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.

Detailed Description

It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

In a first aspect, an embodiment of the present invention provides a MAC address learning device.

Referring to fig. 1, fig. 1 is a schematic diagram of a hardware structure of a MAC address learning device according to an embodiment of the present invention. In this embodiment of the present invention, the MAC address learning device may include a processor 1001 (e.g., a Central Processing Unit, CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used for realizing connection communication among the components; the user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard); the network interface 1004 may optionally include a standard wired interface, a WIreless interface (e.g., a WI-FI interface, WI-FI interface); the memory 1005 may be a Random Access Memory (RAM) or a non-volatile memory (non-volatile memory), such as a magnetic disk memory, and the memory 1005 may optionally be a storage device independent of the processor 1001. Those skilled in the art will appreciate that the hardware configuration depicted in FIG. 1 is not intended to be limiting of the present invention, and may include more or less components than those shown, or some components in combination, or a different arrangement of components.

With continued reference to fig. 1, a memory 1005, which is one type of computer storage medium in fig. 1, may include therein an operating system, a network communication module, a user interface module, and a MAC address learning program. The processor 1001 may call a MAC address learning program stored in the memory 1005, and execute the MAC address learning method provided by the embodiment of the present invention.

In a second aspect, an embodiment of the present invention provides a MAC address learning method.

In an embodiment, referring to fig. 2, fig. 2 is a flowchart illustrating an embodiment of a MAC address learning method according to the present invention. As shown in fig. 2, the MAC address learning method includes:

step S10, receiving Ethernet message from message inlet, wherein the attribute of the message inlet is two-layer interface, relating EVPN service;

in this embodiment, an ethernet packet is received from a packet entry of a current station, where the attribute of the packet entry is a two-layer interface and is associated with an EVPN service.

Step S20, detecting whether the Ethernet message is a learning message;

in this embodiment, after receiving the ethernet packet from the packet entry, it needs to further detect whether the ethernet packet is a learning packet. Specifically, the learning message has a corresponding attribute, and whether the learning message is a learning message can be determined by the attribute of the ethernet message.

Further, in one embodiment, step S20 includes:

acquiring a source MAC and a destination MAC of the Ethernet message; using the BD associated with the message inlet and the source MAC of the Ethernet message as key values to query an MAC table in the TCAM; and if the matching action field of the query result is a value corresponding to the default state or the learning state, determining the Ethernet message as the learning message.

In this embodiment, the ethernet message received from the message inlet is analyzed to obtain the source MAC and the destination MAC of the ethernet message, the BD associated with the message inlet and the source MAC of the ethernet message are used as key values to query the MAC table in the TCAM, and then whether the ethernet message is a learning message is determined according to the matching action field of the query result. Specifically, if the matching action field of the query result is a value corresponding to the default state or the learning state, the ethernet packet is determined to be the learning packet.

Further, in an embodiment, the format of the MAC table is defined as: the key value part consists of a BD field, a MAC field and a PAD filling field, the length of the mask part is consistent with that of the key value part, all bits of the mask take the value of 1, and the data part consists of a matching action field, a destination port field and a mirror image index field.

In this embodiment, referring to fig. 3, fig. 3 is a schematic diagram of a format of a MAC table in an embodiment of the MAC address learning method of the present invention. As shown in fig. 3, the key value portion of the MAC table is composed of a BD field, a MAC field, and a PAD padding field, the length of the mask portion is consistent with the key value portion, all bits of the mask take a value of 1, and the data portion is composed of a matching action field, a destination port field, and a mirror index field.

Wherein, the value of the matching action field is defined as: the value 0 represents a default state, the value 1 represents a pseudo-existence state, the value 2 represents a forwarding state, and the value 3 represents a learning state. The flow of processing an ethernet packet according to the matching action field may be specified as: if the matching action field is 0 or 3, determining that the Ethernet message is a learning message and uploading the learning message to a packet receiving thread; if the matching action field is 1, discarding the message; and (3) if the matching action field is 2, using the BD field and the target MAC field of the Ethernet message as key values to inquire the MAC table entry of the TCAM and continuously forward the Ethernet message.

Step S30, if the Ethernet message is a learning message, storing the Ethernet message into a message queue through a learning message callback function in a packet receiving thread, and then recombining and packaging the Ethernet message to be sent to a control plane;

in this embodiment, a learning message callback function is registered in the packet receiving thread, and when the ethernet message is a learning message, the ethernet message is stored in the message queue through the learning message callback function. Specifically, after receiving the ethernet packet, the packet receiving thread polls a callback function, enters a learning packet callback function, and the learning packet callback obtains the type of the ethernet packet by analyzing the private header of the ethernet packet, and skips over and does not process the ethernet packet if the type of the ethernet packet is not the MAC learning packet type, and only processes the MAC learning packet. And the learning message callback function sends the Ethernet message to the MAC message queue and informs the MAC learning thread to process the MAC message queue. And then, the Ethernet message is recombined and packaged and sent to the control plane.

Further, in an embodiment, the step of re-assembling and packaging the ethernet packet to be sent to the control plane includes:

and taking out the effective field in the private header of the Ethernet message and storing the effective field in a packet cache, wherein the first byte of the packet cache is defined as a counter which represents the number of the effective fields, the effective field is of a fixed length, the counter is added with 1 after being stored in the packet cache, the offset of the packet cache is of a fixed length, and after the counter reaches a threshold value, a component packet sending callback interface is called to send the recombined Ethernet message to a control plane.

In this embodiment, effective fields such as a source MAC in a private header of an ethernet packet are taken out and stored in a packet cache, a first byte of the packet cache is defined as a counter, the number of the effective fields is represented, the effective fields are fixed in length, the counter is added with 1 after being stored in the packet cache, the offset of the packet cache is fixed in length, and after the counter reaches a threshold value, a component packet sending callback interface is called to send a reassembled ethernet packet to a control plane.

Step S40, creating an MAC learning thread on the forwarding surface, converting the Ethernet message in the message queue into an MAC table entry through the MAC learning thread, writing the MAC table entry into a TCAM, and storing the mirror image of the MAC table entry in a memory;

in this embodiment, an MAC learning thread is newly created on the forwarding plane, after receiving a message sent by the learning callback function, the MAC learning thread reads an ethernet message from the MAC message queue, analyzes a private head of the ethernet message to obtain a BD field, a source MAC field, and a destination port field, uses the BD field and the source MAC field as key values of the MAC table, where the length of a mask is consistent with the length of the key values, all bits of the mask take a value of 1, the destination port field is used as a data portion of the MAC table, and a matching action field of the data portion is set to a pseudo-existence state, so that the ethernet message can be converted into an MAC entry as shown in fig. 3. After the Ethernet message is converted into the MAC table entry, the MAC learning thread refreshes the MAC table entry to the TCAM, and the mirror image of the MAC table entry is stored in the memory.

The method comprises the steps that an MAC learning thread inquires an MAC table item in a TCAM before refreshing the MAC table item, if the matching action of an inquiry result is a default state, an available mirror image index is distributed in the specification of the MAC table item and is filled into the data part of the MAC table item, the range of the mirror image index is [1, the specification of the MAC table item ], and then the MAC table item is issued to the TCAM; if the matching action of the query result is a learning state, assigning the mirror index as the queried mirror index, filling the queried mirror index into the data part of the MAC table entry, and then issuing the MAC table entry into the TCAM; and if the matching action of the query result is a forwarding state or a pseudo-existence state, the mirror image index is not distributed, and the MAC table entry is not issued to the TCAM.

The rule that the MAC learning thread stores the mirror image of the MAC table entry in the memory is as follows: if the mirror image index is not distributed, the MAC table entry is not stored in the mirror image cache; and if the mirror image index is distributed, storing the MAC table entry in a mirror image cache according to the mirror image index.

Further, in one embodiment, step S40 includes:

newly building an MAC learning thread on the forwarding surface; the MAC learning thread reads the Ethernet message from the message queue, analyzes the private head of the Ethernet message to obtain a BD field, a source MAC field and a destination port field, takes the BD field and the source MAC field as key values of an MAC table, sets the length of a mask to be consistent with the length of the key values, sets all bits of the mask to take a value of 1, sets the destination port field as a data part of the MAC table, sets a matching action field of the data part to be in a false existence state, and obtains an MAC table item corresponding to the Ethernet message; and the MAC learning thread refreshes the MAC table entry to the TCAM and stores the mirror image of the MAC table entry in the memory.

Step S50, the control plane learns the local MAC through the uploaded Ethernet message which is recombined and packaged, and then notifies the remote end through BGP, and simultaneously issues the local MAC table entry to the forwarding plane, the forwarding plane adaptation layer writes the local MAC table entry into TCAM, and sets the matching action as the forwarding state;

in this embodiment, the control plane learns the local MAC through the uploaded ethernet packet that is reassembled and packaged, and then notifies the remote end through the BGP, where the BGP is a routing protocol between autonomous systems, and network reachability information exchanged by the BGP provides sufficient information to detect a routing loop and make a decision on a route according to performance preference and policy constraint. Meanwhile, the local MAC table entry is issued to the forwarding plane, the forwarding plane adaptation layer writes the local MAC table entry into the TCAM, the matching action is set as the forwarding state, namely the matching action field is set as the value corresponding to the forwarding state.

Step S60, the forwarding plane creates an aging thread, the aging thread periodically traverses the mirror cache of the MAC table entry, modifies the matching action field of the MAC table entry of which the matching action field is the value corresponding to the pseudo-existence state into the value corresponding to the learning state, and writes the MAC table entry of which the matching action field is modified into the value corresponding to the learning state into the TCAM.

In the embodiment, an aging thread is newly established on a forwarding surface, the aging thread periodically traverses the mirror cache of the MAC table entry, the mirror cache is accessed and the MAC table entry is read according to the mirror index from the initial mirror index, the MAC table entry in the TCAM is inquired through the read key value, the matching action of the inquiry result is a pseudo-existence state, the matching action is set to a learning state, namely, the matching action field of the MAC table entry of which the matching action field is the value corresponding to the pseudo-existence state is modified into the value corresponding to the learning state, and then the MAC table entry modified by the matching action field is issued to the TCAM; and if the matching action of the query result is a forwarding state, deleting the mirror image of the MAC table entry, and not issuing the MAC table entry to the TCAM. And if the mirror index is increased progressively and the mirror of the MAC table entry exists, querying the MAC table entry of the TCAM through the key value of the mirror, and performing corresponding processing according to the matching action of the query result until the mirror index is equal to the specification of the MAC table entry and the specification is terminated.

In this embodiment, an ethernet packet is received from a packet entry, where the attribute of the packet entry is a two-layer interface and is associated with an EVPN service; detecting whether the Ethernet message is a learning message; if the Ethernet message is a learning message, storing the Ethernet message into a message queue through a learning message callback function in a packet receiving thread, and then recombining and packaging the Ethernet message to be sent to a control plane; newly building an MAC learning thread on the forwarding surface, converting the Ethernet message in the message queue into an MAC table entry through the MAC learning thread, writing the MAC table entry into a TCAM (ternary content addressable memory), and storing a mirror image of the MAC table entry in a memory; the control plane learns local MAC through the uploaded Ethernet messages which are recombined and packaged, notifies the local MAC to a remote end through BGP, simultaneously issues local MAC table entries to a forwarding plane, the forwarding plane adaptation layer writes the local MAC table entries into TCAM, and sets matching action as a forwarding state; and newly building an aging thread on the forwarding surface, periodically traversing the mirror cache of the MAC table entry by the aging thread, modifying the matching action field of the MAC table entry of which the matching action field is the value corresponding to the pseudo-existence state into the value corresponding to the learning state, and writing the MAC table entry of which the matching action field is modified into the value corresponding to the learning state into the TCAM. By the embodiment, the MAC table entry is defined as the TCAM table instead of the HASH table, so that the HASH calculation and HASH conflict are avoided, and the read-write performance of the MAC table entry is improved; the Ethernet message is recombined and packaged, so that the uploading quantity of the Ethernet messages is reduced, and the performance of the control plane for processing the Ethernet messages and the bandwidth utilization rate of a signaling channel are improved; the MAC learning thread refreshes the pseudo-existing state of the MAC table entry, so that the repeated uploading of the Ethernet message is prevented, the learning rate of the Ethernet message is improved, meanwhile, the mirror image of the MAC table entry is stored in a linear table mode, the MAC table entry is convenient to read and modify, and the mirror image index can ensure that the stored mirror image is not repeated; the aging thread refreshes the learning state of the MAC table entry, and periodically sends the local MAC which cannot be learned to the control plane until all the local MACs are learned, so that the reliability of MAC learning is enhanced.

In a third aspect, an embodiment of the present invention further provides an MAC address learning apparatus.

In one embodiment, the MAC address learning apparatus includes:

a receiving module, configured to receive an ethernet packet from a packet entry, where an attribute of the packet entry is a two-layer interface and is associated with an EVPN service;

the detection module is used for detecting whether the Ethernet message is a learning message;

the forwarding module is used for storing the Ethernet message into a message queue through a learning message callback function in a packet receiving thread if the Ethernet message is a learning message, and then recombining and packaging the Ethernet message to be sent to a control plane;

the forwarding surface is used for creating an MAC learning thread, converting the Ethernet message in the message queue into an MAC table entry through the MAC learning thread, writing the MAC table entry into the TCAM, and storing a mirror image of the MAC table entry in the memory;

the control plane is used for informing the remote end through BGP after learning the local MAC through the uploaded Ethernet messages which are recombined and packaged, simultaneously issuing the local MAC table entry to the forwarding plane, writing the local MAC table entry into TCAM by the forwarding plane adaptation layer, and setting the matching action as a forwarding state;

the forwarding surface is further used for newly building an aging thread, the aging thread periodically traverses the mirror cache of the MAC table entry, modifies the matching action field of the MAC table entry of which the matching action field is the value corresponding to the pseudo-existence state into the value corresponding to the learning state, and writes the MAC table entry of which the matching action field is modified into the value corresponding to the learning state into the TCAM.

Further, in an embodiment, the detection module is configured to:

acquiring a source MAC and a destination MAC of the Ethernet message;

using the BD associated with the message inlet and the source MAC of the Ethernet message as key values to query an MAC table in the TCAM;

and if the matching action field of the query result is a value corresponding to the default state or the learning state, determining the Ethernet message as the learning message.

Further, in an embodiment, the format of the MAC table is defined as: the key value part consists of a BD field, a MAC field and a PAD filling field, the length of the mask part is consistent with that of the key value part, all bits of the mask take the value of 1, and the data part consists of a matching action field, a destination port field and a mirror image index field.

Further, in an embodiment, the forwarding module is configured to take out an effective field in the private header of the ethernet packet and store the effective field in a packet cache, where a first byte of the packet cache is defined as a counter, the number of the effective field is represented, the effective field is of a fixed length, after the effective field is stored in the packet cache, the counter is self-incremented by 1, the packet cache is offset by a fixed length, and after the counter reaches a threshold value, the component is called to send a packet callback interface to send the reassembled ethernet packet to the control plane.

Further, in one embodiment, the forwarding plane is configured to:

newly building an MAC learning thread;

the MAC learning thread reads the Ethernet message from the message queue, analyzes the private head of the Ethernet message to obtain a BD field, a source MAC field and a destination port field, takes the BD field and the source MAC field as key values of an MAC table, sets the length of a mask to be consistent with the length of the key values, sets all bits of the mask to take a value of 1, sets the destination port field as a data part of the MAC table, sets a matching action field of the data part to be in a false existence state, and obtains an MAC table item corresponding to the Ethernet message;

and the MAC learning thread refreshes the MAC table entry to the TCAM and stores the mirror image of the MAC table entry in the memory.

The function implementation of each module in the MAC address learning apparatus corresponds to each step in the MAC address learning method embodiment, and the function and implementation process thereof are not described in detail here.

In a fourth aspect, the embodiment of the present invention further provides a readable storage medium.

The readable storage medium of the present invention stores a MAC address learning program, wherein the MAC address learning program, when executed by a processor, implements the steps of the MAC address learning method as described above.

The method implemented when the MAC address learning program is executed may refer to various embodiments of the MAC address learning method of the present invention, and will not be described herein again.

It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.

The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.

Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for causing a terminal device to execute the method according to the embodiments of the present invention.

The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

13页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:网络流量可视化的方法、装置、系统、及介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!