]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
EVPN: Parse EVPN MPLS labels as VXLAN VNIs evpn
authorOndrej Zajicek <santiago@crfreenet.org>
Thu, 16 Oct 2025 16:08:56 +0000 (18:08 +0200)
committerOndrej Zajicek <santiago@crfreenet.org>
Thu, 16 Oct 2025 16:08:56 +0000 (18:08 +0200)
EVPN reuses 20bit MPLS labels as 24bit VXLAN VNIs. We focus primarily on
VXLAN case, so parse them as such.

proto/bgp/packets.c

index 3bc5b616bd34a5ed80a6b2bb909b21a186ebacaa..793e09064698a917394ec666c49bffbdc495bac6 100644 (file)
@@ -2255,7 +2255,7 @@ bgp_encode_evpn_ead(struct bgp_write_state *s UNUSED, const net_addr_evpn *net,
 
   /* Encode MPLS label */
   u32 label = bgp_get_label(s->mpls_labels, 0);
-  put_u24(pos, label << 4);
+  put_u24(pos, label); // << 4);
   ADVANCE(pos, size, 3);
 
   return pos - buf;
@@ -2281,7 +2281,7 @@ bgp_decode_evpn_ead(struct bgp_parse_state *s, net_addr_evpn *net, byte *pos, ui
   ADVANCE(pos, len, 4);
 
   /* Decode MPLS label */
-  u32 label = get_u24(pos) >> 4;
+  u32 label = get_u24(pos); // >> 4;
   ADVANCE(pos, len, 3);
 
   s->mpls_labels = lp_alloc_adata(s->pool, 4);
@@ -2324,13 +2324,13 @@ bgp_encode_evpn_mac(struct bgp_write_state *s UNUSED, const net_addr_evpn *net,
 
   /* Encode MPLS label */
   u32 label1 = bgp_get_label(s->mpls_labels, 0);
-  put_u24(pos, label1 << 4);
+  put_u24(pos, label1); // << 4);
   ADVANCE(pos, size, 3);
 
   if (bgp_label_ready(s->mpls_labels, 1))
   {
     u32 label2 = bgp_get_label_(s->mpls_labels, 1);
-    put_u24(pos, label2 << 4);
+    put_u24(pos, label2); // << 4);
     ADVANCE(pos, size, 3);
   }
 
@@ -2376,12 +2376,12 @@ bgp_decode_evpn_mac(struct bgp_parse_state *s, net_addr_evpn *net, byte *pos, ui
     bgp_parse_error(s, 1);
 
   u32 label[2], lnum = 1;
-  label[0] = get_u24(pos) >> 4;
+  label[0] = get_u24(pos); // >> 4;
   ADVANCE(pos, len, 3);
 
   if (len >= 3)
   {
-    label[1] = get_u24(pos) >> 4;
+    label[1] = get_u24(pos); // >> 4;
     ADVANCE(pos, len, 3);
     lnum++;
   }