]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
MPLS: Update to support and use 64bit source id
authorOndrej Zajicek <santiago@crfreenet.org>
Wed, 4 Oct 2023 13:00:24 +0000 (15:00 +0200)
committerOndrej Zajicek <santiago@crfreenet.org>
Wed, 4 Oct 2023 13:00:24 +0000 (15:00 +0200)
nest/mpls.c
nest/mpls.h
proto/l3vpn/l3vpn.c

index 54bfb4021dec3b7d4b8cc40a79f1bf44858cb8aa..e37535c5dde67a619c4615300669a569f0936b17 100644 (file)
@@ -847,12 +847,12 @@ mpls_get_fec_by_label(struct mpls_fec_map *m, u32 label)
 }
 
 struct mpls_fec *
-mpls_get_fec_by_net(struct mpls_fec_map *m, const net_addr *net, u32 path_id)
+mpls_get_fec_by_net(struct mpls_fec_map *m, const net_addr *net, u64 path_id)
 {
   if (!m->net_hash.data)
     HASH_INIT(m->net_hash, m->pool, 4);
 
-  u32 hash = net_hash(net) ^ u32_hash(path_id);
+  u32 hash = net_hash(net) ^ u64_hash(path_id);
   struct mpls_fec *fec = HASH_FIND(m->net_hash, NET, net, path_id, hash);
 
   if (fec)
index def490c13d05b7fc1a382010cac84770553ddd55..c2bdf5ef531af24f4148b648c86a99286901014f 100644 (file)
@@ -126,11 +126,6 @@ struct mpls_fec {
   u32 label;                           /* Label for FEC */
   u32 hash;                            /* Hash for primary key (net / rta) */
   u32 uc;                              /* Number of LSPs for FEC */
-  union {                              /* Extension part of key */
-    u32 path_id;                       /* Source path_id */
-    u32 class_id;                      /* Aaggregation class */
-  };
-
   u8 state;                            /* FEC state (MPLS_FEC_*) */
   u8 policy;                           /* Label policy (MPLS_POLICY_*) */
 
@@ -138,6 +133,11 @@ struct mpls_fec {
 
   struct mpls_fec *next_k;             /* Next in mpls_fec.net_hash/rta_hash */
   struct mpls_fec *next_l;             /* Next in mpls_fec.label_hash */
+
+  union {                              /* Extension part of key */
+    u64 path_id;                       /* Source path_id */
+    u32 class_id;                      /* Aaggregation class */
+  };
   union {                              /* Primary key */
     struct rta *rta;
     struct iface *iface;
@@ -169,7 +169,7 @@ void mpls_fec_map_reconfigure(struct mpls_fec_map *m, struct channel *C);
 void mpls_fec_map_free(struct mpls_fec_map *m);
 struct mpls_fec *mpls_find_fec_by_label(struct mpls_fec_map *x, u32 label);
 struct mpls_fec *mpls_get_fec_by_label(struct mpls_fec_map *m, u32 label);
-struct mpls_fec *mpls_get_fec_by_net(struct mpls_fec_map *m, const net_addr *net, u32 path_id);
+struct mpls_fec *mpls_get_fec_by_net(struct mpls_fec_map *m, const net_addr *net, u64 path_id);
 struct mpls_fec *mpls_get_fec_by_rta(struct mpls_fec_map *m, const rta *src, u32 class_id);
 void mpls_free_fec(struct mpls_fec_map *x, struct mpls_fec *fec);
 int  mpls_handle_rte(struct mpls_fec_map *m, const net_addr *n, rte *r, linpool *lp, struct mpls_fec **locked_fec);
index 2952f32b7171cfd05b5b3012f7990ce8950e7684..8b56cd734d7f194487b0a1c2f1a6481f767ff277 100644 (file)
@@ -148,11 +148,6 @@ l3vpn_prepare_export_targets(struct l3vpn_proto *p)
   ASSERT(p->export_target_length == len);
 }
 
-/* Convert 64-bit RD to 32bit source ID, unfortunately it has collisions */
-static inline struct rte_src * l3vpn_get_source(struct l3vpn_proto *p, u64 rd)
-{ return rt_get_source(&p->p, (u32)(rd >> 32) ^ u32_hash(rd)); }
-//{ return p->p.main_source; }
-
 static void
 l3vpn_rt_notify(struct proto *P, struct channel *c0, net *net, rte *new, rte *old UNUSED)
 {
@@ -182,14 +177,14 @@ l3vpn_rt_notify(struct proto *P, struct channel *c0, net *net, rte *new, rte *ol
 
   case NET_VPN4:
     net_fill_ip4(n, net4_prefix(n0), net4_pxlen(n0));
-    src = l3vpn_get_source(p, ((const net_addr_vpn4 *) n0)->rd);
+    src = rt_get_source(&p->p, ((const net_addr_vpn4 *) n0)->rd);
     dst = p->ip4_channel;
     export = 0;
     break;
 
   case NET_VPN6:
     net_fill_ip6(n, net6_prefix(n0), net6_pxlen(n0));
-    src = l3vpn_get_source(p, ((const net_addr_vpn6 *) n0)->rd);
+    src = rt_get_source(&p->p, ((const net_addr_vpn6 *) n0)->rd);
     dst = p->ip6_channel;
     export = 0;
     break;