? bgpd/rserver-todo.txt ? doc/docs-html Index: bgpd/bgp_attr.c =================================================================== RCS file: /var/cvsroot/quagga/bgpd/bgp_attr.c,v retrieving revision 1.1.1.1 diff -u -w -b -r1.1.1.1 bgp_attr.c --- bgpd/bgp_attr.c 13 Dec 2002 20:15:29 -0000 1.1.1.1 +++ bgpd/bgp_attr.c 7 Oct 2003 12:03:41 -0000 @@ -1363,7 +1363,8 @@ && (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED) || attr->aspath->length == 0) && ! (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) - && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))) + && CHECK_FLAG (peer->af_flags[afi][safi], + PEER_FLAG_RSERVER_CLIENT))) { aspath = aspath_dup (attr->aspath); @@ -1468,7 +1469,9 @@ { if (attr->community->size * 4 > 255) { - stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_EXTLEN); + stream_putc (s, + BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS | + BGP_ATTR_FLAG_EXTLEN); stream_putc (s, BGP_ATTR_COMMUNITIES); stream_putw (s, attr->community->size * 4); } @@ -1483,8 +1486,7 @@ /* Route Reflector. */ if (peer_sort (peer) == BGP_PEER_IBGP - && from - && peer_sort (from) == BGP_PEER_IBGP) + && from && peer_sort (from) == BGP_PEER_IBGP) { /* Originator ID. */ stream_putc (s, BGP_ATTR_FLAG_OPTIONAL); @@ -1526,6 +1528,22 @@ } } + /* Route-server ADVERTISER attr */ + if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) + && peer_sort (peer) == BGP_PEER_EBGP + && from && peer_sort (from) == BGP_PEER_EBGP) + { + stream_putc (s, BGP_ATTR_FLAG_OPTIONAL); + stream_putc (s, BGP_ATTR_ADVERTISER); + if (&from->remote_id) + stream_put_in_addr (s, &from->remote_id); + else if (&from->su) + stream_put_in_addr (s, &from->su.sin.sin_addr); + else + /* last resort - use origin id */ + stream_put_in_addr (s, &attr->originator_id); + } + #ifdef HAVE_IPV6 /* If p is IPv6 address put it into attribute. */ if (p->family == AF_INET6) @@ -1655,7 +1673,9 @@ { if (attr->ecommunity->size * 8 > 255) { - stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_EXTLEN); + stream_putc (s, + BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS | + BGP_ATTR_FLAG_EXTLEN); stream_putc (s, BGP_ATTR_EXT_COMMUNITIES); stream_putw (s, attr->ecommunity->size * 8); } Index: bgpd/bgp_damp.c =================================================================== RCS file: /var/cvsroot/quagga/bgpd/bgp_damp.c,v retrieving revision 1.1.1.1 diff -u -w -b -r1.1.1.1 bgp_damp.c --- bgpd/bgp_damp.c 13 Dec 2002 20:15:29 -0000 1.1.1.1 +++ bgpd/bgp_damp.c 7 Oct 2003 12:03:42 -0000 @@ -113,7 +113,6 @@ struct bgp_damp_info *next; time_t t_now, t_diff; struct bgp *bgp; - int bgp_process (struct bgp *, struct bgp_node *, afi_t, safi_t); damp->t_reuse = NULL; damp->t_reuse = @@ -160,7 +159,7 @@ UNSET_FLAG (bdi->binfo->flags, BGP_INFO_HISTORY); bgp_aggregate_increment (bgp, &bdi->rn->p, bdi->binfo, bdi->afi, bdi->safi); - bgp_process (bgp, bdi->rn, bdi->afi, bdi->safi); + bgp_process (bgp, bdi->rn, bdi->binfo, bdi->afi, bdi->safi); } if (bdi->penalty <= damp->reuse_limit / 2.0) Index: bgpd/bgp_nexthop.c =================================================================== RCS file: /var/cvsroot/quagga/bgpd/bgp_nexthop.c,v retrieving revision 1.4 diff -u -w -b -r1.4 bgp_nexthop.c --- bgpd/bgp_nexthop.c 29 Sep 2003 19:54:53 -0000 1.4 +++ bgpd/bgp_nexthop.c 7 Oct 2003 12:03:42 -0000 @@ -75,9 +75,6 @@ /* BGP nexthop lookup query client. */ static struct zclient *zlookup = NULL; -/* BGP process function. */ -int bgp_process (struct bgp *, struct bgp_node *, afi_t, safi_t); - /* Add nexthop to the end of the list. */ void bnc_nexthop_add (struct bgp_nexthop_cache *bnc, struct nexthop *nexthop) @@ -504,7 +501,7 @@ AFI_IP, SAFI_UNICAST); } } - bgp_process (bgp, rn, AFI_IP, SAFI_UNICAST); + bgp_process (bgp, rn, bi, AFI_IP, SAFI_UNICAST); } /* Flash old cache. */ @@ -601,7 +598,7 @@ AFI_IP6, SAFI_UNICAST); } } - bgp_process (bgp, rn, AFI_IP6, SAFI_UNICAST); + bgp_process (bgp, rn, bi, AFI_IP6, SAFI_UNICAST); } /* Flash old cache. */ Index: bgpd/bgp_route.c =================================================================== RCS file: /var/cvsroot/quagga/bgpd/bgp_route.c,v retrieving revision 1.6 diff -u -w -b -r1.6 bgp_route.c --- bgpd/bgp_route.c 27 Aug 2003 12:25:49 -0000 1.6 +++ bgpd/bgp_route.c 7 Oct 2003 12:03:50 -0000 @@ -526,7 +526,8 @@ /* ORF prefix-list filter check */ if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) - || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) + || CHECK_FLAG (peer->af_cap[afi][safi], + PEER_CAP_ORF_PREFIX_SM_OLD_RCV))) if (peer->orf_plist[afi][safi]) { if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY) @@ -565,8 +566,7 @@ if (BGP_DEBUG (filter, FILTER)) zlog (peer->log, LOG_INFO, "%s [Update:SEND] suppress announcement to peer AS %d is AS path.", - peer->host, - bgp->confed_id); + peer->host, bgp->confed_id); return 0; } } @@ -588,14 +588,16 @@ is already done. So there is noting to do. */ /* no bgp client-to-client reflection check. */ if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) - if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) + if (CHECK_FLAG + (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) return 0; } else { /* A route from a Non-client peer. Reflect to all other clients. */ - if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) + if (!CHECK_FLAG + (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) return 0; } } @@ -644,7 +646,8 @@ if (p->family == AF_INET) { if (safi == SAFI_MPLS_VPN) - memcpy (&attr->mp_nexthop_global_in, &peer->nexthop.v4, IPV4_MAX_BYTELEN); + memcpy (&attr->mp_nexthop_global_in, &peer->nexthop.v4, + IPV4_MAX_BYTELEN); else memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN); } @@ -693,8 +696,7 @@ attr->aspath = aspath_empty_get (); /* Route map & unsuppress-map apply. */ - if (ROUTE_MAP_OUT_NAME (filter) - || ri->suppress) + if (ROUTE_MAP_OUT_NAME (filter) || ri->suppress) { info.peer = peer; info.attr = attr; @@ -726,8 +728,10 @@ return 1; } + int -bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) +bgp_process (struct bgp *bgp, struct bgp_node *rn, struct bgp_info *binfo, + afi_t afi, safi_t safi) { struct prefix *p; struct bgp_info *ri; @@ -835,9 +839,19 @@ if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) continue; - /* Announcement to peer->conf. If the route is filtered, - withdraw it. */ - if (new_select + /* Announcement to peer->conf of best route. If the route is filtered, + * withdraw it. Route-server-clients get update of original route + * regardless. + */ + if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) + { + if (binfo + && bgp_announce_check (binfo, peer, p, &attr, afi, safi)) + bgp_adj_out_set (rn, peer, p, &attr, afi, safi, binfo); + else + bgp_adj_out_unset (rn, peer, p, afi, safi); + } + else if (new_select && bgp_announce_check (new_select, peer, p, &attr, afi, safi)) bgp_adj_out_set (rn, peer, p, &attr, afi, safi, new_select); else @@ -909,7 +923,7 @@ peer->pcount[afi][safi]--; bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi); UNSET_FLAG (ri->flags, BGP_INFO_VALID); - bgp_process (peer->bgp, rn, afi, safi); + bgp_process (peer->bgp, rn, ri, afi, safi); } bgp_info_delete (rn, ri); bgp_info_free (ri); @@ -941,7 +955,7 @@ valid = CHECK_FLAG (ri->flags, BGP_INFO_VALID); UNSET_FLAG (ri->flags, BGP_INFO_VALID); - bgp_process (peer->bgp, rn, afi, safi); + bgp_process (peer->bgp, rn, ri, afi, safi); if (valid) SET_FLAG (ri->flags, BGP_INFO_VALID); @@ -990,7 +1004,8 @@ if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) aspath_loop_count = 1; - if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count) + if (aspath_loop_check (attr->aspath, peer->change_local_as) > + aspath_loop_count) { reason = "as-path contains our own AS;"; goto filtered; @@ -1089,7 +1104,7 @@ if (ret != BGP_DAMP_SUPPRESSED) { bgp_aggregate_increment (bgp, p, ri, afi, safi); - bgp_process (bgp, rn, afi, safi); + bgp_process (bgp, rn, ri, afi, safi); } } else @@ -1170,7 +1185,7 @@ /* Process change. */ bgp_aggregate_increment (bgp, p, ri, afi, safi); - bgp_process (bgp, rn, afi, safi); + bgp_process (bgp, rn, ri, afi, safi); bgp_unlock_node (rn); return 0; } @@ -1227,7 +1242,7 @@ return -1; /* Process change. */ - bgp_process (bgp, rn, afi, safi); + bgp_process (bgp, rn, new, afi, safi); return 0; @@ -1249,6 +1264,7 @@ return 0; } + int bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr, int afi, int safi, int type, int sub_type, struct prefix_rd *prd, @@ -1389,7 +1405,9 @@ for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn)) for (ri = rn->info; ri; ri = ri->next) - if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer) + if ( (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) + || CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) + && ri->peer != peer) { if (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi)) bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri); @@ -1856,7 +1874,7 @@ /* Process change. */ bgp_aggregate_increment (bgp, p, ri, afi, safi); - bgp_process (bgp, rn, afi, safi); + bgp_process (bgp, rn, ri, afi, safi); bgp_unlock_node (rn); aspath_unintern (attr.aspath); return; @@ -1879,7 +1897,7 @@ bgp_info_add (rn, new); /* Process change. */ - bgp_process (bgp, rn, afi, safi); + bgp_process (bgp, rn, new, afi, safi); /* Unintern original. */ aspath_unintern (attr.aspath); @@ -1911,7 +1929,7 @@ bgp_info_add (rn, (struct bgp_info *) new); /* Process change. */ - bgp_process (bgp, rn, afi, safi); + bgp_process (bgp, rn, new, afi, safi); } void @@ -1935,7 +1953,7 @@ { bgp_aggregate_decrement (bgp, p, ri, afi, safi); UNSET_FLAG (ri->flags, BGP_INFO_VALID); - bgp_process (bgp, rn, afi, safi); + bgp_process (bgp, rn, ri, afi, safi); bgp_info_delete (rn, ri); bgp_info_free (ri); bgp_unlock_node (rn); @@ -1966,7 +1984,7 @@ { bgp_aggregate_decrement (bgp, p, ri, afi, safi); UNSET_FLAG (ri->flags, BGP_INFO_VALID); - bgp_process (bgp, rn, afi, safi); + bgp_process (bgp, rn, ri, afi, safi); bgp_info_delete (rn, ri); bgp_info_free (ri); bgp_unlock_node (rn); @@ -2786,7 +2804,7 @@ } } if (match) - bgp_process (bgp, rn, afi, safi); + bgp_process (bgp, rn, ri, afi, safi); } bgp_unlock_node (top); @@ -2838,7 +2856,7 @@ new->uptime = time (NULL); bgp_info_add (rn, new); - bgp_process (bgp, rn, afi, safi); + bgp_process (bgp, rn, ri, afi, safi); } else { @@ -2990,7 +3008,7 @@ /* If this node is suppressed, process the change. */ if (match) - bgp_process (bgp, rn, afi, safi); + bgp_process (bgp, rn, NULL, afi, safi); } bgp_unlock_node (top); @@ -3010,7 +3028,7 @@ bgp_info_add (rn, new); /* Process change. */ - bgp_process (bgp, rn, afi, safi); + bgp_process (bgp, rn, NULL, afi, safi); } } @@ -3061,7 +3079,7 @@ /* If this node is suppressed, process the change. */ if (match) - bgp_process (bgp, rn, afi, safi); + bgp_process (bgp, rn, NULL, afi, safi); } bgp_unlock_node (top); @@ -3078,7 +3096,7 @@ if (ri) { UNSET_FLAG (ri->flags, BGP_INFO_VALID); - bgp_process (bgp, rn, afi, safi); + bgp_process (bgp, rn, NULL, afi, safi); bgp_info_delete (rn, ri); bgp_info_free (ri); bgp_unlock_node (rn); @@ -3608,7 +3626,7 @@ /* Process change. */ bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST); - bgp_process (bgp, bn, afi, SAFI_UNICAST); + bgp_process (bgp, bn, NULL, afi, SAFI_UNICAST); bgp_unlock_node (bn); aspath_unintern (attr.aspath); return; @@ -3625,7 +3643,7 @@ bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST); bgp_info_add (bn, new); - bgp_process (bgp, bn, afi, SAFI_UNICAST); + bgp_process (bgp, bn, NULL, afi, SAFI_UNICAST); } } @@ -3659,7 +3677,7 @@ { bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST); UNSET_FLAG (ri->flags, BGP_INFO_VALID); - bgp_process (bgp, rn, afi, SAFI_UNICAST); + bgp_process (bgp, rn, NULL, afi, SAFI_UNICAST); bgp_info_delete (rn, ri); bgp_info_free (ri); bgp_unlock_node (rn); @@ -3690,7 +3708,7 @@ { bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST); UNSET_FLAG (ri->flags, BGP_INFO_VALID); - bgp_process (bgp, rn, afi, SAFI_UNICAST); + bgp_process (bgp, rn, NULL, afi, SAFI_UNICAST); bgp_info_delete (rn, ri); bgp_info_free (ri); bgp_unlock_node (rn); Index: bgpd/bgp_route.h =================================================================== RCS file: /var/cvsroot/quagga/bgpd/bgp_route.h,v retrieving revision 1.1.1.1 diff -u -w -b -r1.1.1.1 bgp_route.h --- bgpd/bgp_route.h 13 Dec 2002 20:15:29 -0000 1.1.1.1 +++ bgpd/bgp_route.h 7 Oct 2003 12:03:50 -0000 @@ -18,12 +18,20 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#ifndef _ZEBRA_BGP_ROUTE_H +#define _ZEBRA_BGP_ROUTE_H + +#include + struct bgp_info { /* For linked list. */ struct bgp_info *next; struct bgp_info *prev; + /* reference count */ + u_int ref; + /* BGP route type. This can be static, RIP, OSPF, BGP etc. */ u_char type; @@ -126,6 +134,8 @@ void bgp_clear_route (struct peer *, afi_t, safi_t); void bgp_clear_route_all (struct peer *); void bgp_clear_adj_in (struct peer *, afi_t, safi_t); +int bgp_process (struct bgp *, struct bgp_node *, struct bgp_info *, + afi_t, safi_t); int bgp_nlri_sanity_check (struct peer *, int, u_char *, bgp_size_t); int bgp_nlri_parse (struct peer *, struct attr *, struct bgp_nlri *); @@ -157,3 +167,5 @@ afi_t bgp_node_afi (struct vty *); safi_t bgp_node_safi (struct vty *); + +#endif /* _ZEBRA_BGP_ROUTE */ Index: bgpd/bgp_table.h =================================================================== RCS file: /var/cvsroot/quagga/bgpd/bgp_table.h,v retrieving revision 1.1.1.1 diff -u -w -b -r1.1.1.1 bgp_table.h --- bgpd/bgp_table.h 13 Dec 2002 20:15:29 -0000 1.1.1.1 +++ bgpd/bgp_table.h 7 Oct 2003 12:03:50 -0000 @@ -18,6 +18,9 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#ifndef _ZEBRA_BGP_TABLE_H +#define _ZEBRA_BGP_TABLE_H + struct bgp_table { struct bgp_node *top; @@ -63,3 +66,5 @@ struct bgp_node *bgp_node_match_ipv6 (struct bgp_table *, struct in6_addr *); #endif /* HAVE_IPV6 */ + +#endif /* _ZEBRA_BGP_TABLE_H */