summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau2021-11-16 16:23:22 +0000
committerFelix Fietkau2021-11-16 16:23:22 +0000
commit3f0acf039f413172fb08b3e6224f35775c53d543 (patch)
tree7e5a46de3013f34c0a5ba8ccca56f4a01bfdfd54
parent1ca3e26b816903742b228ff70e94c2aff5058af0 (diff)
downloadqosify-3f0acf039f413172fb08b3e6224f35775c53d543.tar.gz
bpf: move flow prio/bulk detection config into a separate data structure
Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r--map.c8
-rw-r--r--qosify-bpf.c10
-rw-r--r--qosify-bpf.h10
-rw-r--r--ubus.c10
4 files changed, 23 insertions, 15 deletions
diff --git a/map.c b/map.c
index 466ad3f..9b17165 100644
--- a/map.c
+++ b/map.c
@@ -602,10 +602,10 @@ void qosify_map_reset_config(void)
qosify_active_timeout = 300;
memset(&config, 0, sizeof(config));
- config.dscp_prio.ingress = 0xff;
- config.dscp_prio.egress = 0xff;
- config.dscp_bulk.ingress = 0xff;
- config.dscp_bulk.egress = 0xff;
+ config.flow.dscp_prio.ingress = 0xff;
+ config.flow.dscp_prio.egress = 0xff;
+ config.flow.dscp_bulk.ingress = 0xff;
+ config.flow.dscp_bulk.egress = 0xff;
config.dscp_icmp.ingress = 0xff;
config.dscp_icmp.egress = 0xff;
}
diff --git a/qosify-bpf.c b/qosify-bpf.c
index 1e036f0..2153fcd 100644
--- a/qosify-bpf.c
+++ b/qosify-bpf.c
@@ -255,7 +255,7 @@ parse_l4proto(struct qosify_config *config, struct __sk_buff *skb,
}
static __always_inline void
-check_flow_bulk(struct qosify_config *config, struct __sk_buff *skb,
+check_flow_bulk(struct qosify_flow_config *config, struct __sk_buff *skb,
struct flow_bucket *flow, struct qosify_dscp_val *out_val)
{
bool trigger = false;
@@ -304,7 +304,7 @@ clear:
}
static __always_inline void
-check_flow_prio(struct qosify_config *config, struct __sk_buff *skb,
+check_flow_prio(struct qosify_flow_config *config, struct __sk_buff *skb,
struct flow_bucket *flow, struct qosify_dscp_val *out_val)
{
if ((flow->val.flags & QOSIFY_VAL_FLAG_BULK_CHECK) ||
@@ -321,7 +321,7 @@ check_flow_prio(struct qosify_config *config, struct __sk_buff *skb,
}
static __always_inline void
-check_flow(struct qosify_config *config, struct __sk_buff *skb,
+check_flow(struct qosify_flow_config *config, struct __sk_buff *skb,
struct qosify_dscp_val *out_val)
{
struct flow_bucket flow_data;
@@ -438,6 +438,8 @@ int classify(struct __sk_buff *skb)
int type;
config = get_config();
+ if (!config)
+ return TC_ACT_OK;
if (module_flags & QOSIFY_IP_ONLY)
type = skb->protocol;
@@ -458,7 +460,7 @@ int classify(struct __sk_buff *skb)
val = ip_val->dscp;
}
- check_flow(config, skb, &val);
+ check_flow(&config->flow, skb, &val);
dscp = dscp_val(&val, ingress);
if (dscp == 0xff)
diff --git a/qosify-bpf.h b/qosify-bpf.h
index d9d4e9f..ce1c4e7 100644
--- a/qosify-bpf.h
+++ b/qosify-bpf.h
@@ -27,10 +27,10 @@ struct qosify_dscp_val {
} __attribute__((packed));
/* global config data */
-struct qosify_config {
+
+struct qosify_flow_config {
struct qosify_dscp_val dscp_prio;
struct qosify_dscp_val dscp_bulk;
- struct qosify_dscp_val dscp_icmp;
uint8_t bulk_trigger_timeout;
uint16_t bulk_trigger_pps;
@@ -38,6 +38,12 @@ struct qosify_config {
uint16_t prio_max_avg_pkt_len;
};
+struct qosify_config {
+ struct qosify_dscp_val dscp_icmp;
+
+ struct qosify_flow_config flow;
+};
+
struct qosify_ip_map_val {
struct qosify_dscp_val dscp; /* must be first */
uint8_t seen;
diff --git a/ubus.c b/ubus.c
index 39a775c..e99a77f 100644
--- a/ubus.c
+++ b/ubus.c
@@ -213,19 +213,19 @@ qosify_ubus_config(struct ubus_context *ctx, struct ubus_object *obj,
if (dscp.ingress != 0xff)
qosify_map_set_dscp_default(CL_MAP_TCP_PORTS, dscp);
- if (__set_dscp(&config.dscp_prio, tb[CL_CONFIG_DSCP_PRIO], reset) ||
- __set_dscp(&config.dscp_bulk, tb[CL_CONFIG_DSCP_BULK], reset) ||
+ if (__set_dscp(&config.flow.dscp_prio, tb[CL_CONFIG_DSCP_PRIO], reset) ||
+ __set_dscp(&config.flow.dscp_bulk, tb[CL_CONFIG_DSCP_BULK], reset) ||
__set_dscp(&config.dscp_icmp, tb[CL_CONFIG_DSCP_ICMP], reset))
return UBUS_STATUS_INVALID_ARGUMENT;
if ((cur = tb[CL_CONFIG_BULK_TIMEOUT]) != NULL)
- config.bulk_trigger_timeout = blobmsg_get_u32(cur);
+ config.flow.bulk_trigger_timeout = blobmsg_get_u32(cur);
if ((cur = tb[CL_CONFIG_BULK_PPS]) != NULL)
- config.bulk_trigger_pps = blobmsg_get_u32(cur);
+ config.flow.bulk_trigger_pps = blobmsg_get_u32(cur);
if ((cur = tb[CL_CONFIG_PRIO_PKT_LEN]) != NULL)
- config.prio_max_avg_pkt_len = blobmsg_get_u32(cur);
+ config.flow.prio_max_avg_pkt_len = blobmsg_get_u32(cur);
qosify_map_update_config();