summaryrefslogtreecommitdiffstats
path: root/ospfd/ospf_sr.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2019-08-08 02:06:03 +0200
committerRenato Westphal <renato@opensourcerouting.org>2019-09-07 02:06:11 +0200
commitbad6b0e72ea5730031b7851ee6c8e422cbb1f270 (patch)
treedb3eaf1a8e36efa4f23248b6468cc04ad1e22f60 /ospfd/ospf_sr.c
parentMerge pull request #4937 from mjstapp/fix_evpn_brif (diff)
downloadfrr-bad6b0e72ea5730031b7851ee6c8e422cbb1f270.tar.xz
frr-bad6b0e72ea5730031b7851ee6c8e422cbb1f270.zip
lib: introduce encode/decode functions for the MPLS zapi messages
Do this for the following reasons: * Improve modularity of the code by separating the decoding of the ZAPI messages from their processing; * Create an API that is easier to use by the client daemons. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'ospfd/ospf_sr.c')
-rw-r--r--ospfd/ospf_sr.c33
1 files changed, 12 insertions, 21 deletions
diff --git a/ospfd/ospf_sr.c b/ospfd/ospf_sr.c
index 6947393a6..a361d1781 100644
--- a/ospfd/ospf_sr.c
+++ b/ospfd/ospf_sr.c
@@ -608,26 +608,7 @@ static int compute_prefix_nhlfe(struct sr_prefix *srp)
/* Send MPLS Label entry to Zebra for installation or deletion */
static int ospf_zebra_send_mpls_labels(int cmd, struct sr_nhlfe nhlfe)
{
- struct stream *s;
-
- /* Reset stream. */
- s = zclient->obuf;
- stream_reset(s);
-
- zclient_create_header(s, cmd, VRF_DEFAULT);
- stream_putc(s, ZEBRA_LSP_SR);
- /* OSPF Segment Routing currently support only IPv4 */
- stream_putl(s, nhlfe.prefv4.family);
- stream_put_in_addr(s, &nhlfe.prefv4.prefix);
- stream_putc(s, nhlfe.prefv4.prefixlen);
- stream_put_in_addr(s, &nhlfe.nexthop);
- stream_putl(s, nhlfe.ifindex);
- stream_putc(s, OSPF_SR_PRIORITY_DEFAULT);
- stream_putl(s, nhlfe.label_in);
- stream_putl(s, nhlfe.label_out);
-
- /* Put length at the first point of the stream. */
- stream_putw_at(s, 0, stream_get_endp(s));
+ struct zapi_labels zl = {};
if (IS_DEBUG_OSPF_SR)
zlog_debug(" |- %s LSP %u/%u for %s/%u via %u",
@@ -636,7 +617,17 @@ static int ospf_zebra_send_mpls_labels(int cmd, struct sr_nhlfe nhlfe)
inet_ntoa(nhlfe.prefv4.prefix),
nhlfe.prefv4.prefixlen, nhlfe.ifindex);
- return zclient_send_message(zclient);
+ zl.type = ZEBRA_LSP_SR;
+ zl.prefix.family = nhlfe.prefv4.family;
+ zl.prefix.prefixlen = nhlfe.prefv4.prefixlen;
+ zl.prefix.u.prefix4 = nhlfe.prefv4.prefix;
+ zl.nexthop.ipv4 = nhlfe.nexthop;
+ zl.ifindex = nhlfe.ifindex;
+ zl.distance = OSPF_SR_PRIORITY_DEFAULT;
+ zl.local_label = nhlfe.label_in;
+ zl.remote_label = nhlfe.label_out;
+
+ return zebra_send_mpls_labels(zclient, cmd, &zl);
}
/* Request zebra to install/remove FEC in FIB */