Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linkstate reversal (backport #14560) #14562

Merged
merged 26 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
82a5f9e
Revert "bgpd: fix printing link state ospf opaque data"
donaldsharp Oct 10, 2023
83d4391
Revert "bgpd: fix insecure data write with area addresses"
donaldsharp Oct 10, 2023
8ed3bbd
Revert "bgpd: fix insecure data write with ip addresses"
donaldsharp Oct 10, 2023
0f02b85
Revert "bgpd: fix link_state_hash_cmp()"
donaldsharp Oct 10, 2023
609ee2b
Revert "bgpd: fix illegal memory access in bgp_ls_tlv_check_size()"
donaldsharp Oct 10, 2023
a6f5a7a
Revert "bgpd: do not check attr in bgp_packet_attribute"
donaldsharp Oct 10, 2023
5dab3bb
Revert "doc: add information to display bgp-ls attributes"
donaldsharp Oct 10, 2023
89bf992
Revert "tests: add link-state attribute display in bgp_linkstate_topo1"
donaldsharp Oct 10, 2023
e3f8e7d
Revert "bgpd: store and send bgp link-state attributes"
donaldsharp Oct 10, 2023
8a1f542
Revert "doc: add the bgp link-state user documentation"
donaldsharp Oct 10, 2023
492d542
Revert "doc: move bgp references at the right place"
donaldsharp Oct 10, 2023
8801834
Revert "tests: add bgp_linkstate_topo1"
donaldsharp Oct 10, 2023
ca8af99
Revert "bgpd: add linkstate debug"
donaldsharp Oct 10, 2023
8e063b9
Revert "bgpd: add show bgp link-state link-state commands"
donaldsharp Oct 10, 2023
cb7df45
Revert "bgpd: add bgp default link-state command"
donaldsharp Oct 10, 2023
22f952a
Revert "bgpd: do not announce link-state routes to zebra"
donaldsharp Oct 10, 2023
35b55e6
Revert "bgpd: display link-state prefixes detail"
donaldsharp Oct 10, 2023
5bb55d2
Revert "bgpd: do not display vty output headers for link-state prefixes"
donaldsharp Oct 10, 2023
d636ba8
Revert "bgpd, lib: extend the size of the prefix string buffer"
donaldsharp Oct 10, 2023
f5132b1
Revert "bgpd: send bgp link-state prefixes"
donaldsharp Oct 10, 2023
9b9d180
Revert "bgpd: store bgp link-state prefixes"
donaldsharp Oct 10, 2023
dc0da8d
Revert "lib: add link-state prefixes"
donaldsharp Oct 10, 2023
f98f17d
Revert "bgpd: accept bgp link-state capability"
donaldsharp Oct 10, 2023
9b3be70
Revert "bgpd: add bgp link-state address-family configuration context"
donaldsharp Oct 10, 2023
0877b37
Revert "yang: add bgp link-state"
donaldsharp Oct 10, 2023
0c91f45
Revert "lib: register bgp link-state afi/safi"
donaldsharp Oct 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
169 changes: 2 additions & 167 deletions bgpd/bgp_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,8 @@
#endif
#include "bgp_evpn.h"
#include "bgp_flowspec_private.h"
#include "bgp_linkstate_tlv.h"
#include "bgp_mac.h"

DEFINE_MTYPE_STATIC(BGPD, BGP_ATTR_LS, "BGP Attribute Link-State");
DEFINE_MTYPE_STATIC(BGPD, BGP_ATTR_LS_DATA, "BGP Attribute Link-State Data");

/* Attribute strings for logging. */
static const struct message attr_str[] = {
{BGP_ATTR_ORIGIN, "ORIGIN"},
Expand All @@ -69,7 +65,6 @@ static const struct message attr_str[] = {
#ifdef ENABLE_BGP_VNC_ATTR
{BGP_ATTR_VNC, "VNC"},
#endif
{BGP_ATTR_LINK_STATE, "LINK_STATE"},
{BGP_ATTR_LARGE_COMMUNITIES, "LARGE_COMMUNITY"},
{BGP_ATTR_PREFIX_SID, "PREFIX_SID"},
{BGP_ATTR_IPV6_EXT_COMMUNITIES, "IPV6_EXT_COMMUNITIES"},
Expand Down Expand Up @@ -204,8 +199,6 @@ static struct hash *vnc_hash = NULL;
static struct hash *srv6_l3vpn_hash;
static struct hash *srv6_vpn_hash;

static struct hash *link_state_hash;

struct bgp_attr_encap_subtlv *encap_tlv_dup(struct bgp_attr_encap_subtlv *orig)
{
struct bgp_attr_encap_subtlv *new;
Expand Down Expand Up @@ -723,99 +716,6 @@ static void srv6_finish(void)
hash_clean_and_free(&srv6_vpn_hash, (void (*)(void *))srv6_vpn_free);
}

static void *link_state_hash_alloc(void *p)
{
return p;
}

static void link_state_free(struct bgp_attr_ls *link_state)
{
XFREE(MTYPE_BGP_ATTR_LS_DATA, link_state->data);
XFREE(MTYPE_BGP_ATTR_LS, link_state);
}

static struct bgp_attr_ls *link_state_intern(struct bgp_attr_ls *link_state)
{
struct bgp_attr_ls *find;

find = hash_get(link_state_hash, link_state, link_state_hash_alloc);
if (find != link_state)
link_state_free(link_state);
find->refcnt++;
return find;
}

static void link_state_unintern(struct bgp_attr_ls **link_statep)
{
struct bgp_attr_ls *link_state = *link_statep;

if (!*link_statep)
return;

if (link_state->refcnt)
link_state->refcnt--;

if (link_state->refcnt == 0) {
hash_release(link_state_hash, link_state);
link_state_free(link_state);
*link_statep = NULL;
}
}

static uint32_t link_state_hash_key_make(const void *p)
{
const struct bgp_attr_ls *link_state = p;
uint32_t key = 0;

key = jhash_1word(link_state->length, key);
key = jhash(link_state->data, link_state->length, key);

return key;
}

static bool link_state_hash_cmp(const void *p1, const void *p2)
{
const struct bgp_attr_ls *link_state1 = p1;
const struct bgp_attr_ls *link_state2 = p2;

if (!link_state1 && link_state2)
return false;
if (link_state1 && !link_state2)
return false;
if (!link_state1 && !link_state2)
return true;

if (link_state1->length != link_state2->length)
return false;

return !memcmp(link_state1->data, link_state2->data,
link_state1->length);
}

static bool link_state_same(const struct bgp_attr_ls *h1,
const struct bgp_attr_ls *h2)
{
if (h1 == h2)
return true;
else if (h1 == NULL || h2 == NULL)
return false;
else
return link_state_hash_cmp((const void *)h1, (const void *)h2);
}

static void link_state_init(void)
{
link_state_hash =
hash_create(link_state_hash_key_make, link_state_hash_cmp,
"BGP Link-State Attributes TLVs");
}

static void link_state_finish(void)
{
hash_clean_and_free(&link_state_hash,
(void (*)(void *))link_state_free);
}

static unsigned int transit_hash_key_make(const void *p)
{
const struct transit *transit = p;
Expand Down Expand Up @@ -905,8 +805,6 @@ unsigned int attrhash_key_make(const void *p)
MIX(attr->bh_type);
MIX(attr->otc);
MIX(bgp_attr_get_aigp_metric(attr));
if (attr->link_state)
MIX(link_state_hash_key_make(attr->link_state));

return key;
}
Expand Down Expand Up @@ -972,8 +870,7 @@ bool attrhash_cmp(const void *p1, const void *p2)
attr1->srte_color == attr2->srte_color &&
attr1->nh_type == attr2->nh_type &&
attr1->bh_type == attr2->bh_type &&
attr1->otc == attr2->otc &&
link_state_same(attr1->link_state, attr2->link_state))
attr1->otc == attr2->otc)
return true;
}

