Re: [Networking][socket] When is network is ready to accept a socket connection


Jukka Rissanen
 

Hi Karthik,

You are now looking the subsys/net/lib/config/init.c which is only used
when the device starts. There is no ADD handler for manual addition of
IPv4 address because the manual address is added automatically by that
file anyway.

I created a new version of PR#9370 which is now a bit more simpler and
easier to understand. Please review and comment there if you have
concerns/questions.

Cheers,
Jukka

On Mon, 2019-04-15 at 19:25 +0000, Prabhu Vinod, Karthik wrote:
Hi Jukka,

Just a follow-up question:

So I was going through the code, I realized the
NET_EVENT_IPV4_ADDR_ADD event only works when the setup uses DHCP.
Looks it won't work if the IP address is statically allocated. Is my
understanding correct?

As a work around for this: In case of static allocation can I do
this?

1.) Reassign the same static ip-address to the interface using
net_if_ipv4_addr_add like net_if_ipv4_addr_add(iface, &addr,
NET_ADDR_MANUAL, 0);
2.)
a.) net_if_ipv4_addr_add returns NULL if the ip address cannot
be added if the network is not ready or some other error:
b.) net_if_ipv4_addr_add returns a pointer to the
network_interface if the ip address could be successfully added.
3.) That generates the event.

Does it make sense?

Many Regards,
Karthik Prabhu Vinod

Help save the planet by choosing not to use single use plastics. Pick
paper, bamboo or metal cutlery and carry your own bag to the grocery
store. Every little thing you do makes an impact.

´╗┐On 4/10/19, 9:56 AM, "users@lists.zephyrproject.org on behalf of
Prabhu Vinod, Karthik" <users@lists.zephyrproject.org on behalf of
karthik.prabhu.vinod@intel.com> wrote:

Sounds good. Thank you so much Jukka. I think I will end up using
NET_EVENT_IPV4_ADDR_ADD event for now. Any expected ETA for the patch
you mentioned? ...Approximately !

Many Regards,
Karthik Prabhu Vinod

Help save the planet by choosing not to use single use plastics.
Pick paper, bamboo or metal cutlery and carry your own bag to the
grocery store. Every little thing you do makes an impact.

On 4/10/19, 1:35 AM, "users@lists.zephyrproject.org on behalf of
Jukka Rissanen" <users@lists.zephyrproject.org on behalf of
jukka.rissanen@linux.intel.com> wrote:

Hi Karthik,

For IPv4 monitoring NET_EVENT_IPV4_ADDR_ADD is best option
atm.
For IPv6 the NET_EVENT_IPV6_DAD_SUCCEED and/or
NET_EVENT_IPV6_ROUTER_ADD should be used instead.

These events are not optimal and some more work is needed in
the future
to make this more generic. So something like this draft
https://github.com/zephyrproject-rtos/zephyr/pull/9370 that
is still
pending.


Cheers,
Jukka


On Tue, 2019-04-09 at 22:13 +0000, Prabhu Vinod, Karthik
wrote:
> Hi,
>
> I wanted to know if there are network events which I can
subscribe,
> to know when the network init is complete. If there is one,
I want to
> wait and use the callback to notify my app that then It can
perform
> socket_connection. Because a socket connection on a non-
ready network
> is blocking call.
>
> I looked through include/net/net_event.h and found that
there is
> NET_EVENT_IPV4_ADDR_ADD which comes closest to our use case
since
> assigning IPv4 address to an network interface should be
last thing
> to perform in a network_boot sequence. Is there something
else that I
> could do?
>
> Many Regards,
> Karthik Prabhu Vinod
>
> Help save the planet by choosing not to use single use
plastics. Pick
> paper, bamboo or metal cutlery and carry your own bag to
the grocery
> store. Every little thing you do makes an impact.
>













Join users@lists.zephyrproject.org to automatically receive all group messages.