Routing conflict processing method and related device
By employing an autonomous routing conflict detection and repair method, the uncertainty in routing decisions caused by default route configuration in multi-network interface devices is resolved, ensuring the correct data path and improving the stability of the communication link.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-19
- Publication Date
- 2026-03-31
AI Technical Summary
In multi-network interface devices, existing technologies cannot effectively solve the problem of data path errors and network connection drops caused by the uncertainty of routing decisions due to default route configuration.
By employing autonomous routing conflict detection and repair methods, the DNS server address of the reference network interface is obtained, simulated routing decisions are made to determine whether routing conflicts exist, and conflict repair strategies are executed when conflicts exist. Static host routing rules are added to ensure that data packets are forwarded through the correct network interface.
It improves the stability of the communication link, ensures the correct data path, avoids secondary interference caused by global routing changes, and reduces the impact on the global system.
Smart Images

Figure CN121771103A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of network communication technology, and in particular to a method and related apparatus for handling routing conflicts. Background Technology
[0002] With the rapid development of mobile internet and IoT technologies, the functions of smart terminals and various embedded devices are becoming increasingly complex, and their network connectivity capabilities are also showing a trend of diversification. Modern smart devices typically integrate multiple network interfaces, such as Wi-Fi, cellular networks (e.g., 4G / 5G), and Ethernet, to achieve optimal connectivity and seamless switching in different scenarios. While this multi-interface architecture improves the flexibility and reliability of device connectivity, it also introduces complex network routing management issues.
[0003] However, existing technical solutions have significant drawbacks, especially in complex environments where multiple network interfaces are configured as default routes. For example, when a device is simultaneously connected to both Wi-Fi and LTE / 5G cellular networks, and both provide valid default gateways, the operating system kernel's routing table will contain two or more entries with these networks as default routes. In this case, the kernel's routing decision mechanism may become uncertain due to implementation differences, dynamic changes in interface priorities, or improper routing metric settings, leading to data path errors and ultimately, network connection drops. Summary of the Invention
[0004] In view of this, this application provides a method and related apparatus for handling routing conflicts, aiming to ensure the correctness of data paths and improve the stability of communication links by autonomously detecting and repairing routing conflicts, while ensuring global routing rules.
[0005] In a first aspect, embodiments of this application provide a method for handling routing conflicts, the method comprising: Obtain a route detection indication and determine the reference network interface of the target device. The reference network interface is the interface corresponding to the default route of the target device. The target device includes multiple network interfaces. Obtain the DNS server address of the reference network interface; Simulated routing decisions are made based on the DNS server address to determine the target network interface; Based on the reference network interface and the target network interface, determine whether there is a routing conflict in the target device; When a routing conflict exists on the target device, a conflict resolution strategy is executed.
[0006] In one possible embodiment, before obtaining the route detection indication, the method includes: generating the route detection indication when a network interface switching event is detected in the network management task of the target device; or, generating the route detection indication based on a preset period.
[0007] In one possible embodiment, determining the reference network interface of the target device includes: reading and traversing the system routing table of the target device, the system routing table including a set of rules for network information of the target device sending data packets to multiple target networks, the network information including gateway information and network interface information; filtering target entries in the system routing table that meet the following conditions: the target network and subnet mask of the target entry are consistent, and the gateway information and network interface information of the target entry are both non-zero values; and using the network interface corresponding to the target entry as the reference network interface.
[0008] In one possible embodiment, obtaining the DNS server address of the reference network interface includes: reading the configuration file corresponding to the reference network interface; and sequentially obtaining multiple DNS server addresses according to the storage order of the DNS server addresses in the configuration file.
[0009] In one possible embodiment, the simulated routing decision based on the DNS server address includes: selecting a DNS server address to be detected from the plurality of DNS server addresses; and performing a simulated routing decision on the address to be detected based on the system routing table of the target device to determine the network interface used when accessing the address to be detected, which is then designated as the target network interface.
[0010] In one possible embodiment, determining whether the target device has a routing conflict includes: determining whether the reference network interface and the target network interface are consistent; if the reference network interface and the target network interface are inconsistent, then determining that the target device has the routing conflict; if the reference network interface and the target network interface are consistent, then determining that the target device does not have the routing conflict.
[0011] In one possible embodiment, the execution of the conflict resolution strategy includes: adding a static host routing rule to the system routing table of the target device for the DNS server address involved in the routing conflict, wherein the static host routing rule is used to specify that data packets destined for the DNS server address are forwarded through the gateway of the reference network interface.
[0012] Secondly, embodiments of this application provide a routing conflict processing apparatus, comprising: a detection unit, an acquisition unit, a determination unit, a judgment unit, and an execution unit; wherein, the detection unit is used to acquire a routing detection indication and determine a reference network interface of a target device, the reference network interface being the interface corresponding to the default route of the target device, and the target device including multiple network interfaces; the acquisition unit is used to acquire the DNS server address of the reference network interface; the determination unit is used to perform simulated routing decisions based on the DNS server address to determine the target network interface; the judgment unit is used to determine whether the target device has a routing conflict based on the reference network interface and the target network interface; and the execution unit is used to execute a conflict resolution strategy when the target device has a routing conflict.
[0013] Thirdly, embodiments of this application provide an electronic device, including a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the programs include instructions for performing the steps in the first aspect of embodiments of this application.
[0014] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program for electronic data interchange, wherein the computer program causes a computer to perform some or all of the steps described in the first aspect of embodiments of this application.
[0015] Fifthly, embodiments of this application provide a computer program product, wherein the computer program product includes a non-transitory computer-readable storage medium storing a computer program operable to cause a computer to perform some or all of the steps described in the first aspect of embodiments of this application. The computer program product may be a software installation package.
[0016] As can be seen, the routing conflict handling method and related apparatus provided in this application first obtain a routing detection indication to determine the reference network interface of the target device. The reference network interface is the interface corresponding to the default route of the target device, and the target device includes multiple network interfaces. Second, the DNS server address of the reference network interface is obtained. Next, a simulated routing decision is performed based on the DNS server address to determine the target network interface. Then, based on the reference network interface and the target network interface, it is determined whether there is a routing conflict in the target device. Finally, when there is a routing conflict in the target device, a conflict repair strategy is executed. In this way, by triggering a dynamic detection mechanism, multi-network interface devices can adapt to changes in the network environment, ensuring the correctness of the data path and improving the stability of the communication link. At the same time, by executing the repair strategy on a specific repair target, secondary interference that may be caused by global routing changes is avoided, reducing the impact on the global system. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is a functional unit diagram of a target device provided in an embodiment of this application; Figure 2 This is a schematic diagram illustrating the specific process of a routing conflict handling method provided in an embodiment of this application; Figure 3 This is a schematic diagram of a process for determining a reference network interface provided in an embodiment of this application; Figure 4 This is a schematic diagram illustrating the specific process of another routing conflict handling method provided in this application embodiment; Figure 5 This is a functional unit block diagram of a routing conflict handling device provided in an embodiment of this application; Figure 6 This is a structural block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0019] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present application.
[0020] The terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but in some embodiments includes steps or units not listed, or in some embodiments includes other steps or units inherent to these processes, methods, products, or apparatuses.
[0021] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0022] In the embodiments of this application, "and / or" describes the relationship between associated objects, indicating that three relationships can exist. For example, A and / or B can represent the following three situations: A exists alone; A and B exist simultaneously; B exists alone. Among them, A and B can be singular or plural.
[0023] In this embodiment, the symbol " / " can indicate that the preceding and following objects are in an "or" relationship. Alternatively, the symbol " / " can also represent a division sign, i.e., performing a division operation. For example, A / B can mean A divided by B.
[0024] In the embodiments of this application, "at least one item" or its similar expression refers to any combination of these items, including any combination of a single item or a plurality of items. "One or more" means one or more, while "multiple" means two or more. For example, "at least one item" of a, b, or c can represent the following seven cases: a, b, c; a and b; a and c; b and c; a, b, and c. Each of a, b, and c can be an element or a set containing one or more elements.
[0025] In the embodiments of this application, "equal to" can be used with "greater than" and is applicable to technical solutions used when "greater than" is used; it can also be used with "less than" and is applicable to technical solutions used when "less than" is used. When "equal to" is used with "greater than", it is not used with "less than"; when "equal to" is used with "less than", it is not used with "greater than".
[0026] The following describes the relevant content, concepts, meanings, technical issues, technical solutions, and beneficial effects involved in the embodiments of this application.
[0027] DNS (Domain Name System Server) is one of the core infrastructures of the Internet. It is a non-distributed database server that maps domain names to IP addresses. It is responsible for resolving easy-to-remember domain names into IP addresses that computers can recognize, so as to enable accurate communication between network terminals and target servers.
[0028] With the rapid development of mobile internet and IoT technologies, the functions of smart terminals and various embedded devices are becoming increasingly complex, and their network connectivity capabilities are also showing a trend of diversification. Modern smart devices typically integrate multiple network interfaces, such as Wi-Fi, cellular networks (e.g., 4G / 5G), and Ethernet, to achieve optimal connectivity and seamless switching in different scenarios. While this multi-interface architecture improves the flexibility and reliability of device connectivity, it also introduces complex network routing management issues.
[0029] However, existing technical solutions have significant drawbacks, especially in complex environments where multiple network interfaces are configured as default routes. For example, when a device is simultaneously connected to both Wi-Fi and LTE / 5G cellular networks, and both provide valid default gateways, the operating system kernel's routing table will contain two or more entries with these networks as default routes. In this case, the kernel's routing decision mechanism may become uncertain due to implementation differences, dynamic changes in interface priorities, or improper routing metric settings, leading to data path errors and ultimately, network connection drops.
[0030] In view of this, this application provides a method and related apparatus for handling routing conflicts, aiming to ensure the correctness of data paths and improve the stability of communication links by autonomously detecting and repairing routing conflicts, while ensuring global routing rules.
[0031] Please see Figure 1 , Figure 1 This is a functional unit diagram of a target device provided in an embodiment of this application, such as... Figure 1As shown, the target device 100 includes: a central processing unit (CPU) 110, a storage unit (RAM / ROM) 120, and multiple network interface controllers (NICs) 130. The CPU 110, the storage unit 120, and the multiple network interface controllers 130 are connected via a system bus 140.
[0032] Specifically, the central processing unit 110 obtains a route detection indication to determine the reference network interface of the target device 100. The reference network interface is the interface corresponding to the default route of the target device 100, and the target device 100 includes multiple network interfaces 130. The central processing unit 110 obtains the DNS server address of the reference network interface. The central processing unit 110 performs simulated route decision based on the DNS server address to determine the target network interface. Specifically, the target network interface is also one of the multiple network interfaces 130. The central processing unit 110 determines whether there is a route conflict in the target device 100 based on the reference network interface and the target network interface. When there is a route conflict in the target device 100, the central processing unit 110 executes a conflict resolution strategy.
[0033] Specifically, the central processing unit 110 communicates directly with the storage unit 120 and multiple network interface controllers 130 via the system bus 140. The central processing unit 110 performs simulated routing decisions based on DNS server addresses. According to the routing table data read from the storage unit 120, the central processing unit 110 simulates the kernel's selection algorithm, calculates the target network interface, and initiates control commands. After determining that repair is needed, the central processing unit 110 is responsible for generating and issuing system call instructions to add static host routes. The storage unit 120 temporarily stores real-time information such as the routing table read from the kernel, the DNS server address list, and the network interface status in RAM for quick access and analysis by the central processing unit 110. Multiple network interfaces 130, such as Wi-Fi and 4G modules, are simultaneously active and configured with default gateways; these are the objects to be monitored and managed by the solution. The status, IP address, and gateway information of each network interface 130 corresponding to each NIC, such as wlan0 and wwan0, are the basic inputs for determining the reference network interface and performing routing simulation. The added static host routing rules ultimately apply to the drivers or kernel protocol stacks of these NICs, forcing traffic destined for a specific DNS server to originate from the correct NIC, i.e., the NIC corresponding to the reference network interface, thereby correcting the data path.
[0034] Please see Figure 2 , Figure 2 This is a schematic flowchart illustrating a routing conflict handling method provided in an embodiment of this application. Figure 2 As shown, the method includes the following steps: S210, Obtain route detection indication and determine the reference network interface of the target device.
[0035] The reference network interface is the interface corresponding to the default route of the target device, which includes multiple network interfaces. The route detection indication is a trigger signal that can be triggered periodically, such as a scheduled task, or when system events such as network interface switching or IP address updates are detected, to ensure the timeliness and comprehensiveness of conflict detection.
[0036] The reference network interface is the primary network interface currently used by the device to access the Internet. By reading and traversing the system kernel routing table, entries with a destination network and subnet mask of 0.0.0.0 and gateway and interface values of non-zero are identified. These entries are the default routes that are currently in effect in the system, and their corresponding network interfaces, such as wlan0 and wwan0, are the reference network interfaces.
[0037] Specifically, in one possible embodiment, before obtaining the route detection indication, the method includes: generating a route detection indication when a network interface switching event is detected in the network management task of the target device; or, generating a route detection indication based on a preset period.
[0038] Network interface switching events, such as switching a device from Wi-Fi to 4G, adding a new network interface, or disabling an interface, are high-risk scenarios for routing conflicts. During the switching process, the system kernel routing table may experience issues such as overlapping default routes and inconsistent interface priorities. In such cases, generating a routing detection indicator in real time can trigger the conflict detection process immediately, preventing the conflict from persisting and causing network disconnection. Secondly, some routing conflicts may not be directly caused by interface switching, such as dynamic changes in DNS server addresses or abnormal refreshes of routing table entries during operation. Relying solely on event triggering may miss such conflicts. Generating detection indicators at preset intervals, such as 30 seconds or 1 minute, can be adjusted according to device needs to proactively initiate the detection process, ensuring that routing conflicts generated during operation can be detected promptly even without interface switching.
[0039] As can be seen, in this embodiment, a route detection indication is generated when a network interface switching event is detected in the network management task of the target device, or a route detection indication is generated based on a preset period. This not only specifically addresses high-incidence scenarios of route conflicts, ensuring that conflicts are detected in their early stages, but also covers latent conflicts in non-switching scenarios, ensuring the comprehensiveness and timeliness of route conflict detection.
[0040] S220, Obtain the DNS server address of the reference network interface.
[0041] When establishing a connection on the reference network interface, the router sends configuration information including IP address, gateway, subnet mask, and DNS server address through the interface, storing the DNS addresses received by that interface. The router then reads the DNS configuration file bound to that network interface and sequentially retrieves one DNS server address configured for the reference network interface. Specifically, it needs to iterate through all DNS server addresses corresponding to the reference network interface to ensure no conflicts are missed.
[0042] S230 performs simulated routing decisions based on DNS server addresses to determine the target network interface.
[0043] Specifically, for the current DNS server address, the routing decision-making process of the Linux kernel is simulated. Different versions of the Linux kernel can be used, and the corresponding routing strategies will differ. For example, the longest prefix matching rule can be used. Directly relying on the kernel to make automatic decisions may lead to path errors. By simulating the decision, the actual routing selection result of the system can be restored, and the network interface that the system will actually choose when accessing this address can be determined to avoid misjudgment and conflict.
[0044] S240 determines whether there is a routing conflict on the target device based on the reference network interface and the target network interface.
[0045] If the reference network interface and the target network interface are different, it is determined that there is a routing conflict problem on the target device.
[0046] For example, if the reference network interface is WIFI: wlan0, but the simulation shows that when accessing a DNS server, the system will select 4G: wwan0. At this time, the DNS resolution traffic will go through the 4G channel, while the data communication will go through the WIFI channel, causing the resolution result to be unable to match the data channel, and eventually the network will be disconnected.
[0047] S250: When a routing conflict exists on the target device, a conflict resolution strategy is executed.
[0048] Specifically, by implementing a conflict resolution strategy, data packets destined for this specific DNS server address must be forwarded through the default gateway address of the aforementioned record, thereby forcing traffic to be bound to the correct reference network interface, ensuring the consistency between the DNS query path and the data communication path, and thus correcting the data path interface.
[0049] As can be seen, the routing conflict handling method provided in this application first obtains a routing detection indication to determine the reference network interface of the target device. The reference network interface is the interface corresponding to the default route of the target device, and the target device includes multiple network interfaces. Second, the DNS server address of the reference network interface is obtained. Next, a simulated routing decision is performed based on the DNS server address to determine the target network interface. Then, based on the reference network interface and the target network interface, it is determined whether there is a routing conflict in the target device. Finally, when there is a routing conflict in the target device, a conflict repair strategy is executed. In this way, by triggering a dynamic detection mechanism, multi-network interface devices can adapt to changes in the network environment, ensuring the correctness of the data path and improving the stability of the communication link. At the same time, by executing the repair strategy on a specific repair target, secondary interference that may be caused by global routing changes is avoided, reducing the impact on the global system.
[0050] Specifically, please refer to Figure 3 , Figure 3 This is a schematic diagram of a process for determining a reference network interface provided in an embodiment of this application, such as... Figure 3 As shown, determining the reference network interface of the target device includes the following steps: S310 reads and iterates through the system routing table of the target device.
[0051] The system routing table includes a set of rules for network information regarding how a target device sends data packets to multiple target networks. This network information includes gateway information and network interface information. Specifically, the rule set might be: for example, a data packet destined for network A will travel via interface X and be forwarded through gateway Y.
[0052] S320: In the system routing table, filter out target entries that meet the conditions.
[0053] Specifically, the target entry must have the same target network and subnet mask, and both the gateway and network interface information must be non-zero values. The filtering rule is as follows: both the target network field and subnet mask field must be 0.0.0.0, and both the gateway and interface fields must be non-zero.
[0054] S330 uses the network interface corresponding to the target entry as the reference network interface.
[0055] The network interface corresponding to the default route is the device's currently active main network interface, such as wlan0 or wwan0. The target entries selected above are active default routes, and therefore their bound network interfaces are the interfaces used for all general data communication, which are used as reference network interfaces.
[0056] As can be seen, in this embodiment, by reading and traversing the system routing table of the target device, the network interface corresponding to the target entry is determined as the reference network interface. This improves the accuracy of identifying the reference network interface and solves the problem of unclear identification logic for default routes in existing technologies, which leads to ambiguity in determining the main network channel in multi-interface environments.
[0057] In one possible embodiment, obtaining the DNS server address of the reference network interface includes: reading the configuration file corresponding to the reference network interface; and sequentially obtaining multiple DNS server addresses according to the storage order of the DNS server addresses in the configuration file.
[0058] When a network interface establishes a connection, the router sends configuration information, including IP address, gateway, subnet mask, and DNS server address, through the interface. The router stores the DNS addresses received by that interface; that is, each network interface's DNS configuration is uniquely bound, not globally shared. Secondly, the storage order of DNS server addresses follows the order of the valid DNS list corresponding to the reference network interface, which can be based on the router's assigned priority order, the system's preset resolution order, etc. The addresses are retrieved sequentially according to their storage order, traversing all DNS addresses in the configuration file to perform routing conflict detection and handling.
[0059] As can be seen, in this embodiment, by ensuring that the DNS address is bound to the reference interface, the accuracy and specificity of routing conflict detection are improved. At the same time, multiple DNS server addresses are obtained sequentially according to the storage order to avoid omissions. The dedicated configuration file of the reference interface is read, and only the DNS address of that interface is obtained. It does not involve reading or modifying the configuration files of other network interfaces, thus avoiding network configuration chaos caused by cross-interface configuration reading and ensuring device stability.
[0060] In one possible embodiment, the simulated routing decision based on the DNS server address includes: selecting a DNS server address to be detected from multiple DNS server addresses; and performing a simulated routing decision on the address to be detected based on the system routing table of the target device to determine the network interface to be used when accessing the address to be detected, which is then designated as the target network interface.
[0061] Each DNS server address has an independent access path, and there may be some DNS address access interfaces that are consistent with the reference interface and others that are inconsistent. If batch testing or random selection testing is performed, it may lead to missed detections or confusion in the testing logic. Therefore, selecting them sequentially ensures that each DNS address can be tested individually.
[0062] Simulated routing decision refers to the routing selection logic of the target device's operating system kernel, such as the Linux kernel, which takes the address of the DNS server to be detected as input and calculates and determines the network interface that the device will actually use when accessing the DNS address based on the forwarding rules in the system routing table (such as longest prefix matching, route priority, interface availability, etc.).
[0063] Specifically, simulating the routing decision-making process of the Linux kernel is crucial. Different versions of the Linux kernel have different routing policies, and the system routing table is the core basis for kernel routing decisions, storing all forwarding rules. Therefore, simulating decision-making based on the system routing table essentially replicates the kernel's judgment process when actually accessing the DNS address. By substituting the DNS address to be detected and matching it with rules in the system routing table, such as longest prefix matching and routing priority, the kernel ultimately determines the network interface it will choose, i.e., the target network interface.
[0064] As can be seen, in this embodiment, by selecting the DNS server address to be detected, a simulated routing decision is made based on the system routing table of the target device to determine the target network interface. This improves the accuracy of determining the target network interface. By actively simulating routing decisions, the actual access path of the DNS address is captured, thereby realizing an autonomous and dynamic routing detection mechanism.
[0065] In one possible embodiment, determining whether a routing conflict exists in the target device includes: determining whether the reference network interface and the target network interface are consistent; if the reference network interface and the target network interface are inconsistent, then it is determined that a routing conflict exists in the target device; if the reference network interface and the target network interface are consistent, then it is determined that no routing conflict exists in the target device.
[0066] The reference network interface is the main data channel corresponding to the default route currently in effect on the device, such as the WIFI interface: wlan0, representing the correct path that data communication should take; the target network interface is the actual path that DNS resolution will take, obtained through simulated routing decisions, such as the 4G interface: wwan0; the consistency judgment verifies whether the resolution path matches the data path. If they match, the path is smooth and there is no conflict; if they do not match, the resolution result cannot adapt to the data channel, resulting in network disconnection.
[0067] As can be seen, in this embodiment, by determining whether the reference network interface and the target network interface are consistent, the problem of missed or misjudged conflicts caused by ambiguous judgment criteria is avoided, the pertinence of routing conflict detection is improved, system resources are not occupied in the conflict judgment stage, and the normal operation of the device network services is guaranteed.
[0068] In one possible embodiment, the conflict resolution strategy includes: adding a static host routing rule to the system routing table of the target device for the DNS server address with the routing conflict. The static host routing rule is used to specify that data packets destined for the DNS server address are forwarded through the gateway of the reference network interface.
[0069] Adding static host routing rules overrides the kernel's automatic routing decisions. Static routes are fixed forwarding rules configured manually or programmatically, and their priority is higher than the kernel's default dynamic decision logic such as longest prefix matching. The system will prioritize following these rules to forward data packets, thereby correcting previous incorrect routing choices by the kernel. Specifically, specifying the gateway forwarding of the reference network interface, which acts as a relay station for the main data channel (e.g., the Wi-Fi gateway 192.168.1.1), forces data packets destined for conflicting DNS addresses to be forwarded through this gateway. Essentially, this binds DNS resolution traffic to the main data channel, ensuring that the DNS resolution path is fully aligned with the data communication path. This conflict remediation strategy only adds targeted static host routes and does not delete or modify core rules such as default routes and specific network routes in the original routing table, avoiding secondary network failures caused by modifications to global configurations.
[0070] As can be seen, in this embodiment, by adding static host routing rules to the system routing table of the target device for the DNS server address with routing conflict, it avoids affecting other network services of the device and avoids secondary interference that may be caused by modifying global routing rules; and by performing forced forwarding according to the static host routing rules, the DNS resolution path matches the main data channel, thus ensuring the stability and reliability of the network connection.
[0071] Please refer to the details. Figure 4 , Figure 4 This is a schematic flowchart illustrating another routing conflict handling method provided in an embodiment of this application, as shown below. Figure 4 As shown, it includes the following steps: S401, Get route detection indication.
[0072] S402, retrieve the current system default route.
[0073] S403, determine whether all DNS addresses of the default route have been traversed? If yes, proceed to step S410; otherwise, proceed to step S404.
[0074] S404 refers to multiple DNS server addresses in the configuration file corresponding to the network interface in sequence.
[0075] S405 performs simulated routing decisions and calculates and determines the target network interface.
[0076] S406. Determine whether the reference network interface and the target network interface are consistent. If they are consistent, proceed to step S407; if they are inconsistent, proceed to step S408.
[0077] S407, no conflict.
[0078] S408, routing conflict.
[0079] S409 adds a static host routing rule to the system routing table of the target device for DNS server addresses with routing conflicts.
[0080] S410, End.
[0081] This application embodiment can divide the electronic device into functional units according to the above method example. For example, each function can be divided into a separate functional unit, or two or more functions can be integrated into one processing unit. The integrated unit can be implemented in hardware or as a software functional unit. It should be noted that the unit division in this application embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods.
[0082] and Figure 2 The implementation is consistent with the previous one; please refer to [link / reference]. Figure 5 , Figure 5 This is a functional unit block diagram of a routing conflict processing device provided in an embodiment of this application. The routing conflict processing device 500 includes: a detection unit 510, an acquisition unit 520, a determination unit 530, a judgment unit 540, and an execution unit 550. The detection unit 510 is used to acquire a routing detection indication and determine the reference network interface of the target device. The reference network interface is the interface corresponding to the default route of the target device, and the target device includes multiple network interfaces. The acquisition unit 520 is used to acquire the DNS server address of the reference network interface. The determination unit 530 is used to perform simulated routing decisions based on the DNS server address to determine the target network interface. The judgment unit 540 is used to determine whether a routing conflict exists in the target device based on the reference network interface and the target network interface. The execution unit 550 is used to execute a conflict resolution strategy when a routing conflict exists in the target device.
[0083] In one possible embodiment, before obtaining the route detection indication, the detection unit 510 is specifically used to: generate a route detection indication when a network interface switching event is detected in the network management task of the target device; or, generate a route detection indication based on a preset period.
[0084] In one possible embodiment, the detection unit 510 determines the reference network interface of the target device by: reading and traversing the system routing table of the target device, the system routing table including a set of rules for network information of the target device sending data packets to multiple target networks, the network information including gateway information and network interface information; filtering out target entries that meet the conditions in the system routing table, where the target network of the target entry is consistent with the subnet mask, and the gateway information and network interface information of the target entry are both non-zero values; and using the network interface corresponding to the target entry as the reference network interface.
[0085] In one possible embodiment, the DNS server address of the reference network interface is obtained. The obtaining unit 520 is specifically used to: read the configuration file corresponding to the reference network interface; and obtain multiple DNS server addresses in sequence according to the storage order of the DNS server addresses in the configuration file.
[0086] In one possible embodiment, the simulation routing decision is based on the DNS server address. The determining unit 530 is specifically used to: select the DNS server address to be detected from multiple DNS server addresses; and perform a simulation routing decision on the address to be detected based on the system routing table of the target device to determine the network interface used when accessing the address to be detected, which is then used as the target network interface.
[0087] In one possible embodiment, the determination unit 540 is specifically used to: determine whether the reference network interface and the target network interface are consistent; if the reference network interface and the target network interface are inconsistent, then the target device is determined to have a routing conflict; if the reference network interface and the target network interface are consistent, then the target device is determined not to have a routing conflict.
[0088] In one possible embodiment, the conflict resolution strategy is executed. Specifically, the execution unit 550 is used to: add a static host routing rule to the system routing table of the target device for the DNS server address with routing conflict. The static host routing rule is used to specify that data packets sent to the DNS server address are forwarded through the gateway of the reference network interface.
[0089] It is understood that since the method embodiments and the device embodiments are different presentations of the same technical concept, the content of the method embodiment section in this application should be adapted to the device embodiment section in a synchronous manner, and will not be repeated here.
[0090] Figure 6 This is a structural block diagram of an electronic device provided in an embodiment of this application. For example... Figure 6As shown, electronic device 600 may include one or more components: a processor 601 and a memory 602 coupled to the processor 601, wherein the memory 602 may store one or more computer programs, which may be configured to implement the methods described in the examples above when executed by one or more processors 601. Electronic device 600 may be as follows: Figure 1 The target device 100 is shown.
[0091] Processor 601 may include one or more processing cores. Processor 601 connects to various parts within the electronic device 600 using various interfaces and lines, and performs various functions and processes data of the electronic device 600 by running or executing instructions, programs, code sets, or instruction sets stored in memory 602, and by calling data stored in memory 602. Optionally, processor 601 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). Processor 601 may integrate one or a combination of several of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), and modem. It is understood that the aforementioned modem may also not be integrated into processor 601, but may be implemented separately through a communication chip.
[0092] The memory 602 may include random access memory (RAM) or read-only memory (ROM). The memory 602 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 602 may include a program storage area and a data storage area. The program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as touch functionality, sound playback functionality, image playback functionality, etc.), and instructions for implementing the various method examples described above. The data storage area may also store data created during the use of the electronic device 600.
[0093] It is understood that the electronic device 600 may include more or fewer structural elements than those shown in the above block diagram, such as a power module, physical buttons, WiFi (Wireless Fidelity) module, speaker, Bluetooth module, sensor, etc., without limitation.
[0094] This application also provides a computer storage medium storing a computer program / instructions thereon, which, when executed by a processor, implements some or all of the steps of any of the methods described in the above method embodiments.
[0095] This application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program operable to cause a computer to perform some or all of the steps of any of the methods described in the above method embodiments.
[0096] It should be understood that in the various embodiments of this application, the order of the above-mentioned processes does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0097] In the several embodiments provided in this application, it should be understood that the disclosed methods, apparatuses, and systems can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for example, the division of units is merely a logical functional division, and there may be other division methods in actual implementation; for example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0098] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0099] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can be physically comprised separately, or two or more units can be integrated into one unit. The integrated unit described above can be implemented in hardware or in the form of hardware plus software functional units.
[0100] The integrated units implemented as software functional units described above can be stored in a computer-readable storage medium. These software functional units, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute partial steps of the methods of the various embodiments of the present invention. The aforementioned storage medium includes: a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, volatile memory, or non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous linked DRAM (SLDRAM), and direct rambus RAM (DR RAM), etc., which are various media capable of storing program code.
[0101] While the present invention has been disclosed above, it is not limited thereto. Any person skilled in the art can easily conceive of variations or substitutions without departing from the spirit and scope of the present invention, and various modifications and alterations can be made, including combinations of the different functions and implementation steps described above, as well as software and hardware implementation methods, all of which are within the protection scope of the present invention.
Claims
1. A method of handling a routing conflict, characterized by, The method comprises: obtaining a routing detection instruction, determining a reference network interface of a target device, the reference network interface being an interface corresponding to a default route of the target device, the target device comprising a plurality of network interfaces; obtaining a DNS server address of the reference network interface; making a simulated routing decision based on the DNS server address to determine a target network interface; judging whether the target device has a routing conflict according to the reference network interface and the target network interface; when the target device has a routing conflict, executing a conflict repair strategy.
2. The method of claim 1, wherein, Before the obtaining of the routing detection instruction, the method comprises: generating the routing detection instruction when detecting that there is a network interface switching event in a network management task of the target device; or generating the routing detection instruction based on a preset period.
3. The method of claim 2, wherein, The determining of the reference network interface of the target device comprises: reading and traversing a system routing table of the target device, the system routing table comprising a rule set of network information of the target device for sending data packets to a plurality of target networks, the network information comprising gateway information and network interface information; in the system routing table, screening a target entry meeting a condition, the target network of the target entry being consistent with a subnet mask, and the gateway information and the network interface information of the target entry both being non-zero values; taking a network interface corresponding to the target entry as the reference network interface.
4. The method of claim 1, wherein, The obtaining of the DNS server address of the reference network interface comprises: reading a configuration file corresponding to the reference network interface; obtaining a plurality of DNS server addresses in a storage order of the DNS server addresses in the configuration file.
5. The method of claim 4, wherein, The making of the simulated routing decision based on the DNS server address comprises: selecting a to-be-detected DNS server address from the plurality of DNS server addresses; making a simulated routing decision on the to-be-detected address based on the system routing table of the target device to determine a network interface adopted when accessing the to-be-detected address as the target network interface.
6. The method of claim 5, wherein, The judging of whether the target device has a routing conflict comprises: determining whether the reference network interface and the target network interface are consistent; if the reference network interface and the target network interface are inconsistent, determining that the target device has the routing conflict; if the reference network interface and the target network interface are consistent, determining that the target device does not have the routing conflict.
7. The method of claim 3, wherein, The executing of the conflict repair strategy comprises: adding a static host routing rule to the system routing table of the target device for the DNS server address of the routing conflict, the static host routing rule being used to specify that a data packet sent to the DNS server address is forwarded through a gateway of the reference network interface.
8. A processing device for handling a routing conflict, characterized in that The routing conflict processing apparatus comprises a detection unit, an obtaining unit, a determining unit, a judging unit and an executing unit; wherein, The detection unit is configured to acquire a routing detection instruction, and determine a reference network interface of a target device, the reference network interface being an interface corresponding to a default route of the target device, the target device comprising a plurality of network interfaces. The acquisition unit is configured to acquire a DNS server address of the reference network interface. The determination unit is configured to perform a simulated routing decision based on the DNS server address, to determine a target network interface. The judgment unit is configured to determine whether the target device has a routing conflict, according to the reference network interface and the target network interface. The execution unit is configured to perform a conflict repair strategy when the target device has a routing conflict.
9. An electronic device, comprising: A computer program product comprising a processor and a memory configured to store one or more programs for execution by the processor, the programs comprising instructions for performing the steps of the method of any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, A computer program for electronic data interchange, wherein the computer program causes a computer to perform the method of any one of claims 1-7.