mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-15 09:20:25 +00:00
commit
c1927369d6
@ -81,6 +81,12 @@ typedef unsigned int mpls_lse_t;
|
||||
/* MPLS label value as a 32-bit (mostly we only care about the label value). */
|
||||
typedef unsigned int mpls_label_t;
|
||||
|
||||
struct mpls_label_stack {
|
||||
uint8_t num_labels;
|
||||
uint8_t reserved[3];
|
||||
mpls_label_t label[0]; /* 1 or more labels */
|
||||
};
|
||||
|
||||
/* The MPLS explicit-null label is 0 which means when you memset a mpls_label_t
|
||||
* to zero you have set that variable to explicit-null which was probably not
|
||||
* your intent. The work-around is to use one bit to indicate if the
|
||||
|
@ -124,7 +124,7 @@ const char *nexthop_type_to_str(enum nexthop_types_t nh_type)
|
||||
*/
|
||||
int nexthop_labels_match(struct nexthop *nh1, struct nexthop *nh2)
|
||||
{
|
||||
struct nexthop_label *nhl1, *nhl2;
|
||||
struct mpls_label_stack *nhl1, *nhl2;
|
||||
|
||||
nhl1 = nh1->nh_label;
|
||||
nhl2 = nh2->nh_label;
|
||||
@ -210,12 +210,12 @@ void nexthops_free(struct nexthop *nexthop)
|
||||
void nexthop_add_labels(struct nexthop *nexthop, enum lsp_types_t type,
|
||||
u_int8_t num_labels, mpls_label_t *label)
|
||||
{
|
||||
struct nexthop_label *nh_label;
|
||||
struct mpls_label_stack *nh_label;
|
||||
int i;
|
||||
|
||||
nexthop->nh_label_type = type;
|
||||
nh_label = XCALLOC(MTYPE_NH_LABEL,
|
||||
sizeof(struct nexthop_label)
|
||||
sizeof(struct mpls_label_stack)
|
||||
+ num_labels * sizeof(mpls_label_t));
|
||||
nh_label->num_labels = num_labels;
|
||||
for (i = 0; i < num_labels; i++)
|
||||
|
@ -55,13 +55,6 @@ enum blackhole_type {
|
||||
((type) == NEXTHOP_TYPE_IFINDEX || (type) == NEXTHOP_TYPE_BLACKHOLE) \
|
||||
? (type) : ((type) | 1)
|
||||
|
||||
/* Nexthop label structure. */
|
||||
struct nexthop_label {
|
||||
u_int8_t num_labels;
|
||||
u_int8_t reserved[3];
|
||||
mpls_label_t label[0]; /* 1 or more labels. */
|
||||
};
|
||||
|
||||
/* Nexthop structure. */
|
||||
struct nexthop {
|
||||
struct nexthop *next;
|
||||
@ -107,7 +100,7 @@ struct nexthop {
|
||||
enum lsp_types_t nh_label_type;
|
||||
|
||||
/* Label(s) associated with this nexthop. */
|
||||
struct nexthop_label *nh_label;
|
||||
struct mpls_label_stack *nh_label;
|
||||
};
|
||||
|
||||
/* The following for loop allows to iterate over the nexthop
|
||||
|
@ -121,7 +121,7 @@ static int reply_error(int cmd, struct zserv *zserv, vrf_id_t vrf_id)
|
||||
s = zserv->obuf;
|
||||
stream_reset(s);
|
||||
|
||||
zserv_create_header(s, cmd, vrf_id);
|
||||
zclient_create_header(s, cmd, vrf_id);
|
||||
|
||||
/* result */
|
||||
stream_putc(s, 1);
|
||||
|
@ -803,7 +803,7 @@ static void _netlink_route_build_singlepath(const char *routedesc, int bytelen,
|
||||
struct rtmsg *rtmsg,
|
||||
size_t req_size, int cmd)
|
||||
{
|
||||
struct nexthop_label *nh_label;
|
||||
struct mpls_label_stack *nh_label;
|
||||
mpls_lse_t out_lse[MPLS_MAX_LABELS];
|
||||
char label_buf[256];
|
||||
|
||||
@ -1003,7 +1003,7 @@ static void _netlink_route_build_multipath(const char *routedesc, int bytelen,
|
||||
struct rtmsg *rtmsg,
|
||||
union g_addr **src)
|
||||
{
|
||||
struct nexthop_label *nh_label;
|
||||
struct mpls_label_stack *nh_label;
|
||||
mpls_lse_t out_lse[MPLS_MAX_LABELS];
|
||||
char label_buf[256];
|
||||
|
||||
|
@ -67,7 +67,7 @@ static int sin_masklen(struct in_addr mask)
|
||||
#endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
static int kernel_rtm_add_labels(struct nexthop_label *nh_label,
|
||||
static int kernel_rtm_add_labels(struct mpls_label_stack *nh_label,
|
||||
struct sockaddr_mpls *smpls)
|
||||
{
|
||||
if (nh_label->num_labels > 1) {
|
||||
|
@ -104,7 +104,7 @@ static zebra_nhlfe_t *nhlfe_add(zebra_lsp_t *lsp, enum lsp_types_t lsp_type,
|
||||
ifindex_t ifindex, mpls_label_t out_label);
|
||||
static int nhlfe_del(zebra_nhlfe_t *snhlfe);
|
||||
static void nhlfe_out_label_update(zebra_nhlfe_t *nhlfe,
|
||||
struct nexthop_label *nh_label);
|
||||
struct mpls_label_stack *nh_label);
|
||||
static int mpls_lsp_uninstall_all(struct hash *lsp_table, zebra_lsp_t *lsp,
|
||||
enum lsp_types_t type);
|
||||
static int mpls_static_lsp_uninstall_all(struct zebra_vrf *zvrf,
|
||||
@ -457,7 +457,7 @@ static int fec_send(zebra_fec_t *fec, struct zserv *client)
|
||||
s = client->obuf;
|
||||
stream_reset(s);
|
||||
|
||||
zserv_create_header(s, ZEBRA_FEC_UPDATE, VRF_DEFAULT);
|
||||
zclient_create_header(s, ZEBRA_FEC_UPDATE, VRF_DEFAULT);
|
||||
|
||||
stream_putw(s, rn->p.family);
|
||||
stream_put_prefix(s, &rn->p);
|
||||
@ -1217,7 +1217,7 @@ static int nhlfe_del(zebra_nhlfe_t *nhlfe)
|
||||
* Update label for NHLFE entry.
|
||||
*/
|
||||
static void nhlfe_out_label_update(zebra_nhlfe_t *nhlfe,
|
||||
struct nexthop_label *nh_label)
|
||||
struct mpls_label_stack *nh_label)
|
||||
{
|
||||
nhlfe->nexthop->nh_label->label[0] = nh_label->label[0];
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ stream_failure:
|
||||
|
||||
stream_reset(s);
|
||||
|
||||
zserv_create_header(s, ZEBRA_IPMR_ROUTE_STATS, zvrf_id(zvrf));
|
||||
zclient_create_header(s, ZEBRA_IPMR_ROUTE_STATS, zvrf_id(zvrf));
|
||||
stream_put_in_addr(s, &mroute.sg.src);
|
||||
stream_put_in_addr(s, &mroute.sg.grp);
|
||||
stream_put(s, &mroute.lastused, sizeof(mroute.lastused));
|
||||
|
@ -41,7 +41,7 @@ static int zsend_interface_bfd_update(int cmd, struct zserv *client,
|
||||
s = client->obuf;
|
||||
stream_reset(s);
|
||||
|
||||
zserv_create_header(s, cmd, vrf_id);
|
||||
zclient_create_header(s, cmd, vrf_id);
|
||||
if (ifp)
|
||||
stream_putl(s, ifp->ifindex);
|
||||
else
|
||||
@ -96,8 +96,7 @@ static int zsend_bfd_peer_replay(int cmd, struct zserv *client)
|
||||
s = client->obuf;
|
||||
stream_reset(s);
|
||||
|
||||
zserv_create_header(
|
||||
s, cmd, VRF_DEFAULT); // Pending: adjust when multi-vrf bfd work
|
||||
zclient_create_header(s, cmd, VRF_DEFAULT);
|
||||
|
||||
/* Write packet size. */
|
||||
stream_putw_at(s, 0, stream_get_endp(s));
|
||||
|
@ -372,6 +372,12 @@ static void nexthop_set_resolved(afi_t afi, struct nexthop *newhop,
|
||||
break;
|
||||
}
|
||||
|
||||
/* Copy labels of the resolved route */
|
||||
if (newhop->nh_label)
|
||||
nexthop_add_labels(resolved_hop, newhop->nh_label_type,
|
||||
newhop->nh_label->num_labels,
|
||||
&newhop->nh_label->label[0]);
|
||||
|
||||
resolved_hop->rparent = nexthop;
|
||||
nexthop_add(&nexthop->resolved, resolved_hop);
|
||||
}
|
||||
|
@ -1000,7 +1000,7 @@ static int send_client(struct rnh *rnh, struct zserv *client, rnh_type_t type,
|
||||
s = client->obuf;
|
||||
stream_reset(s);
|
||||
|
||||
zserv_create_header(s, cmd, vrf_id);
|
||||
zclient_create_header(s, cmd, vrf_id);
|
||||
|
||||
stream_putw(s, rn->p.family);
|
||||
switch (rn->p.family) {
|
||||
|
@ -1166,7 +1166,7 @@ static int zvni_macip_send_msg_to_client(vni_t vni,
|
||||
s = client->obuf;
|
||||
stream_reset(s);
|
||||
|
||||
zserv_create_header(s, cmd, VRF_DEFAULT);
|
||||
zclient_create_header(s, cmd, VRF_DEFAULT);
|
||||
stream_putl(s, vni);
|
||||
stream_put(s, macaddr->octet, ETH_ALEN);
|
||||
if (ip) {
|
||||
@ -2531,7 +2531,7 @@ static int zvni_send_add_to_client(zebra_vni_t *zvni)
|
||||
s = client->obuf;
|
||||
stream_reset(s);
|
||||
|
||||
zserv_create_header(s, ZEBRA_VNI_ADD, VRF_DEFAULT);
|
||||
zclient_create_header(s, ZEBRA_VNI_ADD, VRF_DEFAULT);
|
||||
stream_putl(s, zvni->vni);
|
||||
stream_put_in_addr(s, &zvni->local_vtep_ip);
|
||||
stream_put(s, &zvni->vrf_id, sizeof(vrf_id_t)); /* tenant vrf */
|
||||
@ -2565,7 +2565,7 @@ static int zvni_send_del_to_client(vni_t vni)
|
||||
s = client->obuf;
|
||||
stream_reset(s);
|
||||
|
||||
zserv_create_header(s, ZEBRA_VNI_DEL, VRF_DEFAULT);
|
||||
zclient_create_header(s, ZEBRA_VNI_DEL, VRF_DEFAULT);
|
||||
stream_putl(s, vni);
|
||||
|
||||
/* Write packet size. */
|
||||
@ -3550,7 +3550,7 @@ static int zl3vni_send_add_to_client(zebra_l3vni_t *zl3vni)
|
||||
s = client->obuf;
|
||||
stream_reset(s);
|
||||
|
||||
zserv_create_header(s, ZEBRA_L3VNI_ADD,
|
||||
zclient_create_header(s, ZEBRA_L3VNI_ADD,
|
||||
zl3vni_vrf_id(zl3vni));
|
||||
stream_putl(s, zl3vni->vni);
|
||||
stream_put(s, &rmac, sizeof(struct ethaddr));
|
||||
@ -3586,7 +3586,7 @@ static int zl3vni_send_del_to_client(zebra_l3vni_t *zl3vni)
|
||||
s = client->obuf;
|
||||
stream_reset(s);
|
||||
|
||||
zserv_create_header(s, ZEBRA_L3VNI_DEL,
|
||||
zclient_create_header(s, ZEBRA_L3VNI_DEL,
|
||||
zl3vni_vrf_id(zl3vni));
|
||||
stream_putl(s, zl3vni->vni);
|
||||
|
||||
|
@ -149,16 +149,6 @@ int zebra_server_send_message(struct zserv *client)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void zserv_create_header(struct stream *s, uint16_t cmd, vrf_id_t vrf_id)
|
||||
{
|
||||
/* length placeholder, caller can update */
|
||||
stream_putw(s, ZEBRA_HEADER_SIZE);
|
||||
stream_putc(s, ZEBRA_HEADER_MARKER);
|
||||
stream_putc(s, ZSERV_VERSION);
|
||||
stream_putl(s, vrf_id);
|
||||
stream_putw(s, cmd);
|
||||
}
|
||||
|
||||
static void zserv_encode_interface(struct stream *s, struct interface *ifp)
|
||||
{
|
||||
/* Interface information. */
|
||||
@ -221,7 +211,7 @@ int zsend_interface_add(struct zserv *client, struct interface *ifp)
|
||||
s = client->obuf;
|
||||
stream_reset(s);
|
||||
|
||||
zserv_create_header(s, ZEBRA_INTERFACE_ADD, ifp->vrf_id);
|
||||
zclient_create_header(s, ZEBRA_INTERFACE_ADD, ifp->vrf_id);
|
||||
zserv_encode_interface(s, ifp);
|
||||
|
||||
client->ifadd_cnt++;
|
||||
@ -236,7 +226,7 @@ int zsend_interface_delete(struct zserv *client, struct interface *ifp)
|
||||
s = client->obuf;
|
||||
stream_reset(s);
|
||||
|
||||
zserv_create_header(s, ZEBRA_INTERFACE_DELETE, ifp->vrf_id);
|
||||
zclient_create_header(s, ZEBRA_INTERFACE_DELETE, ifp->vrf_id);
|
||||
zserv_encode_interface(s, ifp);
|
||||
|
||||
client->ifdel_cnt++;
|
||||
@ -250,7 +240,7 @@ int zsend_vrf_add(struct zserv *client, struct zebra_vrf *zvrf)
|
||||
s = client->obuf;
|
||||
stream_reset(s);
|
||||
|
||||
zserv_create_header(s, ZEBRA_VRF_ADD, zvrf_id(zvrf));
|
||||
zclient_create_header(s, ZEBRA_VRF_ADD, zvrf_id(zvrf));
|
||||
zserv_encode_vrf(s, zvrf);
|
||||
|
||||
client->vrfadd_cnt++;
|
||||
@ -265,7 +255,7 @@ int zsend_vrf_delete(struct zserv *client, struct zebra_vrf *zvrf)
|
||||
s = client->obuf;
|
||||
stream_reset(s);
|
||||
|
||||
zserv_create_header(s, ZEBRA_VRF_DELETE, zvrf_id(zvrf));
|
||||
zclient_create_header(s, ZEBRA_VRF_DELETE, zvrf_id(zvrf));
|
||||
zserv_encode_vrf(s, zvrf);
|
||||
|
||||
client->vrfdel_cnt++;
|
||||
@ -285,7 +275,7 @@ int zsend_interface_link_params(struct zserv *client, struct interface *ifp)
|
||||
s = client->obuf;
|
||||
stream_reset(s);
|
||||
|
||||
zserv_create_header(s, ZEBRA_INTERFACE_LINK_PARAMS, ifp->vrf_id);
|
||||
zclient_create_header(s, ZEBRA_INTERFACE_LINK_PARAMS, ifp->vrf_id);
|
||||
|
||||
/* Add Interface Index */
|
||||
stream_putl(s, ifp->ifindex);
|
||||
@ -348,7 +338,7 @@ int zsend_interface_address(int cmd, struct zserv *client,
|
||||
s = client->obuf;
|
||||
stream_reset(s);
|
||||
|
||||
zserv_create_header(s, cmd, ifp->vrf_id);
|
||||
zclient_create_header(s, cmd, ifp->vrf_id);
|
||||
stream_putl(s, ifp->ifindex);
|
||||
|
||||
/* Interface address flag. */
|
||||
@ -393,7 +383,7 @@ static int zsend_interface_nbr_address(int cmd, struct zserv *client,
|
||||
s = client->obuf;
|
||||
stream_reset(s);
|
||||
|
||||
zserv_create_header(s, cmd, ifp->vrf_id);
|
||||
zclient_create_header(s, cmd, ifp->vrf_id);
|
||||
stream_putl(s, ifp->ifindex);
|
||||
|
||||
/* Prefix information. */
|
||||
@ -504,7 +494,7 @@ int zsend_interface_vrf_update(struct zserv *client, struct interface *ifp,
|
||||
s = client->obuf;
|
||||
stream_reset(s);
|
||||
|
||||
zserv_create_header(s, ZEBRA_INTERFACE_VRF_UPDATE, ifp->vrf_id);
|
||||
zclient_create_header(s, ZEBRA_INTERFACE_VRF_UPDATE, ifp->vrf_id);
|
||||
|
||||
/* Fill in the ifIndex of the interface and its new VRF (id) */
|
||||
stream_putl(s, ifp->ifindex);
|
||||
@ -581,7 +571,7 @@ int zsend_interface_update(int cmd, struct zserv *client, struct interface *ifp)
|
||||
s = client->obuf;
|
||||
stream_reset(s);
|
||||
|
||||
zserv_create_header(s, cmd, ifp->vrf_id);
|
||||
zclient_create_header(s, cmd, ifp->vrf_id);
|
||||
zserv_encode_interface(s, ifp);
|
||||
|
||||
if (cmd == ZEBRA_INTERFACE_UP)
|
||||
@ -957,7 +947,7 @@ static int zsend_ipv4_nexthop_lookup_mrib(struct zserv *client,
|
||||
stream_reset(s);
|
||||
|
||||
/* Fill in result. */
|
||||
zserv_create_header(s, ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB, zvrf_id(zvrf));
|
||||
zclient_create_header(s, ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB, zvrf_id(zvrf));
|
||||
stream_put_in_addr(s, &addr);
|
||||
|
||||
if (re) {
|
||||
@ -1009,7 +999,7 @@ int zsend_route_notify_owner(u_char proto, u_short instance,
|
||||
s = client->obuf;
|
||||
stream_reset(s);
|
||||
|
||||
zserv_create_header(s, ZEBRA_ROUTE_NOTIFY_OWNER, vrf_id);
|
||||
zclient_create_header(s, ZEBRA_ROUTE_NOTIFY_OWNER, vrf_id);
|
||||
|
||||
stream_put(s, ¬e, sizeof(note));
|
||||
|
||||
@ -1039,7 +1029,7 @@ int zsend_router_id_update(struct zserv *client, struct prefix *p,
|
||||
stream_reset(s);
|
||||
|
||||
/* Message type. */
|
||||
zserv_create_header(s, ZEBRA_ROUTER_ID_UPDATE, vrf_id);
|
||||
zclient_create_header(s, ZEBRA_ROUTER_ID_UPDATE, vrf_id);
|
||||
|
||||
/* Prefix information. */
|
||||
stream_putc(s, p->family);
|
||||
@ -1063,7 +1053,7 @@ int zsend_pw_update(struct zserv *client, struct zebra_pw *pw)
|
||||
s = client->obuf;
|
||||
stream_reset(s);
|
||||
|
||||
zserv_create_header(s, ZEBRA_PW_STATUS_UPDATE, pw->vrf_id);
|
||||
zclient_create_header(s, ZEBRA_PW_STATUS_UPDATE, pw->vrf_id);
|
||||
stream_write(s, pw->ifname, IF_NAMESIZE);
|
||||
stream_putl(s, pw->ifindex);
|
||||
stream_putl(s, pw->status);
|
||||
@ -2089,7 +2079,7 @@ static int zsend_label_manager_connect_response(struct zserv *client,
|
||||
s = client->obuf;
|
||||
stream_reset(s);
|
||||
|
||||
zserv_create_header(s, ZEBRA_LABEL_MANAGER_CONNECT, vrf_id);
|
||||
zclient_create_header(s, ZEBRA_LABEL_MANAGER_CONNECT, vrf_id);
|
||||
|
||||
/* result */
|
||||
stream_putc(s, result);
|
||||
@ -2151,7 +2141,7 @@ static int zsend_assign_label_chunk_response(struct zserv *client,
|
||||
s = client->obuf;
|
||||
stream_reset(s);
|
||||
|
||||
zserv_create_header(s, ZEBRA_GET_LABEL_CHUNK, vrf_id);
|
||||
zclient_create_header(s, ZEBRA_GET_LABEL_CHUNK, vrf_id);
|
||||
|
||||
if (lmc) {
|
||||
/* keep */
|
||||
|
@ -177,8 +177,6 @@ extern int zsend_route_notify_owner(u_char proto, u_short instance,
|
||||
vrf_id_t vrf_id, struct prefix *p,
|
||||
enum zapi_route_notify_owner note);
|
||||
|
||||
extern void zserv_create_header(struct stream *s, uint16_t cmd,
|
||||
vrf_id_t vrf_id);
|
||||
extern void zserv_nexthop_num_warn(const char *, const struct prefix *,
|
||||
const unsigned int);
|
||||
extern int zebra_server_send_message(struct zserv *client);
|
||||
|
Loading…
Reference in New Issue
Block a user