Expand Down Expand Up @@ -1133,12 +1030,6 @@ struct attr *bgp_attr_intern(struct attr *attr)
else
attr->srv6_vpn->refcnt++;
}
if (attr->link_state) {
if (!attr->link_state->refcnt)
attr->link_state = link_state_intern(attr->link_state);
else
attr->link_state->refcnt++;
}
#ifdef ENABLE_BGP_VNC
struct bgp_attr_encap_subtlv *vnc_subtlvs =
bgp_attr_get_vnc_subtlvs(attr);
Expand Down Expand Up @@ -1357,8 +1248,6 @@ void bgp_attr_unintern_sub(struct attr *attr)

srv6_l3vpn_unintern(&attr->srv6_l3vpn);
srv6_vpn_unintern(&attr->srv6_vpn);

link_state_unintern(&attr->link_state);
}

/* Free bgp attribute and aspath. */
Expand Down Expand Up @@ -1522,7 +1411,6 @@ bgp_attr_malformed(struct bgp_attr_parser_args *args, uint8_t subcode,
case BGP_ATTR_ENCAP:
case BGP_ATTR_OTC:
return BGP_ATTR_PARSE_WITHDRAW;
case BGP_ATTR_LINK_STATE:
case BGP_ATTR_MP_REACH_NLRI:
case BGP_ATTR_MP_UNREACH_NLRI:
bgp_notify_send_with_data(peer->connection,
Expand Down Expand Up @@ -1609,7 +1497,6 @@ const uint8_t attr_flags_values[] = {
[BGP_ATTR_IPV6_EXT_COMMUNITIES] =
BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_AIGP] = BGP_ATTR_FLAG_OPTIONAL,
[BGP_ATTR_LINK_STATE] = BGP_ATTR_FLAG_OPTIONAL,
};
static const size_t attr_flags_values_max = array_size(attr_flags_values) - 1;

Expand Down Expand Up @@ -3403,32 +3290,6 @@ static enum bgp_attr_parse_ret bgp_attr_aigp(struct bgp_attr_parser_args *args)
return bgp_attr_ignore(peer, args->type);
}

