]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: use const in dplane pw nhlfe accessors 3893/head
authorMark Stapp <mjs@voltanet.io>
Thu, 7 Mar 2019 18:09:51 +0000 (13:09 -0500)
committerMark Stapp <mjs@voltanet.io>
Thu, 7 Mar 2019 20:06:36 +0000 (15:06 -0500)
Use const in the accessors for pseudowire nhlfe data; pull
that through the kernel-facing apis that use that data.

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

index 9cea1d3c79891ebe58819de4b29a4d54bb0f34ec..2ba1f890716d5e9d6c7e4259c06fb0e0f39a7a1e 100644 (file)
@@ -927,7 +927,7 @@ static void _netlink_route_nl_add_gateway_info(uint8_t route_family,
                                               uint8_t gw_family,
                                               struct nlmsghdr *nlmsg,
                                               size_t req_size, int bytelen,
-                                              struct nexthop *nexthop)
+                                              const struct nexthop *nexthop)
 {
        if (route_family == AF_MPLS) {
                struct gw_family_t gw_fam;
@@ -954,7 +954,7 @@ static void _netlink_route_rta_add_gateway_info(uint8_t route_family,
                                                struct rtattr *rta,
                                                struct rtnexthop *rtnh,
                                                size_t req_size, int bytelen,
-                                               struct nexthop *nexthop)
+                                               const struct nexthop *nexthop)
 {
        if (route_family == AF_MPLS) {
                struct gw_family_t gw_fam;
@@ -990,7 +990,7 @@ static void _netlink_route_rta_add_gateway_info(uint8_t route_family,
  * @param req_size: The size allocated for the message.
  */
 static void _netlink_route_build_singlepath(const char *routedesc, int bytelen,
-                                           struct nexthop *nexthop,
+                                           const struct nexthop *nexthop,
                                            struct nlmsghdr *nlmsg,
                                            struct rtmsg *rtmsg,
                                            size_t req_size, int cmd)
@@ -1009,7 +1009,7 @@ static void _netlink_route_build_singlepath(const char *routedesc, int bytelen,
        label_buf[0] = '\0';
 
        assert(nexthop);
-       for (struct nexthop *nh = nexthop; nh; nh = nh->rparent) {
+       for (const struct nexthop *nh = nexthop; nh; nh = nh->rparent) {
                char label_buf1[20];
 
                nh_label = nh->nh_label;
@@ -1175,11 +1175,11 @@ static void _netlink_route_build_singlepath(const char *routedesc, int bytelen,
  *             the prefsrc should be stored.
  */
 static void _netlink_route_build_multipath(const char *routedesc, int bytelen,
-                                          struct nexthop *nexthop,
+                                          const struct nexthop *nexthop,
                                           struct rtattr *rta,
                                           struct rtnexthop *rtnh,
                                           struct rtmsg *rtmsg,
-                                          union g_addr **src)
+                                          const union g_addr **src)
 {
        struct mpls_label_stack *nh_label;
        mpls_lse_t out_lse[MPLS_MAX_LABELS];
@@ -1200,7 +1200,7 @@ static void _netlink_route_build_multipath(const char *routedesc, int bytelen,
        label_buf[0] = '\0';
 
        assert(nexthop);
-       for (struct nexthop *nh = nexthop; nh; nh = nh->rparent) {
+       for (const struct nexthop *nh = nexthop; nh; nh = nh->rparent) {
                char label_buf1[20];
 
                nh_label = nh->nh_label;
@@ -1342,7 +1342,7 @@ static void _netlink_route_build_multipath(const char *routedesc, int bytelen,
 }
 
 static inline void _netlink_mpls_build_singlepath(const char *routedesc,
-                                                 zebra_nhlfe_t *nhlfe,
+                                                 const zebra_nhlfe_t *nhlfe,
                                                  struct nlmsghdr *nlmsg,
                                                  struct rtmsg *rtmsg,
                                                  size_t req_size, int cmd)
@@ -1358,9 +1358,9 @@ static inline void _netlink_mpls_build_singlepath(const char *routedesc,
 
 
 static inline void
-_netlink_mpls_build_multipath(const char *routedesc, zebra_nhlfe_t *nhlfe,
+_netlink_mpls_build_multipath(const char *routedesc, const zebra_nhlfe_t *nhlfe,
                              struct rtattr *rta, struct rtnexthop *rtnh,
-                             struct rtmsg *rtmsg, union g_addr **src)
+                             struct rtmsg *rtmsg, const union g_addr **src)
 {
        int bytelen;
        uint8_t family;
@@ -1655,7 +1655,7 @@ static int netlink_route_multipath(int cmd, struct zebra_dplane_ctx *ctx)
                char buf[NL_PKT_BUF_SIZE];
                struct rtattr *rta = (void *)buf;
                struct rtnexthop *rtnh;
-               union g_addr *src1 = NULL;
+               const union g_addr *src1 = NULL;
 
                rta->rta_type = RTA_MULTIPATH;
                rta->rta_len = RTA_LENGTH(0);
@@ -2744,7 +2744,7 @@ int kernel_upd_neigh(struct interface *ifp, struct ipaddr *ip,
 int netlink_mpls_multipath(int cmd, struct zebra_dplane_ctx *ctx)
 {
        mpls_lse_t lse;
-       zebra_nhlfe_t *nhlfe;
+       const zebra_nhlfe_t *nhlfe;
        struct nexthop *nexthop = NULL;
        unsigned int nexthop_num;
        const char *routedesc;
@@ -2847,7 +2847,7 @@ int netlink_mpls_multipath(int cmd, struct zebra_dplane_ctx *ctx)
                char buf[NL_PKT_BUF_SIZE];
                struct rtattr *rta = (void *)buf;
                struct rtnexthop *rtnh;
-               union g_addr *src1 = NULL;
+               const union g_addr *src1 = NULL;
 
                rta->rta_type = RTA_MULTIPATH;
                rta->rta_len = RTA_LENGTH(0);
index e4bc3a85a8c4145ddce267fff53d23a75cb70b8e..df26a8534cc95f6a67567806f043f170a07f7568 100644 (file)
@@ -756,14 +756,15 @@ uint32_t dplane_ctx_get_lsp_flags(const struct zebra_dplane_ctx *ctx)
        return ctx->u.lsp.flags;
 }
 
-zebra_nhlfe_t *dplane_ctx_get_nhlfe(struct zebra_dplane_ctx *ctx)
+const zebra_nhlfe_t *dplane_ctx_get_nhlfe(const struct zebra_dplane_ctx *ctx)
 {
        DPLANE_CTX_VALID(ctx);
 
        return ctx->u.lsp.nhlfe_list;
 }
 
-zebra_nhlfe_t *dplane_ctx_get_best_nhlfe(struct zebra_dplane_ctx *ctx)
+const zebra_nhlfe_t *
+dplane_ctx_get_best_nhlfe(const struct zebra_dplane_ctx *ctx)
 {
        DPLANE_CTX_VALID(ctx);
 
index 4cd8031d730086c88bd55fc8f475ab7628b8318f..149ff8dc607947fb4b225aa4a5d0e18fd9580900 100644 (file)
@@ -203,8 +203,9 @@ const struct nexthop_group *dplane_ctx_get_old_ng(
 mpls_label_t dplane_ctx_get_in_label(const struct zebra_dplane_ctx *ctx);
 uint8_t dplane_ctx_get_addr_family(const struct zebra_dplane_ctx *ctx);
 uint32_t dplane_ctx_get_lsp_flags(const struct zebra_dplane_ctx *ctx);
-zebra_nhlfe_t *dplane_ctx_get_nhlfe(struct zebra_dplane_ctx *ctx);
-zebra_nhlfe_t *dplane_ctx_get_best_nhlfe(struct zebra_dplane_ctx *ctx);
+const zebra_nhlfe_t *dplane_ctx_get_nhlfe(const struct zebra_dplane_ctx *ctx);
+const zebra_nhlfe_t *dplane_ctx_get_best_nhlfe(
+       const struct zebra_dplane_ctx *ctx);
 uint32_t dplane_ctx_get_lsp_num_ecmp(const struct zebra_dplane_ctx *ctx);
 
 /* Accessors for pseudowire information */
index 12ec84b92fe2d9997a0a889a2e0300e94087eaa6..977a8eaf3c7711d7a3c9b464f1d70c909d33cbc7 100644 (file)
@@ -43,7 +43,7 @@ struct {
 } kr_state;
 
 static int kernel_send_rtmsg_v4(int action, mpls_label_t in_label,
-                               zebra_nhlfe_t *nhlfe)
+                               const zebra_nhlfe_t *nhlfe)
 {
        struct iovec iov[5];
        struct rt_msghdr hdr;
@@ -135,7 +135,7 @@ static int kernel_send_rtmsg_v4(int action, mpls_label_t in_label,
 #endif
 
 static int kernel_send_rtmsg_v6(int action, mpls_label_t in_label,
-                               zebra_nhlfe_t *nhlfe)
+                               const zebra_nhlfe_t *nhlfe)
 {
        struct iovec iov[5];
        struct rt_msghdr hdr;
@@ -238,7 +238,7 @@ static int kernel_send_rtmsg_v6(int action, mpls_label_t in_label,
 
 static int kernel_lsp_cmd(struct zebra_dplane_ctx *ctx)
 {
-       zebra_nhlfe_t *nhlfe;
+       const zebra_nhlfe_t *nhlfe;
        struct nexthop *nexthop = NULL;
        unsigned int nexthop_num = 0;
        int action;