summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--device.c9
-rw-r--r--device.h3
-rw-r--r--system-linux.c18
3 files changed, 30 insertions, 0 deletions
diff --git a/device.c b/device.c
index d261e25..aa5818f 100644
--- a/device.c
+++ b/device.c
@@ -40,6 +40,7 @@ static const struct blobmsg_policy dev_attrs[__DEV_ATTR_MAX] = {
[DEV_ATTR_IPV6] = { .name = "ipv6", .type = BLOBMSG_TYPE_BOOL },
[DEV_ATTR_PROMISC] = { .name = "promisc", .type = BLOBMSG_TYPE_BOOL },
[DEV_ATTR_RPFILTER] = { .name = "rpfilter", .type = BLOBMSG_TYPE_STRING },
+ [DEV_ATTR_ACCEPTLOCAL] = { .name = "acceptlocal", .type = BLOBMSG_TYPE_BOOL },
};
const struct uci_blob_param_list device_attr_list = {
@@ -156,6 +157,7 @@ device_merge_settings(struct device *dev, struct device_settings *n)
n->ipv6 = s->flags & DEV_OPT_IPV6 ? s->ipv6 : os->ipv6;
n->promisc = s->flags & DEV_OPT_PROMISC ? s->promisc : os->promisc;
n->rpfilter = s->flags & DEV_OPT_RPFILTER ? s->rpfilter : os->rpfilter;
+ n->acceptlocal = s->flags & DEV_OPT_ACCEPTLOCAL ? s->acceptlocal : os->acceptlocal;
n->flags = s->flags | os->flags;
}
@@ -206,6 +208,11 @@ device_init_settings(struct device *dev, struct blob_attr **tb)
DPRINTF("Failed to resolve rpfilter: %s\n", (char *) blobmsg_data(cur));
}
+ if ((cur = tb[DEV_ATTR_ACCEPTLOCAL])) {
+ s->acceptlocal = blobmsg_get_bool(cur);
+ s->flags |= DEV_OPT_ACCEPTLOCAL;
+ }
+
device_set_disabled(dev, disabled);
}
@@ -745,6 +752,8 @@ device_dump_status(struct blob_buf *b, struct device *dev)
blobmsg_add_u8(b, "promisc", st.promisc);
if (st.flags & DEV_OPT_RPFILTER)
blobmsg_add_u32(b, "rpfilter", st.rpfilter);
+ if (st.flags & DEV_OPT_ACCEPTLOCAL)
+ blobmsg_add_u8(b, "acceptlocal", st.acceptlocal);
}
s = blobmsg_open_table(b, "statistics");
diff --git a/device.h b/device.h
index 0af65be..8569be7 100644
--- a/device.h
+++ b/device.h
@@ -34,6 +34,7 @@ enum {
DEV_ATTR_IPV6,
DEV_ATTR_PROMISC,
DEV_ATTR_RPFILTER,
+ DEV_ATTR_ACCEPTLOCAL,
__DEV_ATTR_MAX,
};
@@ -68,6 +69,7 @@ enum {
DEV_OPT_IPV6 = (1 << 3),
DEV_OPT_PROMISC = (1 << 4),
DEV_OPT_RPFILTER = (1 << 5),
+ DEV_OPT_ACCEPTLOCAL = (1 << 6),
};
/* events broadcasted to all users of a device */
@@ -116,6 +118,7 @@ struct device_settings {
bool ipv6;
bool promisc;
unsigned int rpfilter;
+ bool acceptlocal;
};
/*
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)