/* Link-State (rfc7752) */
static enum bgp_attr_parse_ret
bgp_attr_linkstate(struct bgp_attr_parser_args *args)
{
struct peer *const peer = args->peer;
struct attr *const attr = args->attr;
const bgp_size_t length = args->length;
struct stream *s = peer->curr;
struct bgp_attr_ls *bgp_attr_ls;
void *bgp_attr_ls_data;

if (STREAM_READABLE(s) == 0)
return BGP_ATTR_PARSE_PROCEED;

attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_LINK_STATE);

bgp_attr_ls = XCALLOC(MTYPE_BGP_ATTR_LS, sizeof(struct bgp_attr_ls));
bgp_attr_ls->length = length;
bgp_attr_ls_data = XCALLOC(MTYPE_BGP_ATTR_LS_DATA, length);
bgp_attr_ls->data = bgp_attr_ls_data;
stream_get(bgp_attr_ls_data, s, length);
attr->link_state = link_state_intern(bgp_attr_ls);

return BGP_ATTR_PARSE_PROCEED;
}

/* OTC attribute. */
static enum bgp_attr_parse_ret bgp_attr_otc(struct bgp_attr_parser_args *args)
{
Expand Down Expand Up @@ -3886,9 +3747,6 @@ enum bgp_attr_parse_ret bgp_attr_parse(struct peer *peer, struct attr *attr,
case BGP_ATTR_AIGP:
ret = bgp_attr_aigp(&attr_args);
break;
case BGP_ATTR_LINK_STATE:
ret = bgp_attr_linkstate(&attr_args);
break;
default:
ret = bgp_attr_unknown(&attr_args);
break;
Expand Down Expand Up @@ -4145,8 +4003,6 @@ size_t bgp_packet_mpattr_start(struct stream *s, struct peer *peer, afi_t afi,
switch (nh_afi) {
case AFI_IP:
switch (safi) {
case SAFI_LINKSTATE:
case SAFI_LINKSTATE_VPN:
case SAFI_UNICAST:
case SAFI_MULTICAST:
case SAFI_LABELED_UNICAST:
Expand Down Expand Up @@ -4180,8 +4036,6 @@ size_t bgp_packet_mpattr_start(struct stream *s, struct peer *peer, afi_t afi,
break;
case AFI_IP6:
switch (safi) {
case SAFI_LINKSTATE:
case SAFI_LINKSTATE_VPN:
case SAFI_UNICAST:
case SAFI_MULTICAST:
case SAFI_LABELED_UNICAST:
Expand Down Expand Up @@ -4232,9 +4086,8 @@ size_t bgp_packet_mpattr_start(struct stream *s, struct peer *peer, afi_t afi,
break;
}
break;
case AFI_LINKSTATE:
case AFI_L2VPN:
if (nh_afi == AFI_L2VPN && safi != SAFI_FLOWSPEC)
if (safi != SAFI_FLOWSPEC)
flog_err(
EC_BGP_ATTR_NH_SEND_LEN,
"Bad nexthop when sending to %s, AFI %u SAFI %u nhlen %d",
Expand Down Expand Up @@ -4285,12 +4138,6 @@ void bgp_packet_mpattr_prefix(struct stream *s, afi_t afi, safi_t safi,
stream_put_labeled_prefix(s, p, label, addpath_capable,
addpath_tx_id);
break;
case SAFI_LINKSTATE:
bgp_nlri_encode_linkstate(s, p);
break;
case SAFI_LINKSTATE_VPN:
/* not yet supported */
break;
case SAFI_FLOWSPEC:
stream_putc(s, p->u.prefix_flowspec.prefixlen);
stream_put(s, (const void *)p->u.prefix_flowspec.ptr,
Expand All @@ -4317,8 +4164,6 @@ size_t bgp_packet_mpattr_prefix_size(afi_t afi, safi_t safi,
case SAFI_MAX:
assert(!"Attempting to figure size for a SAFI_UNSPEC/SAFI_MAX this is a DEV ESCAPE");
break;
case SAFI_LINKSTATE:
case SAFI_LINKSTATE_VPN:
case SAFI_UNICAST:
case SAFI_MULTICAST:
break;
Expand Down Expand Up @@ -4981,14 +4826,6 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
#endif
}

/* BGP Link-State */
if (attr->link_state) {
stream_putc(s, BGP_ATTR_FLAG_OPTIONAL);
stream_putc(s, BGP_ATTR_LINK_STATE);
stream_putc(s, attr->link_state->length);
stream_put(s, attr->link_state->data, attr->link_state->length);
}

/* PMSI Tunnel */
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL)) {
stream_putc(s, BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS);
Expand Down Expand Up @@ -5093,7 +4930,6 @@ void bgp_attr_init(void)
transit_init();
encap_init();
srv6_init();
link_state_init();
}

void bgp_attr_finish(void)
Expand All @@ -5107,7 +4943,6 @@ void bgp_attr_finish(void)
transit_finish();
encap_finish();
srv6_finish();
link_state_finish();
}

/* Make attribute packet. */
Expand Down
9 changes: 0 additions & 9 deletions bgpd/bgp_attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,6 @@ struct bgp_attr_srv6_l3vpn {
uint8_t transposition_offset;
};

struct bgp_attr_ls {
unsigned long refcnt;

uint8_t length;
void *data;
};

/* BGP core attribute structure. */
struct attr {
/* AS Path structure */
Expand All @@ -166,8 +159,6 @@ struct attr {
/* Path origin attribute */
uint8_t origin;

struct bgp_attr_ls *link_state; /* BGP Link State attribute */

/* PMSI tunnel type (RFC 6514). */
enum pta_type pmsi_tnl_type;

Expand Down
3 changes: 0 additions & 3 deletions bgpd/bgp_btoa.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,6 @@ int main(int argc, char **argv)
case AFI_IP6:
printf("/AFI_IP6\n");
break;
case AFI_LINKSTATE:
printf("/AFI_LINKSTATE\n");
break;
default:
printf("/UNKNOWN %d", subtype);
break;
Expand Down
2 changes: 0 additions & 2 deletions bgpd/bgp_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ unsigned long conf_bgp_debug_nht;
unsigned long conf_bgp_debug_update_groups;
unsigned long conf_bgp_debug_vpn;
unsigned long conf_bgp_debug_flowspec;
unsigned long conf_bgp_debug_linkstate;
unsigned long conf_bgp_debug_labelpool;
unsigned long conf_bgp_debug_pbr;
unsigned long conf_bgp_debug_graceful_restart;
Expand All @@ -73,7 +72,6 @@ unsigned long term_bgp_debug_nht;
unsigned long term_bgp_debug_update_groups;
unsigned long term_bgp_debug_vpn;
unsigned long term_bgp_debug_flowspec;
unsigned long term_bgp_debug_linkstate;
unsigned long term_bgp_debug_labelpool;
unsigned long term_bgp_debug_pbr;
unsigned long term_bgp_debug_graceful_restart;
Expand Down
3 changes: 0 additions & 3 deletions bgpd/bgp_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ extern unsigned long conf_bgp_debug_nht;
extern unsigned long conf_bgp_debug_update_groups;
extern unsigned long conf_bgp_debug_vpn;
extern unsigned long conf_bgp_debug_flowspec;
extern unsigned long conf_bgp_debug_linkstate;
extern unsigned long conf_bgp_debug_labelpool;
extern unsigned long conf_bgp_debug_pbr;
extern unsigned long conf_bgp_debug_graceful_restart;
Expand All @@ -80,7 +79,6 @@ extern unsigned long term_bgp_debug_nht;
extern unsigned long term_bgp_debug_update_groups;
extern unsigned long term_bgp_debug_vpn;
extern unsigned long term_bgp_debug_flowspec;
extern unsigned long term_bgp_debug_linkstate;
extern unsigned long term_bgp_debug_labelpool;
extern unsigned long term_bgp_debug_pbr;
extern unsigned long term_bgp_debug_graceful_restart;
Expand Down Expand Up @@ -120,7 +118,6 @@ struct bgp_debug_filter {
#define BGP_DEBUG_VPN_LEAK_RMAP_EVENT 0x04
#define BGP_DEBUG_VPN_LEAK_LABEL 0x08
#define BGP_DEBUG_FLOWSPEC 0x01
#define BGP_DEBUG_LINKSTATE 0x01
#define BGP_DEBUG_LABELPOOL 0x01
#define BGP_DEBUG_PBR 0x01
#define BGP_DEBUG_PBR_ERROR 0x02
Expand Down
6 changes: 0 additions & 6 deletions bgpd/bgp_errors.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,12 +449,6 @@ static struct log_ref ferr_bgp_err[] = {
.description = "The BGP flowspec subsystem has detected that there was a failure for installation/removal/modification of Flowspec from the dataplane",
.suggestion = "Gather log files from the router and open an issue, Restart FRR"
},
{
.code = EC_BGP_LINKSTATE_PACKET,
.title = "BGP Link-State packet processing error",
.description = "The BGP Link-State subsystem has detected a error in the send or receive of a packet",
.suggestion = "Gather log files from both sides of the peering relationship and open an issue"
},
{
.code = EC_BGP_DOPPELGANGER_CONFIG,
.title = "BGP has detected a configuration overwrite during peer collision resolution",
Expand Down
Loading
Loading