void pma_bcache::deregister_callback(in_addr_t hoa, in_addr_t ha, in_addr_t coa) { char const *ifname = miface_[hoa].c_str(); int &tab = tunnel_tab_[ha]; unregister_source_route(hoa, tab, ifname); if (mif_refcnt_[ifname] == 0 || --mif_refcnt_[ifname] == 0) { set_proxy_arp(ifname, 0); unregister_route_to_tunnel(ha, tab); free_rtable(tab); } if (ha_refcnt_[ha] == 0 || --ha_refcnt_[ha] == 0) release_tunnel(ha); /* unregister from PMA: ARP are sent to HOME CN to update MN's MAC */ send_grat_arp(ifname, &hoa, 1); }
void netlink_link_down(struct rproto *netlink, struct link *link) { /* Must find all routes, that depend on this link.. and call unlearn */ struct route *r, *q; struct rtable *tmp; tmp = new_rtable(); for (r=main_rtable->routes; r ; r=r->next) { if (r->source_link != link) continue; if (r->flags & RF_UNREACH) continue; q = dup_route(r); q->flags |= RF_UNREACH; q->garbage = time(NULL) + 120; add_route(tmp, q); } if(tmp->num_routes != 0) unlearn_routes(&system_proto, tmp); free_rtable(tmp); }
void netlink_link_up(struct rproto *netlink, struct link *link) { struct rtable *tmp; struct route *route; if(!(link->flags & LF_UP)) return; if(!(link->flags & LF_ANNOUNCETHIS)) return; if((route = malloc(sizeof(struct route))) == NULL) { error("Insufficient memory allocating route"); return; } tmp = new_rtable(); if(link->flags & LF_POINTOPOINT) { route->dst = link->broadcast & link->netmask; }else{ route->dst = link->address & link->netmask; } route->dstmask = link->netmask; route->nexthop = 0; // Через нас route->metric = link->cost; route->type = RT_DYNAMIC; route->flags = 0; route->source = 0; route->source_link = link; route->domain = 0; route->expire = 0; route->garbage = 0; route->timerset = 0; strncpy(route->iface,link->iface,sizeof(route->iface)); add_route(tmp, route); learn_routes(&system_proto, tmp); free_rtable(tmp); }