warmcat / libwebsockets

canonical libwebsockets.org networking library
https://libwebsockets.org
Other
4.73k stars 1.48k forks source link

Changing Ip address from dynamic to static LWS doesn't switch to static IP and the current TCP connection is stable #2871

Open sachusachin622 opened 1 year ago

sachusachin622 commented 1 year ago

Hi

I am running the lib-websockets in Raspberry Pi and am changing the configuration from dynamic to static IP address, I think I should get one event to terminate the WSI connection and re-establish but what event am getting is LWS_CALLBACK_EVENT_WAIT_CANCELLED , what i think i should get is LWS_CALLBACK_CLIENT_CLOSED

these are the logs am getting before LWS_CALLBACK_EVENT_WAIT_CANCELLED

Apr 20 11:12:11 user.info LWS_CLIENT[3039]: rops_handle_POLLIN_netlink: RTM 21 Apr 20 11:12:11 user.info LWS_CLIENT[3039]: rops_handle_POLLIN_netlink: DELADDR Apr 20 11:12:11 user.notice LWS_CLIENT[3039]: rops_handle_POLLIN_netlink: DELADDR Apr 20 11:12:11 user.info LWS_CLIENT[3039]: _lws_routing_entry_dump: dst: 0.0.0.0/22, ifidx: 12, pri: -1, proto: 0 Apr 20 11:12:11 user.info LWS_CLIENT[3039]: _lws_route_remove: deleting route Apr 20 11:12:11 user.debug LWS_CLIENT[3039]: _lws_route_pt_close_unroutable: in Apr 20 11:12:11 user.info LWS_CLIENT[3039]: _lws_routing_table_dump: Apr 20 11:12:11 user.info LWS_CLIENT[3039]: _lws_routing_entry_dump: src: 10.154.231.125/0, ifidx: 17, pri: -1, proto: 2 Apr 20 11:12:11 user.info LWS_CLIENT[3039]: _lws_routing_entry_dump: src: 169.254.17.11/0, ifidx: 12, pri: -1, proto: 2 Apr 20 11:12:11 Duser.info LWS_CLIENT[3039]: _lws_routing_entry_dump: src: 10.154.231.125/0, ifidx: 17, pri: -1, proto: 2 Apr 20 11:12:11 user.info LWS_CLIENT[3039]: _lws_routing_entry_dump: src: 127.0.0.1/0, ifidx: 1, pri: -1, proto: 2 Apr 20 11:12:11 user.info LWS_CLIENT[3039]: _lws_routing_entry_dump: src: 127.0.0.1/0, ifidx: 1, pri: -1, proto: 2 Apr 20 11:12:11 _sachin-ap user.info LWS_CLIENT[3039]: _lws_routing_entry_dump: src: 169.254.17.11/0, ifidx: 12, pri: -1, proto: 2 Apr 20 11:12:11 user.info LWS_CLIENT[3039]: _lws_routing_entry_dump: dst: (ipv6 unsupp)/128, ifidx: 1, pri: 0, proto: 0 Apr 20 11:12:11 user.info LWS_CLIENT[3039]: _lws_routing_entry_dump: src: 10.74.136.155/0, ifidx: 12, pri: -1, proto: 2 Apr 20 11:12:11 user.info LWS_CLIENT[3039]: _lws_routing_entry_dump: gw: 10.74.139.254, ifidx: 12, pri: -1, proto: 3 Apr 20 11:12:11 user.debug LWS_CLIENT[3039]: _lws_route_est_outgoing: dest af 2, rou gw af 0, pri -1 Apr 20 11:12:11 user.debug LWS_CLIENT[3039]: message repeated 5 times: [ _lws_route_est_outgoing: dest af 2, rou gw af 0, pri -1 ] Apr 20 11:12:11 user.debug LWS_CLIENT[3039]: _lws_route_est_outgoing: dest af 2, rou gw af 0, pri 0 Apr 20 11:12:11 user.debug LWS_CLIENT[3039]: _lws_route_est_outgoing: dest af 2, rou gw af 0, pri -1 Apr 20 11:12:11 user.debug LWS_CLIENT[3039]: _lws_route_est_outgoing: dest af 2, rou gw af 2, pri -1 Apr 20 11:12:11 user.info LWS_CLIENT[3039]: _lws_route_est_outgoing: gw hit Apr 20 11:12:11 user.info LWS_CLIENT[3039]: _lws_route_est_outgoing: returning 0x116c670 Apr 20 11:12:11 user.debug LWS_CLIENT[3039]: [wsicli|4|WS/h1/10.74.136.75]: _lws_route_check_wsi: source + dest OK Apr 20 11:12:11 user.info LWS_CLIENT[3039]: rops_handle_POLLIN_netlink: RTM 25 Apr 20 11:12:11 user.info LWS_CLIENT[3039]: rops_handle_POLLIN_netlink: DELROUTE Apr 20 11:12:11 user.info LWS_CLIENT[3039]: rops_handle_POLLIN_netlink: RTA_DST: 10.74.136.0 Apr 20 11:12:11 user.info LWS_CLIENT[3039]: rops_handle_POLLIN_netlink: RTA_SRC: 10.74.136.155 Apr 20 11:12:11 user.info LWS_CLIENT[3039]: rops_handle_POLLIN_netlink: ifidx 12 Apr 20 11:12:11 user.info LWS_CLIENT[3039]: rops_handle_POLLIN_netlink: DELROUTE: if_idx 12 Apr 20 11:12:11 user.debug LWS_CLIENT[3039]: _realloc: size 47: lws_smd_msg_alloc Apr 20 11:12:11 user.debug LWS_CLIENT[3039]: lws_cancel_service: Apr 20 11:12:11 user.info LWS_CLIENT[3039]: _lws_routing_table_dump: Apr 20 11:12:11 user.info LWS_CLIENT[3039]: _lws_routing_entry_dump: src: 10.154.231.125/0, ifidx: 17, pri: -1, proto: 2 Apr 20 11:12:11 user.info LWS_CLIENT[3039]: _lws_routing_entry_dump: src: 169.254.17.11/0, ifidx: 12, pri: -1, proto: 2 Apr 20 11:12:11 user.info LWS_CLIENT[3039]: _lws_routing_entry_dump: src: 10.154.231.125/0, ifidx: 17, pri: -1, proto: 2 Apr 20 11:12:11 user.info LWS_CLIENT[3039]: _lws_routing_entry_dump: src: 127.0.0.1/0, ifidx: 1, pri: -1, proto: 2 Apr 20 11:12:11 user.info LWS_CLIENT[3039]: _lws_routing_entry_dump: src: 127.0.0.1/0, ifidx: 1, pri: -1, proto: 2 Apr 20 11:12:11 user.info LWS_CLIENT[3039]: _lws_routing_entry_dump: src: 169.254.17.11/0, ifidx: 12, pri: -1, proto: 2 Apr 20 11:12:11 user.info LWS_CLIENT[3039]: _lws_routing_entry_dump: dst: (ipv6 unsupp)/128, ifidx: 1, pri: 0, proto: 0 Apr 20 11:12:11 user.info LWS_CLIENT[3039]: _lws_routing_entry_dump: src: 10.74.136.155/0, ifidx: 12, pri: -1, proto: 2 Apr 20 11:12:11 user.info LWS_CLIENT[3039]: _lws_routing_entry_dump: gw: 10.74.139.254, ifidx: 12, pri: -1, proto: 3 Apr 20 11:12:11 user.info LWS_CLIENT[3039]: _lws_smd_msg_deliver_peer: deliver cl 0x4, len 13, refc 1, to peer 0x115ca08 Apr 20 11:12:11 user.info LWS_CLIENT[3039]: _lws_smd_msg_destroy: destroy msg 0x116ddb8 Apr 20 11:12:11 user.err LWS_CLIENT[3039]: reason is LWS_CALLBACK_EVENT_WAIT_CANCELLED Apr 20 11:12:11 user.info LWS_CLIENT[3039]: rops_handle_POLLIN_netlink: RTM 25 Apr 20 11:12:11 user.info LWS_CLIENT[3039]: rops_handle_POLLINnetlink: DELROUTE 

I am getting DELADDR , Does DELADDR mean i can terminate the current connection, If so how do i get that context in that callback. because i think it is tied to lwsl_service_cancel which could be triggered with multiple other cases, right?

Thanks

lws-team commented 1 year ago

Make sure you're using main branch which has fixes for this.

lws uses netlink to try to understand if the route for an established connection has disappeared. If it sees that, it will close the connection automatically. You should then retry.

DELADDR itself just means it observed one interface lost its address, it doesn't mean that is relevant to a particular connection.

sachusachin622 commented 1 year ago

Hi Thanks for your replay, Is it possible to get commit id's which fixes this issue? I also found out we can disable netlink using this flag -DLWS_WITH_NETLINK=0 So does it mean that netlink is only way to find out if the ip address is changed for the established connection, reason why am asking is am not getting a specific callback after disabling the netlink.