dankamongmen / libnetstack

Small library around rtnetlink to track networking stack elements
https://nick-black.com/dankwiki/index.php/Libnetstack
Apache License 2.0
10 stars 0 forks source link

NETSTACK_INITIAL_EVENTS_BLOCK only waits on transmits, not receives #49

Closed dankamongmen closed 1 year ago

dankamongmen commented 1 year ago

NETSTACK_INITIAL_EVENTS_BLOCK is documented as waiting until all initial messages have received replies. From experience using libnetstack, and furthermore from looking at the relevant code, it seems only to block until all messages have been sent, not necessarily replied to. From netstack_init():

  if(ns->opts.initial_events == NETSTACK_INITIAL_EVENTS_BLOCK){                                                                     
    pthread_mutex_lock(&ns->txlock);                                                                                                
    while(ns->txqueue[ns->dequeueidx] != -1){                                                                                       
      pthread_cond_wait(&ns->txcond, &ns->txlock);                                                                                  
    }                                                                                                                               
    pthread_mutex_unlock(&ns->txlock);                                                                                              
  }       

wait on all replies. this will require some fairly extensive plumbing.

dankamongmen commented 1 year ago

actually, unless i'm missing something, this was easier than expected: we just needed to check clear_to_send in the condwait loop.

dankamongmen commented 1 year ago

yeah, this looks to have fixed our Garuda problem. marking done!