MCPcopy Create free account
hub / github.com/F-Stack/f-stack / add_action

Function add_action

dpdk/drivers/net/tap/tap_flow.c:919–962  ·  view source on GitHub ↗

* Configure the kernel with a TC action and its configured parameters * Handled actions: "gact", "mirred", "skbedit", "bpf" * * @param[in] flow * Pointer to rte flow containing the netlink message * * @param[in, out] act_index * Pointer to action sequence number in the TC command * * @param[in] adata * Pointer to struct holding the action parameters * * @return * -1 on failure,

Source from the content-addressed store, hash-verified

917 * -1 on failure, 0 on success
918 */
919static int
920add_action(struct rte_flow *flow, size_t *act_index, struct action_data *adata)
921{
922 struct nlmsg *msg = &flow->msg;
923
924 if (tap_nlattr_nested_start(msg, (*act_index)++) < 0)
925 return -1;
926
927 tap_nlattr_add(&msg->nh, TCA_ACT_KIND,
928 strlen(adata->id) + 1, adata->id);
929 if (tap_nlattr_nested_start(msg, TCA_ACT_OPTIONS) < 0)
930 return -1;
931 if (strcmp("gact", adata->id) == 0) {
932 tap_nlattr_add(&msg->nh, TCA_GACT_PARMS, sizeof(adata->gact),
933 &adata->gact);
934 } else if (strcmp("mirred", adata->id) == 0) {
935 if (adata->mirred.eaction == TCA_EGRESS_MIRROR)
936 adata->mirred.action = TC_ACT_PIPE;
937 else /* REDIRECT */
938 adata->mirred.action = TC_ACT_STOLEN;
939 tap_nlattr_add(&msg->nh, TCA_MIRRED_PARMS,
940 sizeof(adata->mirred),
941 &adata->mirred);
942 } else if (strcmp("skbedit", adata->id) == 0) {
943 tap_nlattr_add(&msg->nh, TCA_SKBEDIT_PARMS,
944 sizeof(adata->skbedit.skbedit),
945 &adata->skbedit.skbedit);
946 tap_nlattr_add16(&msg->nh, TCA_SKBEDIT_QUEUE_MAPPING,
947 adata->skbedit.queue);
948 } else if (strcmp("bpf", adata->id) == 0) {
949 tap_nlattr_add32(&msg->nh, TCA_ACT_BPF_FD, adata->bpf.bpf_fd);
950 tap_nlattr_add(&msg->nh, TCA_ACT_BPF_NAME,
951 strlen(adata->bpf.annotation) + 1,
952 adata->bpf.annotation);
953 tap_nlattr_add(&msg->nh, TCA_ACT_BPF_PARMS,
954 sizeof(adata->bpf.bpf),
955 &adata->bpf.bpf);
956 } else {
957 return -1;
958 }
959 tap_nlattr_nested_finish(msg); /* nested TCA_ACT_OPTIONS */
960 tap_nlattr_nested_finish(msg); /* nested act_index */
961 return 0;
962}
963
964/**
965 * Helper function to send a series of TC actions to the kernel

Callers 1

add_actionsFunction · 0.85

Calls 6

tap_nlattr_nested_startFunction · 0.85
tap_nlattr_addFunction · 0.85
strcmpFunction · 0.85
tap_nlattr_add16Function · 0.85
tap_nlattr_add32Function · 0.85
tap_nlattr_nested_finishFunction · 0.85

Tested by

no test coverage detected