Move NEXT_HOP attribute so that we can exclude it.
We will need to do that when we will send IPv6 routes (RFC4760 says we SHOULD NOT carry this attribute when we will send UPDATE without NLRI). So, we save the length of all the attributes except NEXT_HOP for later memcpy(). Signed-off-by: Benjamin Cama <benoar@dolka.fr>
This commit is contained in:
parent
f2e59e9881
commit
02611e54fc
2 changed files with 13 additions and 9 deletions
21
bgp.c
21
bgp.c
|
|
@ -193,15 +193,6 @@ int bgp_start(struct bgp_peer *peer, char *name, int as, int keepalive,
|
|||
|
||||
ADD_ATTRIBUTE();
|
||||
|
||||
/* NEXT_HOP */
|
||||
a.flags = BGP_PATH_ATTR_FLAG_TRANS;
|
||||
a.code = BGP_PATH_ATTR_CODE_NEXT_HOP;
|
||||
ip = my_address; /* we're it */
|
||||
a.data.s.len = sizeof(ip);
|
||||
memcpy(a.data.s.value, &ip, sizeof(ip));
|
||||
|
||||
ADD_ATTRIBUTE();
|
||||
|
||||
/* MULTI_EXIT_DISC */
|
||||
a.flags = BGP_PATH_ATTR_FLAG_OPTIONAL;
|
||||
a.code = BGP_PATH_ATTR_CODE_MULTI_EXIT_DISC;
|
||||
|
|
@ -231,6 +222,18 @@ int bgp_start(struct bgp_peer *peer, char *name, int as, int keepalive,
|
|||
|
||||
ADD_ATTRIBUTE();
|
||||
|
||||
/* remember the len before adding NEXT_HOP */
|
||||
peer->path_attr_len_without_nexthop = peer->path_attr_len;
|
||||
|
||||
/* NEXT_HOP */
|
||||
a.flags = BGP_PATH_ATTR_FLAG_TRANS;
|
||||
a.code = BGP_PATH_ATTR_CODE_NEXT_HOP;
|
||||
ip = my_address; /* we're it */
|
||||
a.data.s.len = sizeof(ip);
|
||||
memcpy(a.data.s.value, &ip, sizeof(ip));
|
||||
|
||||
ADD_ATTRIBUTE();
|
||||
|
||||
if (!(peer->path_attrs = malloc(peer->path_attr_len)))
|
||||
{
|
||||
LOG(0, 0, 0, "Can't allocate path_attrs for %s (%s)\n",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue