Changeset View
Changeset View
Standalone View
Standalone View
sys/net/netisr.c
Show First 20 Lines • Show All 339 Lines • ▼ Show 20 Lines | netisr_dispatch_policy_from_str(const char *str, u_int *dispatch_policyp) | ||||
} | } | ||||
return (EINVAL); | return (EINVAL); | ||||
} | } | ||||
static int | static int | ||||
sysctl_netisr_dispatch_policy(SYSCTL_HANDLER_ARGS) | sysctl_netisr_dispatch_policy(SYSCTL_HANDLER_ARGS) | ||||
{ | { | ||||
char tmp[NETISR_DISPATCH_POLICY_MAXSTR]; | char tmp[NETISR_DISPATCH_POLICY_MAXSTR]; | ||||
size_t len; | |||||
u_int dispatch_policy; | u_int dispatch_policy; | ||||
int error; | int error; | ||||
netisr_dispatch_policy_to_str(netisr_dispatch_policy, tmp, | netisr_dispatch_policy_to_str(netisr_dispatch_policy, tmp, | ||||
sizeof(tmp)); | sizeof(tmp)); | ||||
error = sysctl_handle_string(oidp, tmp, sizeof(tmp), req); | /* | ||||
if (error == 0 && req->newptr != NULL) { | * netisr is initialised very early during the boot when malloc isn't | ||||
* available yet so we can't use sysctl_handle_string() to process | |||||
* any non-default value that was potentially set via loader. | |||||
*/ | |||||
if (req->newptr != NULL) { | |||||
len = req->newlen - req->newidx; | |||||
if (len >= NETISR_DISPATCH_POLICY_MAXSTR) { | |||||
kib: Why >= ? Should it be > (althought it probably does not matter practically) ? | |||||
kibUnsubmitted Not Done Inline ActionsI see, you do tmp[len] = 0, which breaks for len == MAXSTR, ignore this question. kib: I see, you do tmp[len] = 0, which breaks for len == MAXSTR, ignore this question. | |||||
return (EINVAL); | |||||
} | |||||
kibUnsubmitted Not Done Inline ActionsNo need for {} for single-statement then block. kib: No need for {} for single-statement then block. | |||||
error = SYSCTL_IN(req, tmp, len); | |||||
if (error == 0) { | |||||
tmp[len] = '\0'; | |||||
error = netisr_dispatch_policy_from_str(tmp, | error = netisr_dispatch_policy_from_str(tmp, | ||||
&dispatch_policy); | &dispatch_policy); | ||||
if (error == 0 && dispatch_policy == NETISR_DISPATCH_DEFAULT) | if (error == 0 && | ||||
dispatch_policy == NETISR_DISPATCH_DEFAULT) | |||||
error = EINVAL; | error = EINVAL; | ||||
if (error == 0) | if (error == 0) | ||||
netisr_dispatch_policy = dispatch_policy; | netisr_dispatch_policy = dispatch_policy; | ||||
} | |||||
} else { | |||||
error = sysctl_handle_string(oidp, tmp, sizeof(tmp), req); | |||||
} | } | ||||
return (error); | return (error); | ||||
} | } | ||||
/* | /* | ||||
* Register a new netisr handler, which requires initializing per-protocol | * Register a new netisr handler, which requires initializing per-protocol | ||||
* fields for each workstream. All netisr work is briefly suspended while | * fields for each workstream. All netisr work is briefly suspended while | ||||
* the protocol is installed. | * the protocol is installed. | ||||
▲ Show 20 Lines • Show All 1,171 Lines • Show Last 20 Lines |
Why >= ? Should it be > (althought it probably does not matter practically) ?