]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: remove old kernel one-update-at-a-time api
authorJakub Urbańczyk <xthaid@gmail.com>
Thu, 30 Jul 2020 22:15:51 +0000 (00:15 +0200)
committerJakub Urbańczyk <xthaid@gmail.com>
Mon, 10 Aug 2020 19:57:04 +0000 (21:57 +0200)
The old one is replaced by the api that is suitable for the batching.

Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
zebra/if_netlink.c
zebra/kernel_netlink.c
zebra/kernel_socket.c
zebra/rt.h
zebra/rt_netlink.c
zebra/rule_netlink.c
zebra/zebra_dplane.c
zebra/zebra_mpls_netlink.c
zebra/zebra_pbr.h

index ce04b3e04dc2b9cce576abc0124515ef56634b5b..5cd3e69299ca48f2ae8af0b11cac16281363fd9d 100644 (file)
@@ -1058,15 +1058,6 @@ static ssize_t netlink_address_msg_encoder(struct zebra_dplane_ctx *ctx,
        return NLMSG_ALIGN(req->n.nlmsg_len);
 }
 
-/*
- * The communication with the kernel is done using the message batching
- * interface, so return a failure.
- */
-enum zebra_dplane_result kernel_address_update_ctx(struct zebra_dplane_ctx *ctx)
-{
-       return ZEBRA_DPLANE_REQUEST_FAILURE;
-}
-
 enum netlink_msg_status
 netlink_put_address_update_msg(struct nl_batch *bth,
                               struct zebra_dplane_ctx *ctx)
index cd8d3c095c9a38f53980344b188fc5671e2cc203..2ce48b33ef541682a0938ba93438646dddf0a064 100644 (file)
@@ -1429,11 +1429,6 @@ void kernel_update_multi(struct dplane_ctx_q *ctx_list)
        dplane_ctx_list_append(ctx_list, &handled_list);
 }
 
-bool kernel_supports_batch(void)
-{
-       return true;
-}
-
 /* Exported interface function.  This function simply calls
    netlink_socket (). */
 void kernel_init(struct zebra_ns *zns)
index 896926bcbe7d25d27e39b05a84a252f7d29b5488..9e56e2988dddf292c77fdbc2b2fd5c540e9759db 100644 (file)
@@ -1466,12 +1466,96 @@ void kernel_terminate(struct zebra_ns *zns, bool complete)
 
 void kernel_update_multi(struct dplane_ctx_q *ctx_list)
 {
-       /* no-op */
-}
+       struct zebra_dplane_ctx *ctx;
+       struct dplane_ctx_q handled_list;
+       enum zebra_dplane_result res;
 
-bool kernel_supports_batch(void)
-{
-       return false;
+       TAILQ_INIT(&handled_list);
+
+       while (true) {
+               ctx = dplane_ctx_dequeue(ctx_list);
+               if (ctx == NULL)
+                       break;
+
+               /*
+                * A previous provider plugin may have asked to skip the
+                * kernel update.
+                */
+               if (dplane_ctx_is_skip_kernel(ctx)) {
+                       res = ZEBRA_DPLANE_REQUEST_SUCCESS;
+                       goto skip_one;
+               }
+
+               switch (dplane_ctx_get_op(ctx)) {
+
+               case DPLANE_OP_ROUTE_INSTALL:
+               case DPLANE_OP_ROUTE_UPDATE:
+               case DPLANE_OP_ROUTE_DELETE:
+                       res = kernel_route_update(ctx);
+                       break;
+
+               case DPLANE_OP_NH_INSTALL:
+               case DPLANE_OP_NH_UPDATE:
+               case DPLANE_OP_NH_DELETE:
+                       res = kernel_nexthop_update(ctx);
+                       break;
+
+               case DPLANE_OP_LSP_INSTALL:
+               case DPLANE_OP_LSP_UPDATE:
+               case DPLANE_OP_LSP_DELETE:
+                       res = kernel_lsp_update(ctx);
+                       break;
+
+               case DPLANE_OP_PW_INSTALL:
+               case DPLANE_OP_PW_UNINSTALL:
+                       res = kernel_pw_update(ctx);
+                       break;
+
+               case DPLANE_OP_ADDR_INSTALL:
+               case DPLANE_OP_ADDR_UNINSTALL:
+                       res = kernel_address_update_ctx(ctx);
+                       break;
+
+               case DPLANE_OP_MAC_INSTALL:
+               case DPLANE_OP_MAC_DELETE:
+                       res = kernel_mac_update_ctx(ctx);
+                       break;
+
+               case DPLANE_OP_NEIGH_INSTALL:
+               case DPLANE_OP_NEIGH_UPDATE:
+               case DPLANE_OP_NEIGH_DELETE:
+               case DPLANE_OP_VTEP_ADD:
+               case DPLANE_OP_VTEP_DELETE:
+                       res = kernel_neigh_update_ctx(ctx);
+                       break;
+
+               case DPLANE_OP_RULE_ADD:
+               case DPLANE_OP_RULE_DELETE:
+               case DPLANE_OP_RULE_UPDATE:
+                       res = kernel_pbr_rule_update(ctx);
+                       break;
+
+               /* Ignore 'notifications' - no-op */
+               case DPLANE_OP_SYS_ROUTE_ADD:
+               case DPLANE_OP_SYS_ROUTE_DELETE:
+               case DPLANE_OP_ROUTE_NOTIFY:
+               case DPLANE_OP_LSP_NOTIFY:
+                       res = ZEBRA_DPLANE_REQUEST_SUCCESS;
+                       break;
+
+               default:
+                       res = ZEBRA_DPLANE_REQUEST_FAILURE;
+                       break;
+               }
+
+       skip_one:
+               dplane_ctx_set_status(ctx, res);
+
+               dplane_ctx_enqueue_tail(&handled_list, ctx);
+       }
+
+       TAILQ_INIT(ctx_list);
+       dplane_ctx_list_append(ctx_list, &handled_list);
 }
 
 #endif /* !HAVE_NETLINK */
