Fix segfault in "lost interface" monitor if interface goes down which is no OLSR interface OLSRD_0_5_6_BRANCH
authorHenning Rogge <hrogge@googlemail.com>
Fri Oct 16 17:18:44 2009 +0200 (10 months ago)
branchOLSRD_0_5_6_BRANCH
changeset 1881438bd63a1ab8
parent 188043ec4870a4ef
child 18825c90efefc766
Fix segfault in "lost interface" monitor if interface goes down which is no OLSR interface
src/linux/kernel_routes.c
     1.1 --- a/src/linux/kernel_routes.c	Sat Oct 10 23:13:22 2009 +0200
     1.2 +++ b/src/linux/kernel_routes.c	Fri Oct 16 17:18:44 2009 +0200
     1.3 @@ -101,7 +101,13 @@ int rtnetlink_register_socket(int rtnl_m
     1.4  static void netlink_process_link(struct nlmsghdr *h)
     1.5  {
     1.6    struct ifinfomsg *ifi = (struct ifinfomsg *) NLMSG_DATA(h);
     1.7 -  struct interface *iface = if_ifwithindex(ifi->ifi_index);
     1.8 +  struct interface *iface;
     1.9 +  struct olsr_if *tmp_if;
    1.10 +
    1.11 +  iface = if_ifwithindex(ifi->ifi_index);
    1.12 +  if (iface == NULL) {
    1.13 +    return;
    1.14 +  }
    1.15    
    1.16    //all IFF flags: LOOPBACK,BROADCAST;POINTOPOINT;MULTICAST;NOARP;ALLMULTI;PROMISC;MASTER;SLAVE;DEBUG;DYNAMIC;AUTOMEDIA;PORTSEL;NOTRAILERS;UP;LOWER_UP;DORMANT
    1.17    /* check if interface is up and running? (a not running interface keeps its routes, so better not react like on ifdown!!??) */
    1.18 @@ -113,14 +119,11 @@ static void netlink_process_link(struct 
    1.19    }
    1.20  
    1.21    //only for still configured interfaces (ifup has to be detected with regular interface polling)
    1.22 -  if ( iface != NULL ) {
    1.23 -    struct olsr_if *tmp_if;
    1.24 -    for (tmp_if = olsr_cnf->interfaces; tmp_if != NULL; tmp_if = tmp_if->next) {
    1.25 -      if (tmp_if->interf==iface) {
    1.26 -        OLSR_PRINTF(1,"-> removing %s from olsr config! ", iface->int_name);
    1.27 -        RemoveInterface(tmp_if,true);
    1.28 -        break;
    1.29 -      }
    1.30 +  for (tmp_if = olsr_cnf->interfaces; tmp_if != NULL; tmp_if = tmp_if->next) {
    1.31 +    if (tmp_if->interf==iface) {
    1.32 +      OLSR_PRINTF(1,"-> removing %s from olsr config! ", iface->int_name);
    1.33 +      RemoveInterface(tmp_if,true);
    1.34 +      break;
    1.35      }
    1.36    }
    1.37  }