summaryrefslogtreecommitdiff
path: root/proto/bgp/packets.c
diff options
context:
space:
mode:
Diffstat (limited to 'proto/bgp/packets.c')
-rw-r--r--proto/bgp/packets.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/proto/bgp/packets.c b/proto/bgp/packets.c
index 6b728b4e..ee98115d 100644
--- a/proto/bgp/packets.c
+++ b/proto/bgp/packets.c
@@ -214,6 +214,13 @@ bgp_af_caps_cmp(const void *X, const void *Y)
return (x->afi < y->afi) ? -1 : (x->afi > y->afi) ? 1 : 0;
}
+struct bgp_caps *
+bgp_alloc_capabilities(struct bgp_proto *p, int n)
+{
+ struct bgp_caps *caps = mb_allocz(p->p.pool, sizeof(struct bgp_caps) + n * sizeof(struct bgp_af_caps));
+ caps->role = BGP_ROLE_UNDEFINED;
+ return caps;
+}
void
bgp_prepare_capabilities(struct bgp_conn *conn)
@@ -226,13 +233,13 @@ bgp_prepare_capabilities(struct bgp_conn *conn)
if (!p->cf->capabilities)
{
/* Just prepare empty local_caps */
- conn->local_caps = mb_allocz(p->p.pool, sizeof(struct bgp_caps));
+ conn->local_caps = bgp_alloc_capabilities(p, 0);
return;
}
/* Prepare bgp_caps structure */
int n = list_length(&p->p.channels);
- caps = mb_allocz(p->p.pool, sizeof(struct bgp_caps) + n * sizeof(struct bgp_af_caps));
+ caps = bgp_alloc_capabilities(p, n);
conn->local_caps = caps;
caps->as4_support = p->cf->enable_as4;
@@ -463,10 +470,7 @@ bgp_read_capabilities(struct bgp_conn *conn, byte *pos, int len)
u32 af;
if (!conn->remote_caps)
- {
- caps = mb_allocz(p->p.pool, sizeof(struct bgp_caps) + sizeof(struct bgp_af_caps));
- caps->role = BGP_ROLE_UNDEFINED;
- }
+ caps = bgp_alloc_capabilities(p, 1);
else
{
caps = conn->remote_caps;
@@ -502,7 +506,7 @@ bgp_read_capabilities(struct bgp_conn *conn, byte *pos, int len)
caps->route_refresh = 1;
break;
- case 5: /* Extended next hop encoding capability, RFC 5549 */
+ case 5: /* Extended next hop encoding capability, RFC 8950 */
if (cl % 6)
goto err;
@@ -762,7 +766,7 @@ bgp_read_options(struct bgp_conn *conn, byte *pos, uint len, uint rest)
/* Prepare empty caps if no capability option was announced */
if (!conn->remote_caps)
- conn->remote_caps = mb_allocz(p->p.pool, sizeof(struct bgp_caps));
+ conn->remote_caps = bgp_alloc_capabilities(p, 0);
return 0;
@@ -1262,7 +1266,7 @@ bgp_encode_next_hop_ip(struct bgp_write_state *s, eattr *a, byte *buf, uint size
/*
* Both IPv4 and IPv6 next hops can be used (with ext_next_hop enabled). This
- * is specified in RFC 5549 for IPv4 and in RFC 4798 for IPv6. The difference
+ * is specified in RFC 8950 for IPv4 and in RFC 4798 for IPv6. The difference
* is that IPv4 address is directly encoded with IPv4 NLRI, but as IPv4-mapped
* IPv6 address with IPv6 NLRI.
*/
@@ -1337,7 +1341,7 @@ bgp_encode_next_hop_vpn(struct bgp_write_state *s, eattr *a, byte *buf, uint siz
/*
* Both IPv4 and IPv6 next hops can be used (with ext_next_hop enabled). This
- * is specified in RFC 5549 for VPNv4 and in RFC 4659 for VPNv6. The difference
+ * is specified in RFC 8950 for VPNv4 and in RFC 4659 for VPNv6. The difference
* is that IPv4 address is directly encoded with VPNv4 NLRI, but as IPv4-mapped
* IPv6 address with VPNv6 NLRI.
*/