Skip to content

Commit f1fda7b

Browse files
committed
bgpd: Assign explicit-null for default-originate according to the AFI
RFC 3032 defines: A value of 2 represents the "IPv6 Explicit NULL Label". This label value is only legal at the bottom of the label stack. It indicates that the label stack must be popped, and the forwarding of the packet must then be based on the IPv6 header. Before this patch we set 128, but it was even more wrong, because it was sent in host-byte order, not the network-byte. Signed-off-by: Donatas Abraitis <[email protected]>
1 parent e7dce03 commit f1fda7b

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

bgpd/bgp_updgrp_packet.c

+12-7
Original file line numberDiff line numberDiff line change
@@ -1080,8 +1080,7 @@ void subgroup_default_update_packet(struct update_subgroup *subgrp,
10801080
safi_t safi;
10811081
struct bpacket_attr_vec_arr vecarr;
10821082
bool addpath_capable = false;
1083-
uint8_t default_originate_label[4] = {0x80, 0x00, 0x00};
1084-
mpls_label_t *label = NULL;
1083+
mpls_label_t label = MPLS_LABEL_IMPLICIT_NULL;
10851084
uint32_t num_labels = 0;
10861085

10871086
if (DISABLE_BGP_ANNOUNCE)
@@ -1097,7 +1096,11 @@ void subgroup_default_update_packet(struct update_subgroup *subgrp,
10971096
addpath_capable = bgp_addpath_encode_tx(peer, afi, safi);
10981097

10991098
if (safi == SAFI_LABELED_UNICAST) {
1100-
label = (mpls_label_t *)default_originate_label;
1099+
label = mpls_lse_encode((afi == AFI_IP)
1100+
? MPLS_LABEL_IPV4_EXPLICIT_NULL
1101+
: MPLS_LABEL_IPV6_EXPLICIT_NULL,
1102+
0, 0, 1);
1103+
bgp_set_valid_label(&label);
11011104
num_labels = 1;
11021105
}
11031106

@@ -1142,10 +1145,12 @@ void subgroup_default_update_packet(struct update_subgroup *subgrp,
11421145
/* Make place for total attribute length. */
11431146
pos = stream_get_endp(s);
11441147
stream_putw(s, 0);
1145-
total_attr_len = bgp_packet_attribute(
1146-
NULL, peer, s, attr, &vecarr, &p, afi, safi, from, NULL, label,
1147-
num_labels, addpath_capable,
1148-
BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE, NULL);
1148+
total_attr_len =
1149+
bgp_packet_attribute(NULL, peer, s, attr, &vecarr, &p, afi,
1150+
safi, from, NULL, &label, num_labels,
1151+
addpath_capable,
1152+
BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE,
1153+
NULL);
11491154

11501155
/* Set Total Path Attribute Length. */
11511156
stream_putw_at(s, pos, total_attr_len);

0 commit comments

Comments
 (0)