From 4a7371e9e21569eee0e728f64ea06870d1aafa5e Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 8 Feb 2018 09:12:12 -0500 Subject: *: Track vrfs per nexthop not per route entry Track the vfrs on a per nexthop basis instead of on a per route entry basis. Signed-off-by: Donald Sharp --- lib/zclient.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'lib/zclient.c') diff --git a/lib/zclient.c b/lib/zclient.c index 0c29b523bf..6882a7ecc5 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -975,12 +975,11 @@ int zapi_route_encode(u_char cmd, struct stream *s, struct zapi_route *api) } stream_putw(s, api->nexthop_num); - if (api->nexthop_num) - stream_putl(s, api->nh_vrf_id); for (i = 0; i < api->nexthop_num; i++) { api_nh = &api->nexthops[i]; + stream_putl(s, api_nh->vrf_id); stream_putc(s, api_nh->type); switch (api_nh->type) { case NEXTHOP_TYPE_BLACKHOLE: @@ -1126,12 +1125,10 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api) return -1; } - if (api->nexthop_num) - STREAM_GETL(s, api->nh_vrf_id); - for (i = 0; i < api->nexthop_num; i++) { api_nh = &api->nexthops[i]; + STREAM_GETL(s, api_nh->vrf_id); STREAM_GETC(s, api_nh->type); switch (api_nh->type) { case NEXTHOP_TYPE_BLACKHOLE: @@ -1217,6 +1214,7 @@ struct nexthop *nexthop_from_zapi_nexthop(struct zapi_nexthop *znh) struct nexthop *n = nexthop_new(); n->type = znh->type; + n->vrf_id = znh->vrf_id; n->ifindex = znh->ifindex; n->gate = znh->gate; -- cgit v1.2.3 From c83c5e4482580351d20fb45dc643c368866e33d8 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 30 Jan 2018 13:30:36 -0500 Subject: lib, zebra: Add new api to specify a label associated with the vrf For L3VPN's we need to create a label associated with the specified vrf to be installed into the kernel to allow a pop and lookup operation. The new api is: zclient_send_vrf_label(struct zclient *zclient, vrf_id_t vrf_id, mpls_label_t label); For the specified vrf_id associate the specified label for a pop and lookup operation for forwarding. To setup a POP and Forward use MPLS_LABEL_IMPLICIT_NULL If the same label is passed in we ignore the call. If the label is different we update entry. If the label is MPLS_LABEL_NONE we remove the entry. This sets up the api. Future commits will have the functionality to actually install into the kernel. Signed-off-by: Donald Sharp --- lib/log.c | 1 + lib/zclient.c | 14 ++++++++++++++ lib/zclient.h | 12 ++++++++++++ zebra/zebra_vrf.h | 3 +++ zebra/zserv.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 78 insertions(+) (limited to 'lib/zclient.c') diff --git a/lib/log.c b/lib/log.c index 66be533e84..9fc19ff683 100644 --- a/lib/log.c +++ b/lib/log.c @@ -929,6 +929,7 @@ static const struct zebra_desc_table command_types[] = { DESC_ENTRY(ZEBRA_VRF_UNREGISTER), DESC_ENTRY(ZEBRA_VRF_ADD), DESC_ENTRY(ZEBRA_VRF_DELETE), + DESC_ENTRY(ZEBRA_VRF_LABEL), DESC_ENTRY(ZEBRA_INTERFACE_VRF_UPDATE), DESC_ENTRY(ZEBRA_BFD_CLIENT_REGISTER), DESC_ENTRY(ZEBRA_INTERFACE_ENABLE_RADV), diff --git a/lib/zclient.c b/lib/zclient.c index 6882a7ecc5..9327201f73 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -363,6 +363,20 @@ static int zebra_hello_send(struct zclient *zclient) return 0; } +void zclient_send_vrf_label(struct zclient *zclient, vrf_id_t vrf_id, + mpls_label_t label) +{ + struct stream *s; + + s = zclient->obuf; + stream_reset(s); + + zclient_create_header(s, ZEBRA_VRF_LABEL, vrf_id); + stream_putl(s, label); + stream_putw_at(s, 0, stream_get_endp(s)); + zclient_send_message(zclient); +} + /* Send register requests to zebra daemon for the information in a VRF. */ void zclient_send_reg_requests(struct zclient *zclient, vrf_id_t vrf_id) { diff --git a/lib/zclient.h b/lib/zclient.h index 910d25aa2f..6b39a2713a 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -93,6 +93,7 @@ typedef enum { ZEBRA_VRF_UNREGISTER, ZEBRA_VRF_ADD, ZEBRA_VRF_DELETE, + ZEBRA_VRF_LABEL, ZEBRA_INTERFACE_VRF_UPDATE, ZEBRA_BFD_CLIENT_REGISTER, ZEBRA_INTERFACE_ENABLE_RADV, @@ -382,6 +383,17 @@ extern u_short *redist_check_instance(struct redist_proto *, u_short); extern void redist_add_instance(struct redist_proto *, u_short); extern void redist_del_instance(struct redist_proto *, u_short); +/* + * Send to zebra that the specified vrf is using label to resolve + * itself for L3VPN's. Repeated calls of this function with + * different labels will cause an effective update of the + * label for lookup. If you pass in MPLS_V4_EXP_NULL_LABEL + * we will cause a delete action and remove this label pop + * operation. + */ +extern void zclient_send_vrf_label(struct zclient *zclient, vrf_id_t vrf_id, + mpls_label_t label); + extern void zclient_send_reg_requests(struct zclient *, vrf_id_t); extern void zclient_send_dereg_requests(struct zclient *, vrf_id_t); diff --git a/zebra/zebra_vrf.h b/zebra/zebra_vrf.h index fe7e77e8be..bfeb4b386c 100644 --- a/zebra/zebra_vrf.h +++ b/zebra/zebra_vrf.h @@ -79,6 +79,9 @@ struct zebra_vrf { */ struct zebra_ns *zns; + /* MPLS Label to handle L3VPN <-> vrf popping */ + mpls_label_t label; + /* MPLS static LSP config table */ struct hash *slsp_table; diff --git a/zebra/zserv.c b/zebra/zserv.c index 9da8d593e5..5f2757f52c 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -2486,6 +2486,51 @@ stream_failure: return 1; } +static void zread_vrf_label(struct zserv *client, + struct zebra_vrf *zvrf) +{ + struct interface *ifp; + mpls_label_t nlabel; + struct stream *s; + struct zebra_vrf *def_zvrf; + + s = client->ibuf; + STREAM_GETL(s, nlabel); + + if (nlabel == zvrf->label) { + /* + * Nothing to do here move along + */ + return; + } + + if (zvrf->vrf->vrf_id != VRF_DEFAULT) + ifp = if_lookup_by_name(zvrf->vrf->name, zvrf->vrf->vrf_id); + else + ifp = if_lookup_by_name("lo", VRF_DEFAULT); + + if (!ifp) { + zlog_debug("Unable to find specified Interface for %s", + zvrf->vrf->name); + return; + } + + def_zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT); + + if (zvrf->label != MPLS_LABEL_IPV4NULL) + mpls_lsp_uninstall(def_zvrf, ZEBRA_LSP_STATIC, + zvrf->label, NEXTHOP_TYPE_IFINDEX, + NULL, ifp->ifindex); + + if (nlabel != MPLS_LABEL_IPV4NULL) + mpls_lsp_install(def_zvrf, ZEBRA_LSP_STATIC, nlabel, + MPLS_LABEL_IMPLICIT_NULL, NEXTHOP_TYPE_IFINDEX, NULL, ifp->ifindex); + + zvrf->label = nlabel; +stream_failure: + return; +} + static inline void zserv_handle_commands(struct zserv *client, uint16_t command, uint16_t length, @@ -2570,6 +2615,9 @@ static inline void zserv_handle_commands(struct zserv *client, case ZEBRA_VRF_UNREGISTER: zread_vrf_unregister(client, length, zvrf); break; + case ZEBRA_VRF_LABEL: + zread_vrf_label(client, zvrf); + break; case ZEBRA_BFD_CLIENT_REGISTER: zebra_ptm_bfd_client_register(client, length); break; -- cgit v1.2.3 From 70e98a7fe7296a1279c6b7142e57221f71ff3121 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 31 Jan 2018 18:24:06 -0500 Subject: *: Make code use a consisten definition of labels Turns out we had 3 different ways to define labels all of them overlapping with the same meanings. Consolidate to 1. This one choosen is consistent naming wise with what the *bsd and linux kernels use. Signed-off-by: Donald Sharp --- bgpd/bgp_mplsvpn.h | 24 -------------------- bgpd/bgp_route.c | 2 +- ldpd/labelmapping.c | 10 ++++----- ldpd/lde.c | 22 ++++++++++-------- ldpd/logmsg.c | 6 ++--- lib/mpls.h | 60 ++++++++++++++++++++++++-------------------------- lib/zclient.c | 4 ++-- lib/zclient.h | 2 +- ospfd/ospf_sr.c | 20 ++++++++--------- zebra/kernel_socket.c | 2 +- zebra/label_manager.c | 4 ++-- zebra/rt_netlink.c | 4 ++-- zebra/zebra_mpls.c | 17 +++++++------- zebra/zebra_mpls_vty.c | 14 ++++++------ zebra/zebra_vty.c | 4 ++-- zebra/zserv.c | 4 ++-- 16 files changed, 89 insertions(+), 110 deletions(-) (limited to 'lib/zclient.c') diff --git a/bgpd/bgp_mplsvpn.h b/bgpd/bgp_mplsvpn.h index 3b37aadbf8..5c11f7526c 100644 --- a/bgpd/bgp_mplsvpn.h +++ b/bgpd/bgp_mplsvpn.h @@ -24,30 +24,6 @@ #include "bgpd/bgp_route.h" #include "bgpd/bgp_rd.h" -#ifdef MPLS_LABEL_MAX -#undef MPLS_LABEL_MAX -#endif - -typedef enum { - MPLS_LABEL_IPV4_EXPLICIT_NULL = 0, /* [RFC3032] */ - MPLS_LABEL_ROUTER_ALERT = 1, /* [RFC3032] */ - MPLS_LABEL_IPV6_EXPLICIT_NULL = 2, /* [RFC3032] */ - MPLS_LABEL_IMPLICIT_NULL = 3, /* [RFC3032] */ - MPLS_LABEL_UNASSIGNED4 = 4, - MPLS_LABEL_UNASSIGNED5 = 5, - MPLS_LABEL_UNASSIGNED6 = 6, - MPLS_LABEL_ELI = 7, /* Entropy Indicator [RFC6790] */ - MPLS_LABEL_UNASSIGNED8 = 8, - MPLS_LABEL_UNASSIGNED9 = 9, - MPLS_LABEL_UNASSIGNED10 = 10, - MPLS_LABEL_UNASSIGNED11 = 11, - MPLS_LABEL_GAL = 13, /* [RFC5586] */ - MPLS_LABEL_OAM_ALERT = 14, /* [RFC3429] */ - MPLS_LABEL_EXTENSION = 15, /* [RFC7274] */ - MPLS_LABEL_MAX = 1048575, - MPLS_LABEL_ILLEGAL = 0xFFFFFFFF /* for internal use only */ -} mpls_special_label_t; - #define MPLS_LABEL_IS_SPECIAL(label) ((label) <= MPLS_LABEL_EXTENSION) #define MPLS_LABEL_IS_NULL(label) \ ((label) == MPLS_LABEL_IPV4_EXPLICIT_NULL \ diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 36e0c92482..a60484fe0a 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -2099,7 +2099,7 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn, rn->flags, BGP_NODE_REGISTERED_FOR_LABEL)) bgp_unregister_for_label(rn); - label_ntop(MPLS_IMP_NULL_LABEL, 1, + label_ntop(MPLS_LABEL_IMPLICIT_NULL, 1, &rn->local_label); bgp_set_valid_label(&rn->local_label); } else diff --git a/ldpd/labelmapping.c b/ldpd/labelmapping.c index 5662038a58..944f93331f 100644 --- a/ldpd/labelmapping.c +++ b/ldpd/labelmapping.c @@ -320,9 +320,9 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type) /* do not accept invalid labels */ if (label > MPLS_LABEL_MAX || (label <= MPLS_LABEL_RESERVED_MAX && - label != MPLS_LABEL_IPV4NULL && - label != MPLS_LABEL_IPV6NULL && - label != MPLS_LABEL_IMPLNULL)) { + label != MPLS_LABEL_IPV4_EXPLICIT_NULL && + label != MPLS_LABEL_IPV6_EXPLICIT_NULL && + label != MPLS_LABEL_IMPLICIT_NULL)) { session_shutdown(nbr, S_BAD_TLV_VAL, msg.id, msg.type); goto err; @@ -396,7 +396,7 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type) case MAP_TYPE_PREFIX: switch (me->map.fec.prefix.af) { case AF_INET: - if (label == MPLS_LABEL_IPV6NULL) { + if (label == MPLS_LABEL_IPV6_EXPLICIT_NULL) { session_shutdown(nbr, S_BAD_TLV_VAL, msg.id, msg.type); goto err; @@ -405,7 +405,7 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type) goto next; break; case AF_INET6: - if (label == MPLS_LABEL_IPV4NULL) { + if (label == MPLS_LABEL_IPV4_EXPLICIT_NULL) { session_shutdown(nbr, S_BAD_TLV_VAL, msg.id, msg.type); goto err; diff --git a/ldpd/lde.c b/ldpd/lde.c index 63e1e39946..a70b97d06b 100644 --- a/ldpd/lde.c +++ b/ldpd/lde.c @@ -702,20 +702,20 @@ lde_update_label(struct fec_node *fn) switch (fn->fec.type) { case FEC_TYPE_IPV4: if (!(ldeconf->ipv4.flags & F_LDPD_AF_EXPNULL)) - return (MPLS_LABEL_IMPLNULL); + return (MPLS_LABEL_IMPLICIT_NULL); if (lde_acl_check(ldeconf->ipv4.acl_label_expnull_for, AF_INET, (union ldpd_addr *)&fn->fec.u.ipv4.prefix, fn->fec.u.ipv4.prefixlen) != FILTER_PERMIT) - return (MPLS_LABEL_IMPLNULL); - return (MPLS_LABEL_IPV4NULL); + return (MPLS_LABEL_IMPLICIT_NULL); + return MPLS_LABEL_IPV4_EXPLICIT_NULL; case FEC_TYPE_IPV6: if (!(ldeconf->ipv6.flags & F_LDPD_AF_EXPNULL)) - return (MPLS_LABEL_IMPLNULL); + return (MPLS_LABEL_IMPLICIT_NULL); if (lde_acl_check(ldeconf->ipv6.acl_label_expnull_for, AF_INET6, (union ldpd_addr *)&fn->fec.u.ipv6.prefix, fn->fec.u.ipv6.prefixlen) != FILTER_PERMIT) - return (MPLS_LABEL_IMPLNULL); - return (MPLS_LABEL_IPV6NULL); + return (MPLS_LABEL_IMPLICIT_NULL); + return MPLS_LABEL_IPV6_EXPLICIT_NULL; default: fatalx("lde_update_label: unexpected fec type"); break; @@ -1522,11 +1522,15 @@ lde_change_egress_label(int af) /* explicitly withdraw all null labels */ RB_FOREACH(ln, nbr_tree, &lde_nbrs) { - lde_send_labelwithdraw_wcard(ln, MPLS_LABEL_IMPLNULL); + lde_send_labelwithdraw_wcard(ln, MPLS_LABEL_IMPLICIT_NULL); if (ln->v4_enabled) - lde_send_labelwithdraw_wcard(ln, MPLS_LABEL_IPV4NULL); + lde_send_labelwithdraw_wcard( + ln, + MPLS_LABEL_IPV4_EXPLICIT_NULL); if (ln->v6_enabled) - lde_send_labelwithdraw_wcard(ln, MPLS_LABEL_IPV6NULL); + lde_send_labelwithdraw_wcard( + ln, + MPLS_LABEL_IPV6_EXPLICIT_NULL); } /* update label of connected routes */ diff --git a/ldpd/logmsg.c b/ldpd/logmsg.c index c819b33b43..a9b066a3da 100644 --- a/ldpd/logmsg.c +++ b/ldpd/logmsg.c @@ -115,11 +115,11 @@ log_label(uint32_t label) case NO_LABEL: snprintf(buf, TF_LEN, "-"); break; - case MPLS_LABEL_IMPLNULL: + case MPLS_LABEL_IMPLICIT_NULL: snprintf(buf, TF_LEN, "imp-null"); break; - case MPLS_LABEL_IPV4NULL: - case MPLS_LABEL_IPV6NULL: + case MPLS_LABEL_IPV4_EXPLICIT_NULL: + case MPLS_LABEL_IPV6_EXPLICIT_NULL: snprintf(buf, TF_LEN, "exp-null"); break; default: diff --git a/lib/mpls.h b/lib/mpls.h index 95882c26ec..c6c0297ff0 100644 --- a/lib/mpls.h +++ b/lib/mpls.h @@ -24,21 +24,27 @@ #include +#ifdef MPLS_LABEL_MAX +#undef MPLS_LABEL_MAX +#endif + /* Well-known MPLS label values (RFC 3032 etc). */ -#define MPLS_V4_EXP_NULL_LABEL 0 -#define MPLS_RA_LABEL 1 -#define MPLS_V6_EXP_NULL_LABEL 2 -#define MPLS_IMP_NULL_LABEL 3 -#define MPLS_ENTROPY_LABEL_INDICATOR 7 -#define MPLS_GAL_LABEL 13 -#define MPLS_OAM_ALERT_LABEL 14 -#define MPLS_EXTENSION_LABEL 15 +#define MPLS_LABEL_IPV4_EXPLICIT_NULL 0 /* [RFC3032] */ +#define MPLS_LABEL_ROUTER_ALERT 1 /* [RFC3032] */ +#define MPLS_LABEL_IPV6_EXPLICIT_NULL 2 /* [RFC3032] */ +#define MPLS_LABEL_IMPLICIT_NULL 3 /* [RFC3032] */ +#define MPLS_LABEL_ELI 7 /* [RFC6790] */ +#define MPLS_LABEL_GAL 13 /* [RFC5586] */ +#define MPLS_LABEL_OAM_ALERT 14 /* [RFC3429] */ +#define MPLS_LABEL_EXTENSION 15 /* [RFC7274] */ +#define MPLS_LABEL_MAX 1048575 +#define MPLS_LABEL_ILLEGAL 0xFFFFFFFF /* for internal use only */ /* Minimum and maximum label values */ -#define MPLS_MIN_RESERVED_LABEL 0 -#define MPLS_MAX_RESERVED_LABEL 15 -#define MPLS_MIN_UNRESERVED_LABEL 16 -#define MPLS_MAX_UNRESERVED_LABEL 1048575 +#define MPLS_LABEL_RESERVED_MIN 0 +#define MPLS_LABEL_RESERVED_MAX 15 +#define MPLS_LABEL_UNRESERVED_MIN 16 +#define MPLS_LABEL_UNRESERVED_MAX 1048575 /* Default min and max SRGB label range */ /* Even if the SRGB allows to manage different Label space between routers, @@ -56,11 +62,11 @@ #define MPLS_MAX_LABELS 16 #define IS_MPLS_RESERVED_LABEL(label) \ - (label >= MPLS_MIN_RESERVED_LABEL && label <= MPLS_MAX_RESERVED_LABEL) + (label >= MPLS_LABEL_RESERVED_MIN && label <= MPLS_LABEL_RESERVED_MAX) #define IS_MPLS_UNRESERVED_LABEL(label) \ - (label >= MPLS_MIN_UNRESERVED_LABEL \ - && label <= MPLS_MAX_UNRESERVED_LABEL) + (label >= MPLS_LABEL_UNRESERVED_MIN \ + && label <= MPLS_LABEL_UNRESERVED_MAX) /* Definitions for a MPLS label stack entry (RFC 3032). This encodes the * label, EXP, BOS and TTL fields. @@ -153,28 +159,28 @@ static inline void mpls_lse_decode(mpls_lse_t lse, mpls_label_t *label, static inline char *label2str(mpls_label_t label, char *buf, size_t len) { switch (label) { - case MPLS_V4_EXP_NULL_LABEL: + case MPLS_LABEL_IPV4_EXPLICIT_NULL: strlcpy(buf, "IPv4 Explicit Null", len); return (buf); - case MPLS_RA_LABEL: + case MPLS_LABEL_ROUTER_ALERT: strlcpy(buf, "Router Alert", len); return (buf); - case MPLS_V6_EXP_NULL_LABEL: + case MPLS_LABEL_IPV6_EXPLICIT_NULL: strlcpy(buf, "IPv6 Explict Null", len); return (buf); - case MPLS_IMP_NULL_LABEL: + case MPLS_LABEL_IMPLICIT_NULL: strlcpy(buf, "implicit-null", len); return (buf); - case MPLS_ENTROPY_LABEL_INDICATOR: + case MPLS_LABEL_ELI: strlcpy(buf, "Entropy Label Indicator", len); return (buf); - case MPLS_GAL_LABEL: + case MPLS_LABEL_GAL: strlcpy(buf, "Generic Associated Channel", len); return (buf); - case MPLS_OAM_ALERT_LABEL: + case MPLS_LABEL_OAM_ALERT: strlcpy(buf, "OAM Alert", len); return (buf); - case MPLS_EXTENSION_LABEL: + case MPLS_LABEL_EXTENSION: strlcpy(buf, "Extension", len); return (buf); default: @@ -186,13 +192,5 @@ static inline char *label2str(mpls_label_t label, char *buf, size_t len) } } -/* constants used by ldpd */ -#define MPLS_LABEL_IPV4NULL 0 /* IPv4 Explicit NULL Label */ -#define MPLS_LABEL_RTALERT 1 /* Router Alert Label */ -#define MPLS_LABEL_IPV6NULL 2 /* IPv6 Explicit NULL Label */ -#define MPLS_LABEL_IMPLNULL 3 /* Implicit NULL Label */ - /* MPLS_LABEL_RESERVED 4-15 */ /* Values 4-15 are reserved */ -#define MPLS_LABEL_RESERVED_MAX 15 -#define MPLS_LABEL_MAX ((1 << 20) - 1) #endif diff --git a/lib/zclient.c b/lib/zclient.c index 9327201f73..f8cdc61f7d 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -1991,8 +1991,8 @@ int lm_get_label_chunk(struct zclient *zclient, u_char keep, __func__, *start, *end, keep, response_keep); } /* sanity */ - if (*start > *end || *start < MPLS_MIN_UNRESERVED_LABEL - || *end > MPLS_MAX_UNRESERVED_LABEL) { + if (*start > *end || *start < MPLS_LABEL_UNRESERVED_MIN + || *end > MPLS_LABEL_UNRESERVED_MAX) { zlog_err("%s: Invalid Label chunk: %u - %u", __func__, *start, *end); return -1; diff --git a/lib/zclient.h b/lib/zclient.h index 6b39a2713a..23cedf97bd 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -387,7 +387,7 @@ extern void redist_del_instance(struct redist_proto *, u_short); * Send to zebra that the specified vrf is using label to resolve * itself for L3VPN's. Repeated calls of this function with * different labels will cause an effective update of the - * label for lookup. If you pass in MPLS_V4_EXP_NULL_LABEL + * label for lookup. If you pass in MPLS_LABEL_IPV4_EXPLICIT_NULL * we will cause a delete action and remove this label pop * operation. */ diff --git a/ospfd/ospf_sr.c b/ospfd/ospf_sr.c index 725bf952e5..c6649a7a04 100644 --- a/ospfd/ospf_sr.c +++ b/ospfd/ospf_sr.c @@ -511,8 +511,8 @@ static int compute_link_nhlfe(struct sr_link *srl) srl->nhlfe[1].label_in = index2label(srl->sid[1], srl->srn->srgb); - srl->nhlfe[0].label_out = MPLS_IMP_NULL_LABEL; - srl->nhlfe[1].label_out = MPLS_IMP_NULL_LABEL; + srl->nhlfe[0].label_out = MPLS_LABEL_IMPLICIT_NULL; + srl->nhlfe[1].label_out = MPLS_LABEL_IMPLICIT_NULL; rc = 1; return rc; @@ -599,7 +599,7 @@ static int compute_prefix_nhlfe(struct sr_prefix *srp) */ if ((srp->nexthop == NULL) && (!CHECK_FLAG(srp->flags, EXT_SUBTLV_PREFIX_SID_NPFLG))) - srp->nhlfe.label_out = MPLS_IMP_NULL_LABEL; + srp->nhlfe.label_out = MPLS_LABEL_IMPLICIT_NULL; else if (CHECK_FLAG(srp->flags, EXT_SUBTLV_PREFIX_SID_VFLG)) srp->nhlfe.label_out = srp->sid; else @@ -694,7 +694,7 @@ static inline void add_sid_nhlfe(struct sr_nhlfe nhlfe) { if ((nhlfe.label_in != 0) && (nhlfe.label_out != 0)) { ospf_zebra_send_mpls_labels(ZEBRA_MPLS_LABELS_ADD, nhlfe); - if (nhlfe.label_out != MPLS_IMP_NULL_LABEL) + if (nhlfe.label_out != MPLS_LABEL_IMPLICIT_NULL) ospf_zebra_send_mpls_ftn(ZEBRA_ROUTE_ADD, nhlfe); } } @@ -704,7 +704,7 @@ static inline void del_sid_nhlfe(struct sr_nhlfe nhlfe) { if ((nhlfe.label_in != 0) && (nhlfe.label_out != 0)) { ospf_zebra_send_mpls_labels(ZEBRA_MPLS_LABELS_DELETE, nhlfe); - if (nhlfe.label_out != MPLS_IMP_NULL_LABEL) + if (nhlfe.label_out != MPLS_LABEL_IMPLICIT_NULL) ospf_zebra_send_mpls_ftn(ZEBRA_ROUTE_DELETE, nhlfe); } } @@ -1535,7 +1535,7 @@ void ospf_sr_update_prefix(struct interface *ifp, struct prefix *p) EXT_SUBTLV_PREFIX_SID_NPFLG)) { srp->nhlfe.label_in = index2label(srp->sid, OspfSR.self->srgb); - srp->nhlfe.label_out = MPLS_IMP_NULL_LABEL; + srp->nhlfe.label_out = MPLS_LABEL_IMPLICIT_NULL; add_sid_nhlfe(srp->nhlfe); } } @@ -1992,7 +1992,7 @@ DEFUN (sr_prefix_sid, if (argv_find(argv, argc, "no-php-flag", &idx)) { SET_FLAG(new->flags, EXT_SUBTLV_PREFIX_SID_NPFLG); new->nhlfe.label_in = index2label(new->sid, OspfSR.self->srgb); - new->nhlfe.label_out = MPLS_IMP_NULL_LABEL; + new->nhlfe.label_out = MPLS_LABEL_IMPLICIT_NULL; } if (IS_DEBUG_OSPF_SR) @@ -2168,7 +2168,7 @@ static void show_vty_sr_node(struct vty *vty, struct sr_node *srn) for (ALL_LIST_ELEMENTS_RO(srn->ext_prefix, node, srp)) { strncpy(pref, inet_ntoa(srp->nhlfe.prefv4.prefix), 16); snprintf(sid, 22, "SR Pfx (idx %u)", srp->sid); - if (srp->nhlfe.label_out == MPLS_IMP_NULL_LABEL) + if (srp->nhlfe.label_out == MPLS_LABEL_IMPLICIT_NULL) sprintf(label, "pop"); else sprintf(label, "%u", srp->nhlfe.label_out); @@ -2182,7 +2182,7 @@ static void show_vty_sr_node(struct vty *vty, struct sr_node *srn) for (ALL_LIST_ELEMENTS_RO(srn->ext_link, node, srl)) { strncpy(pref, inet_ntoa(srl->nhlfe[0].prefv4.prefix), 16); snprintf(sid, 22, "SR Adj. (lbl %u)", srl->sid[0]); - if (srl->nhlfe[0].label_out == MPLS_IMP_NULL_LABEL) + if (srl->nhlfe[0].label_out == MPLS_LABEL_IMPLICIT_NULL) sprintf(label, "pop"); else sprintf(label, "%u", srl->nhlfe[0].label_out); @@ -2192,7 +2192,7 @@ static void show_vty_sr_node(struct vty *vty, struct sr_node *srn) label, sid, itf ? itf->name : "-", inet_ntoa(srl->nhlfe[0].nexthop)); snprintf(sid, 22, "SR Adj. (lbl %u)", srl->sid[1]); - if (srl->nhlfe[1].label_out == MPLS_IMP_NULL_LABEL) + if (srl->nhlfe[1].label_out == MPLS_LABEL_IMPLICIT_NULL) sprintf(label, "pop"); else sprintf(label, "%u", srl->nhlfe[0].label_out); diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c index 7a64b48964..4d888d8069 100644 --- a/zebra/kernel_socket.c +++ b/zebra/kernel_socket.c @@ -1197,7 +1197,7 @@ int rtm_write(int message, union sockunion *dest, union sockunion *mask, msg.rtm.rtm_flags |= RTF_MPLS; if (mpls->smpls.smpls_label - != htonl(MPLS_IMP_NULL_LABEL << MPLS_LABEL_OFFSET)) + != htonl(MPLS_LABEL_IMPLICIT_NULL << MPLS_LABEL_OFFSET)) msg.rtm.rtm_mpls = MPLS_OP_PUSH; } #endif diff --git a/zebra/label_manager.c b/zebra/label_manager.c index ace13eda71..5bf0fce094 100644 --- a/zebra/label_manager.c +++ b/zebra/label_manager.c @@ -283,13 +283,13 @@ struct label_manager_chunk *assign_label_chunk(u_char proto, u_short instance, return NULL; if (list_isempty(lbl_mgr.lc_list)) - lmc->start = MPLS_MIN_UNRESERVED_LABEL; + lmc->start = MPLS_LABEL_UNRESERVED_MIN; else lmc->start = ((struct label_manager_chunk *)listgetdata( listtail(lbl_mgr.lc_list))) ->end + 1; - if (lmc->start > MPLS_MAX_UNRESERVED_LABEL - size + 1) { + if (lmc->start > MPLS_LABEL_UNRESERVED_MAX - size + 1) { zlog_err("Reached max labels. Start: %u, size: %u", lmc->start, size); XFREE(MTYPE_LM_CHUNK, lmc); diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index b8011c2a76..d778990141 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -864,7 +864,7 @@ static void _netlink_route_build_singlepath(const char *routedesc, int bytelen, char label_buf1[20]; for (i = 0; i < nh_label->num_labels; i++) { - if (nh_label->label[i] != MPLS_IMP_NULL_LABEL) { + if (nh_label->label[i] != MPLS_LABEL_IMPLICIT_NULL) { bos = ((i == (nh_label->num_labels - 1)) ? 1 : 0); out_lse[i] = mpls_lse_encode(nh_label->label[i], @@ -1074,7 +1074,7 @@ static void _netlink_route_build_multipath(const char *routedesc, int bytelen, char label_buf1[20]; for (i = 0; i < nh_label->num_labels; i++) { - if (nh_label->label[i] != MPLS_IMP_NULL_LABEL) { + if (nh_label->label[i] != MPLS_LABEL_IMPLICIT_NULL) { bos = ((i == (nh_label->num_labels - 1)) ? 1 : 0); out_lse[i] = mpls_lse_encode(nh_label->label[i], diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index adc893302c..3ceebf417e 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -411,12 +411,13 @@ static int fec_change_update_lsp(struct zebra_vrf *zvrf, zebra_fec_t *fec, afi_t afi; /* Uninstall label forwarding entry, if previously installed. */ - if (old_label != MPLS_INVALID_LABEL && old_label != MPLS_IMP_NULL_LABEL) + if (old_label != MPLS_INVALID_LABEL && + old_label != MPLS_LABEL_IMPLICIT_NULL) lsp_uninstall(zvrf, old_label); /* Install label forwarding entry corr. to new label, if needed. */ if (fec->label == MPLS_INVALID_LABEL - || fec->label == MPLS_IMP_NULL_LABEL) + || fec->label == MPLS_LABEL_IMPLICIT_NULL) return 0; afi = family2afi(PREFIX_FAMILY(&fec->rn->p)); @@ -1821,7 +1822,7 @@ int zebra_mpls_lsp_install(struct zebra_vrf *zvrf, struct route_node *rn, /* We cannot install a label forwarding entry if local label is the * implicit-null label. */ - if (fec->label == MPLS_IMP_NULL_LABEL) + if (fec->label == MPLS_LABEL_IMPLICIT_NULL) return 0; if (lsp_install(zvrf, fec->label, rn, re)) @@ -2565,8 +2566,8 @@ int zebra_mpls_lsp_label_consistent(struct zebra_vrf *zvrf, int cur_op, new_op; cur_op = (slsp->snhlfe_list->out_label - == MPLS_IMP_NULL_LABEL); - new_op = (out_label == MPLS_IMP_NULL_LABEL); + == MPLS_LABEL_IMPLICIT_NULL); + new_op = (out_label == MPLS_LABEL_IMPLICIT_NULL); if (cur_op != new_op) return 0; } @@ -2850,11 +2851,11 @@ int zebra_mpls_write_lsp_config(struct vty *vty, struct zebra_vrf *zvrf) snhlfe2str(snhlfe, buf, sizeof(buf)); switch (snhlfe->out_label) { - case MPLS_V4_EXP_NULL_LABEL: - case MPLS_V6_EXP_NULL_LABEL: + case MPLS_LABEL_IPV4_EXPLICIT_NULL: + case MPLS_LABEL_IPV6_EXPLICIT_NULL: strlcpy(lstr, "explicit-null", sizeof(lstr)); break; - case MPLS_IMP_NULL_LABEL: + case MPLS_LABEL_IMPLICIT_NULL: strlcpy(lstr, "implicit-null", sizeof(lstr)); break; default: diff --git a/zebra/zebra_mpls_vty.c b/zebra/zebra_mpls_vty.c index 9d100bb7d0..0d922830c7 100644 --- a/zebra/zebra_mpls_vty.c +++ b/zebra/zebra_mpls_vty.c @@ -68,7 +68,7 @@ static int zebra_mpls_transit_lsp(struct vty *vty, int add_cmd, return CMD_WARNING_CONFIG_FAILED; } - out_label = MPLS_IMP_NULL_LABEL; /* as initialization */ + out_label = MPLS_LABEL_IMPLICIT_NULL; /* as initialization */ label = atoi(inlabel_str); if (!IS_MPLS_UNRESERVED_LABEL(label)) { vty_out(vty, "%% Invalid label\n"); @@ -107,11 +107,11 @@ static int zebra_mpls_transit_lsp(struct vty *vty, int add_cmd, if (outlabel_str) { if (outlabel_str[0] == 'i') - out_label = MPLS_IMP_NULL_LABEL; + out_label = MPLS_LABEL_IMPLICIT_NULL; else if (outlabel_str[0] == 'e' && gtype == NEXTHOP_TYPE_IPV4) - out_label = MPLS_V4_EXP_NULL_LABEL; + out_label = MPLS_LABEL_IPV4_EXPLICIT_NULL; else if (outlabel_str[0] == 'e' && gtype == NEXTHOP_TYPE_IPV6) - out_label = MPLS_V6_EXP_NULL_LABEL; + out_label = MPLS_LABEL_IPV6_EXPLICIT_NULL; else out_label = atoi(outlabel_str); } @@ -221,12 +221,12 @@ static int zebra_mpls_bind(struct vty *vty, int add_cmd, const char *prefix, } if (!strcmp(label_str, "implicit-null")) - label = MPLS_IMP_NULL_LABEL; + label = MPLS_LABEL_IMPLICIT_NULL; else if (!strcmp(label_str, "explicit-null")) { if (p.family == AF_INET) - label = MPLS_V4_EXP_NULL_LABEL; + label = MPLS_LABEL_IPV4_EXPLICIT_NULL; else - label = MPLS_V6_EXP_NULL_LABEL; + label = MPLS_LABEL_IPV6_EXPLICIT_NULL; } else { label = atoi(label_str); if (!IS_MPLS_UNRESERVED_LABEL(label)) { diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 3f6db5986f..f5ad9c1c8a 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -165,8 +165,8 @@ static int zebra_static_route_leak(struct vty *vty, case -2: vty_out(vty, "%% Cannot use reserved label(s) (%d-%d)\n", - MPLS_MIN_RESERVED_LABEL, - MPLS_MAX_RESERVED_LABEL); + MPLS_LABEL_RESERVED_MIN, + MPLS_LABEL_RESERVED_MAX); break; case -3: vty_out(vty, diff --git a/zebra/zserv.c b/zebra/zserv.c index 5f2757f52c..bf8f66e20f 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -2517,12 +2517,12 @@ static void zread_vrf_label(struct zserv *client, def_zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT); - if (zvrf->label != MPLS_LABEL_IPV4NULL) + if (zvrf->label != MPLS_LABEL_IPV4_EXPLICIT_NULL) mpls_lsp_uninstall(def_zvrf, ZEBRA_LSP_STATIC, zvrf->label, NEXTHOP_TYPE_IFINDEX, NULL, ifp->ifindex); - if (nlabel != MPLS_LABEL_IPV4NULL) + if (nlabel != MPLS_LABEL_IPV4_EXPLICIT_NULL) mpls_lsp_install(def_zvrf, ZEBRA_LSP_STATIC, nlabel, MPLS_LABEL_IMPLICIT_NULL, NEXTHOP_TYPE_IFINDEX, NULL, ifp->ifindex); -- cgit v1.2.3 From 339e36d258ad73701d7b9eccc0e56e48cdea1a2d Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 8 Feb 2018 09:50:32 -0500 Subject: lib, sharpd, zebra: Add new enum for lsp type and pass it through. Add the ability to pass the lsp owner type through the zapi and in addition add a new label type for the sharp protocol for testing. Finally modify zebra_mpls.h to not have defaults specified for the enum. That way when we add a new LSP type the compile fails and the person doing the addition knows where he has to touch shit. Signed-off-by: Donald Sharp --- lib/mpls.h | 3 ++- lib/zclient.c | 3 ++- lib/zclient.h | 2 +- sharpd/sharp_zebra.c | 2 +- zebra/zebra_mpls.h | 37 ++++++++++++++++++++++++++++++++++--- zebra/zserv.c | 12 ++++++------ 6 files changed, 46 insertions(+), 13 deletions(-) (limited to 'lib/zclient.c') diff --git a/lib/mpls.h b/lib/mpls.h index c6c0297ff0..b55d4875ae 100644 --- a/lib/mpls.h +++ b/lib/mpls.h @@ -115,7 +115,8 @@ enum lsp_types_t { ZEBRA_LSP_STATIC = 1, /* Static LSP. */ ZEBRA_LSP_LDP = 2, /* LDP LSP. */ ZEBRA_LSP_BGP = 3, /* BGP LSP. */ - ZEBRA_LSP_SR = 4 /* Segment Routing LSP. */ + ZEBRA_LSP_SR = 4, /* Segment Routing LSP. */ + ZEBRA_LSP_SHARP = 5, /* Identifier for test protocol */ }; /* Functions for basic label operations. */ diff --git a/lib/zclient.c b/lib/zclient.c index f8cdc61f7d..8e8b50b15e 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -364,7 +364,7 @@ static int zebra_hello_send(struct zclient *zclient) } void zclient_send_vrf_label(struct zclient *zclient, vrf_id_t vrf_id, - mpls_label_t label) + mpls_label_t label, enum lsp_types_t ltype) { struct stream *s; @@ -373,6 +373,7 @@ void zclient_send_vrf_label(struct zclient *zclient, vrf_id_t vrf_id, zclient_create_header(s, ZEBRA_VRF_LABEL, vrf_id); stream_putl(s, label); + stream_putc(s, ltype); stream_putw_at(s, 0, stream_get_endp(s)); zclient_send_message(zclient); } diff --git a/lib/zclient.h b/lib/zclient.h index 23cedf97bd..ff65838b53 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -392,7 +392,7 @@ extern void redist_del_instance(struct redist_proto *, u_short); * operation. */ extern void zclient_send_vrf_label(struct zclient *zclient, vrf_id_t vrf_id, - mpls_label_t label); + mpls_label_t label, enum lsp_types_t ltype); extern void zclient_send_reg_requests(struct zclient *, vrf_id_t); extern void zclient_send_dereg_requests(struct zclient *, vrf_id_t); diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c index 5dffd4ab9b..f771e53f0c 100644 --- a/sharpd/sharp_zebra.c +++ b/sharpd/sharp_zebra.c @@ -154,7 +154,7 @@ static void zebra_connected(struct zclient *zclient) void vrf_label_add(vrf_id_t vrf_id, mpls_label_t label) { - zclient_send_vrf_label(zclient, vrf_id, label); + zclient_send_vrf_label(zclient, vrf_id, label, ZEBRA_LSP_SHARP); } void route_add(struct prefix *p, struct nexthop *nh) diff --git a/zebra/zebra_mpls.h b/zebra/zebra_mpls.h index 27a4971691..fd14b29ca9 100644 --- a/zebra/zebra_mpls.h +++ b/zebra/zebra_mpls.h @@ -428,9 +428,19 @@ static inline u_char lsp_distance(enum lsp_types_t type) return (route_distance(ZEBRA_ROUTE_LDP)); case ZEBRA_LSP_BGP: return (route_distance(ZEBRA_ROUTE_BGP)); - default: + case ZEBRA_LSP_NONE: + case ZEBRA_LSP_SHARP: + case ZEBRA_LSP_SR: return 150; } + + /* + * For some reason certain compilers do not believe + * that all the cases have been handled. And + * WTF does this work differently than when I removed + * the default case???? + */ + return 150; } /* @@ -444,6 +454,8 @@ static inline enum lsp_types_t lsp_type_from_re_type(int re_type) return ZEBRA_LSP_STATIC; case ZEBRA_ROUTE_BGP: return ZEBRA_LSP_BGP; + case ZEBRA_ROUTE_SHARP: + return ZEBRA_LSP_SHARP; default: return ZEBRA_LSP_NONE; } @@ -464,9 +476,18 @@ static inline int re_type_from_lsp_type(enum lsp_types_t lsp_type) case ZEBRA_LSP_SR: return ZEBRA_ROUTE_OSPF; case ZEBRA_LSP_NONE: - default: return ZEBRA_ROUTE_KERNEL; + case ZEBRA_LSP_SHARP: + return ZEBRA_ROUTE_SHARP; } + + /* + * For some reason certain compilers do not believe + * that all the cases have been handled. And + * WTF does this work differently than when I removed + * the default case???? + */ + return ZEBRA_ROUTE_KERNEL; } /* NHLFE type as printable string. */ @@ -481,9 +502,19 @@ static inline const char *nhlfe_type2str(enum lsp_types_t lsp_type) return "BGP"; case ZEBRA_LSP_SR: return "SR"; - default: + case ZEBRA_LSP_SHARP: + return "SHARP"; + case ZEBRA_LSP_NONE: return "Unknown"; } + + /* + * For some reason certain compilers do not believe + * that all the cases have been handled. And + * WTF does this work differently than when I removed + * the default case???? + */ + return "Unknown"; } static inline void mpls_mark_lsps_for_processing(struct zebra_vrf *zvrf) diff --git a/zebra/zserv.c b/zebra/zserv.c index bf8f66e20f..3d8be27f3b 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -2493,16 +2493,17 @@ static void zread_vrf_label(struct zserv *client, mpls_label_t nlabel; struct stream *s; struct zebra_vrf *def_zvrf; + enum lsp_types_t ltype; s = client->ibuf; STREAM_GETL(s, nlabel); - if (nlabel == zvrf->label) { /* * Nothing to do here move along */ return; } + STREAM_GETC(s, ltype); if (zvrf->vrf->vrf_id != VRF_DEFAULT) ifp = if_lookup_by_name(zvrf->vrf->name, zvrf->vrf->vrf_id); @@ -2518,13 +2519,12 @@ static void zread_vrf_label(struct zserv *client, def_zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT); if (zvrf->label != MPLS_LABEL_IPV4_EXPLICIT_NULL) - mpls_lsp_uninstall(def_zvrf, ZEBRA_LSP_STATIC, - zvrf->label, NEXTHOP_TYPE_IFINDEX, - NULL, ifp->ifindex); + mpls_lsp_uninstall(def_zvrf, ltype, zvrf->label, + NEXTHOP_TYPE_IFINDEX, NULL, ifp->ifindex); if (nlabel != MPLS_LABEL_IPV4_EXPLICIT_NULL) - mpls_lsp_install(def_zvrf, ZEBRA_LSP_STATIC, nlabel, - MPLS_LABEL_IMPLICIT_NULL, NEXTHOP_TYPE_IFINDEX, NULL, ifp->ifindex); + mpls_lsp_install(def_zvrf, ltype, nlabel, MPLS_LABEL_IMPLICIT_NULL, + NEXTHOP_TYPE_IFINDEX, NULL, ifp->ifindex); zvrf->label = nlabel; stream_failure: -- cgit v1.2.3 From 7d061b3cb120c35c5b580bbbcfb1ec9602f58956 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 14 Feb 2018 01:11:09 -0500 Subject: lib, sharpd, zebra: Update the zapi_vrf_label call to add afi Add the ability to pass in an afi to zebra. zebra_vrf keeps track of the afi/label tuple and then does the right thing before we call down. AF_MPLS does not care about v4 or v6 it just knows label and what device to use for lookup. Signed-off-by: Donald Sharp --- lib/zclient.c | 3 ++- lib/zclient.h | 8 +++++++- sharpd/sharp_vty.c | 7 +++++-- sharpd/sharp_zebra.c | 4 ++-- sharpd/sharp_zebra.h | 2 +- zebra/zebra_vrf.h | 2 +- zebra/zserv.c | 12 ++++++++---- 7 files changed, 26 insertions(+), 12 deletions(-) (limited to 'lib/zclient.c') diff --git a/lib/zclient.c b/lib/zclient.c index 8e8b50b15e..714888a3f3 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -363,7 +363,7 @@ static int zebra_hello_send(struct zclient *zclient) return 0; } -void zclient_send_vrf_label(struct zclient *zclient, vrf_id_t vrf_id, +void zclient_send_vrf_label(struct zclient *zclient, vrf_id_t vrf_id, afi_t afi, mpls_label_t label, enum lsp_types_t ltype) { struct stream *s; @@ -373,6 +373,7 @@ void zclient_send_vrf_label(struct zclient *zclient, vrf_id_t vrf_id, zclient_create_header(s, ZEBRA_VRF_LABEL, vrf_id); stream_putl(s, label); + stream_putc(s, afi); stream_putc(s, ltype); stream_putw_at(s, 0, stream_get_endp(s)); zclient_send_message(zclient); diff --git a/lib/zclient.h b/lib/zclient.h index 344b45fb54..d8a70c6cf3 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -390,9 +390,15 @@ extern void redist_del_instance(struct redist_proto *, u_short); * label for lookup. If you pass in MPLS_LABEL_NONE * we will cause a delete action and remove this label pop * operation. + * + * The underlying AF_MPLS doesn't care about afi's + * but we can make the zebra_vrf keep track of what + * we have installed and play some special games + * to get them both installed. */ extern void zclient_send_vrf_label(struct zclient *zclient, vrf_id_t vrf_id, - mpls_label_t label, enum lsp_types_t ltype); + afi_t afi, mpls_label_t label, + enum lsp_types_t ltype); extern void zclient_send_reg_requests(struct zclient *, vrf_id_t); extern void zclient_send_dereg_requests(struct zclient *, vrf_id_t); diff --git a/sharpd/sharp_vty.c b/sharpd/sharp_vty.c index 4f7d61b22f..0e7d1f2c29 100644 --- a/sharpd/sharp_vty.c +++ b/sharpd/sharp_vty.c @@ -80,14 +80,17 @@ DEFPY (install_routes, } DEFPY(vrf_label, vrf_label_cmd, - "sharp label vrf NAME$name label (0-100000)$label", + "sharp label vrf NAME$name label (0-100000)$label", "Sharp Routing Protocol\n" "Give a vrf a label\n" + "Pop and forward for IPv4\n" + "Pop and forward for IPv6\n" VRF_CMD_HELP_STR "The label to use, 0 specifies remove the label installed from previous\n" "Specified range to use\n") { struct vrf *vrf; + afi_t afi = (ipv4) ? AFI_IP : AFI_IP6; if (strcmp(name, "default") == 0) vrf = vrf_lookup_by_id(VRF_DEFAULT); @@ -102,7 +105,7 @@ DEFPY(vrf_label, vrf_label_cmd, if (label == 0) label = MPLS_LABEL_NONE; - vrf_label_add(vrf->vrf_id, label); + vrf_label_add(vrf->vrf_id, afi, label); return CMD_SUCCESS; } diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c index f771e53f0c..78e8cf0adc 100644 --- a/sharpd/sharp_zebra.c +++ b/sharpd/sharp_zebra.c @@ -152,9 +152,9 @@ static void zebra_connected(struct zclient *zclient) zclient_send_reg_requests(zclient, VRF_DEFAULT); } -void vrf_label_add(vrf_id_t vrf_id, mpls_label_t label) +void vrf_label_add(vrf_id_t vrf_id, afi_t afi, mpls_label_t label) { - zclient_send_vrf_label(zclient, vrf_id, label, ZEBRA_LSP_SHARP); + zclient_send_vrf_label(zclient, vrf_id, afi, label, ZEBRA_LSP_SHARP); } void route_add(struct prefix *p, struct nexthop *nh) diff --git a/sharpd/sharp_zebra.h b/sharpd/sharp_zebra.h index 281c67ff94..0bba443bd4 100644 --- a/sharpd/sharp_zebra.h +++ b/sharpd/sharp_zebra.h @@ -24,7 +24,7 @@ extern void sharp_zebra_init(void); -extern void vrf_label_add(vrf_id_t vrf_id, mpls_label_t label); +extern void vrf_label_add(vrf_id_t vrf_id, afi_t afi, mpls_label_t label); extern void route_add(struct prefix *p, struct nexthop *nh); extern void route_delete(struct prefix *p); #endif diff --git a/zebra/zebra_vrf.h b/zebra/zebra_vrf.h index bfeb4b386c..d3a5316b9d 100644 --- a/zebra/zebra_vrf.h +++ b/zebra/zebra_vrf.h @@ -80,7 +80,7 @@ struct zebra_vrf { struct zebra_ns *zns; /* MPLS Label to handle L3VPN <-> vrf popping */ - mpls_label_t label; + mpls_label_t label[AFI_MAX]; /* MPLS static LSP config table */ struct hash *slsp_table; diff --git a/zebra/zserv.c b/zebra/zserv.c index 704b861960..ab8d8b51bc 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -2486,23 +2486,27 @@ stream_failure: return 1; } + static void zread_vrf_label(struct zserv *client, struct zebra_vrf *zvrf) { struct interface *ifp; mpls_label_t nlabel; + afi_t afi; struct stream *s; struct zebra_vrf *def_zvrf; enum lsp_types_t ltype; s = client->ibuf; STREAM_GETL(s, nlabel); - if (nlabel == zvrf->label) { + STREAM_GETC(s, afi); + if (nlabel == zvrf->label[afi]) { /* * Nothing to do here move along */ return; } + STREAM_GETC(s, ltype); if (zvrf->vrf->vrf_id != VRF_DEFAULT) @@ -2518,15 +2522,15 @@ static void zread_vrf_label(struct zserv *client, def_zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT); - if (zvrf->label != MPLS_LABEL_NONE) - mpls_lsp_uninstall(def_zvrf, ltype, zvrf->label, + if (zvrf->label[afi] != MPLS_LABEL_NONE) + mpls_lsp_uninstall(def_zvrf, ltype, zvrf->label[afi], NEXTHOP_TYPE_IFINDEX, NULL, ifp->ifindex); if (nlabel != MPLS_LABEL_NONE) mpls_lsp_install(def_zvrf, ltype, nlabel, MPLS_LABEL_IMPLICIT_NULL, NEXTHOP_TYPE_IFINDEX, NULL, ifp->ifindex); - zvrf->label = nlabel; + zvrf->label[afi] = nlabel; stream_failure: return; } -- cgit v1.2.3