summaryrefslogtreecommitdiff
path: root/system-linux.c
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2014-11-13 15:57:59 +0000
committerSteven Barth <steven@midlink.org>2014-11-19 09:30:30 +0100
commita34e76b707355a2bdaee0cda243f4f82ef17eb9a (patch)
tree947562bba412810932f6e3dcc1968f9e77ded5ae /system-linux.c
parentf6f065d3997ccc8d42805529e4aad59b789579ad (diff)
downloadnetifd-a34e76b707355a2bdaee0cda243f4f82ef17eb9a.tar.gz
netifd: Add acceptlocal config support
Adds support to accept packets with local source address. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'system-linux.c')
-rw-r--r--system-linux.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/system-linux.c b/system-linux.c
index bb7ccf9..83827d5 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -270,6 +270,11 @@ static void system_set_rpfilter(struct device *dev, const char *val)
system_set_dev_sysctl("/proc/sys/net/ipv4/conf/%s/rp_filter", dev->ifname, val);
}
+static void system_set_acceptlocal(struct device *dev, const char *val)
+{
+ system_set_dev_sysctl("/proc/sys/net/ipv4/conf/%s/accept_local", dev->ifname, val);
+}
+
static int system_get_sysctl(const char *path, char *buf, const size_t buf_sz)
{
int fd = -1, ret = -1;
@@ -310,6 +315,12 @@ static int system_get_rpfilter(struct device *dev, char *buf, const size_t buf_s
dev->ifname, buf, buf_sz);
}
+static int system_get_acceptlocal(struct device *dev, char *buf, const size_t buf_sz)
+{
+ return system_get_dev_sysctl("/proc/sys/net/ipv4/conf/%s/accept_local",
+ dev->ifname, buf, buf_sz);
+}
+
// Evaluate netlink messages
static int cb_rtnl_event(struct nl_msg *msg, void *arg)
{
@@ -969,6 +980,11 @@ system_if_get_settings(struct device *dev, struct device_settings *s)
s->rpfilter = strtoul(buf, NULL, 0);
s->flags |= DEV_OPT_RPFILTER;
}
+
+ if (!system_get_acceptlocal(dev, buf, sizeof(buf))) {
+ s->acceptlocal = strtoul(buf, NULL, 0);
+ s->flags |= DEV_OPT_ACCEPTLOCAL;
+ }
}
void
@@ -1010,6 +1026,8 @@ system_if_apply_settings(struct device *dev, struct device_settings *s, unsigned
snprintf(buf, sizeof(buf), "%d", s->rpfilter);
system_set_rpfilter(dev, buf);
}
+ if (s->flags & DEV_OPT_ACCEPTLOCAL & apply_mask)
+ system_set_acceptlocal(dev, s->acceptlocal ? "1" : "0");
}
int system_if_up(struct device *dev)