From: Ondrej Zajicek Date: Tue, 29 Apr 2014 15:23:38 +0000 (+0200) Subject: Merge commit 'f48fa14214301382b2e6b134788a7506b61b664f' into integrated X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a485fd2909b947ee45810c71d8d7a6543f7e40e5;p=thirdparty%2Fbird.git Merge commit 'f48fa14214301382b2e6b134788a7506b61b664f' into integrated Conflicts: nest/rt-table.c proto/bgp/attrs.c proto/bgp/packets.c proto/ospf/ospf.c proto/rip/rip.c proto/static/static.c sysdep/unix/krt.c --- a485fd2909b947ee45810c71d8d7a6543f7e40e5 diff --cc nest/rt-table.c index c8d0c1f73,8c91ea0aa..66f6c3c62 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@@ -688,8 -688,7 +695,8 @@@ rte_recalculate(struct announce_hook *a #ifdef CONFIG_RIP /* lastmod is used internally by RIP as the last time when the route was received. */ - if ((src->proto == &proto_rip) || - (src->proto == &proto_ripng)) - if (src->proto->proto == &proto_rip) ++ if ((src->proto->proto == &proto_rip) || ++ (src->proto->proto == &proto_ripng)) old->lastmod = now; #endif return; @@@ -1240,44 -1243,12 +1251,47 @@@ rt_event(void *ptr rt_next_hop_update(tab); if (tab->gc_scheduled) - rt_prune_nets(tab); + { + rt_prune_nets(tab); + rt_prune_sources(); // FIXME this should be moved to independent event + } } +/** + * rt_addrsize - returns (host format) size of address of given type + * @addr_type: address type + * + * Returns sizeof() appropriate structure or sizeof(ip_addr) if + * address type is unknown + * + */ +int +rt_addrsize(int addr_type) +{ + switch (addr_type) + { +#ifdef MPLS_VPN + case RT_VPN4: + return sizeof(vpn4_addr); + case RT_VPN6: + return sizeof(vpn6_addr); +#endif + case RT_IPV4: + // XXXX + return sizeof(ip6_addr); + case RT_IPV6: + return sizeof(ip6_addr); + } + + return sizeof(ip_addr); +} + + +/** + * rt_setup - initialize routing table + * + * This function is called to set up rtable (hooks, lists, fib, ..) + */ void rt_setup(pool *p, rtable *t, char *name, struct rtable_config *cf) { @@@ -2140,12 -2075,10 +2153,13 @@@ rt_get_hostentry(rtable *tab, ip_addr a void rta_set_recursive_next_hop(rtable *dep, rta *a, rtable *tab, ip_addr *gw, ip_addr *ll) { + if (tab->addr_type != RT_IP) + return; + - rta_apply_hostentry(a, rt_find_hostentry(tab, *gw, *ll, dep)); + rta_apply_hostentry(a, rt_get_hostentry(tab, *gw, *ll, dep)); } + /* * CLI commands */ @@@ -2192,11 -2128,11 +2209,11 @@@ rt_show_rte(struct cli *c, byte *prefix ea_merge(t, tmpa); ea_sort(tmpa); } - if (a->proto->proto->get_route_info) - a->proto->proto->get_route_info(e, info, tmpa); + if (get_route_info) + get_route_info(e, info, tmpa); else bsprintf(info, " (%d)", e->pref); - cli_printf(c, -1007, "%-18s %s [%s %s%s]%s%s", prefix, via, a->proto->name, - cli_printf(c, -1007, "%-18s %s [%s %s%s]%s%s", ia, via, a->src->proto->name, ++ cli_printf(c, -1007, "%-18s %s [%s %s%s]%s%s", prefix, via, a->src->proto->name, tm, from, primary ? (sync_error ? " !" : " *") : "", info); for (nh = a->nexthops; nh; nh = nh->next) cli_printf(c, -1007, "\tvia %I on %s weight %d", nh->gw, nh->iface->name, nh->weight + 1); diff --cc proto/bgp/packets.c index a70c24a6c,420643327..94f95e2a5 --- a/proto/bgp/packets.c +++ b/proto/bgp/packets.c @@@ -229,10 -247,17 +247,17 @@@ bgp_encode_prefixes(struct bgp_proto *p while (!EMPTY_LIST(buck->prefixes) && remains >= (1+sizeof(ip_addr))) { struct bgp_prefix *px = SKIP_BACK(struct bgp_prefix, bucket_node, HEAD(buck->prefixes)); - DBG("\tDequeued route %I/%d\n", px->n.prefix, px->n.pxlen); + DBG("\tDequeued route %F\n", &px->n); + + if (p->add_path_tx) + { + put_u32(w, px->path_id); + w += 4; + } + *w++ = px->n.pxlen; bytes = (px->n.pxlen + 7) / 8; - a = px->n.prefix; + a = *FPREFIX_IP(&px->n); ipa_hton(a); memcpy(w, &a, bytes); w += bytes; @@@ -249,9 -275,10 +275,10 @@@ bgp_flush_prefixes(struct bgp_proto *p while (!EMPTY_LIST(buck->prefixes)) { struct bgp_prefix *px = SKIP_BACK(struct bgp_prefix, bucket_node, HEAD(buck->prefixes)); - log(L_ERR "%s: - route %I/%d skipped", p->p.name, px->n.prefix, px->n.pxlen); + log(L_ERR "%s: - route %F skipped", p->p.name, &px->n); rem_node(&px->bucket_node); - fib_delete(&p->prefix_fib, px); + bgp_free_prefix(p, px); + // fib_delete(&p->prefix_fib, px); } } diff --cc proto/ospf/ospf.c index 43e248051,232f3f6c4..ad027403c --- a/proto/ospf/ospf.c +++ b/proto/ospf/ospf.c @@@ -297,17 -298,16 +297,17 @@@ ospf_dump(struct proto *p static struct proto * ospf_init(struct proto_config *c) { + struct ospf_config *oc = (struct ospf_config *) c; struct proto *p = proto_new(c, sizeof(struct proto_ospf)); - p->make_tmp_attrs = ospf_make_tmp_attrs; - p->store_tmp_attrs = ospf_store_tmp_attrs; - p->import_control = ospf_import_control; - p->reload_routes = ospf_reload_routes; p->accept_ra_types = RA_OPTIMAL; p->rt_notify = ospf_rt_notify; p->if_notify = ospf_if_notify; - p->ifa_notify = ospf_ifa_notify; + p->ifa_notify = oc->ospf2 ? ospf_ifa_notify2 : ospf_ifa_notify3; + p->import_control = ospf_import_control; + p->reload_routes = ospf_reload_routes; + p->make_tmp_attrs = ospf_make_tmp_attrs; + p->store_tmp_attrs = ospf_store_tmp_attrs; p->rte_better = ospf_rte_better; p->rte_same = ospf_rte_same; diff --cc proto/ospf/rt.c index 51fbf66c1,52110aa17..b8f41f8d0 --- a/proto/ospf/rt.c +++ b/proto/ospf/rt.c @@@ -1917,11 -2042,11 +1917,11 @@@ again1 nf->old_rta = NULL; net *ne = net_get(p->table, nf->fn.prefix, nf->fn.pxlen); - rte_update(p->table, ne, p, p, NULL); + rte_update(p, ne, NULL); } - /* Remove unused rt entry. Entries with fn.x0 == 1 are persistent. */ - if (!nf->n.type && !nf->fn.x0 && !nf->fn.x1) + /* Remove unused rt entry. Entries with any flags are persistent. */ + if (!nf->n.type && !nf->fn.flags) { FIB_ITERATE_PUT(&fit, nftmp); fib_delete(fib, nftmp); diff --cc proto/rip/rip.c index 125a193e6,5cc40403f..bc93dc7e6 --- a/proto/rip/rip.c +++ b/proto/rip/rip.c @@@ -356,28 -325,9 +358,28 @@@ process_block( struct proto *p, struct return; } - A.iface = neighbor->iface; - if (!(rif = neighbor->data)) { - rif = neighbor->data = find_interface(p, A.iface); + + TRACE(D_PACKETS, "Received %I/%d metric %d from %I", + prefix, pxlen, metric, from); + + rta A = { - .proto = p, ++ .src= p->main_source, + .source = RTS_RIP, + .scope = SCOPE_UNIVERSE, + .cast = RTC_UNICAST, + .dest = RTD_ROUTER, + .gw = gw, + .from = from, + .iface = neigh->iface + }; + + if (rip_is_old(p)) pxlen += 96; // XXXX: Hack + net *n = net_get(p->table, prefix, pxlen); + rta *a = rta_lookup(&A); + rte *r = rte_get_temp(a); + + if (!(rif = neigh->data)) { + rif = neigh->data = find_interface(p, A.iface); } if (!rif) bug("Route packet using unknown interface? No."); diff --cc proto/static/static.c index f1359b003,9b115acd2..d84cbb89d --- a/proto/static/static.c +++ b/proto/static/static.c @@@ -62,16 -66,14 +62,16 @@@ static_install(struct proto *p, struct return; DBG("Installing static route %I/%d, rtd=%d\n", r->net, r->masklen, r->dest); - bzero(&a, sizeof(a)); - a.src = p->main_source; - a.source = (r->dest == RTD_DEVICE) ? RTS_STATIC_DEVICE : RTS_STATIC; - a.scope = SCOPE_UNIVERSE; - a.cast = RTC_UNICAST; - a.dest = r->dest; - a.gw = r->via; - a.iface = ifa; + + rta a = { - .proto = p, ++ .src = p->main_source; + .source = (r->dest == RTD_DEVICE) ? RTS_STATIC_DEVICE : RTS_STATIC, + .scope = SCOPE_UNIVERSE, + .cast = RTC_UNICAST, + .dest = r->dest, + .gw = r->via, + .iface = ifa + }; if (r->dest == RTD_MULTIPATH) { @@@ -106,13 -108,12 +106,13 @@@ if (r->dest == RTDX_RECURSIVE) rta_set_recursive_next_hop(p->table, &a, p_igp_table(p), &r->via, &r->via); - aa = rta_lookup(&a); - n = net_get(p->table, r->net, r->masklen); - e = rte_get_temp(aa); + // int pxlen = r->masklen + (ipa_is_ip4(r->net) ? 96 : 0); // XXXX: Hack + net *n = net_get(p->table, r->net, r->masklen); + rta *aa = rta_lookup(&a); + rte *e = rte_get_temp(aa); e->net = n; e->pflags = 0; - rte_update(p->table, n, p, p, e); + rte_update(p, n, e); r->installed = 1; } @@@ -123,11 -126,8 +123,10 @@@ static_remove(struct proto *p, struct s return; DBG("Removing static route %I/%d\n", r->net, r->masklen); - n = net_find(p->table, r->net, r->masklen); + + // int pxlen = r->masklen + (ipa_is_ip4(r->net) ? 96 : 0); // XXXX: Hack + net *n = net_find(p->table, r->net, r->masklen); - if (n) - rte_update(p->table, n, p, p, NULL); + rte_update(p, n, NULL); r->installed = 0; } diff --cc sysdep/linux/netlink.c index 0f458b2c8,ed8769b70..17cf0291b --- a/sysdep/linux/netlink.c +++ b/sysdep/linux/netlink.c @@@ -834,11 -802,10 +834,11 @@@ nl_parse_route(struct nlmsghdr *h, int src = KRT_SRC_ALIEN; } - net *net = net_get(p->p.table, dst, i->rtm_dst_len); + int pxlen = i->rtm_dst_len + (ipv4 ? 96 : 0); // XXXX: Hack + net *net = net_get(p->p.table, dst, pxlen); rta ra = { - .proto = &p->p, + .src= p->p.main_source, .source = RTS_INHERIT, .scope = SCOPE_UNIVERSE, .cast = RTC_UNICAST diff --cc sysdep/unix/krt.c index 40827898d,6fdef6199..d64e14f26 --- a/sysdep/unix/krt.c +++ b/sysdep/unix/krt.c @@@ -357,9 -357,8 +357,8 @@@ krt_learn_announce_update(struct krt_pr static void krt_learn_announce_delete(struct krt_proto *p, net *n) { - n = net_find(p->p.table, n->n.prefix, n->n.pxlen); + n = fib_find(&p->p.table->fib, FPREFIX(&n->n), n->n.pxlen); - if (n) - rte_update(p->p.table, n, &p->p, &p->p, NULL); + rte_update(&p->p, n, NULL); } /* Called when alien route is discovered during scan */