]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: consolidate dataplane interface name and ifindex attrs
authorMark Stapp <mjs@voltanet.io>
Thu, 25 Jul 2019 18:01:22 +0000 (14:01 -0400)
committerMark Stapp <mjs@voltanet.io>
Thu, 25 Jul 2019 18:01:22 +0000 (14:01 -0400)
Move interface name and index to shared data struct, and remove
operation-specific values.

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

index f93562b31b53a2263dc11d05b2455dc073b7efb5..930141ba5401a20d1b9322fd06e50772f7c29de4 100644 (file)
@@ -109,8 +109,6 @@ struct dplane_route_info {
  * Pseudowire info for the dataplane
  */
 struct dplane_pw_info {
-       char ifname[IF_NAMESIZE];
-       ifindex_t ifindex;
        int type;
        int af;
        int status;
@@ -130,9 +128,6 @@ struct dplane_pw_info {
  */
 struct dplane_intf_info {
 
-       char ifname[INTERFACE_NAMSIZ];
-       ifindex_t ifindex;
-
        uint32_t metric;
        uint32_t flags;
 
@@ -188,6 +183,9 @@ struct zebra_dplane_ctx {
        vrf_id_t zd_vrf_id;
        uint32_t zd_table_id;
 
+       char zd_ifname[INTERFACE_NAMSIZ];
+       ifindex_t zd_ifindex;
+
        /* Support info for different kinds of updates */
        union {
                struct dplane_route_info rinfo;
@@ -744,6 +742,19 @@ void dplane_ctx_set_notif_provider(struct zebra_dplane_ctx *ctx,
 
        ctx->zd_notif_provider = id;
 }
+const char *dplane_ctx_get_ifname(const struct zebra_dplane_ctx *ctx)
+{
+       DPLANE_CTX_VALID(ctx);
+
+       return ctx->zd_ifname;
+}
+
+ifindex_t dplane_ctx_get_ifindex(const struct zebra_dplane_ctx *ctx)
+{
+       DPLANE_CTX_VALID(ctx);
+
+       return ctx->zd_ifindex;
+}
 
 void dplane_ctx_set_type(struct zebra_dplane_ctx *ctx, int type)
 {
@@ -1030,13 +1041,6 @@ uint32_t dplane_ctx_get_lsp_num_ecmp(const struct zebra_dplane_ctx *ctx)
        return ctx->u.lsp.num_ecmp;
 }
 
-const char *dplane_ctx_get_pw_ifname(const struct zebra_dplane_ctx *ctx)
-{
-       DPLANE_CTX_VALID(ctx);
-
-       return ctx->u.pw.ifname;
-}
-
 mpls_label_t dplane_ctx_get_pw_local_label(const struct zebra_dplane_ctx *ctx)
 {
        DPLANE_CTX_VALID(ctx);
@@ -1104,20 +1108,6 @@ dplane_ctx_get_pw_nhg(const struct zebra_dplane_ctx *ctx)
 }
 
 /* Accessors for interface information */
-const char *dplane_ctx_get_ifname(const struct zebra_dplane_ctx *ctx)
-{
-       DPLANE_CTX_VALID(ctx);
-
-       return ctx->u.intf.ifname;
-}
-
-ifindex_t dplane_ctx_get_ifindex(const struct zebra_dplane_ctx *ctx)
-{
-       DPLANE_CTX_VALID(ctx);
-
-       return ctx->u.intf.ifindex;
-}
-
 uint32_t dplane_ctx_get_intf_metric(const struct zebra_dplane_ctx *ctx)
 {
        DPLANE_CTX_VALID(ctx);
@@ -1422,10 +1412,10 @@ static int dplane_ctx_pw_init(struct zebra_dplane_ctx *ctx,
        memset(&ctx->u.pw, 0, sizeof(ctx->u.pw));
 
        /* This name appears to be c-string, so we use string copy. */
-       strlcpy(ctx->u.pw.ifname, pw->ifname, sizeof(ctx->u.pw.ifname));
+       strlcpy(ctx->zd_ifname, pw->ifname, sizeof(ctx->zd_ifname));
 
        ctx->zd_vrf_id = pw->vrf_id;
-       ctx->u.pw.ifindex = pw->ifindex;
+       ctx->zd_ifindex = pw->ifindex;
        ctx->u.pw.type = pw->type;
        ctx->u.pw.af = pw->af;
        ctx->u.pw.local_label = pw->local_label;
@@ -1967,8 +1957,8 @@ static enum zebra_dplane_result intf_addr_update_internal(
        /* Init the interface-addr-specific area */
        memset(&ctx->u.intf, 0, sizeof(ctx->u.intf));
 
-       strlcpy(ctx->u.intf.ifname, ifp->name, sizeof(ctx->u.intf.ifname));
-       ctx->u.intf.ifindex = ifp->ifindex;
+       strlcpy(ctx->zd_ifname, ifp->name, sizeof(ctx->zd_ifname));
+       ctx->zd_ifindex = ifp->ifindex;
        ctx->u.intf.prefix = *(ifc->address);
 
        if (if_is_broadcast(ifp))
@@ -2374,7 +2364,7 @@ kernel_dplane_pw_update(struct zebra_dplane_ctx *ctx)
 
        if (IS_ZEBRA_DEBUG_DPLANE_DETAIL)
                zlog_debug("Dplane pw %s: op %s af %d loc: %u rem: %u",
-                          dplane_ctx_get_pw_ifname(ctx),
+                          dplane_ctx_get_ifname(ctx),
                           dplane_op2str(ctx->zd_op),
                           dplane_ctx_get_pw_af(ctx),
                           dplane_ctx_get_pw_local_label(ctx),
index 6238026bcfcf542979da3a9695fd9b957426918c..01a23b08817041b807c9b0b2b522e92c20ab66f6 100644 (file)
@@ -180,6 +180,8 @@ const char *dplane_op2str(enum dplane_op_e op);
 const struct prefix *dplane_ctx_get_dest(const struct zebra_dplane_ctx *ctx);
 void dplane_ctx_set_dest(struct zebra_dplane_ctx *ctx,
                         const struct prefix *dest);
+const char *dplane_ctx_get_ifname(const struct zebra_dplane_ctx *ctx);
+ifindex_t dplane_ctx_get_ifindex(const struct zebra_dplane_ctx *ctx);
 
 /* Retrieve last/current provider id */
 uint32_t dplane_ctx_get_provider(const struct zebra_dplane_ctx *ctx);
@@ -262,7 +264,6 @@ const zebra_nhlfe_t *dplane_ctx_set_best_nhlfe(struct zebra_dplane_ctx *ctx,
 uint32_t dplane_ctx_get_lsp_num_ecmp(const struct zebra_dplane_ctx *ctx);
 
 /* Accessors for pseudowire information */
-const char *dplane_ctx_get_pw_ifname(const struct zebra_dplane_ctx *ctx);
 mpls_label_t dplane_ctx_get_pw_local_label(const struct zebra_dplane_ctx *ctx);
 mpls_label_t dplane_ctx_get_pw_remote_label(const struct zebra_dplane_ctx *ctx);
 int dplane_ctx_get_pw_type(const struct zebra_dplane_ctx *ctx);
@@ -277,8 +278,6 @@ const struct nexthop_group *dplane_ctx_get_pw_nhg(
        const struct zebra_dplane_ctx *ctx);
 
 /* Accessors for interface information */
-const char *dplane_ctx_get_ifname(const struct zebra_dplane_ctx *ctx);
-ifindex_t dplane_ctx_get_ifindex(const struct zebra_dplane_ctx *ctx);
 uint32_t dplane_ctx_get_intf_metric(const struct zebra_dplane_ctx *ctx);
 /* Is interface addr p2p? */
 bool dplane_ctx_intf_is_connected(const struct zebra_dplane_ctx *ctx);
index e7fdaf127d38ad30368f585edeb1083781db0198..9f3ea70c77aa5b4035889584e9872df4cc3edc65 100644 (file)
@@ -369,7 +369,7 @@ static enum zebra_dplane_result kmpw_install(struct zebra_dplane_ctx *ctx)
 
        /* ioctl */
        memset(&ifr, 0, sizeof(ifr));
-       strlcpy(ifr.ifr_name, dplane_ctx_get_pw_ifname(ctx),
+       strlcpy(ifr.ifr_name, dplane_ctx_get_ifname(ctx),
                sizeof(ifr.ifr_name));
        ifr.ifr_data = (caddr_t)&imr;
        if (ioctl(kr_state.ioctl_fd, SIOCSETMPWCFG, &ifr) == -1) {
@@ -388,7 +388,7 @@ static enum zebra_dplane_result kmpw_uninstall(struct zebra_dplane_ctx *ctx)
 
        memset(&ifr, 0, sizeof(ifr));
        memset(&imr, 0, sizeof(imr));
-       strlcpy(ifr.ifr_name, dplane_ctx_get_pw_ifname(ctx),
+       strlcpy(ifr.ifr_name, dplane_ctx_get_ifname(ctx),
                sizeof(ifr.ifr_name));
        ifr.ifr_data = (caddr_t)&imr;
        if (ioctl(kr_state.ioctl_fd, SIOCSETMPWCFG, &ifr) == -1) {
index afe59b95933483f081ed831abf76203b6e5d078b..601970785ea0afa4de963eadee3cd55c59923b9a 100644 (file)
@@ -3220,7 +3220,7 @@ static int handle_pw_result(struct zebra_dplane_ctx *ctx)
 
        if (dplane_ctx_get_status(ctx) != ZEBRA_DPLANE_REQUEST_SUCCESS) {
                vrf = zebra_vrf_lookup_by_id(dplane_ctx_get_vrf(ctx));
-               pw = zebra_pw_find(vrf, dplane_ctx_get_pw_ifname(ctx));
+               pw = zebra_pw_find(vrf, dplane_ctx_get_ifname(ctx));
                if (pw)
                        zebra_pw_install_failure(pw);
        }