sysctl-util: introduce sysctl_write_ip_property() and friends
This commit is contained in:
@@ -60,6 +60,22 @@ int sysctl_write(const char *property, const char *value) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sysctl_write_ip_property(int af, const char *ifname, const char *property, const char *value) {
|
||||
const char *p;
|
||||
|
||||
assert(IN_SET(af, AF_INET, AF_INET6));
|
||||
assert(property);
|
||||
assert(value);
|
||||
|
||||
p = strjoina("/proc/sys/net/ipv", af == AF_INET ? "4" : "6",
|
||||
ifname ? "/conf/" : "", strempty(ifname),
|
||||
property[0] == '/' ? "" : "/", property);
|
||||
|
||||
log_debug("Setting '%s' to '%s'", p, value);
|
||||
|
||||
return write_string_file(p, value, WRITE_STRING_FILE_VERIFY_ON_FAILURE | WRITE_STRING_FILE_DISABLE_BUFFER);
|
||||
}
|
||||
|
||||
int sysctl_read(const char *property, char **content) {
|
||||
char *p;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user