Without this patch, this just crashes:
```
(gdb) bt
0 raise (sig=sig@entry=11) at ../sysdeps/unix/sysv/linux/raise.c:51
1 0x00007f66d977b10c in core_handler (signo=11, siginfo=0x7ffd87aa0430, context=<optimized out>) at lib/sigevent.c:261
2 <signal handler called>
3 stream_put_labeled_prefix (s=s@entry=0x55bd3ce53050, p=p@entry=0x7ffd87aa0a20, label=label@entry=0x0, addpath_capable=<optimized out>, addpath_tx_id=addpath_tx_id@entry=1)
at lib/stream.c:1057
4 0x000055bd3bfba176 in bgp_packet_mpattr_prefix (s=s@entry=0x55bd3ce53050, afi=afi@entry=AFI_IP, safi=safi@entry=SAFI_LABELED_UNICAST, p=p@entry=0x7ffd87aa0a20, prd=prd@entry=0x0,
label=label@entry=0x0, num_labels=0, addpath_capable=true, addpath_tx_id=1, attr=0x7ffd87aa2c20) at bgpd/bgp_attr.c:3964
5 0x000055bd3bfba2b5 in bgp_packet_attribute (bgp=0x55bd3cd8e470, bgp@entry=0x0, peer=peer@entry=0x55bd3cf21fc0, s=s@entry=0x55bd3ce53050, attr=attr@entry=0x7ffd87aa2c20,
vecarr=vecarr@entry=0x7ffd87aa0a10, p=p@entry=0x7ffd87aa0a20, afi=AFI_IP, safi=SAFI_LABELED_UNICAST, from=0x7f66d9ba9010, prd=0x0, label=0x0, num_labels=0, addpath_capable=true,
addpath_tx_id=1, bpi=0x0) at bgpd/bgp_attr.c:4139
6 0x000055bd3c04d455 in subgroup_default_update_packet (subgrp=subgrp@entry=0x55bd3cd885b0, attr=attr@entry=0x7ffd87aa2c20, from=from@entry=0x7f66d9ba9010) at bgpd/bgp_updgrp_packet.c:1129
7 0x000055bd3c04a9a5 in subgroup_default_originate (subgrp=0x55bd3cd885b0, withdraw=withdraw@entry=0) at bgpd/bgp_updgrp_adv.c:972
8 0x000055bd3c022668 in bgp_default_originate (peer=peer@entry=0x7f66d574a010, afi=afi@entry=AFI_IP, safi=safi@entry=SAFI_LABELED_UNICAST, withdraw=withdraw@entry=0)
at bgpd/bgp_route.c:5037
9 0x000055bd3c0922e0 in peer_default_originate_set (peer=0x7f66d574a010, afi=afi@entry=AFI_IP, safi=safi@entry=SAFI_LABELED_UNICAST, rmap=rmap@entry=0x0, route_map=route_map@entry=0x0)
at bgpd/bgpd.c:5428
10 0x000055bd3c076c07 in peer_default_originate_set_vty (set=1, rmap=0x0, safi=SAFI_LABELED_UNICAST, afi=AFI_IP, peer_str=<optimized out>, vty=0x55bd3ce4c900) at bgpd/bgp_vty.c:6941
11 neighbor_default_originate (self=<optimized out>, vty=0x55bd3ce4c900, argc=<optimized out>, argv=<optimized out>) at bgpd/bgp_vty.c:6958
12 0x00007f66d9721dc0 in cmd_execute_command_real (vline=vline@entry=0x55bd3cd874d0, vty=vty@entry=0x55bd3ce4c900, cmd=cmd@entry=0x0, up_level=up_level@entry=0, filter=FILTER_RELAXED)
at lib/command.c:996
13 0x00007f66d9721f39 in cmd_execute_command (vline=vline@entry=0x55bd3cd874d0, vty=vty@entry=0x55bd3ce4c900, cmd=cmd@entry=0x0, vtysh=vtysh@entry=0) at lib/command.c:1055
14 0x00007f66d9722162 in cmd_execute (vty=vty@entry=0x55bd3ce4c900, cmd=cmd@entry=0x55bd3cd8a230 "neighbor 192.168.34.4 default-originate ", matched=matched@entry=0x0, vtysh=vtysh@entry=0)
at lib/command.c:1223
15 0x00007f66d9792337 in vty_command (vty=vty@entry=0x55bd3ce4c900, buf=<optimized out>) at lib/vty.c:486
16 0x00007f66d9792570 in vty_execute (vty=0x55bd3ce4c900) at lib/vty.c:1249
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
struct peer *peer;
afi_t afi;
safi_t safi;
+ safi_t safi_rib;
bool addpath_capable;
struct bgp *bgp;
bool advertise;
addpath_capable = bgp_addpath_encode_tx(peer, afi, safi);
if (safi == SAFI_LABELED_UNICAST)
- safi = SAFI_UNICAST;
+ safi_rib = SAFI_UNICAST;
+ else
+ safi_rib = safi;
if (!table)
- table = peer->bgp->rib[afi][safi];
+ table = peer->bgp->rib[afi][safi_rib];
if (safi != SAFI_MPLS_VPN && safi != SAFI_ENCAP && safi != SAFI_EVPN
&& CHECK_FLAG(peer->af_flags[afi][safi],
for (ri = bgp_dest_get_bgp_path_info(dest); ri; ri = ri->next) {
if (!bgp_check_selected(ri, peer, addpath_capable, afi,
- safi))
+ safi_rib))
continue;
if (subgroup_announce_check(dest, ri, subgrp, dest_p,
bgp_adj_out_unset_subgroup(
dest, subgrp, 1,
bgp_addpath_id_for_peer(
- peer, afi, safi,
+ peer, afi,
+ safi_rib,
&ri->tx_addpath));
}
} else {
bgp_adj_out_unset_subgroup(
dest, subgrp, 1,
bgp_addpath_id_for_peer(
- peer, afi, safi,
+ peer, afi, safi_rib,
&ri->tx_addpath));
}
}
route_map_result_t new_ret = RMAP_DENYMATCH;
afi_t afi;
safi_t safi;
+ safi_t safi_rib;
int pref = 65536;
int new_pref = 0;
if (!(afi == AFI_IP || afi == AFI_IP6))
return;
+ if (safi == SAFI_LABELED_UNICAST)
+ safi_rib = SAFI_UNICAST;
+ else
+ safi_rib = safi;
+
bgp = peer->bgp;
from = bgp->peer_self;
* the default route. We announce the default
* route only if route-map has a match.
*/
- for (dest = bgp_table_top(bgp->rib[afi][safi]); dest;
+ for (dest = bgp_table_top(bgp->rib[afi][safi_rib]); dest;
dest = bgp_route_next(dest)) {
if (!bgp_dest_has_bgp_path_info_data(dest))
continue;
memset(&p, 0, sizeof(p));
p.family = afi2family(afi);
p.prefixlen = 0;
- dest = bgp_afi_node_lookup(bgp->rib[afi][safi], afi, safi, &p, NULL);
+ dest = bgp_afi_node_lookup(bgp->rib[afi][safi_rib], afi, safi_rib, &p,
+ NULL);
if (withdraw) {
/* Withdraw the default route advertised using default
safi_t safi;
struct bpacket_attr_vec_arr vecarr;
bool addpath_capable = false;
+ uint8_t default_originate_label[4] = {0x80, 0x00, 0x00};
+ mpls_label_t *label = NULL;
+ uint32_t num_labels = 0;
if (DISABLE_BGP_ANNOUNCE)
return;
bpacket_attr_vec_arr_reset(&vecarr);
addpath_capable = bgp_addpath_encode_tx(peer, afi, safi);
+ if (safi == SAFI_LABELED_UNICAST) {
+ label = (mpls_label_t *)default_originate_label;
+ num_labels = 1;
+ }
+
memset(&p, 0, sizeof(p));
p.family = afi2family(afi);
p.prefixlen = 0;
pos = stream_get_endp(s);
stream_putw(s, 0);
total_attr_len = bgp_packet_attribute(
- NULL, peer, s, attr, &vecarr, &p, afi, safi, from, NULL, NULL,
- 0, addpath_capable, BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE,
- NULL);
+ NULL, peer, s, attr, &vecarr, &p, afi, safi, from, NULL, label,
+ num_labels, addpath_capable,
+ BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE, NULL);
/* Set Total Path Attribute Length. */
stream_putw_at(s, pos, total_attr_len);