]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: dplane pseudowires including nexthop info
authorMark Stapp <mjs@voltanet.io>
Fri, 1 Mar 2019 18:33:17 +0000 (13:33 -0500)
committerMark Stapp <mjs@voltanet.io>
Thu, 7 Mar 2019 20:06:36 +0000 (15:06 -0500)
Add nexthop info to the data that the zebra dataplane captures
when programming pseudowires.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
zebra/zebra_dplane.c
zebra/zebra_dplane.h

index 63ac7666f4a44c02aa6ad4ff81c0bf5dcb301f84..e4bc3a85a8c4145ddce267fff53d23a75cb70b8e 100644 (file)
@@ -842,6 +842,14 @@ const union pw_protocol_fields *dplane_ctx_get_pw_proto(
        return &(ctx->u.pw.fields);
 }
 
+const struct nexthop_group *
+dplane_ctx_get_pw_nhg(const struct zebra_dplane_ctx *ctx)
+{
+       DPLANE_CTX_VALID(ctx);
+
+       return &(ctx->u.pw.nhg);
+}
+
 /*
  * End of dplane context accessors
  */
@@ -1051,6 +1059,12 @@ static int dplane_ctx_pw_init(struct zebra_dplane_ctx *ctx,
                              enum dplane_op_e op,
                              struct zebra_pw *pw)
 {
+       struct prefix p;
+       afi_t afi;
+       struct route_table *table;
+       struct route_node *rn;
+       struct route_entry *re;
+
        if (IS_ZEBRA_DEBUG_DPLANE_DETAIL)
                zlog_debug("init dplane ctx %s: pw '%s', loc %u, rem %u",
                           dplane_op2str(op), pw->ifname, pw->local_label,
@@ -1081,6 +1095,33 @@ static int dplane_ctx_pw_init(struct zebra_dplane_ctx *ctx,
 
        ctx->u.pw.fields = pw->data;
 
+       /* Capture nexthop info for the pw destination. We need to look
+        * up and use zebra datastructs, but we're running in the zebra
+        * pthread here so that should be ok.
+        */
+       memcpy(&p.u, &pw->nexthop, sizeof(pw->nexthop));
+       p.family = pw->af;
+       p.prefixlen = ((pw->af == AF_INET) ?
+                      IPV4_MAX_PREFIXLEN : IPV6_MAX_PREFIXLEN);
+
+       afi = (pw->af == AF_INET) ? AFI_IP : AFI_IP6;
+       table = zebra_vrf_table(afi, SAFI_UNICAST, pw->vrf_id);
+       if (table) {
+               rn = route_node_match(table, &p);
+               if (rn) {
+                       RNODE_FOREACH_RE(rn, re) {
+                               if (CHECK_FLAG(re->flags, ZEBRA_FLAG_SELECTED))
+                                       break;
+                       }
+
+                       if (re)
+                               copy_nexthops(&(ctx->u.pw.nhg.nexthop),
+                                             re->ng.nexthop, NULL);
+
+                       route_unlock_node(rn);
+               }
+       }
+
        return AOK;
 }
 
index 84da20f2a7dabde1dbe787b0fdd6f297c044efe6..4cd8031d730086c88bd55fc8f475ab7628b8318f 100644 (file)
@@ -219,6 +219,8 @@ const union g_addr *dplane_ctx_get_pw_dest(
        const struct zebra_dplane_ctx *ctx);
 const union pw_protocol_fields *dplane_ctx_get_pw_proto(
        const struct zebra_dplane_ctx *ctx);
+const struct nexthop_group *dplane_ctx_get_pw_nhg(
+       const struct zebra_dplane_ctx *ctx);
 
 /* Namespace info - esp. for netlink communication */
 const struct zebra_dplane_info *dplane_ctx_get_ns(