toggle quoted messageShow quoted text
do you need both interfaces be up all the time? If you do not, then simplest way is to take the other interface down.
The stack selects the network interface according to destination IP address. If you do not have specific routes set, then default network interface is selected.
The default interface select function can be found in subsys/net/ip/net_if.c:net_if_get_default(), it is not very smart and as you noticed it selects offline interface over the ethernet one. Some more intelligence could be created there. Patches are welcome if you want to investigate this further.
On Wed, 2020-11-25 at 06:06 -0800, johnnyboy_theUnixSlayer@... wrote:
Hi Zephyr Users,
I wonder how I can make my app switch between which network interface it use during runtime. My idea is to automate the if-selection depending on which of the ifs that has a internet connection.
I have begun simply with using http_get sample and it works fine when I'm using the ifs one at the time. But when I compile in both of them Zephyr wants to use one of the ifs over the other. The setup I'm using is the STM32H747i_disco dev. kit with its built in ethernet-if (aka not offloaded) and Sparkfuns Ublox Sara R4 shield (which is offloaded).
Zephyr always chooses R4 in this sample even though I have set CONFIG_NET_DEFAULT_IF_ETHERNET in prj.conf. Zephyr sets up both my ifs and runs a DCHP request for the ethernet-if. When the sample is done with its HTTP
request (which it does over R4) I can send net cmds like DNS-requests and ping servers with the ethernet-if. Which leads me to believe that the ethernet-if is ready to use by the sample somehow.
So how can I make the sample tell Zephyr to use the ethernet-if instead of the R4?
Further more I'm a bit preplexed because to my untrained eye it seems that Zephyr don't support to use offloaded and non offloaded ifs at the same time from a BSD-socket perspective. When zsock_getaddrinfo() runs it first checks if
CONFIG_NET_SOCKETS_OFFLOAD is enabled and the does the DNS request on the offloaded-if, and thus wont use the internal DNS resolver (which comes after the offloaded check in the code).
Thank you in advance//