mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-30 04:33:00 +02:00
src/confd: add support for ietf-ip:ipv4/forwarding
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -3,6 +3,26 @@
|
||||
#include <stdarg.h>
|
||||
#include "core.h"
|
||||
|
||||
/*
|
||||
* Write interger value to a file composed from fmt and optional args.
|
||||
*/
|
||||
int writedf(int value, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int rc = -1;
|
||||
FILE *fp;
|
||||
|
||||
va_start(ap, fmt);
|
||||
fp = fopenf("w", fmt, ap);
|
||||
if (fp) {
|
||||
fprintf(fp, "%d\n", value);
|
||||
rc = fclose(fp);
|
||||
}
|
||||
va_end(ap);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write str to a file composed from fmt and optional args.
|
||||
*/
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#ifndef CONFD_HELPERS_H_
|
||||
#define CONFD_HELPERS_H_
|
||||
|
||||
int writedf(int value, const char *fmt, ...);
|
||||
int writesf(const char *str, const char *fmt, ...);
|
||||
|
||||
#endif /* CONFD_HELPERS_H_ */
|
||||
|
||||
@@ -61,6 +61,9 @@ static int ifchange(sr_session_ctx_t *session, uint32_t sub_id, const char *modu
|
||||
writesf(ptr, "/sys/class/net/%s/ifalias", ifname);
|
||||
free(ptr);
|
||||
|
||||
writedf(srx_enabled(session, "%s/ietf-ip:ipv4/forwarding", xpath),
|
||||
"/proc/sys/net/ipv4/conf/%s/forwarding", ifname);
|
||||
|
||||
systemf("ip addr flush dev %s", ifname);
|
||||
|
||||
snprintf(path, sizeof(path), "%s/ietf-ip:ipv4/address", xpath);
|
||||
|
||||
Reference in New Issue
Block a user