/** * process the kernel change list. * the routes are already ordered such that nexthop routes * are on the head of the queue. * non-nexthop routes need to be changed first and therefore * the queue needs to be traversed from tail to head. */ static void olsr_chg_kernel_routes(struct list_node *head_node) { struct rt_entry *rt; if (list_is_empty(head_node)) { return; } /* * Traverse from the beginning to the end of the list, * such that nexthop routes are added first. */ while (!list_is_empty(head_node)) { rt = changelist2rt(head_node->next); /*deleting routes should not be required anymore as we use (NLM_F_CREATE | NLM_F_REPLACE) in linux rtnetlink*/ #ifdef LINUX_NETLINK_ROUTING /*delete routes with ipv6 only as it still doesn`t support NLM_F_REPLACE*/ if (((olsr_cnf->ip_version != AF_INET ) || (olsr_addroute_function != olsr_ioctl_add_route) || (olsr_addroute6_function != olsr_ioctl_add_route6) || (olsr_delroute_function != olsr_ioctl_del_route) || (olsr_delroute6_function != olsr_ioctl_del_route6)) && (rt->rt_nexthop.iif_index > -1)) { olsr_delete_kernel_route(rt); } #else /*no rtnetlink we have to delete routes*/ if (rt->rt_nexthop.iif_index > -1) olsr_delete_kernel_route(rt); #endif /*LINUX_NETLINK_ROUTING*/ olsr_add_kernel_route(rt); list_remove(&rt->rt_change_node); } }
/** * process the kernel change list. * the routes are already ordered such that nexthop routes * are on the head of the queue. * non-nexthop routes need to be changed first and therefore * the queue needs to be traversed from tail to head. */ static void olsr_chg_kernel_routes(struct list_node *head_node) { struct rt_entry *rt; if (list_is_empty(head_node)) { return; } /* * Traverse from the beginning to the end of the list, * such that nexthop routes are added first. */ while (!list_is_empty(head_node)) { rt = changelist2rt(head_node->next); #ifdef linux /* * actively deleting routes is not necessary as we use (NLM_F_CREATE | NLM_F_REPLACE) with linux * (i.e. new routes simply overwrite the old ones in kernel) * BUT: We still have to actively delete routes if fib_metric != FLAT or we run on ipv6. * As NLM_F_REPLACE is not supported with IPv6, or simply of no use with varying route metrics. * We also actively delete routes if custom route functions are in place. (e.g. quagga plugin) */ if (((olsr_cnf->ip_version != AF_INET ) || (olsr_cnf->fib_metric != FIBM_FLAT) || (olsr_addroute_function != olsr_ioctl_add_route) || (olsr_addroute6_function != olsr_ioctl_add_route6) || (olsr_delroute_function != olsr_ioctl_del_route) || (olsr_delroute6_function != olsr_ioctl_del_route6)) && (rt->rt_nexthop.iif_index > -1)) { olsr_delete_kernel_route(rt); } #else /*no rtnetlink we have to delete routes*/ if (rt->rt_nexthop.iif_index > -1) olsr_delete_kernel_route(rt); #endif /* linux */ olsr_add_kernel_route(rt); list_remove(&rt->rt_change_node); } }