index c0ff2e22b332670534e281c1d1a2c1c7eb6f6bf4..48f1df28685ef419d6980282f87a0b4473d79846 100644 (file)
@@ -40,7 +40,7 @@ extern "C" {
 #define RSYSTEM_ROUTE(type)                                                    \
        ((RKERNEL_ROUTE(type)) || (type) == ZEBRA_ROUTE_CONNECT)
 
-
+#ifndef HAVE_NETLINK
 /*
  * Update or delete a route, nexthop, LSP, pseudowire, or vxlan MAC from the
  * kernel, using info from a dataplane context.
@@ -63,6 +63,11 @@ enum zebra_dplane_result kernel_mac_update_ctx(struct zebra_dplane_ctx *ctx);
 
 enum zebra_dplane_result kernel_neigh_update_ctx(struct zebra_dplane_ctx *ctx);
 
+extern enum zebra_dplane_result
+kernel_pbr_rule_update(struct zebra_dplane_ctx *ctx);
+
+#endif /* !HAVE_NETLINK */
+
 extern int kernel_neigh_update(int cmd, int ifindex, uint32_t addr, char *lla,
                               int llalen, ns_id_t ns_id);
 extern int kernel_interface_set_master(struct interface *master,
@@ -101,7 +106,6 @@ extern int kernel_del_mac_nhg(uint32_t nhg_id);
  * Message batching interface.
  */
 extern void kernel_update_multi(struct dplane_ctx_q *ctx_list);
-extern bool kernel_supports_batch(void);
 
 #ifdef __cplusplus
 }
index 2f1f2c4bc9b4ebfed64da7819cf16857e94aa87c..190af3f59d9795991267837bf0e994576aba013f 100644 (file)
@@ -2251,15 +2251,6 @@ static ssize_t netlink_nexthop_msg_encoder(struct zebra_dplane_ctx *ctx,
        return netlink_nexthop_msg_encode(cmd, ctx, buf, buflen);
 }
 
-/*
- * The communication with the kernel is done using the message batching
- * interface, so return a failure.
- */
-enum zebra_dplane_result kernel_nexthop_update(struct zebra_dplane_ctx *ctx)
-{
-       return ZEBRA_DPLANE_REQUEST_FAILURE;
-}
-
 enum netlink_msg_status
 netlink_put_nexthop_update_msg(struct nl_batch *bth,
                               struct zebra_dplane_ctx *ctx)
@@ -2347,15 +2338,6 @@ netlink_put_route_update_msg(struct nl_batch *bth, struct zebra_dplane_ctx *ctx)
                                     false);
 }
 
-/*
- * The communication with the kernel is done using the message batching
- * interface, so return a failure.
- */
-enum zebra_dplane_result kernel_route_update(struct zebra_dplane_ctx *ctx)
-{
-       return ZEBRA_DPLANE_REQUEST_FAILURE;
-}
-
 /**
  * netlink_nexthop_process_nh() - Parse the gatway/if info from a new nexthop
  *
@@ -2777,9 +2759,8 @@ netlink_vxlan_flood_update_ctx(const struct zebra_dplane_ctx *ctx, int cmd,
 
        return netlink_neigh_update_msg_encode(
                ctx, cmd, &dst_mac, dplane_ctx_neigh_get_ipaddr(ctx), false,
-               PF_BRIDGE, 0, NTF_SELF, (NUD_NOARP | NUD_PERMANENT),
-               0 /*nhg*/, false /*nfy*/, 0 /*nfy_flags*/, 
-               buf, buflen);
+               PF_BRIDGE, 0, NTF_SELF, (NUD_NOARP | NUD_PERMANENT), 0 /*nhg*/,
+               false /*nfy*/, 0 /*nfy_flags*/, buf, buflen);
 }
 
 #ifndef NDA_RTA
