libpcp / pcp

PCP client library
BSD 2-Clause "Simplified" License
69 stars 30 forks source link

looping in state pss_allocated #5

Closed miniupnp closed 10 years ago

miniupnp commented 10 years ago

If I run pcp_app/pcp -i :12345 it loops forever and output the following :

  1s 280ms 407us DEBUG  : FILE: src/pcp_event_handler.c:1183; Func: run_server_state_machine: END 

  1s 280ms 420us DEBUG  : FILE: src/pcp_event_handler.c:1158; Func: run_server_state_machine: BEGIN 

  1s 280ms 433us DEBUG  : FILE: src/pcp_event_handler.c:1172; Func: run_server_state_machine:
     Executing server state handler log_unexepected_state_event
    server      : fe80::f6ca:e5ff:fe45:5e1a (index 1)
    state       : pss_allocated
    event       : pcpe_timeout
  1s 280ms 457us ERROR  : FILE: src/pcp_event_handler.c:1105; Func: log_unexepected_state_event:
     Event happened in the state 1 on PCP server fe80::f6ca:e5ff:fe45:5e1a and there is no event handler defined.
  1s 280ms 471us DEBUG  : FILE: src/pcp_event_handler.c:1178; Func: run_server_state_machine:
     Return from server state handler's log_unexepected_state_event 
    result state: pss_allocated
miniupnp commented 10 years ago

I have theses logs before :

  0s 000ms 269us DEBUG  : FILE: src/pcp_client_db.c:348; Func: get_pcp_server: BEGIN 

  0s 000ms 287us DEBUG  : FILE: src/pcp_client_db.c:368; Func: get_pcp_server: END 

  0s 000ms 294us DEBUG  : FILE: src/pcp_server_discovery.c:60; Func: psd_fill_pcp_server_src: BEGIN 

  0s 000ms 311us WARNING: FILE: src/pcp_server_discovery.c:118; Func: psd_fill_pcp_server_src:
     Error (failed to connect to peer for src addr selection.) occurred while registering a new PCP server fe80::f6ca:e5ff:fe45:5e1a
  0s 000ms 323us DEBUG  : FILE: src/pcp_server_discovery.c:120; Func: psd_fill_pcp_server_src: END 

  0s 000ms 330us ERROR  : FILE: src/pcp_server_discovery.c:164; Func: psd_add_gws:
     Failed to initialize gateway fe80::f6ca:e5ff:fe45:5e1a as a PCP server.
  0s 000ms 337us DEBUG  : FILE: src/pcp_api.c:132; Func: pcp_init: END 
libpcp commented 10 years ago

I can see you have link local IPv6 address of gateway, and it seems to be an issue here. Because the code doesn't set scope_id. Try to disable autodiscovery with -d option and set pcp server manually, like this: pcp_app/pcp -d -s 10.0.0.1:5351 -i :12345 If you want to use IPv6 address you have to avoid use of link local addresses, the code doesn't work with them, yet.

miniupnp commented 10 years ago

when it fails to find the IPv6 address, the "server" should not be left in a state which is not handled properly by run_server_state_machine(). Or the server state machine should be improved to do something more intelligent than loop forever taking 100% of CPU time.

The stuff about link local IPv6 addresses is independent. It is always possible that an error occurs, it must be handled properly.

in psd_add_gws() I see that no action is taken if psd_fill_pcp_server_src() returns error, apart from outputing error log. Shouldn't it do s->state = pss_error; or something like that ?

libpcp commented 10 years ago

Commnit b4c09de should fix this. If you could give it a try.

miniupnp commented 10 years ago

it works