diff options
author | Philippe Guibert <philippe.guibert@6wind.com> | 2023-02-16 10:39:40 +0100 |
---|---|---|
committer | Philippe Guibert <philippe.guibert@6wind.com> | 2023-03-22 12:06:29 +0100 |
commit | aa274376040e216710560b230fa473ea5f922ac2 (patch) | |
tree | 78867a66b15526c47b801e1b80afed9e297e6a7c /bgpd/bgp_mplsvpn.c | |
parent | bgpd: add support for l3vpn per-nexthop label (diff) | |
download | frr-aa274376040e216710560b230fa473ea5f922ac2.tar.xz frr-aa274376040e216710560b230fa473ea5f922ac2.zip |
bgpd: use nexthop interface when adding LSP in BGP MPLSVPN
BGP MPLSVPN next hop label allocation was using only the next-hop
IP address. As MPLSVPN contexts rely on bnc contexts, the real
nexthop interface is known, and the LSP entry to enter can apply
to the specific interface. To illustrate, the BGP service is able
to handle the following two iproute2 commands:
> ip -f mpls route add 105 via inet 192.0.2.45 dev r1-eth1
> ip -f mpls route add 105 via inet 192.0.2.46 dev r1-eth2
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'bgpd/bgp_mplsvpn.c')
-rw-r--r-- | bgpd/bgp_mplsvpn.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 01081ff11..dfa275036 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -1388,8 +1388,9 @@ static int bgp_mplsvpn_get_label_per_nexthop_cb(mpls_label_t label, /* update paths */ if (blnc->label != MPLS_INVALID_LABEL) - bgp_zebra_send_nexthop_label(ZEBRA_MPLS_LABELS_ADD, blnc->label, - ZEBRA_LSP_BGP, &blnc->nexthop); + bgp_zebra_send_nexthop_label( + ZEBRA_MPLS_LABELS_ADD, blnc->label, blnc->nh->ifindex, + blnc->nh->vrf_id, ZEBRA_LSP_BGP, &blnc->nexthop); LIST_FOREACH (pi, &(blnc->paths), label_nh_thread) { if (!pi->net) @@ -1470,6 +1471,21 @@ static mpls_label_t _vpn_leak_from_vrf_get_per_nexthop_label( pi->label_nexthop_cache = blnc; pi->label_nexthop_cache->path_count++; } + + /* then add or update the selected nexthop */ + if (!blnc->nh) + blnc->nh = nexthop_dup(bnc->nexthop, NULL); + else if (!nexthop_same(bnc->nexthop, blnc->nh)) { + nexthop_free(blnc->nh); + blnc->nh = nexthop_dup(bnc->nexthop, NULL); + if (blnc->label != MPLS_INVALID_LABEL) { + bgp_zebra_send_nexthop_label( + ZEBRA_MPLS_LABELS_REPLACE, blnc->label, + bnc->nexthop->ifindex, bnc->nexthop->vrf_id, + ZEBRA_LSP_BGP, &blnc->nexthop); + } + } + return blnc->label; } |