The old one is replaced by the api that is suitable for the batching.
Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
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)
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)
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 */
#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.
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,
* Message batching interface.
*/
extern void kernel_update_multi(struct dplane_ctx_q *ctx_list);
-extern bool kernel_supports_batch(void);
#ifdef __cplusplus
}
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)
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
*
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
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,
* 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)
{
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)
{
/* 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)
{
}
}
-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
*/
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);
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
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.
*/