diff options
Diffstat (limited to 'proto/bgp/packets.c')
-rw-r--r-- | proto/bgp/packets.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/proto/bgp/packets.c b/proto/bgp/packets.c index 8e657cc..ad3a0bb 100644 --- a/proto/bgp/packets.c +++ b/proto/bgp/packets.c @@ -6,7 +6,7 @@ * Can be freely distributed and used under the terms of the GNU GPL. */ -#define LOCAL_DEBUG +#undef LOCAL_DEBUG #include "nest/bird.h" #include "nest/iface.h" @@ -335,10 +335,12 @@ bgp_create_update(struct bgp_conn *conn, byte *buf) #else /* IPv6 version */ static byte * -bgp_create_update(struct bgp_conn *conn, byte *buf) +bgp_create_update_cast(struct bgp_conn *conn, byte *buf, int cast) { struct bgp_proto *p = conn->bgp; - struct bgp_bucket_info *bi = &p->unicast_buckets; + int multicast = (cast == RTC_MULTICAST); + struct bgp_bucket_info *bi = multicast ? &p->multicast_buckets : &p->unicast_buckets; + int sub = multicast ? BGP_SAF_MULTICAST : BGP_SAF_UNICAST; struct bgp_bucket *buck; int size, second, rem_stored; int remains = BGP_MAX_PACKET_LENGTH - BGP_HEADER_LENGTH - 4; @@ -357,7 +359,7 @@ bgp_create_update(struct bgp_conn *conn, byte *buf) tmp = bgp_attach_attr_wa(&ea, bgp_linpool, BA_MP_UNREACH_NLRI, remains-8); *tmp++ = 0; *tmp++ = BGP_AF_IPV6; - *tmp++ = BGP_SAF_UNICAST; + *tmp++ = sub; ea->attrs[0].u.ptr->length = 3 + bgp_encode_prefixes(bi, tmp, buck, remains-11); size = bgp_encode_attrs(p, w, ea, remains); ASSERT(size >= 0); @@ -449,7 +451,7 @@ bgp_create_update(struct bgp_conn *conn, byte *buf) tstart = tmp = bgp_attach_attr_wa(&ea, bgp_linpool, BA_MP_REACH_NLRI, remains-8); *tmp++ = 0; *tmp++ = BGP_AF_IPV6; - *tmp++ = 1; + *tmp++ = sub; if (ipa_nonzero(ip_ll)) { @@ -490,6 +492,17 @@ bgp_create_update(struct bgp_conn *conn, byte *buf) return NULL; } +static byte * +bgp_create_update(struct bgp_conn *conn, byte *buf) +{ + byte *end = bgp_create_update_cast(conn, buf, RTC_UNICAST); + + if ((!end) && conn->bgp->multicast_session) + end = bgp_create_update_cast(conn, buf, RTC_MULTICAST); + + return end; +} + #endif static byte * @@ -500,8 +513,8 @@ bgp_create_route_refresh(struct bgp_conn *conn, byte *buf) *buf++ = 0; *buf++ = BGP_AF; - *buf++ = 0; /* RFU */ - *buf++ = 1; /* and SAFI 1 */ + *buf++ = 0; /* RFU */ + *buf++ = BGP_SAF_UNICAST; /* and SAFI 1 */ return buf; } |