quic_drop for kmod

This commit is contained in:
Vadim Vetrov 2024-12-06 14:05:37 +03:00
parent f9a51944dd
commit b452ed2d55
No known key found for this signature in database
GPG Key ID: E8A308689D7A73A5

33
kargs.c
View File

@ -161,7 +161,38 @@ static const struct kernel_param_ops exclude_domains_ops = {
module_param_cb(exclude_domains, &exclude_domains_ops, &def_section->exclude_domains_str, 0664); module_param_cb(exclude_domains, &exclude_domains_ops, &def_section->exclude_domains_str, 0664);
module_param_cb(no_ipv6, &inverse_boolean_ops, &config.use_ipv6, 0664); module_param_cb(no_ipv6, &inverse_boolean_ops, &config.use_ipv6, 0664);
// module_param_cb(quic_drop, &boolean_parameter_ops, &def_section->quic_drop, 0664);
static int quic_drop_set(const char *val, const struct kernel_param *kp) {
int n = 0, ret;
ret = kstrtoint(val, 10, &n);
if (ret != 0 || (n != 0 && n != 1))
return -EINVAL;
if (n) {
def_section->udp_mode = UDP_MODE_DROP;
def_section->udp_filter_quic = UDP_FILTER_QUIC_ALL;
} else {
def_section->udp_filter_quic = UDP_FILTER_QUIC_DISABLED;
}
return 0;
}
static int quic_drop_get(char *buffer, const struct kernel_param *kp) {
if (def_section->udp_mode == UDP_MODE_DROP &&
def_section->udp_filter_quic == UDP_FILTER_QUIC_ALL) {
return sprintf(buffer, "%d\n", 1);
} else {
return sprintf(buffer, "%d\n", 0);
}
}
static const struct kernel_param_ops quic_drop_ops = {
.set = quic_drop_set,
.get = quic_drop_get
};
module_param_cb(quic_drop, &quic_drop_ops, NULL, 0664);
static int verbosity_set(const char *val, const struct kernel_param *kp) { static int verbosity_set(const char *val, const struct kernel_param *kp) {
size_t len; size_t len;