@@ -3637,11 +3618,9 @@ static ssize_t netlink_neigh_update_ctx(const struct zebra_dplane_ctx *ctx,
                        flags, state);
        }
 
-       return netlink_neigh_update_msg_encode(ctx, cmd, mac, ip, true, family,
-                                              RTN_UNICAST, flags, state,
-                                                  0 /*nhg*/, false /*nfy*/, 0 /*nfy_flags*/,
-                                               buf,
-                                          buflen);
+       return netlink_neigh_update_msg_encode(
+               ctx, cmd, mac, ip, true, family, RTN_UNICAST, flags, state,
+               0 /*nhg*/, false /*nfy*/, 0 /*nfy_flags*/, buf, buflen);
 }
 
 static ssize_t netlink_neigh_msg_encoder(struct zebra_dplane_ctx *ctx,
@@ -3676,15 +3655,6 @@ static ssize_t netlink_neigh_msg_encoder(struct zebra_dplane_ctx *ctx,
  * Update MAC, using dataplane context object.
  */
 
-/*
- * The communication with the kernel is done using the message batching
- * interface, so return a failure.
- */
-enum zebra_dplane_result kernel_mac_update_ctx(struct zebra_dplane_ctx *ctx)
-{
-       return ZEBRA_DPLANE_REQUEST_FAILURE;
-}
-
 enum netlink_msg_status netlink_put_mac_update_msg(struct nl_batch *bth,
                                                   struct zebra_dplane_ctx *ctx)
 {
@@ -3692,15 +3662,6 @@ enum netlink_msg_status netlink_put_mac_update_msg(struct nl_batch *bth,
                                     false);
 }
 
-/*
- * The communication with the kernel is done using the message batching
- * interface, so return a failure.
- */
-enum zebra_dplane_result kernel_neigh_update_ctx(struct zebra_dplane_ctx *ctx)
-{
-       return ZEBRA_DPLANE_REQUEST_FAILURE;
-}
-
 enum netlink_msg_status
 netlink_put_neigh_update_msg(struct nl_batch *bth, struct zebra_dplane_ctx *ctx)
 {
index 9f9ea27748030fa8647828dde492ca95d6b7e2aa..3a3baab4ca34a651c6f3133ec0b684a3583025be 100644 (file)
@@ -182,15 +182,6 @@ static ssize_t netlink_oldrule_msg_encoder(struct zebra_dplane_ctx *ctx,
 
 /* Public functions */
 
-/*
- * The communication with the kernel is done using the message batching
- * interface, so return a failure.
- */
-enum zebra_dplane_result kernel_pbr_rule_update(struct zebra_dplane_ctx *ctx)
-{
-       return ZEBRA_DPLANE_REQUEST_FAILURE;
-}
-
 enum netlink_msg_status
 netlink_put_rule_update_msg(struct nl_batch *bth, struct zebra_dplane_ctx *ctx)
 {
index 2520a029b90828e7e55eb4ddad974e3914ade38f..3bff95101c059fd1ee81164c6531dbc3a90dad04 100644 (file)
@@ -3911,89 +3911,6 @@ static void kernel_dplane_handle_result(struct zebra_dplane_ctx *ctx)
        }
 }
 
-static void kernel_dplane_dispatch_updates(struct dplane_ctx_q *ctx_list)
-{
-       enum zebra_dplane_result res;
-       struct zebra_dplane_ctx *ctx;
-
-       TAILQ_FOREACH (ctx, ctx_list, zd_q_entries) {
-               /*
-                * A previous provider plugin may have asked to skip the
-                * kernel update.
-                */
-               if (dplane_ctx_is_skip_kernel(ctx)) {
-                       res = ZEBRA_DPLANE_REQUEST_SUCCESS;
-                       goto skip_one;
-               }
-
-               /* Dispatch to appropriate kernel-facing apis */
-               switch (dplane_ctx_get_op(ctx)) {
-
-               case DPLANE_OP_ROUTE_INSTALL:
-               case DPLANE_OP_ROUTE_UPDATE:
-               case DPLANE_OP_ROUTE_DELETE:
-                       res = kernel_route_update(ctx);
-                       break;
-
-               case DPLANE_OP_NH_INSTALL:
-               case DPLANE_OP_NH_UPDATE:
-               case DPLANE_OP_NH_DELETE:
-                       res = kernel_nexthop_update(ctx);
-                       break;
-
-               case DPLANE_OP_LSP_INSTALL:
-               case DPLANE_OP_LSP_UPDATE:
-               case DPLANE_OP_LSP_DELETE:
-                       res = kernel_lsp_update(ctx);
-                       break;
-
-               case DPLANE_OP_PW_INSTALL:
-               case DPLANE_OP_PW_UNINSTALL:
-                       res = kernel_pw_update(ctx);
-                       break;
-
-               case DPLANE_OP_ADDR_INSTALL:
-               case DPLANE_OP_ADDR_UNINSTALL:
-                       res = kernel_address_update_ctx(ctx);
-                       break;
-
-               case DPLANE_OP_MAC_INSTALL:
-               case DPLANE_OP_MAC_DELETE:
-                       res = kernel_mac_update_ctx(ctx);
-                       break;
-
-               case DPLANE_OP_NEIGH_INSTALL:
-               case DPLANE_OP_NEIGH_UPDATE:
-               case DPLANE_OP_NEIGH_DELETE:
-               case DPLANE_OP_VTEP_ADD:
-               case DPLANE_OP_VTEP_DELETE:
-                       res = kernel_neigh_update_ctx(ctx);
-                       break;
-
-               case DPLANE_OP_RULE_ADD:
-               case DPLANE_OP_RULE_DELETE:
-               case DPLANE_OP_RULE_UPDATE:
-                       res = kernel_pbr_rule_update(ctx);
-                       break;
-
-               /* Ignore 'notifications' - no-op */
-               case DPLANE_OP_SYS_ROUTE_ADD:
-               case DPLANE_OP_SYS_ROUTE_DELETE:
-               case DPLANE_OP_ROUTE_NOTIFY:
-               case DPLANE_OP_LSP_NOTIFY:
-                       res = ZEBRA_DPLANE_REQUEST_SUCCESS;
-                       break;
-
-               default:
-                       res = ZEBRA_DPLANE_REQUEST_FAILURE;
-                       break;
-               }
-
-       skip_one:
-               dplane_ctx_set_status(ctx, res);
-       }
-}
-
 /*
  * Kernel provider callback
  */
@@ -4022,10 +3939,7 @@ static int kernel_dplane_process_func(struct zebra_dplane_provider *prov)
                TAILQ_INSERT_TAIL(&work_list, ctx, zd_q_entries);
        }
 
-       if (kernel_supports_batch())
-               kernel_update_multi(&work_list);
-       else
-               kernel_dplane_dispatch_updates(&work_list);
+       kernel_update_multi(&work_list);
 
        TAILQ_FOREACH_SAFE (ctx, &work_list, zd_q_entries, tctx) {
                kernel_dplane_handle_result(ctx);
index 742b08c376a7d97709202724b03a8ad11a32ac09..3b2279c66c2f1af740d885e5907f36b5eae2fdeb 100644 (file)
@@ -55,30 +55,12 @@ static ssize_t netlink_lsp_msg_encoder(struct zebra_dplane_ctx *ctx, void *buf,
        return netlink_mpls_multipath_msg_encode(cmd, ctx, buf, buflen);
 }
 
-/*
- * The communication with the kernel is done using the message batching
- * interface, so return a failure.
- */
-enum zebra_dplane_result kernel_lsp_update(struct zebra_dplane_ctx *ctx)
-{
-       return ZEBRA_DPLANE_REQUEST_FAILURE;
-}
-
 enum netlink_msg_status netlink_put_lsp_update_msg(struct nl_batch *bth,
                                                   struct zebra_dplane_ctx *ctx)
 {
        return netlink_batch_add_msg(bth, ctx, netlink_lsp_msg_encoder, false);
 }
 
-/*
- * The communication with the kernel is done using the message batching
- * interface, so return a failure.
- */
-enum zebra_dplane_result kernel_pw_update(struct zebra_dplane_ctx *ctx)
-{
-       return ZEBRA_DPLANE_REQUEST_FAILURE;
-}
-
 /*
  * Pseudowire update api - not supported by netlink as of 12/18,
  * but note that the default has been to report 'success' for pw updates
index dd2d7a190d87b4a2cb1eee867369f9e5b32fc3eb..888d2fcfa0c33ced7941639be9e223bd27b452bc 100644 (file)
@@ -171,13 +171,6 @@ void zebra_pbr_del_ipset_entry(struct zebra_pbr_ipset_entry *ipset);
 void zebra_pbr_add_iptable(struct zebra_pbr_iptable *iptable);
 void zebra_pbr_del_iptable(struct zebra_pbr_iptable *iptable);
 
-/*
- * Add, update or delete a rule from the
- * kernel, using info from a dataplane context.
- */
-extern enum zebra_dplane_result
-kernel_pbr_rule_update(struct zebra_dplane_ctx *ctx);
-
 /*
  * Get to know existing PBR rules in the kernel - typically called at startup.
  */